Using GPU with Theano

472 views Asked by At

I'm trying to execute the next code https://github.com/erogol/KLP_KMEANS/blob/master/klp_kmeans.py using my gpu

I execute:

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

But it says:

Using gpu device 0: GeForce GTX 750 Ti
Cluster number comparison ----
Used the cpu

After doing a little debug, I noticed that it has detected cpu usage due to an instance of class 'Gemm' (checked in line #71)

Why is not using the gpu?

Thanks in advance

1

There are 1 answers

0
Daniel Renshaw On

You really need to contact the author of this script for support. The 'Used the cpu' message is coming from this script, not from Theano. It's the author's code that is doing the detection, and that detection logic may be faulty.

As far as Theano is concerned, given your THEANO_FLAGS and the 'Using gpu device 0: GeForce GTX 750 Ti' message you see at startup, it will use the GPU for all computation graphs that can be run on the GPU.

Are you running the script as is? If so, it looks like parts of it are intended to be run on the CPU, and other parts on the GPU (it seems to be doing a speed comparison between the two). Only those calls to klp_kmeans where use_gpu=True will run on the GPU because of the way the variables are typed (e.g. theano.tensor.dmatrix vs. theano.tensor.matrix).