mmdeploy
mmdeploy copied to clipboard
[Bug] Cannot use MMDeploy with MMAction2
Checklist
- [X] I have searched related issues but cannot get the expected help.
- [X] 2. I have read the FAQ documentation but cannot get the expected help.
- [X] 3. The bug has not been fixed in the latest version.
Describe the bug
I am trying to use MMAction2 with MMDeploy so that I can deploy a finetuned MMAction2 TSN model as an ONNX model.
I am following this guide: https://github.com/open-mmlab/mmdeploy/blob/dev-1.x/docs/en/04-supported-codebases/mmaction2.md
However, I am stuck at setting up the environment. I am trying to use the Docker image provided by MMDeploy and install MMAction2 on top of it.
However, it does not work for me.
Reproduction
I am trying to use the Docker image provided by MMDeploy.
docker pull openmmlab/mmdeploy:ubuntu20.04-cuda11.8-mmdeploy1.3.1
Since MMDeploy also requires me to have MMAction2 installed first, I installed MMAction2 by:
git clone https://github.com/open-mmlab/mmaction2.git
cd mmaction2
pip install -v -e .
Then, I tried to convert video recognition model into ONNX model by something like this in the guide:
python3 tools/deploy.py configs/mmaction/video-recognition/video-recognition_onnxruntime_static.py shared/tsn_imagenet-pretrained-r50_8xb32-1x1x3-100e_kinetics400-rgb.py shared/tsn_imagenet-pretrained-r50_8xb32-1x1x3-100e_kinetics400-rgb_20220906-cd10898e.pth tests/data/arm_wrestling.mp4 --work-dir mmdeploy_models/mmaction/tsn/ort
--device cpu --show --dump-info
Environment
It is very strange that it tells me mmaction is not installed. Because when I run pip freeze in ~/workspace/mmaction2, it has mmaction2==1.2.0.
This is my file structure, "mmdeploy" and "mmaction2" are two folders under a common dir "workspace":
~/workspace# ls
TensorRT cmake mmaction2 ncnn onnxruntime-linux-x64-gpu-1.15.1 ppl.cv
TensorRT-8.6.1.6 jdk-18 mmdeploy onnxruntime-linux-x64-1.15.1 openvino_toolkit ppl.nn
python tools/check_env.py:
04/22 04:09:08 - mmengine - INFO -
04/22 04:09:08 - mmengine - INFO - **********Environmental information**********
04/22 04:09:09 - mmengine - INFO - sys.platform: linux
04/22 04:09:09 - mmengine - INFO - Python: 3.8.10 (default, May 26 2023, 14:05:08) [GCC 9.4.0]
04/22 04:09:09 - mmengine - INFO - CUDA available: True
04/22 04:09:09 - mmengine - INFO - MUSA available: False
04/22 04:09:09 - mmengine - INFO - numpy_random_seed: 2147483648
04/22 04:09:09 - mmengine - INFO - GPU 0: NVIDIA GeForce RTX 4060 Laptop GPU
04/22 04:09:09 - mmengine - INFO - CUDA_HOME: /usr/local/cuda
04/22 04:09:09 - mmengine - INFO - NVCC: Cuda compilation tools, release 11.8, V11.8.89
04/22 04:09:09 - mmengine - INFO - GCC: x86_64-linux-gnu-gcc (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0
04/22 04:09:09 - mmengine - INFO - PyTorch: 2.0.0+cu118
04/22 04:09:09 - mmengine - INFO - PyTorch compiling details: PyTorch built with:
- GCC 9.3
- C++ Version: 201703
- Intel(R) oneAPI Math Kernel Library Version 2022.2-Product Build 20220804 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
- CUDA Runtime 11.8
- NVCC architecture flags: -gencode;arch=compute_37,code=sm_37;-gencode;arch=compute_50,code=sm_50;-gencode;arch=compute_60,code=sm_60;-gencode;arch=compute_70,code=sm_70;-gencode;arch=compute_75,code=sm_75;-gencode;arch=compute_80,code=sm_80;-gencode;arch=compute_86,code=sm_86;-gencode;arch=compute_90,code=sm_90
- CuDNN 8.7
- Magma 2.6.1
- Build settings: BLAS_INFO=mkl, BUILD_TYPE=Release, CUDA_VERSION=11.8, CUDNN_VERSION=8.7.0, 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_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=ON, USE_CUDNN=ON, USE_EXCEPTION_PTR=1, USE_GFLAGS=OFF, USE_GLOG=OFF, USE_MKL=ON, USE_MKLDNN=ON, USE_MPI=OFF, USE_NCCL=1, USE_NNPACK=ON, USE_OPENMP=ON, USE_ROCM=OFF,
04/22 04:09:09 - mmengine - INFO - TorchVision: 0.15.0+cu118
04/22 04:09:09 - mmengine - INFO - OpenCV: 4.5.4
04/22 04:09:09 - mmengine - INFO - MMEngine: 0.10.3
04/22 04:09:09 - mmengine - INFO - MMCV: 2.1.0
04/22 04:09:09 - mmengine - INFO - MMCV Compiler: GCC 9.3
04/22 04:09:09 - mmengine - INFO - MMCV CUDA Compiler: 11.8
04/22 04:09:09 - mmengine - INFO - MMDeploy: 1.3.1+bc75c9d
04/22 04:09:09 - mmengine - INFO -
04/22 04:09:09 - mmengine - INFO - **********Backend information**********
04/22 04:09:09 - mmengine - INFO - tensorrt: 8.6.1
04/22 04:09:09 - mmengine - INFO - tensorrt custom ops: Available
04/22 04:09:09 - mmengine - INFO - ONNXRuntime: None
04/22 04:09:09 - mmengine - INFO - ONNXRuntime-gpu: 1.15.1
04/22 04:09:09 - mmengine - INFO - ONNXRuntime custom ops: Available
04/22 04:09:09 - mmengine - INFO - pplnn: 0.8.1
04/22 04:09:09 - mmengine - INFO - ncnn: 1.0.20230905
04/22 04:09:09 - mmengine - INFO - ncnn custom ops: Available
04/22 04:09:09 - mmengine - INFO - snpe: None
04/22 04:09:09 - mmengine - INFO - openvino: 2023.0.2
04/22 04:09:09 - mmengine - INFO - torchscript: 2.0.0+cu118
04/22 04:09:09 - mmengine - INFO - torchscript custom ops: Available
04/22 04:09:09 - mmengine - INFO - rknn-toolkit: None
04/22 04:09:09 - mmengine - INFO - rknn-toolkit2: None
04/22 04:09:09 - mmengine - INFO - ascend: None
04/22 04:09:09 - mmengine - INFO - coreml: None
04/22 04:09:09 - mmengine - INFO - tvm: None
04/22 04:09:09 - mmengine - INFO - vacc: None
04/22 04:09:09 - mmengine - INFO -
04/22 04:09:09 - mmengine - INFO - **********Codebase information**********
04/22 04:09:09 - mmengine - INFO - mmdet: None
04/22 04:09:09 - mmengine - INFO - mmseg: None
04/22 04:09:09 - mmengine - INFO - mmpretrain: None
04/22 04:09:09 - mmengine - INFO - mmocr: None
04/22 04:09:09 - mmengine - INFO - mmagic: None
04/22 04:09:09 - mmengine - INFO - mmdet3d: None
04/22 04:09:09 - mmengine - INFO - mmpose: None
04/22 04:09:09 - mmengine - INFO - mmrotate: None
04/22 04:09:09 - mmengine - INFO - mmaction: None
04/22 04:09:09 - mmengine - INFO - mmrazor: None
04/22 04:09:09 - mmengine - INFO - mmyolo: None
### Error traceback
```Shell
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/workspace/mmdeploy/mmdeploy/backend/sdk/export_info.py", line 352, in export2SDK
deploy_info = get_deploy(deploy_cfg, model_cfg, work_dir, device)
File "/root/workspace/mmdeploy/mmdeploy/backend/sdk/export_info.py", line 267, in get_deploy
_, customs = get_model_name_customs(
File "/root/workspace/mmdeploy/mmdeploy/backend/sdk/export_info.py", line 61, in get_model_name_customs
task_processor = build_task_processor(
File "/root/workspace/mmdeploy/mmdeploy/apis/utils/utils.py", line 46, in build_task_processor
import_codebase(codebase_type, custom_module_list)
File "/root/workspace/mmdeploy/mmdeploy/codebase/__init__.py", line 31, in import_codebase
raise ImportError(f'{lib} has not been installed. '
ImportError: mmaction has not been installed. Import mmaction failed.