Using GPU based on Theano and Keras

I am very exited today, since I finally deployed my computer successfully using GPU. I almost spent one week to complete such work, from installed Ubuntu to CUDA. And I need to right some memos about the important procedure.

Ubuntu 14.04

My desktop is alienware 51, a very nice machine. But unfortunately I can not install dual System based on Windows 10, though the system reminds me that I have installed Ubuntu successfully, still can not find booting root to Ubuntu, even though I tried different ideas according to the internet and others suggesting, just like Grub repair, EasyBCD, EasyUEFL, or change the boot mode from UEFL to Lagency.

Finally I give up Windows, for some times It will be rather difficult to debug and set up the library. And I installed Ubuntu 16.04, however it can not support the newest CUDA version(7.5), I reinstalled Ubuntu 14.04.

Cuda

I installed CUDA 7.5, just under the guidance of following URL is okay:

http://www.r-tutor.com/gpu-computing/cuda-installation/cuda7.5-ubuntu

Some times when  you run cuda, the system will remind you install NVCC (can type nvcc -V), if you installed it, the NVIDIA will broken, and you can not login, unless you uninstalled cuda, and reinstall it again.

Actually, nvcc is in the /usr/local/cuda-7.5/bin if you installed cuda in a right way. the system can not find it, because you need to add the environment variables in the file named .bashrc, as follows:

export PATH=/usr/local/cuda-7.5/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda-7.5/lib64:$LD_LIBRARY_PATH

I reintalled my system at least 5 times because of such problem.

Theano

Install Spyder, panda, pip, theano and Keras, the way is very easy. The important point is adding  following content in .theanorc (make it by self), such file can manipulate the parameter of Theano configure,

[global]
device = gpu
floatX = float32

 

The cnmem (control the memory ), can not be set as 1, or can not wrong, it will call cuDNN

[lib]
cnmem=0.8

if  everything are finished, run the Theano GPU testing program, when you import theano, it will remind you the system using GPU

http://deeplearning.net/software/theano/tutorial/using_gpu.html

Then, enjoy!

Advertisements