How can I use my GPU on an ipython laptop?

OS: Ubuntu 14.04LTS
Language: Python Anaconda 2.7 (keras, theano)
GPU: GTX980Ti CUDA: CUDA 7.5

I want to run python keras code on an IPython laptop using my GPU (GTX980Ti)
But I can’t find him.

I want to check below code. When I run it on the Ubuntu terminal, I have the command as shown below (it uses the GPU well. It has no problems)

First I set the path as below

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

The second I run the code below

 THEANO_FLAGS='floatX=float32,device=gpu0,nvcc.fastmath=True' python myscript.py 


And it works well.

But when I run the code on pycharm (python IDE) or When I run it on the Ipython laptop, it does not use gpu. It uses only CPU

myscript.py is given below.

 from theano import function, config, shared, sandbox import theano.tensor as T import numpy import time vlen = 10 * 30 * 768 # 10 x #cores x # threads per core iters = 1000 rng = numpy.random.RandomState(22) x = shared(numpy.asarray(rng.rand(vlen), config.floatX)) f = function([], T.exp(x)) print(f.maker.fgraph.toposort()) t0 = time.time() for i in xrange(iters): r = f() t1 = time.time() print("Looping %d times took %f seconds" % (iters, t1 - t0)) print("Result is %s" % (r,)) if numpy.any([isinstance(x.op, T.Elemwise) for x in f.maker.fgraph.toposort()]): print('Used the cpu') else: print('Used the gpu') 

To solve this problem, I force the code to use gpu as below (Insert two more lines on myscript.py)

 import theano.sandbox.cuda theano.sandbox.cuda.use("gpu0") 

Then it generates an error as shown below

 ERROR (theano.sandbox.cuda): nvcc compiler not found on $PATH. Check your nvcc installation and try again. 

how to do it??? I spent two days.
And of course, I made a way to use the .theanorc file in the home directory.

+6
source share
1 answer

I use theano on an ipython laptop using my system GPU. This configuration seems to work fine on my system. (Macbook Pro with GTX 750M)

My ~ / .theanorc file:

 [global] cnmem = True floatX = float32 device = gpu0 

Various environment variables (I use virtual environment (macvnev):

 echo $LD_LIBRARY_PATH /opt/local/lib: echo $PATH /Developer/NVIDIA/CUDA-7.5/bin:/opt/local/bin:/opt/local/sbin:/Developer/NVIDIA/CUDA-7.0/bin:/Users/Ramana/projects/macvnev/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin echo $DYLD_LIBRARY_PATH /Developer/NVIDIA/CUDA-7.5/lib:/Developer/NVIDIA/CUDA-7.0/lib: 

How I launched ipython notebook (for me this is a gpu0 device):

 $THEANO_FLAGS=mode=FAST_RUN,device=gpu0,floatX=float32 ipython notebook 

The output of $nvcc -V :

 nvcc: NVIDIA (R) Cuda compiler driver Copyright (c) 2005-2015 NVIDIA Corporation Built on Thu_Sep_24_00:26:39_CDT_2015 Cuda compilation tools, release 7.5, V7.5.19 

From your post, you probably specified the $ PATH variable incorrectly.

+2
source

All Articles