您的位置:首页 > Web前端

tensorflow 在cpu的环境中无法导入gpu训练好的模型(Make sure the device specification refers to a valid device.)

2018-04-08 18:45 2046 查看
在我准备迁移测试mobilenet时
在调用
new_saver.restore(sess, checkpoint_path_data)

出现
InvalidArgumentError: Cannot assign a device for operation 'clone_1/gradients/clone_1/MobileNet/conv_1/batch_norm/moments/sufficient_statistics/Sub_grad/BroadcastGradientArgs_5': Operation was explicitly assigned to /device:GPU:1 but available devices are [ /job:localhost/replica:0/task:0/device:CPU:0 ].
InvalidArgumentError: Cannot assign a device for operation 'clone_1/gradients/clone_1/MobileNet/conv_1/batch_norm/moments/sufficient_statistics/Sub_grad/BroadcastGradientArgs_5': Operation was explicitly assigned to /device:GPU:1 but available devices are [ /job:localhost/replica:0/task:0/device:CPU:0 ]. Make sure the device specification refers to a valid device.
[[Node: clone_1/gradients/clone_1/MobileNet/conv_1/batch_norm/moments/sufficient_statistics/Sub_grad/BroadcastGradientArgs_5 = BroadcastGradientArgs[T=DT_INT32, _device="/device:GPU:1"](clone_1/gradients/clone_1/MobileNet/conv_1/batch_norm/moments/sufficient_statistics/Sub_grad/Shape_6, clone_1/gradients/clone_1/MobileNet/conv_1/batch_norm/moments/sufficient_statistics/Sub_grad/Shape_1_5)]]
..........
其中
/device:GPU:1 but available devices are [ /job:localhost/replica:0/task:0/device:CPU:0 ]. Make sure the device specification refers to a valid device.
说明,环境无法识别自己的cpu环境,这时就需要

#tf.ConfigProto()的参数
log_device_placement=True : 是否打印设备分配日志
allow_soft_placement=True :如果你指定的设备不存在,允许TF自动分配设备
tf.ConfigProto(log_device_placement=True,allow_soft_placement=True)
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