2016-04-26 69 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