2014-10-23 3 views
3

최근 Ubuntu 12.04에 ArrayFire 2.1을 설치했습니다. 파이썬에서 사용하고 싶습니다. 가능합니까? 나는 ArrayFire_Python을 시도했지만 불완전하며 rotate과 같은 기능을 포함하지 않습니다. AF_PATH=/opt/arrayfire을 내 보냈습니다.ArrayFire and Python

ArrayFire가 잘 작동 :

1 - 내가 한 (예에서/helloworld를)

make cuda 

2 - 실행 :

./helloworld_cuda 

3 - 가져 오기 :

ArrayFire v2.1 (CUDA, 64-bit Linux, build fd32605) 
License: Standalone (/opt/arrayfire/arrayfire.lic) 
License expires in 15 days. 
Addons: MGL16, DLA, SLA 
Platform: CUDA toolkit 6.0, Driver: 340.29 
0 : GeForce GTX 480, 1536 MB, CUDA Compute 2.0 
Memory Usage: 1366 MB free (1536 MB total) 


create a 5-by-3 matrix of random floats on the GPU 
A [5 3] = 
     0.7402  0.4464  0.7762 
     0.9210  0.6673  0.2948 
     0.0390  0.1099  0.7140 
     0.9690  0.4702  0.3585 
     0.9251  0.5132  0.6814 

element-wise arithmetic 
B [5 3] = 
     0.7744  0.5317  0.8006 
     0.8962  0.7189  0.3905 
     0.1390  0.2097  0.7549 
     0.9243  0.5531  0.4509 
     0.8987  0.5910  0.7299 

Fourier transform the result 
C [5 3] = 
      3.6327 + 0.0000i  2.6043 + 0.0000i  3.1267 + 0.0000i 
      0.4689 + 0.4640i  0.3193 + 0.0802i  0.1713 + 0.1441i 
      -0.3491 - 0.7454i  -0.2923 - 0.4018i  0.2667 + 0.4886i 
      -0.3491 + 0.7454i  -0.2923 + 0.4018i  0.2667 - 0.4886i 
      0.4689 - 0.4640i  0.3193 - 0.0802i  0.1713 - 0.1441i 

grab last row 
c [1 3] = 
      0.4689 - 0.4640i  0.3193 - 0.0802i  0.1713 - 0.1441i 

zero out every other column 
negate the first three elements of middle column 
B [5 3] = 
     0.0000 -0.5317  0.0000 
     0.0000 -0.7189  0.0000 
     0.0000 -0.2097  0.0000 
     0.0000  0.5531  0.0000 
     0.0000  0.5910  0.0000 

create 2-by-3 matrix from host data 
D [2 3] = 
     1.0000  3.0000  5.0000 
     2.0000  4.0000  6.0000 

copy last column onto first 
D [2 3] = 
     5.0000  3.0000  5.0000 
     6.0000  4.0000  6.0000 

답변

2

파이썬 바인딩은 이제 PyPi의 일부입니다.

2

바인딩을 얻으려면 작동하려면 먼저 ArrayFire가 설치되어 있고 작동하고 있어야한다.하지만 어레이 파일 디렉토리를 github에서 파이썬 라이브러리 디렉토리로 옮겨야한다.

내 우분투 14.04 서버에서 /usr/lib/python2.7/ 디렉토리로 옮겼습니다.

ipython에서 'import arrayfire'는 이제 라이브러리를 가져옵니다. 다음 코드는 배열의 최대 2048x2048을 만들고 그것을 곱하면됩니다 : 당신이 pip install arrayfire로 설치할 수 있도록 arrayfire의

import arrayfire as af 

# create the array 
A = af.constant(1,2048,2048) 
B = af.matmul(A, A)