Debug error for CPU required optimizers

文章描述了在使用TensorFlow时,设置global_clipnorm=1导致的错误,由于试图将Adam优化器与GPU关联,但其他节点要求CPU设备,从而引发了设备不兼容的错误。作者探讨了问题的根源和解决方法。
部署运行你感兴趣的模型镜像
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]
 

您可能感兴趣的与本文相关的镜像

TensorFlow-v2.15

TensorFlow-v2.15

TensorFlow

TensorFlow 是由Google Brain 团队开发的开源机器学习框架,广泛应用于深度学习研究和生产环境。 它提供了一个灵活的平台,用于构建和训练各种机器学习模型

File "c:\program files\python310\lib\site-packages\labelme\app.py", line 377, in <lambda> lambda: self.canvas.initializeAiModel( File "c:\program files\python310\lib\site-packages\labelme\widgets\canvas.py", line 139, in initializeAiModel self._ai_model = model() File "c:\program files\python310\lib\site-packages\labelme\ai\__init__.py", line 140, in __init__ super().__init__( File "c:\program files\python310\lib\site-packages\labelme\ai\efficient_sam.py", line 15, in __init__ self._encoder_session = onnxruntime.InferenceSession(encoder_path) File "c:\program files\python310\lib\site-packages\onnxruntime\capi\onnxruntime_inference_collection.py", line 396, in __init__ raise e File "c:\program files\python310\lib\site-packages\onnxruntime\capi\onnxruntime_inference_collection.py", line 383, in __init__ self._create_inference_session(providers, provider_options, disabled_optimizers) File "c:\program files\python310\lib\site-packages\onnxruntime\capi\onnxruntime_inference_collection.py", line 415, in _create_inference_session raise ValueError( ValueError: This ORT build has ['TensorrtExecutionProvider', 'CUDAExecutionProvider', 'CPUExecutionProvider'] enabled. Since ORT 1.9, you are required to explicitly set the providers parameter when instantiating InferenceSession. For example, onnxruntime.InferenceSession(..., providers=['TensorrtExecutionProvider', 'CUDAExecutionProvider', 'CPUExecutionProvider'], ...) 2025-03-19 23:10:33.421 | DEBUG | labelme.__main__:write:23 - Traceback (most recent call last): File "c:\program files\python310\lib\site-packages\labelme\widgets\canvas.py", line 735, in paintEvent points = self._ai_model.predict_polygon_from_points( AttributeError: 'NoneType' object has no attribute 'predict_polygon_from_points'
最新发布
03-21
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值