解决ValueError: Unsupported ONNX opset version: 16问题

简介: 解决ValueError: Unsupported ONNX opset version: 16问题

转ONNX模型报错

Traceback (most recent call last):
  File "/root/miniconda3/lib/python3.9/runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/root/miniconda3/lib/python3.9/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/root/.vscode-server/extensions/ms-python.python-2022.20.1/pythonFiles/lib/python/debugpy/adapter/../../debugpy/launcher/../../debugpy/__main__.py", line 39, in <module>
    cli.main()
  File "/root/.vscode-server/extensions/ms-python.python-2022.20.1/pythonFiles/lib/python/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/server/cli.py", line 430, in main
    run()
  File "/root/.vscode-server/extensions/ms-python.python-2022.20.1/pythonFiles/lib/python/debugpy/adapter/../../debugpy/launcher/../../debugpy/../debugpy/server/cli.py", line 284, in run_file
    runpy.run_path(target, run_name="__main__")
  File "/root/.vscode-server/extensions/ms-python.python-2022.20.1/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 321, in run_path
    return _run_module_code(code, init_globals, run_name,
  File "/root/.vscode-server/extensions/ms-python.python-2022.20.1/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 135, in _run_module_code
    _run_code(code, mod_globals, init_globals,
  File "/root/.vscode-server/extensions/ms-python.python-2022.20.1/pythonFiles/lib/python/debugpy/_vendored/pydevd/_pydevd_bundle/pydevd_runpy.py", line 124, in _run_code
    exec(code, run_globals)
  File "/cephfs/HZ-AI/usr/hezhiqiang/dou-ai/src/tools/onnx_model.py", line 73, in <module>
    onnx_model.load_weights(model_path='/cephfs/HZ-AI/project/doudizhu/experiments/exp.20221122191411/models/learner_cid_0')
  File "/cephfs/HZ-AI/usr/hezhiqiang/dou-ai/src/tools/onnx_model.py", line 35, in load_weights
    self.export_onnx()
  File "/cephfs/HZ-AI/usr/hezhiqiang/dou-ai/src/tools/onnx_model.py", line 15, in export_onnx
    torch.onnx.export(
  File "/root/miniconda3/lib/python3.9/site-packages/torch/onnx/__init__.py", line 316, in export
    return utils.export(model, args, f, export_params, verbose, training,
  File "/root/miniconda3/lib/python3.9/site-packages/torch/onnx/utils.py", line 107, in export
    _export(model, args, f, export_params, verbose, training, input_names, output_names,
  File "/root/miniconda3/lib/python3.9/site-packages/torch/onnx/utils.py", line 707, in _export
    _set_opset_version(opset_version)
  File "/root/miniconda3/lib/python3.9/site-packages/torch/onnx/symbolic_helper.py", line 849, in _set_opset_version
    raise ValueError("Unsupported ONNX opset version: " + str(opset_version))
ValueError: Unsupported ONNX opset version: 16

修复步骤

  1. 安装PyTorch1.12.1
pip install torch==1.12.1 -ihttps://pypi.tuna.tsinghua.edu.cn/simple
  1. 卸载之前的horovod
pip uninstall horovod
  1. 更新cmake
pip install cmake --upgrade -ihttps://pypi.tuna.tsinghua.edu.cn/simple
  1. 安装horovod
HOROVOD_WITH_TENSORFLOW=1 HOROVOD_WITHOUT_MXNET=1 HOROVOD_WITH_PYTORCH=1 HOROVOD_WITHOUT_GLOO=1 HOROVOD_GPU_OPERATIONS=NCCL HOROVOD_CMAKE=/root/miniconda3/bin/cmake /root/miniconda3/bin/pip install --verbose --no-cache-dir horovod

安装horovod的时候需要GPU。

相关文章
|
IDE PyTorch 网络安全
|
算法框架/工具
成功解决INFO: pip is looking at multiple versions of keras-preprocessing to determine which version is c
成功解决INFO: pip is looking at multiple versions of keras-preprocessing to determine which version is c
|
2月前
|
TensorFlow 算法框架/工具
运行tensorboard报错:ValueError: Duplicate plugins for name projector
运行tensorboard报错:ValueError: Duplicate plugins for name projector
45 0
|
6月前
|
计算机视觉 Python
ERROR: Could not find a version that satisfies the requirement PIL (from versions: none)
ERROR: Could not find a version that satisfies the requirement PIL (from versions: none)
解决 RuntimeError: cuDNN error: CUDNN_STATUS_INTERNAL_ERROR
解决 RuntimeError: cuDNN error: CUDNN_STATUS_INTERNAL_ERROR
228 0
|
并行计算 PyTorch 算法框架/工具
RuntimeError: CUDA error (10): invalid device ordinal
造成这个错误的原因主要是本地只有一个 GPU (GPU:0),而程序中使用 GPUs:1。
300 0
|
PyTorch 算法框架/工具
Pytorch报错:AttributeError: ‘version_info‘ object has no attribute ‘__version__‘
Pytorch报错:AttributeError: ‘version_info‘ object has no attribute ‘__version__‘
130 0
|
数据格式
ValueError: This model has not yet been built. Build the model first by calling `build()` or calling
ValueError: This model has not yet been built. Build the model first by calling `build()` or calling
157 0
ValueError: This model has not yet been built. Build the model first by calling `build()` or calling
|
Python
解决ValueError: `validation_split` is only supported for Tensors or NumPy arrays, found following
解决ValueError: `validation_split` is only supported for Tensors or NumPy arrays, found following
556 0
解决ValueError: `validation_split` is only supported for Tensors or NumPy arrays, found following
|
并行计算
ERROR: cuda requested, but not all dependencies are satisfied: ffnvcodec
ERROR: cuda requested, but not all dependencies are satisfied: ffnvcodec
137 0