ubuntu下Theano使用GPU的问题

配置情况:
在ubuntu14.04下配置theano,在调用官方文档里GPU测试得函数是总是返回 Used CPU

CUDA应该安装的没问题,安装完可以运行测试用例

显卡也是没问题得,支持CUDA妥妥儿得

用的IDE是spyder

使用另一个测试用例
from theano import function, config, shared, sandbox
import theano.sandbox.cuda.basic_ops
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), 'float32'))
f = function([], sandbox.cuda.basic_ops.gpu_from_host(T.exp(x)))
print(f.maker.fgraph.toposort())
t0 = time.time()
for i in xrange(iters):
r = f()
t1 = time.time()
print("Looping %d times took %f seconds" % (iters, t1 - t0))
print("Result is %s" % (r,))
print("Numpy result is %s" % (numpy.asarray(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')

的时候偶尔会返回 找不到nvcc的错误,提示我应该将nvcc加入路径中,但有时候重启一下就不提示这问题了。。虽然仍然显示调用得是cpu

出现这个问题时候我试着查看
nvcc -V -i
提示nvcc未安装,可使用apt-get安装
然后我用apt-get时又会这样:
Reading package lists... Done
Building dependency tree

Reading state information... Done
Note, selecting 'cuda-core-7-5' instead of 'nvcc'
cuda-core-7-5 is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 320 not upgraded.

刚才说了我CUDA都安装好了nvcc肯定妥妥儿的啊,尝试按照CUDA手册上把运行库再添加到路径中一次:
gpu2@gpu2-All-Series:~$ export PATH=/usr/local/cuda-7.5/bin:$PATH
gpu2@gpu2-All-Series:~$ export LD_LIBRARY_PATH=/usr/local/cuda-7.5/lib64:$LD_LIBRARY_PATH

并没有任何卵用

求各位大神协助!感激不尽!

2个回答

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问