For the compatibility requirements between mmcv and cuda and pytorch versions, see the official mmcv documentation: https://mmcv.readthedocs.io/zh_CN/latest/get_started/installation.html#pip installation section.
Currently, the latest version 2.x is defaulted on the web page. If you want to switch to the old version, click on the lower left corner of the page to switch.。
-
Check your cuda and torch versions:
python -c 'import torch;print(torch.__version__);print(torch.version.cuda)' # pytorch 2.0版本需要cuda11.7及以上
-
Click the document link, select the version you want, copy the corresponding installation command, and install it.
Notice! ! !The open-mmlab family has been fully upgraded (1.x), which has major changes from 0.x and is no longer compatible. Operations in mmcv that are not related to cv have been moved to mmengine.Therefore, mmcv1.x and mmcv2.x versions are incompatible. Check whether your mmlab project requires the old version of mmcv or the new version..
The mmcv in the above link is no longer available in the old 1.x version. You can manually modify the mmcv version in the installation command as needed.
mmcv1.x version number description:
PyTorch is usually compatible between 1.x.0 and 1.x.1, so mmcv only provides 1.x.0 compiled packages. If your PyTorch version is 1.x.1, you can safely install mmcv compiled in version 1.x.0.
mmcv1.x version installation command query:https://mmcv.readthedocs.io/zh_CN/1.x/get_started/installation.html#pip
-
If it takes too long to install dependent libraries, you can specify the pypi source:
pip install mmcv -f https://download.openmmlab.com/mmcv/dist/cu111/torch1.9.0/index.html -i https://pypi.tuna.tsinghua.edu.cn/simple
-
Instructions for opencv-python-headless
If you plan to use opencv-python-headless instead of opencv-python, for example, in a small container environment or a server without a graphical user interface, you can install opencv-python-headless first, so that Opencv-python will be skipped during the installation of mmcv dependencies.