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]