我使用ubuntu 14.04和cuda 7.5。我得到使用$ nvcc --version
CUDA版本信息:缺少nvcc编译器 - theano
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2015 NVIDIA Corporation
Built on Tue_Aug_11_14:27:32_CDT_2015
Cuda compilation tools, release 7.5, V7.5.17
$ PATH和$ LD_LIBRARY_PATH低于:
$ echo $PATH
/usr/local/cuda-7.5/bin:/usr/local/cuda-7.5/bin/:/opt/ros/indigo/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games
$ echo $LD_LIBRARY_PATH
/usr/local/cuda-7.5/lib64
我安装theano。我用它与CPU但不是GPU。 This guide说
测试Theano与GPU¶ 要查看是否正在使用您的GPU是,切割和下面的程序粘贴到一个文件并运行它。
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') The program just computes the exp() of a bunch of random numbers. Note that we use the shared function to make
> sure that the input x is stored on the graphics device.
如果我和设备= CPU运行这个程序(check1.py),我的电脑 需要一点点超过3秒,而在GPU上它只需在 0.64秒。 GPU不会总是产生与CPU完全相同的浮点数。作为基准,一个调用 numpy.exp(x.get_value())的循环大约需要46秒。
$ THEANO_FLAGS =模式= FAST_RUN,设备= CPU,floatX = FLOAT32蟒 check1.py [Elemwise {EXP,no_inplace}()] 循环1000次花3.06635117531秒结果为[1.23178029 1.61879337 1.52278066 ... ,2.20771813 2.29967761 1.62323284 ]所使用的CPU
$ THEANO_FLAGS =模式= FAST_RUN,设备= GPU,floatX = FLOAT32蟒 check1.py使用GPU设备0:的GeForce GTX 580 [GpuElemwise {EXP,no_inplace}() , HostFromGpu(GpuElemwise {exp,no_inplace} .0)]循环1000次花费了 0.638810873032秒结果为[1.23178029 1 .61879349 1.52278066 ...,2.20771813 2.29967761 1.62323296]使用gpu请注意,Theano中的GPU操作现在要求floatX为float32(另请参见下文)。
我没有sudo运行GPU版本的命令,它会引发权限被拒绝的错误:
/theano/gof/cmodule.py", line 741, in refresh
files = os.listdir(root)
OSError: [Errno 13] Permission denied: '/home/user/.theano/compiledir_Linux-3.16--generic-x86_64-with-Ubuntu-14.04-trusty-x86_64-2.7.6-64/tmp077r7U'
如果我使用sudo使用它时,编译器无法找到NVCC路径。
ERROR (theano.sandbox.cuda): nvcc compiler not found on $PATH. Check your nvcc installation and try again.
我该如何解决这个错误?
你在用什么用户?运行'whoami'。结果是“用户”? –
不用sudo运行命令,结果是“user”。 – zumma