Skip to content

Commit d9eb6d0

Browse files
authored
[Enhancement] Update the installation of MMCV (open-mmlab#1275)
* Update the installation of MMCV * use matrix.torch_version * fix typo in doc * fix docs * fix colab * change docs
1 parent 346f70d commit d9eb6d0

File tree

4 files changed

+67
-27
lines changed

4 files changed

+67
-27
lines changed

.github/workflows/build.yml

Lines changed: 13 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,20 @@ jobs:
3131
torch: [1.5.1, 1.6.0, 1.7.0, 1.8.0, 1.9.0]
3232
include:
3333
- torch: 1.5.1
34+
torch_version: torch1.5
3435
torchvision: 0.6.1
35-
mmcv: 1.5.0
3636
- torch: 1.6.0
37+
torch_version: torch1.6
3738
torchvision: 0.7.0
38-
mmcv: 1.6.0
3939
- torch: 1.7.0
40+
torch_version: torch1.7
4041
torchvision: 0.8.1
41-
mmcv: 1.7.0
4242
- torch: 1.8.0
43+
torch_version: torch1.8
4344
torchvision: 0.9.0
44-
mmcv: 1.8.0
4545
- torch: 1.9.0
46+
torch_version: torch1.9
4647
torchvision: 0.10.0
47-
mmcv: 1.9.0
4848
steps:
4949
- uses: actions/checkout@v2
5050
- name: Set up Python ${{ matrix.python-version }}
@@ -60,7 +60,7 @@ jobs:
6060
run: pip install torch==${{matrix.torch}}+cpu torchvision==${{matrix.torchvision}}+cpu -f https://download.pytorch.org/whl/torch_stable.html
6161
- name: Install MMCV
6262
run: |
63-
pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cpu/torch${{matrix.mmcv}}/index.html
63+
pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cpu/${{matrix.torch_version}}/index.html
6464
python -c 'import mmcv; print(mmcv.__version__)'
6565
- name: Install unittest dependencies
6666
run: |
@@ -98,21 +98,17 @@ jobs:
9898
]
9999
include:
100100
- torch: 1.5.1+cu101
101-
torch_version: torch1.5.1
101+
torch_version: torch1.5
102102
torchvision: 0.6.1+cu101
103-
mmcv: 1.5.0
104103
- torch: 1.6.0+cu101
105-
torch_version: torch1.6.0
104+
torch_version: torch1.6
106105
torchvision: 0.7.0+cu101
107-
mmcv: 1.6.0
108106
- torch: 1.7.0+cu101
109-
torch_version: torch1.7.0
107+
torch_version: torch1.7
110108
torchvision: 0.8.1+cu101
111-
mmcv: 1.7.0
112109
- torch: 1.8.0+cu101
113-
torch_version: torch1.8.0
110+
torch_version: torch1.8
114111
torchvision: 0.9.0+cu101
115-
mmcv: 1.8.0
116112

117113
steps:
118114
- uses: actions/checkout@v2
@@ -133,7 +129,7 @@ jobs:
133129
- name: Install mmseg dependencies
134130
run: |
135131
python -V
136-
python -m pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cu101/torch${{matrix.mmcv}}/index.html
132+
python -m pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cu101/${{matrix.torch_version}}/index.html
137133
python -m pip install -r requirements.txt
138134
python -c 'import mmcv; print(mmcv.__version__)'
139135
- name: Build and install
@@ -174,9 +170,8 @@ jobs:
174170
torch: [1.9.0+cu102]
175171
include:
176172
- torch: 1.9.0+cu102
177-
torch_version: torch1.9.0
173+
torch_version: torch1.9
178174
torchvision: 0.10.0+cu102
179-
mmcv_link: 1.9.0
180175

181176
steps:
182177
- uses: actions/checkout@v2
@@ -197,7 +192,7 @@ jobs:
197192
- name: Install mmseg dependencies
198193
run: |
199194
python -V
200-
python -m pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cu102/torch${{matrix.mmcv_link}}/index.html
195+
python -m pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cu102/${{matrix.torch_version}}/index.html
201196
python -m pip install -r requirements.txt
202197
python -c 'import mmcv; print(mmcv.__version__)'
203198
- name: Build and install

