Ghilas BELHADJ Ghilas BELHADJ - 1 year ago 299
Python Question

Cannot assign a device to node

I followed this tutoriel to export my own trained tensorflow model to c++ and I got errors when I call

I tensorflow/core/common_runtime/gpu/] Creating TensorFlow device (/gpu:0) -> (device: 0, name: TITAN X (Pascal), pci bus id: 0000:03:00.0)
tensorflow.python.framework.errors.InvalidArgumentError: Cannot assign a device to node 'save/Const_1': Could not satisfy explicit device specification '/device:GPU:0' because no supported kernel for GPU devices is available.
Colocation Debug Info:
Colocation group had the following types and devices:
Identity: CPU
Const: CPU
[[Node: save/Const_1 = Const[dtype=DT_STRING, value=Tensor<type: string shape: [] values: model>, _device="/device:GPU:0"]()]]
Caused by op u'save/Const_1', defined at:

GPU:0 is detected and usable by Tensorflow, so I don't understand from where the error comes from.

Any idea ?

Answer Source

The error means op save/Const_1 is trying to get placed on GPU, and there's no GPU implementation of that node. In fact Const nodes are CPU only and are stored as part of Graph object, so it can't be placed on GPU. One work-around is to run with allow_soft_placement=True, or to open the pbtxt file and manually remove the device line for that node

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download