2016-08-17 80 views
6

在Ubuntu MATE 16.04中我試圖運行使用GPU的深度學習python示例:警告(theano.sandbox.cuda):安裝了CUDA,但設備gpu不可用(錯誤:cuda不可用)

testing Theano with GPU

我並運行該示例代碼,

THEANO_FLAGS=mode=FAST_RUN,device=gpu,floatX=float32 python check1.py 

,但它似乎是使用的CPU,而不是GPU。這裏是終端輸出的最後一部分:

WARNING (theano.sandbox.cuda): CUDA is installed, but device gpu0 is not available (error: cuda unavailable) 
... 
Used the cpu 

我試圖運行此代碼太:

THEANO_FLAGS=device=cuda0 python check1.py 

但輸出是:

ERROR (theano.sandbox.gpuarray): pygpu was configured but could not be imported 
Traceback (most recent call last): 
    File "/usr/local/lib/python2.7/dist-packages/theano/sandbox/gpuarray/__init__.py", line 20, in <module> 
    import pygpu 
ImportError: No module named pygpu 
... 
used cpu 

我從易於安裝CUDA工具包。 這裏有(希望)有用的數據:

python --version 
Python 2.7.12 

g++ -v 
gcc version 5.4.0 

nvcc --version 
Cuda compilation tools, release 7.5, V7.5.17 

lspci 
NVIDIA Corporation GM107 [GeForce GTX 750 Ti] (rev a2) 

nvidia-smi 

+------------------------------------------------------+      
| NVIDIA-SMI 361.42  Driver Version: 361.42   |      
|-------------------------------+----------------------+----------------------+ 
| 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 750 Ti Off | 0000:01:00.0  On |     N/A | 
| 29% 35C P8  1W/38W | 100MiB/2044MiB |  0%  Default | 
+-------------------------------+----------------------+----------------------+ 

+-----------------------------------------------------------------------------+ 
| Processes:              GPU Memory | 
| GPU  PID Type Process name        Usage  | 
|=============================================================================| 
| 0  2861 G /usr/lib/xorg/Xorg        90MiB | 
+-----------------------------------------------------------------------------+ 

回答

6

最後我解決了! 這篇文章 Ubuntu 16.04, Theano and Cuda

建議增加標誌

nvcc.flags=-D_FORCE_INLINES 

到命令行,因此命令行變成了:

THEANO_FLAGS=floatX=float32,device=gpu,nvcc.flags=-D_FORCE_INLINES python check1.py 

這似乎修復bug使用的glibc 2.23

fix for glibc 2.23

現在程序正確地使用GPU,這是正確的輸出:

THEANO_FLAGS=floatX=float32,device=gpu,nvcc.flags=-D_FORCE_INLINES python check1.py 
Using gpu device 0: GeForce GTX 750 Ti (CNMeM is disabled, cuDNN not available) 
[GpuElemwise{exp,no_inplace}(<CudaNdarrayType(float32, vector)>), HostFromGpu(GpuElemwise{exp,no_inplace}.0)] 
Looping 1000 times took 0.317012 seconds 
Result is [ 1.23178029 1.61879349 1.52278066 ..., 2.20771813 2.29967761 
    1.62323296] 
Used the gpu 

注意,嘗試這種解決方案之前,我刪除了NVIDIA-CUDA,工具包和來自Nvidia網站安裝CUDA,下列的108218部分:

CUDA with Ubuntu 16.04

這是我做了什麼:

1)我下載CUDA從這裏 CUDA 7.5 download 選擇LINUX,x86_64的,Ubuntu的15.04,DEB當地

2)我安裝的deb文件

dpkg -i cuda_repo-ubuntu1504-7-5-local_7.5-18_amd64.deb 

3)然後運行

apt-get update 

這給了一些錯誤!我固定它覆蓋在文件發佈\ VAR \ CUDA-回購7.5本地與下面幾行:

Origin: NVIDIA 
Label: NVIDIA CUDA 
Architecture: repogenstagetemp 
MD5Sum: 
51483bc34577facd49f0fbc8c396aea0   75379 Packages 
4ef963dfa4276be01db8e7bf7d8a4f12   21448 Packages.gz 
SHA256: 
532b1bb3b392b9083de4445dab2639b36865d7df1f610aeef8961a3c6f304d8a   75379 Packages 
2e48cc13b6cc5856c9c6f628c6fe8088ef62ed664e9e0046fc72819269f7432c   21448 Packages.gz 

(抱歉,我不記得在那裏我讀到這個解決方案)。

4)我成功地運行

apt-get-update 
apt-get install cuda 

5)一切都在被insatlled \ USR \本地\ CUDA的7.5

6)我評論在文件中的第n行115的\ usr \本地\ CUDA -7.5 \包括\主機的config.h

#if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 9) 

//#error -- unsupported GNU version! gcc versions later than 4.9 are not supported! 

#endif /* __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ > 9) */ 

這似乎防止CUDA使用GCC 5.4 所有這些操作之後,我更新了.theanorc文件,加入CUDA根

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

這是所有:)

PS:我不知道這是否會與NVIDIA,CUDA,工具包,甚至工作!

0

在我的系統中,只需重新啓動系統即可解決此問題。也許你可以試試看。

0

我固定這個問題,通過將CUDA路徑的〜/ .bashrc,如以下,

export LD_LIBRARY_PATH=/usr/lib64:$LD_LIBRARY_PATH 
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH 
export LD_LIBRARY_PATH=/usr/local/cuda-8.0/lib64:$LD_LIBRARY_PATH