错误内容:nvalidArgumentError (see above for traceback): Cannot assign a device for operation ‘Reshape’: Operation was explicitly assigned to /job:worker/task:0 but available devices are [ /job:localhost/replica:0/task:0/device:CPU:0, /job:localhost/replica:0/task:0/device:GPU:0 ]. Make sure the device specification refers to a valid device.
错误原因:训练时指定的设备与当前环境下的设备不匹配
解决方法:在恢复.meta的时候,添加一个参数clear devices = True即可清除之前配置。
代码样本如下:
saver = tf.train.import_meta_graph('./model.ckpt.meta',clear_devices=True)
我也是查了很久,自己无意中看源码看到了这个参数,才解决了问题,所以分享下,帮助后来人!