我想指定gpu來運行我的進程。我把它設置如下:如何在tensorflow中設置特定的gpu?
import tensorflow as tf
with tf.device('/gpu:0'):
a = tf.constant(3.0)
with tf.Session() as sess:
while True:
print sess.run(a)
但它仍然在我的兩個gpus中分配內存。
| 0 7479 C python 5437MiB
| 1 7479 C python 5437MiB
TensorFlow初始化它認爲所有的GPU,你需要設置'CUDA_VISIBLE_DEVICES'限制可見的GPU –
好吧,我知道了。謝謝。 – luohao