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.