2016-04-26 135 views
2

OS:OSX 10.11.4如何在OSX上使用theano與GPU?

GPU:的GeForce GT 750M,CUDA7.5

語言:Python的蟒蛇2.7

我按照我的Mac上theano的設置CUDA指令:

  1. 設置PATH:出口PATH = /開發/ NVIDIA/CUDA-7.5/bin中:$ PATH
  2. 集LD_LIBRARY_PATH:出口LD_LIBRARY_PATH = /開發/ NVIDIA/CUDA-7.5/lib目錄:$ LD_LIBRARY_PATH
  3. 創建.theanorc文件,並添加CUDA_ROOT = /開發商/ NVIDIA/CUDA的7.5 [CUDA]節

我複製從theano網站的代碼並將其粘貼到test.py文件:

from theano import function, config, shared, sandbox 
import theano.tensor as T 
import numpy 
import time 

vlen = 10 * 30 * 768 # 10 x #cores x # threads per core 
iters = 1000 

rng = numpy.random.RandomState(22) 
x = shared(numpy.asarray(rng.rand(vlen), config.floatX)) 
f = function([], T.exp(x)) 
print(f.maker.fgraph.toposort()) 
t0 = time.time() 
for i in range(iters): 
    r = f() 
t1 = time.time() 
print("Looping %d times took %f seconds" % (iters, t1 - t0)) 
print("Result is %s" % (r,)) 
if numpy.any([isinstance(x.op, T.Elemwise) for x in f.maker.fgraph.toposort()]): 
    print('Used the cpu') 
else: 
    print('Used the gpu') 

但是當我運行這條線:

THEANO_FLAGS='floatX=float32,device=gpu0,nvcc.fastmath=True' python test.py

我得到這個錯誤:

nvcc fatal: The version ('70300') of the host compiler ('Apple clang') is not supported

,並警告看起來是這樣的:

WARNING (theano.sandbox.cuda): CUDA is installed, but device gpu0 is not available (error: cuda unavailable)

是因爲我的Xcode的版本,它的東西(這是7.3版)?如何解決這個問題呢?

回答

2

我修復了這個錯誤:「nvcc fatal:The version('70300')..」安裝最新版本的CUDA SDK 7.5.27,對於OSX 10.11.4