I am training neural nets with theano and lasagne on a 4 GPU machine. My .theanorc
contains the following lines:
[global]
device = gpu0
So when in python I execute import theano
, I get Using gpu device 0: GRID K520
What if, after importing theano, I chose to use say gpu1? I'd like to do this dynamically, that is, without editing .theanorc
is it possible? Or even to choose it at runtime?
EDIT: Theano is now based on the GPU array backend and the following API is no longer available.
As @EelkeSpaak mentioned, you can't change the GPU device after theano was imported. But if you want to choose it programmatically before that's possible without changing environment variables.
Make sure you're not choosing a device in your .theanorc file. So nothing like:
device=gpu
before calling import theano
choose the GPU device as follows:
import theano.sandbox.cuda
theano.sandbox.cuda.use('gpu1')
#Results in Using gpu device 1: Tesla K80
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With