ModuleNotFoundError: No module named 'mmcv._ext'报错,不知道是否是版本不匹配的原因。换了多次pytorch和cudatoolkit版本才最终装好
1、nvcc检查cuda版本
nvidia-smi
+-----------------------------------------------------------------------------+
| NVIDIA-SMI 456.71 Driver Version: 456.71 CUDA Version: 11.1 |
|-------------------------------+----------------------+----------------------+
2\ conda新建环境,使用的是python3.7 然后安装pytorch
pip install torch==1.8.0+cu111 torchvision==0.9.0+cu111 torchaudio==0.8.0 -f https://download.pytorch.org/whl/torch_stable.html
3、mmcv安装,
git clone https://github.com/open-mmlab/mmcv.git
cd mmcv
pip install -r requirements.txt
set MMCV_WITH_OPS=1
pip install -e .
pip list 检查是否安装有mmcv
4、mmdetection安装
git clone https://github.com/open-mmlab/mmdetection.git
cd mmdetection
pip install -r requirements.txt
python setup.py build_ext --inplace
python setup.py build_ext --inplace 报错如下:
\lib\site-packages\torch\utils\cpp_extension.py:369: UserWarning: Attempted to use ninja as the BuildExtension backend but we could not find ninja.. Falling back to using the slow distutils backend.
warnings.warn(msg.format('we could not find ninja.'))
修改对应env下Lib\site-packages\torch\utils\cpp_extension.py
self.use_ninja = kwargs.get('use_ninja', True) 改为
self.use_ninja = kwargs.get('use_ninja', False)
再次
python setup.py build_ext --inplace
, 正确的是显示 running build_ext,然后
pip install -e .