demo/MMSegmentation_Tutorial.ipynb

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
"## Install MMSegmentation\n",
3434
"This step may take several minutes. \n",
3535
"\n",
36-
"We use PyTorch 1.5.0 and CUDA 10.1 for this tutorial. You may install other versions by changing the version number in pip install command. "
36+
"We use PyTorch 1.6 and CUDA 10.1 for this tutorial. You may install other versions by change the version number in pip install command. "
3737
]
3838
},
3939
{
@@ -67,9 +67,9 @@
6767
"outputs": [],
6868
"source": [
6969
"# Install PyTorch\n",
70-
"!pip install -U torch==1.5.0+cu101 torchvision==0.6.0+cu101 -f https://download.pytorch.org/whl/torch_stable.html\n",
70+
"!conda install pytorch=1.6.0 torchvision cudatoolkit=10.1 -c pytorch\n",
7171
"# Install MMCV\n",
72-
"!pip install mmcv-full==latest+torch1.5.0+cu101 -f https://download.openmmlab.com/mmcv/dist/index.html"
72+
"!pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cu101/torch1.6/index.html"
7373
]
7474
},
7575
{

docs/en/get_started.md

Lines changed: 26 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,12 +57,36 @@ Either `mmcv` or `mmcv-full` is compatible with MMSegmentation, but for methods
5757

5858
**Install mmcv for Linux:**
5959

60-
The pre-build mmcv-full (with PyTorch 1.6 and CUDA 10.1) can be installed by running: (other available versions could be found [here](https://mmcv.readthedocs.io/en/latest/#install-with-pip))
60+
Install MMCV, we recommend you to install the pre-built mmcv as below.
6161

6262
```shell
63-
pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cu101/torch1.6.0/index.html
63+
pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/{cu_version}/{torch_version}/index.html
64+
```
65+
66+
Please replace ``{cu_version}`` and ``{torch_version}`` in the url to your desired one. mmcv-full is only compiled on
67+
PyTorch 1.x.0 because the compatibility usually holds between 1.x.0 and 1.x.1. If your PyTorch version is 1.x.1,
68+
you can install mmcv-full compiled with PyTorch 1.x.0 and it usually works well.
69+
For example, to install the ``mmcv-full`` with ``CUDA 10.1`` and ``PyTorch 1.6.0``, use the following command:
70+
71+
```shell
72+
pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cu101/torch1.6/index.html
73+
```
74+
75+
See [here](https://github.com/open-mmlab/mmcv#installation) for different versions of MMCV compatible to different PyTorch and CUDA versions.
76+
77+
Optionally you can choose to compile mmcv from source by the following command
78+
79+
```shell
80+
git clone https://github.com/open-mmlab/mmcv.git
81+
cd mmcv
82+
MMCV_WITH_OPS=1 pip install -e . # package mmcv-full, which contains cuda ops, will be installed after this step
83+
# OR pip install -e . # package mmcv, which contains no cuda ops, will be installed after this step
84+
cd ..
6485
```
6586

87+
**Important:** You need to run `pip uninstall mmcv` first if you have mmcv installed. Because if `mmcv` and `mmcv-full` are both installed, there will be `ModuleNotFoundError`.
88+
89+
6690
**Install mmcv for Windows (Experimental):**
6791

6892
For Windows, the installation of MMCV requires native C++ compilers, such as cl.exe. Please add the compiler to %PATH%.

docs/zh_cn/get_started.md

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,14 +57,35 @@ c. 按照 [官方教程](https://mmcv.readthedocs.io/en/latest/#installation)
5757

5858
**在 Linux 下安装 mmcv:**
5959

60-
通过运行
60+
为了安装 MMCV, 我们推荐使用下面的这种预编译好的 MMCV.
6161

6262
```shell
63-
pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cu101/torch1.5.0/index.html
63+
pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/{cu_version}/{torch_version}/index.html
6464
```
6565

66-
可以安装好 mmcv-full (PyTorch 1.5 和 CUDA 10.1) 版本。
67-
其他 PyTorch 和 CUDA 版本的 MMCV 安装请参照[这里](https://mmcv.readthedocs.io/en/latest/#install-with-pip)
66+
请替换 url 里面的 ``{cu_version}````{torch_version}`` 为您想要使用的版本. mmcv-full 仅在
67+
PyTorch 1.x.0 上面编译, 因为在 1.x.0 和 1.x.1 之间通常是兼容的. 如果您的 PyTorch 版本是 1.x.1,
68+
您可以安装用 PyTorch 1.x.0 编译的 mmcv-full 而它通常是可以正常使用的.
69+
例如, 用 ``CUDA 10.1`` and ``PyTorch 1.6.0`` 安装使用 ``mmcv-full``, 使用如下命令:
70+
71+
```shell
72+
pip install mmcv-full -f https://download.openmmlab.com/mmcv/dist/cu101/torch1.6/index.html
73+
```
74+
75+
请查看 [这里](https://github.com/open-mmlab/mmcv#installation) 来找到适配不同 PyTorch 和 CUDA 版本的 MMCV.
76+
77+
您也可以采用下面的命令来从源码编译 MMCV (可选)
78+
79+
```shell
80+
git clone https://github.com/open-mmlab/mmcv.git
81+
cd mmcv
82+
MMCV_WITH_OPS=1 pip install -e . # package mmcv-full, which contains cuda ops, will be installed after this step
83+
# OR pip install -e . # package mmcv, which contains no cuda ops, will be installed after this step
84+
cd ..
85+
```
86+
87+
**重点:** 如果您已经安装了 MMCV, 您需要先运行 `pip uninstall mmcv`. 因为如果 `mmcv``mmcv-full` 被同时安装, 将会报错 `ModuleNotFoundError`.
88+
6889

6990
**在 Windows 下安装 mmcv (有风险):**
7091

0 commit comments

Comments
 (0)