Unverified Commit 192b3b3c authored by Jerry Jiarui XU's avatar Jerry Jiarui XU Committed by GitHub
Browse files

use env to control compile op or not (#400)



* use env to control compile op or not

* use str as env var

* update readme

* update rc01

* update readme
Co-authored-by: default avatarKai Chen <chenkaidev@gmail.com>
parent 5704613e
...@@ -2,6 +2,9 @@ name: build ...@@ -2,6 +2,9 @@ name: build
on: [push, pull_request] on: [push, pull_request]
env:
MMCV_WITH_OPS: 1
jobs: jobs:
lint: lint:
runs-on: ubuntu-latest runs-on: ubuntu-latest
...@@ -28,6 +31,37 @@ jobs: ...@@ -28,6 +31,37 @@ jobs:
extensions: h,c,cpp,hpp,cu,cuh extensions: h,c,cpp,hpp,cu,cuh
style: google style: google
build_without_ops:
runs-on: ubuntu-latest
env:
MMCV_WITH_OPS: 0
strategy:
matrix:
python-version: [3.7]
torch: [1.5.0]
include:
- torch: 1.5.0
torchvision: 0.6.0
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
with:
python-version: ${{ matrix.python-version }}
- name: Install system dependencies
run: sudo apt-get update && sudo apt-get install -y ffmpeg libturbojpeg
- name: Install Pillow
run: pip install Pillow==6.2.2
if: ${{matrix.torchvision == '0.4.2'}}
- name: Install PyTorch
run: pip install torch==${{matrix.torch}}+cpu torchvision==${{matrix.torchvision}}+cpu -f https://download.pytorch.org/whl/torch_stable.html
- name: Install unittest dependencies
run: pip install pytest coverage lmdb PyTurboJPEG
- name: Build and install
run: rm -rf .eggs && pip install -e .
- name: Run unittests
run: pytest tests/ --ignore=tests/test_ops
build_cpu: build_cpu:
runs-on: ubuntu-latest runs-on: ubuntu-latest
strategy: strategy:
......
...@@ -18,3 +18,20 @@ jobs: ...@@ -18,3 +18,20 @@ jobs:
run: | run: |
pip install twine pip install twine
twine upload dist/* -u __token__ -p ${{ secrets.pypi_password }} twine upload dist/* -u __token__ -p ${{ secrets.pypi_password }}
build-n-publish_with_ops:
runs-on: ubuntu-latest
if: startsWith(github.event.ref, 'refs/tags')
steps:
- uses: actions/checkout@v2
- name: Set up Python 3.7
uses: actions/setup-python@v1
with:
python-version: 3.7
- name: Build MMCV with ops
run: python setup.py sdist
- name: Publish distribution to PyPI
run: |
sed -i "s/os.getenv('MMCV_WITH_OPS', '0')/os.getenv('MMCV_WITH_OPS', '1')/g" setup.py
pip install twine
twine upload dist/* -u __token__ -p ${{ secrets.pypi_password }}
...@@ -2,10 +2,8 @@ ...@@ -2,10 +2,8 @@
<img src="https://raw.githubusercontent.com/open-mmlab/mmcv/master/docs/mmcv-logo.png" width="300"/> <img src="https://raw.githubusercontent.com/open-mmlab/mmcv/master/docs/mmcv-logo.png" width="300"/>
</div> </div>
[![PyPI](https://img.shields.io/pypi/v/mmcv)](https://pypi.org/project/mmcv) [![badge](https://github.com/open-mmlab/mmcv/workflows/build/badge.svg)](https://github.com/open-mmlab/mmcv/actions) [![codecov](https://codecov.io/gh/open-mmlab/mmcv/branch/master/graph/badge.svg)](https://codecov.io/gh/open-mmlab/mmcv) [![license](https://img.shields.io/github/license/open-mmlab/mmcv.svg)](https://github.com/open-mmlab/mmcv/blob/master/LICENSE) [![PyPI](https://img.shields.io/pypi/v/mmcv)](https://pypi.org/project/mmcv) [![badge](https://github.com/open-mmlab/mmcv/workflows/build/badge.svg)](https://github.com/open-mmlab/mmcv/actions) [![codecov](https://codecov.io/gh/open-mmlab/mmcv/branch/master/graph/badge.svg)](https://codecov.io/gh/open-mmlab/mmcv) [![license](https://img.shields.io/github/license/open-mmlab/mmcv.svg)](https://github.com/open-mmlab/mmcv/blob/master/LICENSE)
## Introduction ## Introduction
MMCV is a foundational python library for computer vision research and supports many MMCV is a foundational python library for computer vision research and supports many
...@@ -25,48 +23,85 @@ See the [documentation](http://mmcv.readthedocs.io/en/latest) for more features ...@@ -25,48 +23,85 @@ See the [documentation](http://mmcv.readthedocs.io/en/latest) for more features
Note: MMCV requires Python 3.6+. Note: MMCV requires Python 3.6+.
## Installation ## Installation
Try and start with There are two versions of MMCV:
```bash - **mmcv**: lite, without CUDA ops but all other features, similar to mmcv<1.0.0. It is useful when you do not need those CUDA ops.
- **mmcv-full**: comprehensive, with full features and various CUDA ops out of box. It takes longer time to build.
### Install with pip
a. Install the lite version.
```python
pip install mmcv pip install mmcv
``` ```
or install from source b. Install the full version.
We provide the pre-built mmcv package with different PyTorch and CUDA versions to simplify the building.
<table class="docutils"><tbody><tr><th width="80"> CUDA </th><th valign="bottom" align="left" width="100">torch 1.5</th><th valign="bottom" align="left" width="100">torch 1.4</th><th valign="bottom" align="left" width="100">torch 1.3</th></tr>
<tr><td align="left">10.2</td><td align="left"><details><summary> install </summary><pre><code>pip install mmcv-full==1.0rc1+torch1.5.0+cu102 -f https://openmmlab.oss-accelerate.aliyuncs.com/mmcv/dist/index.html
</code></pre> </details> </td> <td align="left"> </td> <td align="left"> </td> </tr>
<tr><td align="left">10.1</td><td align="left"><details><summary> install </summary><pre><code> pip install mmcv-full==1.0rc1+torch1.5.0+cu101 -f https://openmmlab.oss-accelerate.aliyuncs.com/mmcv/dist/index.html
</code></pre> </details> </td> <td align="left"><details><summary> install </summary><pre><code>pip install mmcv-full==1.0rc1+torch1.4.0+cu101 -f https://openmmlab.oss-accelerate.aliyuncs.com/mmcv/dist/index.html
</code></pre> </details> </td> <td align="left"><details><summary> install </summary><pre><code>pip install mmcv-full==1.0rc1+torch1.3.0+cu101 -f https://openmmlab.oss-accelerate.aliyuncs.com/mmcv/dist/index.html
</code></pre> </details> </td></tr>
<tr><td align="left">10.0</td><td align="left"> </td><td align="left"> </td> <td align="left"> </td> </tr>
<tr><td align="left">9.2</td><td align="left"><details><summary> install </summary><pre><code> pip install mmcv-full==1.0rc1+torch1.5.0+cu92 -f https://openmmlab.oss-accelerate.aliyuncs.com/mmcv/dist/index.html
</code></pre> </details> </td> <td align="left"><details><summary> install </summary><pre><code>pip install mmcv-full==1.0rc1+torch1.4.0+cu92 -f https://openmmlab.oss-accelerate.aliyuncs.com/mmcv/dist/index.html
</code></pre> </details> </td> <td align="left"><details><summary> install </summary><pre><code>pip install mmcv-full==1.0rc1+torch1.3.0+cu92 -f https://openmmlab.oss-accelerate.aliyuncs.com/mmcv/dist/index.html
</code></pre> </details> </td></tr>
<tr><td align="left">cpu</td><td align="left"><details><summary> install </summary><pre><code> pip install mmcv-full==1.0rc1+torch1.5.0+cpu -f https://openmmlab.oss-accelerate.aliyuncs.com/mmcv/dist/index.html
</code></pre> </details> </td> <td align="left"><details><summary> install </summary><pre><code>pip install mmcv-full==1.0rc1+torch1.4.0+cpu -f https://openmmlab.oss-accelerate.aliyuncs.com/mmcv/dist/index.html
</code></pre> </details> </td> <td align="left"><details><summary> install </summary><pre><code>pip install mmcv-full==1.0rc1+torch1.3.0+cpu -f https://openmmlab.oss-accelerate.aliyuncs.com/mmcv/dist/index.html
</code></pre> </details> </td> </tr>
</tbody></table>
Another way is to compile locally by running
```python
pip install mmcv-full
```
Note that the local compiling may take up to 10 mins.
### Install from source
After cloning the repo with
```bash ```bash
git clone https://github.com/open-mmlab/mmcv.git git clone https://github.com/open-mmlab/mmcv.git
cd mmcv cd mmcv
pip install -e .
``` ```
If you are on macOS, replace the last command with You can either
- install the lite version
```bash
pip install -e .
```
- install the full version
```bash
MMCV_WITH_OPS=1 pip install -e .
```
If you are on macOS, add the following environment variables before the installing command.
```bash ```bash
CC=lang CXX=clang++ CFLAGS='-stdlib=libc++' pip install -e . CC=lang CXX=clang++ CFLAGS='-stdlib=libc++'
``` ```
Note that the building process may take up to 10 mins. We also provide pre-built mmcv with corresponding Pytorch and CUDA versions to simplify the building. e.g.,
<table class="docutils"><tbody><tr><th width="80"> CUDA </th><th valign="bottom" align="left" width="100">torch 1.5</th><th valign="bottom" align="left" width="100">torch 1.4</th><th valign="bottom" align="left" width="100">torch 1.3</th></tr> ```bash
<tr><td align="left">10.2</td><td align="left"><details><summary> install </summary><pre><code>pip install mmcv==1.0rc0+torch1.5.0+cu102 -f https://openmmlab.oss-accelerate.aliyuncs.com/mmcv/dist/index.html CC=lang CXX=clang++ CFLAGS='-stdlib=libc++' MMCV_WITH_OPS=1 pip install -e .
</code></pre> </details> </td> <td align="left"> </td> <td align="left"> </td> </tr> ```
<tr><td align="left">10.1</td><td align="left"><details><summary> install </summary><pre><code> pip install mmcv==1.0rc0+torch1.5.0+cu101 -f https://openmmlab.oss-accelerate.aliyuncs.com/mmcv/dist/index.html
</code></pre> </details> </td> <td align="left"><details><summary> install </summary><pre><code>pip install mmcv==1.0rc0+torch1.4.0+cu101 -f https://openmmlab.oss-accelerate.aliyuncs.com/mmcv/dist/index.html
</code></pre> </details> </td> <td align="left"><details><summary> install </summary><pre><code>pip install mmcv==1.0rc0+torch1.3.0+cu101 -f https://openmmlab.oss-accelerate.aliyuncs.com/mmcv/dist/index.html
</code></pre> </details> </td></tr>
<tr><td align="left">10.0</td><td align="left"> </td><td align="left"> </td> <td align="left"> </td> </tr>
<tr><td align="left">9.2</td><td align="left"><details><summary> install </summary><pre><code> pip install mmcv==1.0rc0+torch1.5.0+cu92 -f https://openmmlab.oss-accelerate.aliyuncs.com/mmcv/dist/index.html
</code></pre> </details> </td> <td align="left"><details><summary> install </summary><pre><code>pip install mmcv==1.0rc0+torch1.4.0+cu92 -f https://openmmlab.oss-accelerate.aliyuncs.com/mmcv/dist/index.html
</code></pre> </details> </td> <td align="left"><details><summary> install </summary><pre><code>pip install mmcv==1.0rc0+torch1.3.0+cu92 -f https://openmmlab.oss-accelerate.aliyuncs.com/mmcv/dist/index.html
</code></pre> </details> </td></tr>
<tr><td align="left">cpu</td><td align="left"><details><summary> install </summary><pre><code> pip install mmcv==1.0rc0+torch1.5.0+cpu -f https://openmmlab.oss-accelerate.aliyuncs.com/mmcv/dist/index.html
</code></pre> </details> </td> <td align="left"><details><summary> install </summary><pre><code>pip install mmcv==1.0rc0+torch1.4.0+cpu -f https://openmmlab.oss-accelerate.aliyuncs.com/mmcv/dist/index.html
</code></pre> </details> </td> <td align="left"><details><summary> install </summary><pre><code>pip install mmcv==1.0rc0+torch1.3.0+cpu -f https://openmmlab.oss-accelerate.aliyuncs.com/mmcv/dist/index.html
</code></pre> </details> </td> </tr>
</tbody></table>
Note: If you would like to use `opencv-python-headless` instead of `opencv-python`, Note: If you would like to use `opencv-python-headless` instead of `opencv-python`,
e.g., in a minimum container environment or servers without GUI, e.g., in a minimum container environment or servers without GUI,
......
# Copyright (c) Open-MMLab. All rights reserved. # Copyright (c) Open-MMLab. All rights reserved.
__version__ = '1.0rc0' __version__ = '1.0rc1'
...@@ -146,6 +146,9 @@ def get_extensions(): ...@@ -146,6 +146,9 @@ def get_extensions():
language='c++') language='c++')
extensions.extend(cythonize(ext_flow)) extensions.extend(cythonize(ext_flow))
if os.getenv('MMCV_WITH_OPS', '0') == '0':
return extensions
if EXT_TYPE == 'parrots': if EXT_TYPE == 'parrots':
ext_name = 'mmcv._ext' ext_name = 'mmcv._ext'
from parrots.utils.build_extension import Extension from parrots.utils.build_extension import Extension
...@@ -195,10 +198,9 @@ def get_extensions(): ...@@ -195,10 +198,9 @@ def get_extensions():
setup( setup(
name='mmcv', name='mmcv' if os.getenv('MMCV_WITH_OPS', '0') == '0' else 'mmcv-full',
version=get_version(), version=get_version(),
description='OpenMMLab Computer Vision Foundation', description='OpenMMLab Computer Vision Foundation',
long_description=readme(),
keywords='computer vision', keywords='computer vision',
packages=find_packages(), packages=find_packages(),
include_package_data=True, include_package_data=True,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment