0

I have two GPUs, and I just would like to use one GPU to train a network by tensorflow. When I train it, the code use all the memories of two GPUs, but only one GPU is working:

enter image description here

I do not know why and how to solve this problem.

Community
  • 1
  • 1
karl_TUM
  • 5,549
  • 9
  • 22
  • 40

2 Answers2

2

Try setting:

config = tf.ConfigProto()
config.gpu_options.allow_growth=True
sess = tf.Session(config=config)

as in question.

Community
  • 1
  • 1
sygi
  • 4,437
  • 2
  • 33
  • 52
0

By default tensorflow will occupy consume the memory of all available GPUs. You can either set allow growth as per @sygi's answer or make only one of the GPUs visible to tensorflow as per Yaroslav's comment. And as per this question.

Community
  • 1
  • 1
Russell
  • 1,074
  • 12
  • 19