-
Notifications
You must be signed in to change notification settings - Fork 675
Closed
Labels
Description
Checklist
- I have searched related issues but cannot get the expected help.
- 2. I have read the FAQ documentation but cannot get the expected help.
- 3. The bug has not been fixed in the latest version.
Describe the bug
- I want to convert my
.pth
file built by mmpretrain to an onnx model - I followed the installation instructions in Linux-x86_64 with only cpu
- However, when I tried to convert a ResNeXt101 model to onnx, the following error happened:
- I have installed the latest version of mmpretrain and mmdeploy.
- When I ran the example code, the error still came to occur.
Reproduction
In order to reproduce easier for u. u can just run the example code as shown below.
cd mmdeploy
# download resnet18 model from mmpretrain model zoo
mim download mmpretrain --config resnet18_8xb32_in1k --dest .
# convert mmpretrain model to onnxruntime model with dynamic shape
python tools/deploy.py \
configs/mmpretrain/classification_onnxruntime_dynamic.py \
resnet18_8xb32_in1k.py \
resnet18_8xb32_in1k_20210831-fbbb1da6.pth \
tests/data/tiger.jpeg \
--work-dir mmdeploy_models/mmpretrain/ort \
--device cpu \
--show \
--dump-info
I am sure that I didn't make any modifications on the code or config.
Environment
(base) [root@VM-4-17-centos mmdeploy]# python tools/check_env.py
05/15 01:10:49 - mmengine - INFO -
05/15 01:10:49 - mmengine - INFO - **********Environmental information**********
05/15 01:10:51 - mmengine - INFO - sys.platform: linux
05/15 01:10:51 - mmengine - INFO - Python: 3.8.3 (default, May 19 2020, 18:47:26) [GCC 7.3.0]
05/15 01:10:51 - mmengine - INFO - CUDA available: False
05/15 01:10:51 - mmengine - INFO - numpy_random_seed: 2147483648
05/15 01:10:51 - mmengine - INFO - GCC: gcc (GCC) 11.2.0
05/15 01:10:51 - mmengine - INFO - PyTorch: 2.0.0
05/15 01:10:51 - mmengine - INFO - PyTorch compiling details: PyTorch built with:
- GCC 9.3
- C++ Version: 201703
- Intel(R) oneAPI Math Kernel Library Version 2021.4-Product Build 20210904 for Intel(R) 64 architecture applications
- Intel(R) MKL-DNN v2.7.3 (Git Hash 6dbeffbae1f23cbbeae17adb7b5b13f1f37c080e)
- OpenMP 201511 (a.k.a. OpenMP 4.5)
- LAPACK is enabled (usually provided by MKL)
- NNPACK is enabled
- CPU capability usage: AVX2
- Build settings: BLAS_INFO=mkl, BUILD_TYPE=Release, CXX_COMPILER=/opt/rh/devtoolset-9/root/usr/bin/c++, CXX_FLAGS= -D_GLIBCXX_USE_CXX11_ABI=0 -fabi-version=11 -Wno-deprecated -fvisibility-inlines-hidden -DUSE_PTHREADPOOL -DNDEBUG -DUSE_KINETO -DLIBKINETO_NOCUPTI -DLIBKINETO_NOROCTRACER -DUSE_FBGEMM -DUSE_QNNPACK -DUSE_PYTORCH_QNNPACK -DUSE_XNNPACK -DSYMBOLICATE_MOBILE_DEBUG_HANDLE -O2 -fPIC -Wall -Wextra -Werror=return-type -Werror=non-virtual-dtor -Werror=bool-operation -Wnarrowing -Wno-missing-field-initializers -Wno-type-limits -Wno-array-bounds -Wno-unknown-pragmas -Wunused-local-typedefs -Wno-unused-parameter -Wno-unused-function -Wno-unused-result -Wno-strict-overflow -Wno-strict-aliasing -Wno-error=deprecated-declarations -Wno-stringop-overflow -Wno-psabi -Wno-error=pedantic -Wno-error=redundant-decls -Wno-error=old-style-cast -fdiagnostics-color=always -faligned-new -Wno-unused-but-set-variable -Wno-maybe-uninitialized -fno-math-errno -fno-trapping-math -Werror=format -Werror=cast-function-type -Wno-stringop-overflow, LAPACK_INFO=mkl, PERF_WITH_AVX=1, PERF_WITH_AVX2=1, PERF_WITH_AVX512=1, TORCH_DISABLE_GPU_ASSERTS=ON, TORCH_VERSION=2.0.0, USE_CUDA=0, USE_CUDNN=OFF, USE_EXCEPTION_PTR=1, USE_GFLAGS=OFF, USE_GLOG=OFF, USE_MKL=ON, USE_MKLDNN=ON, USE_MPI=OFF, USE_NCCL=OFF, USE_NNPACK=ON, USE_OPENMP=ON, USE_ROCM=OFF,
05/15 01:10:51 - mmengine - INFO - TorchVision: 0.15.0
05/15 01:10:51 - mmengine - INFO - OpenCV: 4.7.0
05/15 01:10:51 - mmengine - INFO - MMEngine: 0.7.3
05/15 01:10:51 - mmengine - INFO - MMCV: 2.0.0
05/15 01:10:51 - mmengine - INFO - MMCV Compiler: GCC 7.3
05/15 01:10:51 - mmengine - INFO - MMCV CUDA Compiler: not available
05/15 01:10:51 - mmengine - INFO - MMDeploy: 1.0.0+26b66ef
05/15 01:10:51 - mmengine - INFO -
05/15 01:10:51 - mmengine - INFO - **********Backend information**********
05/15 01:10:51 - mmengine - INFO - tensorrt: None
05/15 01:10:51 - mmengine - INFO - ONNXRuntime: None
05/15 01:10:51 - mmengine - INFO - pplnn: None
05/15 01:10:51 - mmengine - INFO - ncnn: None
05/15 01:10:51 - mmengine - INFO - snpe: None
05/15 01:10:51 - mmengine - INFO - openvino: None
05/15 01:10:51 - mmengine - INFO - torchscript: 2.0.0
05/15 01:10:51 - mmengine - INFO - torchscript custom ops: NotAvailable
05/15 01:10:51 - mmengine - INFO - rknn-toolkit: None
05/15 01:10:51 - mmengine - INFO - rknn-toolkit2: None
05/15 01:10:51 - mmengine - INFO - ascend: None
05/15 01:10:51 - mmengine - INFO - coreml: None
05/15 01:10:51 - mmengine - INFO - tvm: None
05/15 01:10:51 - mmengine - INFO - vacc: None
05/15 01:10:51 - mmengine - INFO -
05/15 01:10:51 - mmengine - INFO - **********Codebase information**********
05/15 01:10:51 - mmengine - INFO - mmdet: 3.0.0
05/15 01:10:51 - mmengine - INFO - mmseg: None
05/15 01:10:51 - mmengine - INFO - mmcls: None
05/15 01:10:51 - mmengine - INFO - mmocr: None
05/15 01:10:51 - mmengine - INFO - mmedit: None
05/15 01:10:51 - mmengine - INFO - mmdet3d: None
05/15 01:10:51 - mmengine - INFO - mmpose: 1.0.0
05/15 01:10:51 - mmengine - INFO - mmrotate: None
05/15 01:10:51 - mmengine - INFO - mmaction: None
05/15 01:10:51 - mmengine - INFO - mmrazor: None
Error traceback
05/15 01:07:26 - mmengine - WARNING - Failed to get codebase, got: 'Cannot get key by value "mmpretrain" of <enum \'Codebase\'>'. Then export a new codebase in Codebase MMPRETRAIN: mmpretrain
05/15 01:07:26 - mmengine - WARNING - Import mmdeploy.codebase.mmpretrain.deploy failedPlease check whether the module is the custom module.No module named 'mmdeploy.codebase.mmpretrain'
Traceback (most recent call last):
File "tools/deploy.py", line 335, in <module>
main()
File "tools/deploy.py", line 129, in main
export2SDK(
File "/root/miniconda3/lib/python3.8/site-packages/mmdeploy/backend/sdk/export_info.py", line 347, in export2SDK
deploy_info = get_deploy(deploy_cfg, model_cfg, work_dir, device)
File "/root/miniconda3/lib/python3.8/site-packages/mmdeploy/backend/sdk/export_info.py", line 262, in get_deploy
_, customs = get_model_name_customs(
File "/root/miniconda3/lib/python3.8/site-packages/mmdeploy/backend/sdk/export_info.py", line 61, in get_model_name_customs
task_processor = build_task_processor(
File "/root/miniconda3/lib/python3.8/site-packages/mmdeploy/apis/utils/utils.py", line 46, in build_task_processor
import_codebase(codebase_type, custom_module_list)
File "/root/miniconda3/lib/python3.8/site-packages/mmdeploy/codebase/__init__.py", line 35, in import_codebase
codebase = get_codebase_class(codebase_type)
File "/root/miniconda3/lib/python3.8/site-packages/mmdeploy/codebase/base/mmcodebase.py", line 86, in get_codebase_class
return CODEBASE.build({'type': codebase.value})
File "/root/miniconda3/lib/python3.8/site-packages/mmengine/registry/registry.py", line 548, in build
return self.build_func(cfg, *args, **kwargs, registry=self)
File "/root/miniconda3/lib/python3.8/site-packages/mmengine/registry/build_functions.py", line 100, in build_from_cfg
raise KeyError(
KeyError: 'mmpretrain is not in the Codebases registry. Please check whether the value of `mmpretrain` is correct or it was registered as expected. More details can be found at https://mmengine.readthedocs.io/en/latest/advanced_tutorials/config.html#import-the-custom-module'