Debug error for CPU required optimizers

文章描述了在使用TensorFlow时,设置global_clipnorm=1导致的错误,由于试图将Adam优化器与GPU关联,但其他节点要求CPU设备,从而引发了设备不兼容的错误。作者探讨了问题的根源和解决方法。
摘要由CSDN通过智能技术生成
optimizer = tf.keras.optimizers.Adam(learning_rate=0.00051) #, global_clipnorm=1)

this  global_clipnorm = 1 ,will cause this error :

tensorflow.python.framework.errors_impl.InvalidArgumentError: Cannot assign a device for operation ResNet18_one/conv2d_20/Conv2D/ReadVariableOp: Could not satisfy explicit device specification '' because the node {{colocation_node ResNet18_one/conv2d_20/Conv2D/ReadVariableOp}} was colocated with a group of nodes that required incompatible device '/job:localhost/replica:0/task:0/device:GPU:0'. All available devices [/job:localhost/replica:0/task:0/device:CPU:0, /job:localhost/replica:0/task:0/device:GPU:0]. 
Colocation Debug Info:
Colocation group had the following types and supported devices: 
Root Member(assigned_device_name_index_=2 requested_device_name_='/job:localhost/replica:0/task:0/device:GPU:0' assigned_device_name_='/job:localhost/replica:0/task:0/device:GPU:0' resource_device_name_='/job:localhost/replica:0/task:0/device:GPU:0' supported_device_types_=[CPU] possible_devices_=[]
_Arg: GPU CPU 
ReadVariableOp: GPU CPU 
ResourceApplyAdam: CPU 

Colocation members, user-requested devices, and framework assigned devices, if any:
  resnet18_one_conv2d_20_conv2d_readvariableop_resource (_Arg)  framework assigned device=/job:localhost/replica:0/task:0/device:GPU:0
  adam_adam_update_resourceapplyadam_m (_Arg)  framework assigned device=/job:localhost/replica:0/task:0/device:GPU:0
  adam_adam_update_resourceapplyadam_v (_Arg)  framework assigned device=/job:localhost/replica:0/task:0/device:GPU:0
  ResNet18_one/conv2d_20/Conv2D/ReadVariableOp (ReadVariableOp) 
  Adam/Adam/update/ResourceApplyAdam (ResourceApplyAdam) /job:localhost/replica:0/task:0/device:GPU:0

     [[{{node ResNet18_one/conv2d_20/Conv2D/ReadVariableOp}}]] [Op:__inference_train_function_71263]
 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值