【问题标题】:How to use theano with GPU on OSX?如何在 OSX 上将 theano 与 GPU 一起使用?
【发布时间】:2016-08-20 13:49:04
【问题描述】:

操作系统:OSX 10.11.4

GPU:GeForce GT 750M、CUDA7.5

语言:Python Anaconda 2.7

我已按照 theano 的说明在我的 Mac 上设置 CUDA:

  1. 设置路径:export PATH=/Developer/NVIDIA/CUDA-7.5/bin:$PATH
  2. 设置 LD_LIBRARY_PATH:导出 LD_LIBRARY_PATH=/Developer/NVIDIA/CUDA-7.5/lib:$LD_LIBRARY_PATH
  3. 创建了一个 .theanorc 文件并在 [cuda] 部分添加 CUDA_ROOT=/Developer/NVIDIA/CUDA-7.5

我从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 版)?如何解决这个问题?

【问题讨论】:

    标签: python-2.7 gpu theano theano-cuda


    【解决方案1】:

    我修复了这个错误:“nvcc fatal: The version ('70300')..”安装了最新版本的 CUDA SDK 7.5.27,用于 OSX 10.11.4

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-02-04
      • 2016-02-04
      • 2018-05-08
      • 1970-01-01
      相关资源
      最近更新 更多