在Jetson Nano加载Google Colab训练的EfficientDet D1模型遇Op错误求助
解决Jetson Nano加载EfficientDet D1模型时的
DisableCopyOnRead Op未注册问题 在Google Colab完成EfficientDet D1模型训练后,将模型部署到Jetson Nano设备加载时,触发以下错误:
Traceback (most recent call last): File "E:\software\conda2023\envs\older\lib\site-packages\tensorflow\python\saved_model\load.py", line 903, in load_internal ckpt_options, options, filters) File "E:\software\conda2023\envs\older\lib\site-packages\tensorflow\python\saved_model\load.py", line 138, in _init_ meta_graph.graph_def.library, wrapper_function=_WrapperFunction)) File "E:\software\conda2023\envs\older\lib\site-packages\tensorflow\python\saved_model\function_deserialization.py", line 388, in load_function_def_library func_graph = function_def_lib.function_def_to_graph(copy) File "E:\software\conda2023\envs\older\lib\site-packages\tensorflow\python\framework\function_def_to_graph.py", line 64, in function_def_to_graph fdef, input_shapes) File "E:\software\conda2023\envs\older\lib\site-packages\tensorflow\python\framework\function_def_to_graph.py", line 228, in function_def_to_graph_def op_def = default_graph._get_op_def(node_def.op) # pylint: disable=protected-access File "E:\software\conda2023\envs\older\lib\site-packages\tensorflow\python\framework\ops.py", line 3967, in _get_op_def buf) tensorflow.python.framework.errors_impl.NotFoundError: Op type not registered 'DisableCopyOnRead' in binary running on SAMYOB-PC. Make sure the Op and Kernel are registered in the binary running in thiry running in this process. Note that if you are loading a saved graph which used ops from tf.contrib, accessing (e.g.) `tf.contrib.resampler` should be done before importing the graphare lazily regist, as contrib ops are lazily registered when the module is first accessed. During handling of the above exception, another exception occurred: Traceback (most recent call last): File "E:\software\conda2023\envs\older\lib\runpy.py", line 193, in _run_module_as_main "_main_", mod_spec) File "E:\software\conda2023\envs\older\lib\runpy.py", line 85, in _run_code exec(code, run_globals) File "E:\software\conda2023\envs\older\Scripts\saved_model_cli.exe\_main_.py", line 7, in <module> File "E:\software\conda2023\envs\older\lib\site-packages\tensorflow\python\tools\saved_model_cli.py", line 1204, in main args.func(args) File "E:\software\conda2023\envs\older\lib\site-packages\tensorflow\python\tools\saved_model_cli.py", line 729, in show _show_all(args.dir) File "E:\software\conda2023\envs\older\lib\site-packages\tensorflow\python\tools\saved_model_cli.py", line 308, in _show_all _show_defined_functions(saved_model_dir) File "E:\software\conda2023\envs\older\lib\site-packages\tensorflow\python\tools\saved_model_cli.py", line 188, in _show_defined_functions trackable_object = load.load(saved_model_dir) File "E:\software\conda2023\envs\older\lib\site-packages\tensorflow\python\saved_model\load.py", line 864, in load result = load_internal(export_dir, tags, options)["root"] File "E:\software\conda2023\envs\older\lib\site-packages\tensorflow\python\saved_model\load.py", line 906, in load_internal str(err) + " If trying to load on a different device from the " FileNotFoundError: Op type not registered 'DisableCopyOnRead' in binary running on SAMYOB-PC. Make sure the Op and Kernel are registered in the binary running in this process. Note that if you are loadn the binary running in this process. Note that if you are loading a saved graph which used ops from tf.contrib, accessing (e.g.) `tf.cont the graph, as contrib ops are lazily registere is first accessrib.resampler` should be done before importing the graph, as contrib ops are lazily registered when the module is first accessed. If trying to load on a different device from the computational device, consider using setting the `experimental_io_device` option on tf.saved_model.LoadOptions to the io_device such as '/job:localhostaved_model.LoadOptions to the io_device such as '/job:localhost'.
解决方法
1. 对齐TensorFlow版本
DisableCopyOnRead是TensorFlow高版本新增的操作符,Colab默认的TF版本通常高于Jetson Nano适配的版本。解决步骤:
- 查看Jetson Nano上安装的TensorFlow版本(运行
tf.__version__) - 在Colab中降级到相同版本,重新训练并导出模型
# Colab中降级TF示例,替换为Jetson上的实际版本号 !pip install tensorflow==2.8.0
2. 转换为TensorRT优化格式
Jetson Nano对TensorRT优化的模型兼容性更好,训练完成后将模型转换为TF-TRT格式:
import tensorflow as tf from tensorflow.python.compiler.tensorrt import trt_convert as trt # 初始化转换器 converter = trt.TrtGraphConverterV2(input_saved_model_dir='./your_saved_model') # 执行转换 converter.convert() # 保存优化后的模型 converter.save('./trt_optimized_model')
将转换后的模型复制到Jetson Nano加载即可。
3. 加载时指定设备选项
尝试在加载模型时设置experimental_io_device参数,避免跨设备加载问题:
import tensorflow as tf load_options = tf.saved_model.LoadOptions(experimental_io_device='/job:localhost') model = tf.saved_model.load('./your_model_path', options=load_options)
4. 重新安装Jetson适配的TensorFlow
避免使用conda安装通用版本的TensorFlow,改用NVIDIA官方提供的适配JetPack的安装包:
- 参考JetPack对应的TF安装指南,通过pip安装ARM架构专用的TensorFlow版本,确保所有操作符都完整注册。
内容的提问来源于stack exchange,提问作者Firsty Aurellia Hadinanda
相关产品推荐
相关产品推荐

