Theano无法找到Gpu - Ubuntu 16.04

时间:2016-12-10 06:51:31

标签: theano ubuntu-16.04 theano-cuda cudnn

  

警告(theano.sandbox.cuda):已安装CUDA,但设备gpu不可用(错误:cuda不可用)

尝试运行任何示例Theano程序时出现此错误。

我已尝试了此thread中提供的所有建议修补程序。

julia> a = [[],[]] 2-element Array{Array{Any,1},1}: Any[] Any[] julia> push!(a[1],1.0) 1-element Array{Any,1}: 1.0 julia> a 2-element Array{Array{Any,1},1}: Any[1.0] Any[] julia> b = fill([],2) 2-element Array{Array{Any,1},1}: Any[] Any[] julia> push!(b[1],1.0) 1-element Array{Any,1}: 1.0 julia> b 2-element Array{Array{Any,1},1}: Any[1.0] Any[1.0] 输出:

  

nvcc:NVIDIA(R)Cuda编译器驱动程序
      版权所有(c)2005-2015 NVIDIA Corporation
      建于Tue_Aug_11_14:27:32_CDT_2015
      Cuda编译工具,7.5版,V7.5.17

nvcc --version输出:

nvidia-smi

gcc版本:

Sat Dec 10 00:46:14 2016       
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 367.57                 Driver Version: 367.57                    |
|-------------------------------+----------------------+----------------------+
| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
| Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
|===============================+======================+======================|
|   0  GeForce GTX 1070    Off  | 0000:01:00.0     Off |                  N/A |
|  0%   37C    P0    33W / 151W |      0MiB /  8112MiB |      0%      Default |
+-------------------------------+----------------------+----------------------+

+-----------------------------------------------------------------------------+
| Processes:                                                       GPU Memory |
|  GPU       PID  Type  Process name                               Usage      |
|=============================================================================|
|  No running processes found                                                 |
+-----------------------------------------------------------------------------+

我一直试图让它工作一段时间,希望有人指出我正确的方向。

1 个答案:

答案 0 :(得分:1)

所以我终于能够让Theano找到gpu,我完成了here提供的步骤,以清理我最初安装CUDA时可能发生的任何损坏安装。

在此之后,我运行了sudo apt-get install cuda,为我的nvidia显卡安装了正确的驱动程序包。然后我继续从deb安装CUDA 8.0,这能够覆盖给我提出问题的7.5版本。

这是我现在可以从theano_test.py得到的输出:

(venv) rgalbo@blueberry:~$ python theano_test.py
Using gpu device 0: GeForce GTX 1070 (CNMeM is disabled, cuDNN 5103)
[GpuElemwise{exp,no_inplace}(<CudaNdarrayType(float32, vector)>), HostFromGpu(GpuElemwise{exp,no_inplace}.0)]
Looping 1000 times took 0.185949 seconds
Result is [ 1.23178029  1.61879349  1.52278066 ...,  2.20771813  2.29967761
  1.62323296]
Used the gpu

这是我的~/.theanorc文件:

(venv) rgalbo@blueberry:~$ cat ~/.theanorc
[global]
floatX = float32
device = gpu

[nvcc]
flags=-D_FORCE_INLINE

[cuda]
root = /usr/local/cuda-8.0

每次单独安装后,我都会更新并重新启动服务器,这对我来说很有帮助。我发现这很有帮助。