2016-08-17 1 views
6

dans Ubuntu MATE 16.04 J'essaie d'exécuter les exemples de python d'apprentissage en profondeur ici en utilisant le GPU:AVERTISSEMENT (theano.sandbox.cuda): CUDA est installé, mais le périphérique gpu n'est pas disponible (erreur: cuda indisponible)

testing Theano with GPU

J'ai couru le code exemple,

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

mais il semble qu'il est utilisé le CPU et non le GPU. Voici la dernière partie de la sortie du terminal:

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

J'ai essayé d'exécuter ce code aussi:

THEANO_FLAGS=device=cuda0 python check1.py 

mais la sortie est:

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 

J'ai installé la boîte à outils de cuda de apt . Ici, il y a (je l'espère) des données utiles:

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

Répondre

6

Enfin, je résolus! Ce poste Ubuntu 16.04, Theano and Cuda

suggère d'ajouter le drapeau

nvcc.flags=-D_FORCE_INLINES 

à la ligne de commande, de sorte que la ligne de commande devient:

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

Il semble corriger un bug dans l'utilisation de la glibc 2.23

fix for glibc 2.23

Maintenant, le programme utilise correctement le GPU, c'est la sortie correcte:

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 

Notez que avant d'essayer cette solution, je l'ai enlevé nvidia-cuda-boîte à outils et installé CUDA sur le site Nvidia, suivant une partie des instructions données ici :

CUDA with Ubuntu 16.04

C'est exactement ce que je l'ai fait:

1) Je CUDA téléchargé à partir d'ici CUDA 7.5 download sélection LINUX, x86_64, Ubuntu 15.04, je deb installé la deb locale

2)

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

3) Ensuite, exécutez

apt-get update 

Cela donne des erreurs! Je l'ai fixé en écrasant le fichier Rejet dans \ var \ cuda-repo-7.5-locale avec les lignes suivantes:

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

(désolé, je ne me souviens pas où je lis cette solution).

4) I avec succès courir

apt-get-update 
apt-get install cuda 

5) tout était insatlled dans \ usr \ Local \ cuda-7,5

6) je commente la ligne n 115 dans le fichier \ usr \ Local \ cuda -7,5 \ include \ host-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) */ 

qui semble empêcher d'utiliser CUDA gcc 5.4 Après toutes ces opérations, je mis à jour le fichier .theanorc, en ajoutant la racine cuda

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

C'est tout :)

PS: Je ne sais pas si cela fonctionnerait même avec nvidia-cuda-boîte à outils!

0

Dans mon système, ce problème a été résolu simplement en redémarrant le système. Peut-être que vous pouvez essayer.

0

je fixe ce problème, en ajoutant le chemin cuda au ~/.bashrc, comme suit,

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