bschreck bschreck - 1 year ago 60
Python Question

Tensor Flow Explicit Device Requirement Error

I'm trying to run the CIFAR10 tutorial with the training code on one gpu and the eval code on the other. I know for sure I have two gpus on my computer, and I can test this by running the simple examples here:

However, using a

with device('/gpu:0')
does not work for most variables in the CIFAR example. I tried a whole lot of combinations of different variables on gpu vs. cpu, or all the variables on one or the other. Always the same error for some variable, something like this:

Cannot assign a device to node 'shuffle_batch/random_shuffle_queue': Could not satisfy explicit device specification '/gpu:0'

Is this possibly a bug in Tensor Flow or am I missing something?

Answer Source

Could not satisfy explicit device specification means you do not have the corresponding device. Do you actually have a CUDA-enabled GPU on your machine?

UPDATE: As it turned out in the discussion below, this error is also raised if the particular operation (in this case, RandomShuffleQueue) cannot be executed on the GPU, because it only has a CPU implementation.

If you are fine with TensorFlow choosing a device for you (particularly, falling back to CPU when no GPU implementation is available), consider setting allow_soft_placement in your configuration, as per this article:

sess = tf.Session(config=tf.ConfigProto(
    allow_soft_placement=True, log_device_placement=True))
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download