2016-05-29 152 views
1

我使用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. 

我該如何解決這個錯誤?

+0

你在用什麼用戶?運行'whoami'。結果是「用戶」? –

+0

不用sudo運行命令,結果是「user」。 – zumma

回答

1

嘗試運行

chown -R user /home/user/.theano 
chmod -R 775 /home/user/.theano 

這將改變文件夾,你的Python腳本不能訪問的權限。第一個將使該文件夾屬於您的用戶,第二個將更改權限以便用戶可讀,可寫和可執行。

0

對於僅此錯誤:

您可以檢查安裝在您的NVCC其中,默認的路徑是「在/ usr /本地/ CUDA/bin」的,如果你能看到它那裏然後做如下:

$ export PATH="/usr/local/cuda/bin:$PATH" 
$ source .bashrc 

這對我有用,現在我可以使用NVCC,它不再失蹤。