问题描述
- ubuntu下Theano使用GPU的问题
-
配置情况:
在ubuntu14.04下配置theano,在调用官方文档里GPU测试得函数是总是返回 Used CPUCUDA应该安装的没问题,安装完可以运行测试用例
显卡也是没问题得,支持CUDA妥妥儿得
用的IDE是spyder
使用另一个测试用例
from theano import function, config, shared, sandbox
import theano.sandbox.cuda.basic_ops
import theano.tensor as T
import numpy
import timevlen = 10 * 30 * 768 # 10 x #cores x # threads per core
iters = 1000rng = 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 treeReading 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并没有任何卵用
求各位大神协助!感激不尽!
解决方案
http://code.csdn.net/news/2825415
解决方案二:
http://blog.csdn.net/lanbing510/article/details/41774619
解决方案三:
Theano2.1.12-基础知识之使用GPU
在ubuntu14.10上安装theano并且使用GPU加速