NVDS: ModuleNotFoundError: No module named 'mmcv._ext' (Installation Issues)
作者你好,我在复现您提供的github代码时出现了以下的报错,似乎和mmcv-full有关,我是通过pip install mmcv-full==1.3.0 -f https://download.openmmlab.com/mmcv/dist/cu111/torch1.9.0/index.html以及pip install mmcv-full==1.3.0都尝试过,但都是这个报错。请问有什么解决方法吗,以下是报错信息: (NVDS) qjc@omnisky:/data3/qjcnerf/NVDS$ CUDA_VISIBLE_DEVICES=0 python infer_NVDS_dpt_bi.py --base_dir ./demo_outputs/dpt_init/000423/ --vnum 000423 --infer_w 896 --infer_h 384 Traceback (most recent call last): File “infer_NVDS_dpt_bi.py”, line 19, in <module> from backbone import * File “/data3/qjcnerf/NVDS/backbone.py”, line 15, in <module> from mmseg.models.builder import BACKBONES File “/data1/qjc_new/anaconda/envs/NVDS/lib/python3.8/site-packages/mmseg/models/init.py”, line 1, in <module> from .backbones import * # noqa: F401,F403 File “/data1/qjc_new/anaconda/envs/NVDS/lib/python3.8/site-packages/mmseg/models/backbones/init.py”, line 2, in <module> from .fast_scnn import FastSCNN File “/data1/qjc_new/anaconda/envs/NVDS/lib/python3.8/site-packages/mmseg/models/backbones/fast_scnn.py”, line 7, in <module> from mmseg.models.decode_heads.psp_head import PPM File “/data1/qjc_new/anaconda/envs/NVDS/lib/python3.8/site-packages/mmseg/models/decode_heads/init.py”, line 16, in <module> from .point_head import PointHead File “/data1/qjc_new/anaconda/envs/NVDS/lib/python3.8/site-packages/mmseg/models/decode_heads/point_head.py”, line 6, in <module> from mmcv.ops import point_sample File “/data1/qjc_new/anaconda/envs/NVDS/lib/python3.8/site-packages/mmcv/ops/init.py”, line 1, in <module> from .bbox import bbox_overlaps File “/data1/qjc_new/anaconda/envs/NVDS/lib/python3.8/site-packages/mmcv/ops/bbox.py”, line 3, in <module> ext_module = ext_loader.load_ext(‘_ext’, [‘bbox_overlaps’]) File “/data1/qjc_new/anaconda/envs/NVDS/lib/python3.8/site-packages/mmcv/utils/ext_loader.py”, line 11, in load_ext ext = importlib.import_module(‘mmcv.’ + name) File “/data1/qjc_new/anaconda/envs/NVDS/lib/python3.8/importlib/init.py”, line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) ModuleNotFoundError: No module named ‘mmcv._ext’ 以下是我的环境信息: `(NVDS) qjc@omnisky:/data3/qjcnerf/NVDS$ conda list packages in environment at /data1/qjc_new/anaconda/envs/NVDS:
Name Version Build Channel _libgcc_mutex 0.1 main _openmp_mutex 5.1 1_gnu addict 2.4.0 pypi_0 pypi asttokens 2.2.1 pypi_0 pypi attr 0.3.2 pypi_0 pypi backcall 0.2.0 pypi_0 pypi blas 1.0 mkl bzip2 1.0.8 h7f98852_4 conda-forge ca-certificates 2023.7.22 hbcca054_0 conda-forge certifi 2023.7.22 pypi_0 pypi charset-normalizer 3.2.0 pypi_0 pypi click 8.1.6 pypi_0 pypi colorama 0.4.6 pypi_0 pypi cudatoolkit 11.1.1 ha002fc5_10 conda-forge cycler 0.11.0 pypi_0 pypi decorator 5.1.1 pypi_0 pypi einops 0.4.1 pypi_0 pypi executing 1.2.0 pypi_0 pypi ffmpeg 4.3 hf484d3e_0 pytorch fonttools 4.41.1 pypi_0 pypi freetype 2.10.4 h0708190_1 conda-forge gmp 6.2.1 h58526e2_0 conda-forge gnutls 3.6.13 h85f3911_1 conda-forge h5py 3.9.0 pypi_0 pypi idna 3.4 pypi_0 pypi imageio 2.31.1 pypi_0 pypi importlib-metadata 6.8.0 pypi_0 pypi intel-openmp 2022.1.0 h9e868ea_3769 ipython 8.5.0 pypi_0 pypi jedi 0.18.2 pypi_0 pypi jpeg 9b h024ee3a_2 kiwisolver 1.4.4 pypi_0 pypi lame 3.100 h7f98852_1001 conda-forge ld_impl_linux-64 2.38 h1181459_1 libffi 3.3 he6710b0_2 libgcc-ng 11.2.0 h1234567_1 libgomp 11.2.0 h1234567_1 libiconv 1.17 h166bdaf_0 conda-forge libpng 1.6.37 h21135ba_2 conda-forge libstdcxx-ng 11.2.0 h1234567_1 libtiff 4.1.0 h2733197_1 libuv 1.43.0 h7f98852_0 conda-forge lz4-c 1.9.3 h9c3ff4c_1 conda-forge markdown 3.4.3 pypi_0 pypi markdown-it-py 3.0.0 pypi_0 pypi matplotlib 3.5.3 pypi_0 pypi matplotlib-inline 0.1.6 pypi_0 pypi mdurl 0.1.2 pypi_0 pypi mkl 2022.1.0 hc2b9512_224 mmcv 1.3.0 pypi_0 pypi mmcv-full 1.3.0 pypi_0 pypi mmengine 0.8.2 pypi_0 pypi mmsegmentation 0.11.0 pypi_0 pypi model-index 0.1.11 pypi_0 pypi ncurses 6.4 h6a678d5_0 nettle 3.6 he412f7d_0 conda-forge ninja 1.11.0 h924138e_0 conda-forge nose 1.3.7 pypi_0 pypi numpy 1.23.2 pypi_0 pypi olefile 0.46 pyh9f0ad1d_1 conda-forge opencv-python 4.8.0.74 pypi_0 pypi opencv-python-headless 4.8.0.74 pypi_0 pypi opendatalab 0.0.9 pypi_0 pypi openh264 2.1.1 h780b84a_0 conda-forge openmim 0.3.9 pypi_0 pypi openssl 1.1.1u h7f8727e_0 ordered-set 4.1.0 pypi_0 pypi packaging 23.1 pypi_0 pypi pandas 2.0.3 pypi_0 pypi parso 0.8.3 pypi_0 pypi pexpect 4.8.0 pypi_0 pypi pickleshare 0.7.5 pypi_0 pypi pillow 10.0.0 pypi_0 pypi pip 23.1.2 py38h06a4308_0 platformdirs 3.9.1 pypi_0 pypi prettytable 3.8.0 pypi_0 pypi prompt-toolkit 3.0.39 pypi_0 pypi ptyprocess 0.7.0 pypi_0 pypi pure-eval 0.2.2 pypi_0 pypi pycryptodome 3.18.0 pypi_0 pypi pygments 2.15.1 pypi_0 pypi pyparsing 3.1.0 pypi_0 pypi python 3.8.13 haa1d7c7_1 python-dateutil 2.8.2 pypi_0 pypi pytorch 1.9.0 py3.8_cuda11.1_cudnn8.0.5_0 pytorch pytz 2023.3 pypi_0 pypi pyyaml 6.0.1 pypi_0 pypi readline 8.2 h5eee18b_0 requests 2.31.0 pypi_0 pypi resnest 0.0.5 pypi_0 pypi rfconv 0.0.2b20210406 pypi_0 pypi rich 13.4.2 pypi_0 pypi scipy 1.9.1 pypi_0 pypi setuptools 67.8.0 py38h06a4308_0 six 1.16.0 pypi_0 pypi sqlite 3.41.2 h5eee18b_0 stack-data 0.6.2 pypi_0 pypi tabulate 0.9.0 pypi_0 pypi termcolor 2.3.0 pypi_0 pypi terminaltables 3.1.10 pypi_0 pypi timm 0.6.7 pypi_0 pypi tk 8.6.12 h1ccaba5_0 tomli 2.0.1 pypi_0 pypi torchvision 0.10.0 py38_cu111 pytorch tqdm 4.65.0 pypi_0 pypi traitlets 5.9.0 pypi_0 pypi typing_extensions 4.7.1 pyha770c72_0 conda-forge tzdata 2023.3 pypi_0 pypi urllib3 2.0.4 pypi_0 pypi wcwidth 0.2.6 pypi_0 pypi wheel 0.38.4 py38h06a4308_0 xz 5.4.2 h5eee18b_0 yapf 0.40.1 pypi_0 pypi zipp 3.16.2 pypi_0 pypi zlib 1.2.13 h5eee18b_0 zstd 1.4.9 haebb681_0 `
About this issue
- Original URL
- State: open
- Created a year ago
- Comments: 15 (6 by maintainers)
@TouqeerAhmad I met this issue before, but i have solved it now. I think the key point is to match the version of mmcv-full, mmsegmentation, cuda and pytorch. For me, I use cuda 11.6 and pytorch 1.13.0, so I pip install mmcv-full==1.7.1 (i check the available version from this link: https://download.openmmlab.com/mmcv/dist/cu116/torch1.13/index.html), and pip install mmsegmentation==0.30.0. Finally it works. BTW, I advise you to install mmcv-full==1.x.x, because some parts of mmcv have been removed after 2.0.0, like mmcv.runner used in this repository. (https://github.com/open-mmlab/mmcv/pull/2216)
作者的Readme在安装mmcv-full和mmsegmentation是错误的。
我更换了cuda=11.3和pytorch=1.10的版本,使用了如下命令安装: conda install pytorch==1.10.0 torchvision==0.11.0 torchaudio==0.10.0 cudatoolkit=11.3 -c pytorch -c conda-forge
mmcv-full使用了1.7.0的高版本: pip install mmcv-full==1.7.0 -f https://download.openmmlab.com/mmcv/dist/cu113/torch1.10/index.html
mmsegmentation使用了0.3.0的版本 pip install mmsegmentation==0.30.0
然后我补充了一些库,运行我成功运行了!!!
Thank you both @EninumXJ @RaymondWang987! This was very helpful. I was able to successfully run NVDS after properly setting up the requirements. I am just going to state my steps here, in case someone else stumbles upon similar issue.
I first verified the torch and cuda versions for one of my existing virtual environments using:
python -c 'import torch;print(torch.__version__);print(torch.version.cuda)'
which turned out to be 1.10.2 and 11.3 respectively. Then I installed mmcv_full by specifying my torch and cuda version via following:
pip install mmcv_full==1.7.0 -f https://download.openmmlab.com/mmcv/dist/cu113/torch1.10/index.html
and then the mmsgementation:
pip install mmsegmentation==0.30.0
It then complained about three packages one after the other; specifically I installed the following:
pip install attr
pip install einops
pip install ipython
after which I was able to successfully run NVDS on market_6 sequence.
太感谢啦,不好意思,我的表达可能有误~这里只是记录一下我的解决方案,供后来者参考:), 奥利给!
readme的版本在我的服务器上是没有问题的,你可以看前面的讨论,只要mmcv的版本和你的cuda版本适配就可以了,我们readme当中的mmcv版本和我服务器的cuda是适配的。至于每个人不同的cuda版本,那你就需要根据mmcv官网查询版本对应关系进行安装就可以了。每个人服务器的cuda都不一样,我不可能为每一个版本去指定命令,这个自己根据自己的版本查mmcv的官方文档就可以了。所以我们的readme讲的很清楚,我指定的版本是适配的我的cuda,也是我通过命令查询出来的实际环境的版本。而你当然可以根据你的cuda和mmcv的版本更新进行安装,满足官网的适配关系就没问题,mmcv这一年也做了很多的更新,但我report的就是我实际的版本。
@TouqeerAhmad. For mmcv-full and mmseg, their official documents provide detailed version-matching relations with CUDA and Pytorch. For example, the official documents of
mmcv-full 1.3.x
provide a detailed matching table as the screenshot below, along with generating the Linux installation command for your case. These are similar for all mmcv versions by choosing the version numbers on the mmcv documents. Thus, in my previous reply, I suggested that the installation of mmcv-full and mmseg should follow their official documents. If you can read and follow the detailed mmcv-full and mmseg documents, the installation seems to be easy. I can not specify the installation for all people, since different servers have different CUDA and Pytorch versions.For the problems of @TouqeerAhmad, I agree with @EninumXJ. The key is to match the version of mmcv-full and mmsegmentation with the version of cuda and pytorch on your server. For instance, I have
CUDA 11.1
andPyTorch 1.9.0
on my server, thusmmcv-full 1.3.x
andmmseg 0.11.0
(as in our installation instructions) are compatible with my environment (confirmed by mmcv-full 1.3.x). Different servers adopt different Cuda versions. You should check the matching version of your own server on the official documents of mmcv and mmseg.You can see different versions of mmcv-full on their official document and choose the compatible one for your environment.