[Refactor] refactor requirements (#1536)

* [Improve] build using ninja

* [Refactor] refactor requirements

* [Improve] imporve docs

* [Fix] fix file name
pull/1586/head^2
Jiazhen Wang 2021-12-29 23:15:11 +08:00 committed by GitHub
parent e1d6ea8c87
commit d30e37d4d5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 51 additions and 20 deletions

View File

@ -9,6 +9,12 @@ git clone https://github.com/open-mmlab/mmcv.git
cd mmcv
```
It is recommended to install `ninja` to speed up the compilation
```bash
pip install -r requirements/optional.txt
```
You can either
- install the lite version
@ -70,14 +76,14 @@ You should know how to set up environment variables, especially `Path`, on Windo
Do not use raw `cmd.exe` s instruction is based on PowerShell syntax.
1. Create a new conda environment
2. Create a new conda environment
```shell
conda create --name mmcv python=3.7 # 3.6, 3.7, 3.8 should work too as tested
conda activate mmcv # make sure to activate environment before any operation
```
1. Install PyTorch. Choose a version based on your need.
3. Install PyTorch. Choose a version based on your need.
```shell
conda install pytorch torchvision cudatoolkit=10.2 -c pytorch
@ -85,17 +91,23 @@ You should know how to set up environment variables, especially `Path`, on Windo
We only tested PyTorch version >= 1.6.0.
1. Prepare MMCV source code
4. Prepare MMCV source code
```shell
git clone https://github.com/open-mmlab/mmcv.git
cd mmcv
```
1. Install required Python packages
5. Install required Python packages
```shell
pip3 install -r requirements.txt
pip3 install -r requirements/runtime.txt
```
6. It is recommended to install `ninja` to speed up the compilation
```bash
pip install -r requirements/optional.txt
```
#### Build and install MMCV
@ -106,11 +118,11 @@ MMCV can be built in three ways:
In this way, no custom ops are compiled and mmcv is a pure python package.
1. Full version (CPU ops)
2. Full version (CPU ops)
Module `ops` will be compiled as a pytorch extension, but only x86 code will be compiled. The compiled ops can be executed on CPU only.
1. Full version (CUDA ops)
3. Full version (CUDA ops)
Both x86 and CUDA codes of `ops` module will be compiled. The compiled version can be run on both CPU and CUDA-enabled GPU (if implemented).
@ -150,14 +162,14 @@ pip list
##### Option 2: Build MMCV (full version with CPU)
1. Finish above common steps
1. Set up environment variables
2. Set up environment variables
```shell
$env:MMCV_WITH_OPS = 1
$env:MAX_JOBS = 8 # based on your available number of CPU cores and amount of memory
```
1. Following build steps of the lite version
3. Following build steps of the lite version
```shell
# activate environment
@ -175,7 +187,7 @@ pip list
##### Option 3: Build MMCV (full version with CUDA)
1. Finish above common steps
1. Make sure `CUDA_PATH` or `CUDA_HOME` is already set in `envs` via `ls env:`, desired output is shown as below:
2. Make sure `CUDA_PATH` or `CUDA_HOME` is already set in `envs` via `ls env:`, desired output is shown as below:
```none
(base) PS C:\Users\WRH> ls env:
@ -197,7 +209,7 @@ pip list
$env:CUDA_HOME = $env:CUDA_PATH_V10_2 # if CUDA_PATH_V10_2 is in envs:
```
1. Set CUDA target arch
3. Set CUDA target arch
```shell
# Suppose you are using GTX 1080, which is of capability 6.1
@ -210,7 +222,7 @@ pip list
Check your the compute capability of your GPU from [here](https://developer.nvidia.com/cuda-gpus).
```
1. Launch compiling the same way as CPU
4. Launch compiling the same way as CPU
```shell
$env:MMCV_WITH_OPS = 1

View File

@ -9,6 +9,12 @@ git clone https://github.com/open-mmlab/mmcv.git
cd mmcv
```
建议安装 `ninja` 以加快编译速度
```bash
pip install -r requirements/optional.txt
```
你可以安装 lite 版本
```bash
@ -87,7 +93,13 @@ CC=clang CXX=clang++ CFLAGS='-stdlib=libc++' MMCV_WITH_OPS=1 pip install -e .
5. 安装所需 Python 依赖包
```shell
pip3 install -r requirements.txt
pip3 install -r requirements/runtime.txt
```
6. 建议安装 `ninja` 以加快编译速度
```bash
pip install -r requirements/optional.txt
```
#### 编译与安装 MMCV

View File

@ -1,5 +1,4 @@
addict
numpy
pyyaml
regex;sys_platform=='win32'
yapf
-r requirements/build.txt
-r requirements/optional.txt
-r requirements/runtime.txt
-r requirements/test.txt

View File

@ -0,0 +1 @@
pytest-runner

View File

@ -0,0 +1 @@
ninja

View File

@ -378,9 +378,15 @@ setup(
url='https://github.com/open-mmlab/mmcv',
author='MMCV Contributors',
author_email='openmmlab@gmail.com',
setup_requires=['pytest-runner'],
tests_require=['pytest'],
setup_requires=parse_requirements('requirements/build.txt'),
tests_require=parse_requirements('requirements/test.txt'),
install_requires=install_requires,
extras_require={
'all': parse_requirements('requirements.txt'),
'tests': parse_requirements('requirements/test.txt'),
'build': parse_requirements('requirements/build.txt'),
'optional': parse_requirements('requirements/optional.txt'),
},
ext_modules=get_extensions(),
cmdclass=cmd_class,
zip_safe=False)