Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Tensorflow: CUDA_VISIBLE_DEVICES doesn't seem to work

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?

like image 773
user1274878 Avatar asked Nov 21 '16 17:11

user1274878


People also ask

Why GPU is not detected TensorFlow?

This is most likely because the CUDA and CuDNN drivers are not being correctly detected in your system. In both cases, Tensorflow is not detecting your Nvidia GPU. This can be for a variety of reasons: Nvidia Driver not installed.

Can TensorFlow GPU run on CPU?

TensorFlow supports running computations on a variety of types of devices, including CPU and GPU.

What does CUDA_VISIBLE_DEVICES mean?

CUDA_VISIBLE_DEVICES is used to specify which GPUs should be visible to a CUDA application. CUDA_VISIBLE_DEVICES_ORIG is a LSF internal environment variable.

How do I set CUDA visible devices in Jupyter notebook?

To use it, set CUDA_VISIBLE_DEVICES to a comma-separated list of device IDs to make only those devices visible to the application. So, your code is valid. These CUDA APIs are much more low level way of controlling the GPU(s).


1 Answers

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.

like image 52
sygi Avatar answered Sep 19 '22 12:09

sygi