Theano 无法找到 Gpu - Ubuntu 16.04

Theano Not Able To Find Gpu - Ubuntu 16.04

WARNING (theano.sandbox.cuda): CUDA is installed, but device gpu is not available (error: cuda unavailable)

我在尝试 运行 任何示例 Theano 程序时遇到此错误。

我已经尝试了此 thread 中提供的所有建议修复。

nvcc --version 输出:

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

nvidia-smi 输出:

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                                                 |
+-----------------------------------------------------------------------------+

gcc 版本:

(venv) rgalbo@blueberry:~$ gcc --version
gcc (Ubuntu 4.9.3-13ubuntu2) 4.9.3

我一直在努力让它工作一段时间,希望有人能给我指出正确的方向。

所以我终于能够让 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

在每次单独安装后,我更新并重新启动服务器只是为了好运,我发现这很有帮助。