1
votes

for some complicated reasons I use both tensorflow and theano in my python code, and I have 2 gpus which I want them to share, but as stated in another question there is some problem, I want to know if there's some trick to achieve that, like specifying tensorflow to use only 1 gpu while theano using another?

for now I can only disable theano's gpu usage by os.environ['THEANO_FLAGS'] = 'device=cpu,floatX=float64', and let tensorflow use all

os.environ['KERAS_BACKEND'] = 'theano'
os.environ['THEANO_FLAGS'] = 'device=cpu,floatX=float64'
import tensorflow as tf
import keras as ks
1

1 Answers

0
votes

I haven't tried this. However if you have multiple GPUs, you can force to run the code on GPU using the following trick:

import tensorflow as tf
with tf.device('/gpu:0'):
    # Run the tensorflow code

import tensorflow as tf
with tf.device('/gpu:1'):
    # Run the theano code

Hope this helps!