Getting Theano to use GPU

I have quite a few problems setting up Theano to work with my graphics card. Hope you guys can help me.

I have used CUDA before and it is installed correctly, as was necessary to run Nvidia Nsight. However, now I want to use it with PyDev, and I have several problems following the "Using the GPU" part in the tutorial at http://deeplearning.net/software/theano/install.html#gpu-linux

The first is pretty simple, and here's how to set up environment variables. It says that I have to Define the $ CUDA_ROOT environment variable . Several sources said to create a new ".pam_environment" file in my home directory. I did this and wrote the following:

CUDA_ROOT = /usr/local/cuda-5.5/bin LD_LIBRARY_PATH = /usr/local/cuda-5.5/lib64/lib 

I'm not sure that this is how it should be written - apologies if this is the main question. If I could get confirmation that this is really the right place to write this too, it would be helpful.

The second problem is the next part of the tutorial. He says " change the device parameter to name the GPU device on your computer ." This seems to have something to do with THEANO_FLAGS and .theanorc, but nowhere can I find out what it is: are they files? If so, where will I find them? It seems like the textbook assumes that I have no knowledge!

Thank you for taking the time to read this: all and all of the answers are greatly appreciated - I am very stuck right now!

+7
eclipse theano gpu pydev
source share
2 answers

On Linux / OSX:

Edit or create the ~/.theanorc . The file should contain:

 [global] floatX = float32 device = gpu0 [nvcc] fastmath = True [cuda] root=/usr/local/cuda-5.5/ # On a mac, this will probably be /Developer/NVIDIA/CUDA-5.5/ 

You need to add cuda to the $ LD_LIBRARY_PATH variable. If you run eclipse, you can go to Project> Interpreters> Configure and interpreter ...> Environment, and then add the LD_LIBRARY_PATH variable that points to your cuda lib folder (possibly / Developer / NVIDIA / CUDA-5.5 / lib64)

Now that you import theano, it should print a gpu detection message. You can run the test code http://deeplearning.net/software/theano/tutorial/using_gpu.html to see if it uses gpu.

+11
source share

THEANO_FLAGS is the environment variable, and .theoror is the configuration file. You can use both mechanisms to configure Theano. This is described here .

I have never heard of a .pam_environment file. In addition, you should not just override the value of LD_LIBRARY_PATH , but add / add to it like this:

 LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-5.5/lib64/lib 

For Theano, if you define CUDA_ROOT , you do not need to change LD_LIBRARY_PATH , so I would just delete the last line.

Usually, if your shell is bash, people define the env variable CUDA_ROOT in the .bashrc file as follows:

 export CUDA_ROOT=/usr/local/cuda-5.5/bin 

The change to .bashrc will only be used if you log out and start it again.

+1
source share

All Articles