6
votes

When I run my python script with CUDA_VISIBLE_DEVICES=2, Tensorflow still shows the following:

I tensorflow/core/common_runtime/gpu/gpu_device.cc:1041] Creating TensorFlow device (/gpu:0) -> (device: 0, name: Tesla K80, pci bus id: 0000:86:00.0)

Consequently, my code fails with the following message:

Could not satisfy explicit device specification '/device:GPU:2' because no devices matching that specification are registered in this process; available devices: /job:localhost/replica:0/task:0/cpu:0, /job:localhost/replica:0/task:0/gpu:0

Could someone please explain what must be going on?

1

1 Answers

12
votes

Citing the explanation of CUDA_VISIBLE_DEVICES:

CUDA will enumerate the visible devices starting at zero. In the last case, devices 0, 2, 3 will appear as devices 0, 1, 2.

So if you do CUDA_VISIBLE_DEVICES=2, then your gpu #2 will be denoted as gpu:0 inside tensorflow.