train_image_classifier.py:Cannot assign a device for operation CifarNet/conv1/Conv2D: node CifarNet(

Posted 17岁boy想当攻城狮

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了train_image_classifier.py:Cannot assign a device for operation CifarNet/conv1/Conv2D: node CifarNet(相关的知识,希望对你有一定的参考价值。

出错内容如下:

Errors may have originated from an input operation.
Input Source operations connected to node CifarNet/conv1/Conv2D:
 fifo_queue_Dequeue (defined at train_image_classifier.py:487)
 CifarNet/conv1/weights/read (defined at /home/zhihao/.local/lib/python3.7/site-packages/tf_slim/ops/variables.py:256)
I1219 22:12:23.329565 139732271825280 coordinator.py:224] Error reported to Coordinator: <class 'tensorflow.python.framework.errors_impl.InvalidArgumentError'
>, Cannot assign a device for operation CifarNet/conv1/Conv2D: node CifarNet/conv1/Conv2D (defined at /tmp/tmpoxb0c7yp.py:12) was explicitly assigned to /devi
ce:GPU:0 but available devices are [ /job:localhost/replica:0/task:0/device:CPU:0, /job:localhost/replica:0/task:0/device:XLA_CPU:0 ]. Make sure the device sp
ecification refers to a valid device. The requested device appears to be a GPU, but CUDA is not enabled.
         [[CifarNet/conv1/Conv2D]]

这个原因是因为在train_image_classifier.py中使用了GPU的代码,此时你的电脑上没有CUDA,因为TensorFlowGPU方面的代码需求CUDALIB库,如果需要可以去互联网上装它,如果不需要可以打开train_image_classifier.py搜索”clone_on_cpu“,将Flash改为True就可以了。

以上是关于train_image_classifier.py:Cannot assign a device for operation CifarNet/conv1/Conv2D: node CifarNet(的主要内容,如果未能解决你的问题,请参考以下文章