Commit 6f3c5f1c authored by limm's avatar limm
Browse files

support v1.4.0

parent 6f674c7e
## Contributing to OpenMMLab ## Contributing to OpenMMLab
Welcome to the MMCV community, we are committed to building a cutting-edge computer vision foundational library and all kinds of contributions are welcomed, including but not limited to All kinds of contributions are welcome, including but not limited to the following.
**Fix bug** - Fix typo or bugs
- Add documentation or translate the documentation into other languages
- Add new features and components
You can directly post a Pull Request to fix typo in code or documents ### Workflow
The steps to fix the bug of code implementation are as follows. 1. fork and pull the latest OpenMMLab repository
2. checkout a new branch (do not use master branch for PRs)
3. commit your changes
4. create a PR
1. If the modification involve significant changes, you should create an issue first and describe the error information and how to trigger the bug. Other developers will discuss with you and propose an proper solution. ```{note}
If you plan to add some new features that involve large changes, it is encouraged to open an issue for discussion first.
2. Posting a pull request after fixing the bug and adding corresponding unit test.
**New Feature or Enhancement**
1. If the modification involve significant changes, you should create an issue to discuss with our developers to propose an proper design.
2. Post a Pull Request after implementing the new feature or enhancement and add corresponding unit test.
**Document**
You can directly post a pull request to fix documents. If you want to add a document, you should first create an issue to check if it is reasonable.
### Pull Request Workflow
If you're not familiar with Pull Request, don't worry! The following guidance will tell you how to create a Pull Request step by step. If you want to dive into the develop mode of Pull Request, you can refer to the [official documents](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/about-pull-requests)
#### 1. Fork and clone
If you are posting a pull request for the first time, you should fork the OpenMMLab repositories by clicking the **Fork** button in the top right corner of the GitHub page, and the forked repositories will appear under your GitHub profile.
<img src="https://user-images.githubusercontent.com/57566630/167305749-43c7f4e9-449b-4e98-ade5-0c9276d5c9ce.png" width="1200">
Then, you can clone the repositories to local:
```shell
git clone git@github.com:{username}/mmcv.git
``` ```
### Code style
After that, you should ddd official repository as the upstream repository #### Python
```bash We adopt [PEP8](https://www.python.org/dev/peps/pep-0008/) as the preferred code style.
git remote add upstream git@github.com:open-mmlab/mmcv
```
Check whether remote repository has been added successfully by `git remote -v` We use the following tools for linting and formatting:
```bash - [flake8](http://flake8.pycqa.org/en/latest/): A wrapper around some linter tools.
origin git@github.com:{username}/mmcv.git (fetch) - [yapf](https://github.com/google/yapf): A formatter for Python files.
origin git@github.com:{username}/mmcv.git (push) - [isort](https://github.com/timothycrosley/isort): A Python utility to sort imports.
upstream git@github.com:open-mmlab/mmcv (fetch) - [markdownlint](https://github.com/markdownlint/markdownlint): A linter to check markdown files and flag style issues.
upstream git@github.com:open-mmlab/mmcv (push) - [docformatter](https://github.com/myint/docformatter): A formatter to format docstring.
```
> Here's a brief introduction to origin and upstream. When we use "git clone", we create an "origin" remote by default, which points to the repository cloned from. As for "upstream", we add it ourselves to point to the target repository. Of course, if you don't like the name "upstream", you could name it as you wish. Usually, we'll push the code to "origin". If the pushed code conflicts with the latest code in official("upstream"), we should pull the latest code from upstream to resolve the conflicts, and then push to "origin" again. The posted Pull Request will be updated automatically. Style configurations of yapf and isort can be found in [setup.cfg](./setup.cfg).
#### 2. Configure pre-commit We use [pre-commit hook](https://pre-commit.com/) that checks and formats for `flake8`, `yapf`, `isort`, `trailing whitespaces`, `markdown files`,
fixes `end-of-files`, `double-quoted-strings`, `python-encoding-pragma`, `mixed-line-ending`, sorts `requirments.txt` automatically on every commit.
The config for a pre-commit hook is stored in [.pre-commit-config](./.pre-commit-config.yaml).
You should configure [pre-commit](https://pre-commit.com/#intro) in the local development environment to make sure the code style matches that of OpenMMLab. **Note**: The following code should be executed under the MMCV directory. After you clone the repository, you will need to install initialize pre-commit hook.
```shell ```shell
pip install -U pre-commit pip install -U pre-commit
pre-commit install
```
Check that pre-commit is configured successfully, and install the hooks defined in `.pre-commit-config.yaml`.
```shell
pre-commit run --all-files
```
<img src="https://user-images.githubusercontent.com/57566630/173660750-3df20a63-cb66-4d33-a986-1f643f1d8aaf.png" width="1200">
<img src="https://user-images.githubusercontent.com/57566630/202368856-0465a90d-8fce-4345-918e-67b8b9c82614.png" width="1200">
If the installation process is interrupted, you can repeatedly run `pre-commit run ... ` to continue the installation.
If the code does not conform to the code style specification, pre-commit will raise a warning and fixes some of the errors automatically.
<img src="https://user-images.githubusercontent.com/57566630/202369176-67642454-0025-4023-a095-263529107aa3.png" width="1200">
If we want to commit our code bypassing the pre-commit hook, we can use the `--no-verify` option(**only for temporarily commit**).
```shell
git commit -m "xxx" --no-verify
```
#### 3. Create a development branch
After configuring the pre-commit, we should create a branch based on the master branch to develop the new feature or fix the bug. The proposed branch name is `username/pr_name`
```shell
git checkout -b yhc/refactor_contributing_doc
```
In subsequent development, if the master branch of the local repository is behind the master branch of "upstream", we need to pull the upstream for synchronization, and then execute the above command:
```shell
git pull upstream master
```
#### 4. Commit the code and pass the unit test
- MMCV introduces mypy to do static type checking to increase the robustness of the code. Therefore, we need to add Type Hints to our code and pass the mypy check. If you are not familiar with Type Hints, you can refer to [this tutorial](https://docs.python.org/3/library/typing.html).
- The committed code should pass through the unit test
```shell
# Pass all unit tests
pytest tests
# Pass the unit test of runner
pytest tests/test_runner/test_runner.py
```
If the unit test fails for lack of dependencies, you can install the dependencies referring to the [guidance](#unit-test)
- If the documents are modified/added, we should check the rendering result referring to [guidance](#document-rendering)
#### 5. Push the code to remote
We could push the local commits to remote after passing through the check of unit test and pre-commit. You can associate the local branch with remote branch by adding `-u` option.
```shell
git push -u origin {branch_name}
```
This will allow you to use the `git push` command to push code directly next time, without having to specify a branch or the remote repository.
#### 6. Create a Pull Request
(1) Create a pull request in GitHub's Pull request interface
<img src="https://user-images.githubusercontent.com/57566630/201533288-516f7ac4-0b14-4dc8-afbd-912475c368b5.png" width="1200">
(2) Modify the PR description according to the guidelines so that other developers can better understand your changes
<img src="https://user-images.githubusercontent.com/57566630/202242953-c91a18ff-e388-4ff9-8591-5fae0ead6c1e.png" width="1200">
Find more details about Pull Request description in [pull request guidelines](#pr-specs).
**note**
(a) The Pull Request description should contain the reason for the change, the content of the change, and the impact of the change, and be associated with the relevant Issue (see [documentation](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue)
(b) If it is your first contribution, please sign the CLA
<img src="https://user-images.githubusercontent.com/57566630/167307569-a794b967-6e28-4eac-a942-00deb657815f.png" width="1200">
(c) Check whether the Pull Request pass through the CI
<img src="https://user-images.githubusercontent.com/57566630/167307490-f9ebf9fa-63c0-4d83-8ba1-081ea169eb3a.png" width="1200">
MMCV will run unit test for the posted Pull Request on different platforms (Linux, Window, Mac), based on different versions of Python, PyTorch, CUDA to make sure the code is correct. We can see the specific test information by clicking `Details` in the above image so that we can modify the code.
(3) If the Pull Request passes the CI, then you can wait for the review from other developers. You'll modify the code based on the reviewer's comments, and repeat the steps [4](#4-commit-the-code-and-pass-the-unit-test)-[5](#5-push-the-code-to-remote) until all reviewers approve it. Then, we will merge it ASAP.
<img src="https://user-images.githubusercontent.com/57566630/202145400-cc2cd8c4-10b0-472f-ba37-07e6f50acc67.png" width="1200">
#### 7. Resolve conflicts
If your local branch conflicts with the latest master branch of "upstream", you'll need to resolove them. There are two ways to do this:
```shell
git fetch --all --prune
git rebase upstream/master
``` ```
or From the repository folder
```shell
git fetch --all --prune
git merge upstream/master
```
If you are very good at handling conflicts, then you can use rebase to resolve conflicts, as this will keep your commit logs tidy. If you are not familiar with `rebase`, then you can use `merge` to resolve conflicts.
### Guidance
#### Unit test
If you cannot run the unit test of some modules for lacking of some dependencies, such as [video](https://github.com/open-mmlab/mmcv/tree/master/mmcv/video) module, you can try to install the following dependencies:
```shell ```shell
# Linux pre-commit install
sudo apt-get update -y
sudo apt-get install -y libturbojpeg
sudo apt-get install -y ffmpeg
# Windows
conda install ffmpeg
``` ```
We should also make sure the committed code will not decrease the coverage of unit test, we could run the following command to check the coverage of unit test: Try the following steps to install ruby when you encounter an issue on installing markdownlint
```shell ```shell
python -m coverage run -m pytest /path/to/test_file # install rvm
python -m coverage html curl -L https://get.rvm.io | bash -s -- --autolibs=read-fail
# check file in htmlcov/index.html [[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm"
``` rvm autolibs disable
#### Document rendering
If the documents are modified/added, we should check the rendering result. We could install the dependencies and run the following command to render the documents and check the results: # install ruby
rvm install 2.7.1
```shell
pip install -r requirements/docs.txt
cd docs/zh_cn/
# or docs/en
make html
# check file in ./docs/zh_cn/_build/html/index.html
``` ```
### Code style Or refer to [this repo](https://github.com/innerlee/setup) and take [`zzruby.sh`](https://github.com/innerlee/setup/blob/master/zzruby.sh) according its instruction.
#### Python After this on every commit check code linters and formatter will be enforced.
We adopt [PEP8](https://www.python.org/dev/peps/pep-0008/) as the preferred code style. >Before you create a PR, make sure that your code lints and is formatted by yapf.
We use the following tools for linting and formatting:
- [flake8](https://github.com/PyCQA/flake8): A wrapper around some linter tools.
- [isort](https://github.com/timothycrosley/isort): A Python utility to sort imports.
- [yapf](https://github.com/google/yapf): A formatter for Python files.
- [codespell](https://github.com/codespell-project/codespell): A Python utility to fix common misspellings in text files.
- [mdformat](https://github.com/executablebooks/mdformat): Mdformat is an opinionated Markdown formatter that can be used to enforce a consistent style in Markdown files.
- [docformatter](https://github.com/myint/docformatter): A formatter to format docstring.
Style configurations of yapf and isort can be found in [setup.cfg](./setup.cfg).
We use [pre-commit hook](https://pre-commit.com/) that checks and formats for `flake8`, `yapf`, `isort`, `trailing whitespaces`, `markdown files`,
fixes `end-of-files`, `double-quoted-strings`, `python-encoding-pragma`, `mixed-line-ending`, sorts `requirments.txt` automatically on every commit.
The config for a pre-commit hook is stored in [.pre-commit-config](./.pre-commit-config.yaml).
#### C++ and CUDA #### C++ and CUDA
We follow the [Google C++ Style Guide](https://google.github.io/styleguide/cppguide.html). We follow the [Google C++ Style Guide](https://google.github.io/styleguide/cppguide.html).
### PR Specs
1. Use [pre-commit](https://pre-commit.com) hook to avoid issues of code style
2. One short-time branch should be matched with only one PR
3. Accomplish a detailed change in one PR. Avoid large PR
- Bad: Support Faster R-CNN
- Acceptable: Add a box head to Faster R-CNN
- Good: Add a parameter to box head to support custom conv-layer number
4. Provide clear and significant commit message
5. Provide clear and meaningful PR description
- Task name should be clarified in title. The general format is: \[Prefix\] Short description of the PR (Suffix)
- Prefix: add new feature \[Feature\], fix bug \[Fix\], related to documents \[Docs\], in developing \[WIP\] (which will not be reviewed temporarily)
- Introduce main changes, results and influences on other modules in short description
- Associate related issues and pull requests with a milestone
## 贡献代码
欢迎加入 MMCV 社区,我们致力于打造最前沿的计算机视觉基础库,我们欢迎任何类型的贡献,包括但不限于
**修复错误**
修复代码实现错误的步骤如下:
1. 如果提交的代码改动较大,建议先提交 issue,并正确描述 issue 的现象、原因和复现方式,讨论后确认修复方案。
2. 修复错误并补充相应的单元测试,提交拉取请求。
**新增功能或组件**
1. 如果新功能或模块涉及较大的代码改动,建议先提交 issue,确认功能的必要性。
2. 实现新增功能并添单元测试,提交拉取请求。
**文档补充**
修复文档可以直接提交拉取请求
添加文档或将文档翻译成其他语言步骤如下
1. 提交 issue,确认添加文档的必要性。
2. 添加文档,提交拉取请求。
### 拉取请求工作流
如果你对拉取请求不了解,没关系,接下来的内容将会从零开始,一步一步地指引你如何创建一个拉取请求。如果你想深入了解拉取请求的开发模式,可以参考 github [官方文档](https://docs.github.com/en/github/collaborating-with-issues-and-pull-requests/about-pull-requests)
#### 1. 复刻仓库
当你第一次提交拉取请求时,先复刻 OpenMMLab 原代码库,点击 GitHub 页面右上角的 **Fork** 按钮,复刻后的代码库将会出现在你的 GitHub 个人主页下。
<img src="https://user-images.githubusercontent.com/57566630/167305749-43c7f4e9-449b-4e98-ade5-0c9276d5c9ce.png" width="1200">
将代码克隆到本地
```shell
git clone git@github.com:{username}/mmcv.git
```
添加原代码库为上游代码库
```bash
git remote add upstream git@github.com:open-mmlab/mmcv
```
检查 remote 是否添加成功,在终端输入 `git remote -v`
```bash
origin git@github.com:{username}/mmcv.git (fetch)
origin git@github.com:{username}/mmcv.git (push)
upstream git@github.com:open-mmlab/mmcv (fetch)
upstream git@github.com:open-mmlab/mmcv (push)
```
> 这里对 origin 和 upstream 进行一个简单的介绍,当我们使用 git clone 来克隆代码时,会默认创建一个 origin 的 remote,它指向我们克隆的代码库地址,而 upstream 则是我们自己添加的,用来指向原始代码库地址。当然如果你不喜欢他叫 upstream,也可以自己修改,比如叫 open-mmlab。我们通常向 origin 提交代码(即 fork 下来的远程仓库),然后向 upstream 提交一个 pull request。如果提交的代码和最新的代码发生冲突,再从 upstream 拉取最新的代码,和本地分支解决冲突,再提交到 origin。
#### 2. 配置 pre-commit
在本地开发环境中,我们使用 [pre-commit](https://pre-commit.com/#intro) 来检查代码风格,以确保代码风格的统一。在提交代码,需要先安装 pre-commit(需要在 MMCV 目录下执行):
```shell
pip install -U pre-commit
pre-commit install
```
检查 pre-commit 是否配置成功,并安装 `.pre-commit-config.yaml` 中的钩子:
```shell
pre-commit run --all-files
```
<img src="https://user-images.githubusercontent.com/57566630/173660750-3df20a63-cb66-4d33-a986-1f643f1d8aaf.png" width="1200">
<img src="https://user-images.githubusercontent.com/57566630/202368856-0465a90d-8fce-4345-918e-67b8b9c82614.png" width="1200">
> 如果你是中国用户,由于网络原因,可能会出现安装失败的情况,这时可以使用国内源
> pre-commit install -c .pre-commit-config-zh-cn.yaml
> pre-commit run --all-files -c .pre-commit-config-zh-cn.yaml
如果安装过程被中断,可以重复执行 `pre-commit run ...` 继续安装。
如果提交的代码不符合代码风格规范,pre-commit 会发出警告,并自动修复部分错误。
<img src="https://user-images.githubusercontent.com/57566630/202369176-67642454-0025-4023-a095-263529107aa3.png" width="1200">
如果我们想临时绕开 pre-commit 的检查提交一次代码,可以在 `git commit` 时加上 `--no-verify`(需要保证最后推送至远程仓库的代码能够通过 pre-commit 检查)。
```shell
git commit -m "xxx" --no-verify
```
#### 3. 创建开发分支
安装完 pre-commit 之后,我们需要基于 master 创建开发分支,建议的分支命名规则为 `username/pr_name`
```shell
git checkout -b yhc/refactor_contributing_doc
```
在后续的开发中,如果本地仓库的 master 分支落后于 upstream 的 master 分支,我们需要先拉取 upstream 的代码进行同步,再执行上面的命令
```shell
git pull upstream master
```
#### 4. 提交代码并在本地通过单元测试
- MMCV 引入了 mypy 来做静态类型检查,以增加代码的鲁棒性。因此我们在提交代码时,需要补充 Type Hints。具体规则可以参考[教程](https://zhuanlan.zhihu.com/p/519335398)
- 提交的代码同样需要通过单元测试
```shell
# 通过全量单元测试
pytest tests
# 我们需要保证提交的代码能够通过修改模块的单元测试,以 runner 为例
pytest tests/test_runner/test_runner.py
```
如果你由于缺少依赖无法运行修改模块的单元测试,可以参考[指引-单元测试](#单元测试)
- 如果修改/添加了文档,参考[指引](#文档渲染)确认文档渲染正常。
#### 5. 推送代码到远程
代码通过单元测试和 pre-commit 检查后,将代码推送到远程仓库,如果是第一次推送,可以在 `git push` 后加上 `-u` 参数以关联远程分支
```shell
git push -u origin {branch_name}
```
这样下次就可以直接使用 `git push` 命令推送代码了,而无需指定分支和远程仓库。
#### 6. 提交拉取请求(PR)
(1) 在 GitHub 的 Pull request 界面创建拉取请求
<img src="https://user-images.githubusercontent.com/57566630/201533288-516f7ac4-0b14-4dc8-afbd-912475c368b5.png" width="1200">
(2) 根据指引修改 PR 描述,以便于其他开发者更好地理解你的修改
<img src="https://user-images.githubusercontent.com/57566630/202242953-c91a18ff-e388-4ff9-8591-5fae0ead6c1e.png" width="1200">
描述规范详见[拉取请求规范](#拉取请求规范)
&#160;
**注意事项**
(a) PR 描述应该包含修改理由、修改内容以及修改后带来的影响,并关联相关 Issue(具体方式见[文档](https://docs.github.com/en/issues/tracking-your-work-with-issues/linking-a-pull-request-to-an-issue)
(b) 如果是第一次为 OpenMMLab 做贡献,需要签署 CLA
<img src="https://user-images.githubusercontent.com/57566630/167307569-a794b967-6e28-4eac-a942-00deb657815f.png" width="1200">
(c) 检查提交的 PR 是否通过 CI(集成测试)
<img src="https://user-images.githubusercontent.com/57566630/167307490-f9ebf9fa-63c0-4d83-8ba1-081ea169eb3a.png" width="1200">
MMCV 会在不同的平台(Linux、Window、Mac),基于不同版本的 Python、PyTorch、CUDA 对提交的代码进行单元测试,以保证代码的正确性,如果有任何一个没有通过,我们可点击上图中的 `Details` 来查看具体的测试信息,以便于我们修改代码。
(3) 如果 PR 通过了 CI,那么就可以等待其他开发者的 review,并根据 reviewer 的意见,修改代码,并重复 [4](#4-提交代码并本地通过单元测试)-[5](#5-推送代码到远程) 步骤,直到 reviewer 同意合入 PR。
<img src="https://user-images.githubusercontent.com/57566630/202145400-cc2cd8c4-10b0-472f-ba37-07e6f50acc67.png" width="1200">
所有 reviewer 同意合入 PR 后,我们会尽快将 PR 合并到主分支。
#### 7. 解决冲突
随着时间的推移,我们的代码库会不断更新,这时候,如果你的 PR 与主分支存在冲突,你需要解决冲突,解决冲突的方式有两种:
```shell
git fetch --all --prune
git rebase upstream/master
```
或者
```shell
git fetch --all --prune
git merge upstream/master
```
如果你非常善于处理冲突,那么可以使用 rebase 的方式来解决冲突,因为这能够保证你的 commit log 的整洁。如果你不太熟悉 `rebase` 的使用,那么可以使用 `merge` 的方式来解决冲突。
### 指引
#### 单元测试
如果你无法正常执行部分模块的单元测试,例如 [video](https://github.com/open-mmlab/mmcv/tree/master/mmcv/video) 模块,可能是你的当前环境没有安装以下依赖
```shell
# Linux
sudo apt-get update -y
sudo apt-get install -y libturbojpeg
sudo apt-get install -y ffmpeg
# Windows
conda install ffmpeg
```
在提交修复代码错误或新增特性的拉取请求时,我们应该尽可能的让单元测试覆盖所有提交的代码,计算单元测试覆盖率的方法如下
```shell
python -m coverage run -m pytest /path/to/test_file
python -m coverage html
# check file in htmlcov/index.html
```
#### 文档渲染
在提交修复代码错误或新增特性的拉取请求时,可能会需要修改/新增模块的 docstring。我们需要确认渲染后的文档样式是正确的。
本地生成渲染后的文档的方法如下
```shell
pip install -r requirements/docs.txt
cd docs/zh_cn/
# or docs/en
make html
# check file in ./docs/zh_cn/_build/html/index.html
```
### 代码风格
#### Python
[PEP8](https://www.python.org/dev/peps/pep-0008/) 作为 OpenMMLab 算法库首选的代码规范,我们使用以下工具检查和格式化代码
- [flake8](https://github.com/PyCQA/flake8): Python 官方发布的代码规范检查工具,是多个检查工具的封装
- [isort](https://github.com/timothycrosley/isort): 自动调整模块导入顺序的工具
- [yapf](https://github.com/google/yapf): Google 发布的代码规范检查工具
- [codespell](https://github.com/codespell-project/codespell): 检查单词拼写是否有误
- [mdformat](https://github.com/executablebooks/mdformat): 检查 markdown 文件的工具
- [docformatter](https://github.com/myint/docformatter): 格式化 docstring 的工具
yapf 和 isort 的配置可以在 [setup.cfg](./setup.cfg) 找到
通过配置 [pre-commit hook](https://pre-commit.com/) ,我们可以在提交代码时自动检查和格式化 `flake8``yapf``isort``trailing whitespaces``markdown files`
修复 `end-of-files``double-quoted-strings``python-encoding-pragma``mixed-line-ending`,调整 `requirments.txt` 的包顺序。
pre-commit 钩子的配置可以在 [.pre-commit-config](./.pre-commit-config.yaml) 找到。
pre-commit 具体的安装使用方式见[拉取请求](#2-配置-pre-commit)
更具体的规范请参考 [OpenMMLab 代码规范](code_style.md)
#### C++ and CUDA
C++ 和 CUDA 的代码规范遵从 [Google C++ Style Guide](https://google.github.io/styleguide/cppguide.html)
### 拉取请求规范
1. 使用 [pre-commit hook](https://pre-commit.com),尽量减少代码风格相关问题
2. 一个`拉取请求`对应一个短期分支
3. 粒度要细,一个`拉取请求`只做一件事情,避免超大的`拉取请求`
- Bad:实现 Faster R-CNN
- Acceptable:给 Faster R-CNN 添加一个 box head
- Good:给 box head 增加一个参数来支持自定义的 conv 层数
4. 每次 Commit 时需要提供清晰且有意义 commit 信息
5. 提供清晰且有意义的`拉取请求`描述
- 标题写明白任务名称,一般格式:\[Prefix\] Short description of the pull request (Suffix)
- prefix: 新增功能 \[Feature\], 修 bug \[Fix\], 文档相关 \[Docs\], 开发中 \[WIP\] (暂时不会被review)
- 描述里介绍`拉取请求`的主要修改内容,结果,以及对其他部分的影响, 参考`拉取请求`模板
- 关联相关的`议题` (issue) 和其他`拉取请求`
6. 如果引入了其他三方库,或借鉴了三方库的代码,请确认他们的许可证和 mmcv 兼容,并在借鉴的代码上补充 `This code is inspired from http://`
FROM python:3.7
WORKDIR /mmcv
COPY . /mmcv
RUN pip install -e .
...@@ -3,9 +3,6 @@ ...@@ -3,9 +3,6 @@
In this file, we list the operations with other licenses instead of Apache 2.0. Users should be careful about adopting these operations in any commercial matters. In this file, we list the operations with other licenses instead of Apache 2.0. Users should be careful about adopting these operations in any commercial matters.
| Operation | Files | License | | Operation | Files | License |
| :--------------: | :------------------------------------------------------------------------------------------------------------------------------------------------------------: | :------------: | | :--------------: | :---------------------------------------------------------------------------------------------------------------------------------------------------: | :------------: |
| upfirdn2d | [mmcv/ops/csrc/pytorch/cuda/upfirdn2d_kernel.cu](https://github.com/open-mmlab/mmcv/tree/2.x/mmcv/ops/csrc/pytorch/cuda/upfirdn2d_kernel.cu) | NVIDIA License | | upfirdn2d | [mmcv/ops/csrc/pytorch/cuda/upfirdn2d_kernel.cu](https://github.com/open-mmlab/mmcv/blob/master/mmcv/ops/csrc/pytorch/cuda/upfirdn2d_kernel.cu) | NVIDIA License |
| fused_leaky_relu | [mmcv/ops/csrc/pytorch/cuda/fused_bias_leakyrelu_cuda.cu](https://github.com/open-mmlab/mmcv/tree/2.x/mmcv/ops/csrc/pytorch/cuda/fused_bias_leakyrelu_cuda.cu) | NVIDIA License | | fused_leaky_relu | [mmcv/ops/csrc/pytorch/cuda/fused_bias_leakyrelu_cuda.cu](https://github.com/open-mmlab/mmcv/blob/master/mmcv/ops/csrc/pytorch/cuda/fused_bias_leakyrelu_cuda.cu) | NVIDIA License |
| bias_act | [mmcv/ops/csrc/pytorch/cuda/bias_act_cuda.cu](https://github.com/open-mmlab/mmcv/tree/2.x/mmcv/ops/csrc/pytorch/cuda/bias_act_cuda.cu) | NVIDIA License |
| filtered_lrelu | [mmcv/ops/csrc/pytorch/cuda/filtered_lrelu.cu](https://github.com/open-mmlab/mmcv/tree/2.x/mmcv/ops/csrc/pytorch/cuda/filtered_lrelu.cu) | NVIDIA License |
| conv2d_gradfix | [mmcv/ops/conv2d_gradfix.py](https://github.com/open-mmlab/mmcv/tree/2.x/mmcv/ops/conv2d_gradfix.py) | NVIDIA License |
include requirements/runtime.txt include requirements/runtime.txt
include mmcv/model_zoo/open_mmlab.json mmcv/model_zoo/deprecated.json mmcv/model_zoo/mmcls.json
include mmcv/ops/csrc/common/cuda/*.cuh mmcv/ops/csrc/common/cuda/*.hpp mmcv/ops/csrc/common/*.hpp include mmcv/ops/csrc/common/cuda/*.cuh mmcv/ops/csrc/common/cuda/*.hpp mmcv/ops/csrc/common/*.hpp
include mmcv/ops/csrc/pytorch/*.cpp mmcv/ops/csrc/pytorch/cuda/*.cu mmcv/ops/csrc/pytorch/cuda/*.cpp mmcv/ops/csrc/pytorch/cpu/*.cpp include mmcv/ops/csrc/pytorch/*.cpp mmcv/ops/csrc/pytorch/cuda/*.cu mmcv/ops/csrc/pytorch/cuda/*.cpp mmcv/ops/csrc/pytorch/cpu/*.cpp
include mmcv/ops/csrc/parrots/*.h mmcv/ops/csrc/parrots/*.cpp include mmcv/ops/csrc/parrots/*.h mmcv/ops/csrc/parrots/*.cpp
include mmcv/ops/csrc/pytorch/mps/*.mm mmcv/ops/csrc/common/mps/*.h mmcv/ops/csrc/common/mps/*.mm
recursive-include mmcv/ops/csrc/ *.h *.hpp *.cpp *.cuh *.cu *.mm
...@@ -7,7 +7,7 @@ MMCV是计算机视觉研究的基础库,主要提供以下功能:图像处 ...@@ -7,7 +7,7 @@ MMCV是计算机视觉研究的基础库,主要提供以下功能:图像处
+ Python 3.7、3.8、3.9 + Python 3.7、3.8、3.9
### 1、使用pip方式安装 ### 1、使用pip方式安装
mmcv whl包下载目录:[https://cancon.hpccube.com:65024/4/main/mmcv/dtk23.04](https://cancon.hpccube.com:65024/4/main/mmcv/dtk23.04),选择对应的pytorch版本和python版本下载对应mmcv的whl包 mmcv whl包下载目录:[https://cancon.hpccube.com:65024/4/main/mmcv](https://cancon.hpccube.com:65024/4/main/mmcv),选择对应的pytorch版本和python版本下载对应mmcv的whl包
```shell ```shell
pip install mmcv* (下载的mmcv的whl包) pip install mmcv* (下载的mmcv的whl包)
``` ```
...@@ -18,7 +18,7 @@ pip install mmcv* (下载的mmcv的whl包) ...@@ -18,7 +18,7 @@ pip install mmcv* (下载的mmcv的whl包)
1. 基于光源pytorch基础镜像环境:镜像下载地址:[https://sourcefind.cn/#/image/dcu/pytorch](https://sourcefind.cn/#/image/dcu/pytorch),根据pytorch、python、dtk及系统下载对应的镜像版本。 1. 基于光源pytorch基础镜像环境:镜像下载地址:[https://sourcefind.cn/#/image/dcu/pytorch](https://sourcefind.cn/#/image/dcu/pytorch),根据pytorch、python、dtk及系统下载对应的镜像版本。
2. 基于现有python环境:安装pytorch,pytorch whl包下载目录:[https://cancon.hpccube.com:65024/4/main/pytorch/dtk23.04](https://cancon.hpccube.com:65024/4/main/pytorch/dtk23.04),根据python、dtk版本,下载对应pytorch的whl包。安装命令如下: 2. 基于现有python环境:安装pytorch,pytorch whl包下载目录:[https://cancon.hpccube.com:65024/4/main/pytorch/dtk24.04.1](https://cancon.hpccube.com:65024/4/main/pytorch/dtk24.04.1),根据python、dtk版本,下载对应pytorch的whl包。安装命令如下:
```shell ```shell
pip install torch* (下载的torch的whl包) pip install torch* (下载的torch的whl包)
pip install setuptools==59.5.0 wheel pip install setuptools==59.5.0 wheel
...@@ -32,11 +32,17 @@ git clone https://developer.hpccube.com/codes/aicomponent/mmcv # 根据编译需 ...@@ -32,11 +32,17 @@ git clone https://developer.hpccube.com/codes/aicomponent/mmcv # 根据编译需
- 提供2种源码编译方式(进入mmcv目录): - 提供2种源码编译方式(进入mmcv目录):
``` ```
1. 编译whl包并安装 1. 编译whl包并安装
MMCV_WITH_OPS=1 ROCM_HOME=${ROCM_PATH} python3 setup.py -v bdist_wheel MMCV_WITH_OPS=1 python3 setup.py -v bdist_wheel
pip install dist/mmcv* pip install dist/mmcv*
2. 源码编译安装 2. 源码编译安装
MMCV_WITH_OPS=1 ROCM_HOME=${ROCM_PATH} python3 setup.py install MMCV_WITH_OPS=1 python3 setup.py install
```
3. 测试验证
```
cd test
pytest -s ./test_arraymisc.py
pytest -s ./test_ops
``` ```
#### 注意事项 #### 注意事项
+ 若使用pip install下载安装过慢,可添加pypi清华源:-i https://pypi.tuna.tsinghua.edu.cn/simple/ + 若使用pip install下载安装过慢,可添加pypi清华源:-i https://pypi.tuna.tsinghua.edu.cn/simple/
...@@ -52,3 +58,4 @@ MMCV_WITH_OPS=1 ROCM_HOME=${ROCM_PATH} python3 setup.py install ...@@ -52,3 +58,4 @@ MMCV_WITH_OPS=1 ROCM_HOME=${ROCM_PATH} python3 setup.py install
- [README_ORIGIN](README_ORIGIN.md) - [README_ORIGIN](README_ORIGIN.md)
- [README_zh-CN](README_zh-CN.md) - [README_zh-CN](README_zh-CN.md)
- [https://github.com/open-mmlab/mmcv](https://github.com/open-mmlab/mmcv) - [https://github.com/open-mmlab/mmcv](https://github.com/open-mmlab/mmcv)
This diff is collapsed.
This diff is collapsed.
...@@ -5,7 +5,7 @@ This document is used as a reference for English-Chinese terminology translation ...@@ -5,7 +5,7 @@ This document is used as a reference for English-Chinese terminology translation
该文档用作中英文翻译对照参考。 该文档用作中英文翻译对照参考。
| English | 中文 | | English | 中文 |
| :---------------: | :----------: | | :-----: | :---:|
| annotation | 标注 | | annotation | 标注 |
| backbone | 主干网络 | | backbone | 主干网络 |
| benchmark | 基准测试 | | benchmark | 基准测试 |
......
# Docker images
There are two `Dockerfile` files to build docker images, one to build an image with the mmcv pre-built package and the other with the mmcv development environment.
```text
.
|-- README.md
|-- dev # build with mmcv development environment
| `-- Dockerfile
`-- release # build with mmcv pre-built package
`-- Dockerfile
```
## Build docker images
### Build with mmcv pre-built package
Build with local repository
```bash
git clone https://github.com/open-mmlab/mmcv.git && cd mmcv
docker build -t mmcv -f docker/release/Dockerfile .
```
Or build with remote repository
```bash
docker build -t mmcv https://github.com/open-mmlab/mmcv.git#master:docker/release
```
The [Dockerfile](release/Dockerfile) installs latest released version of mmcv by default, but you can specify mmcv versions to install expected versions.
```bash
docker image build -t mmcv -f docker/release/Dockerfile --build-arg MMCV=2.0.0rc1 .
```
If you also want to use other versions of PyTorch and CUDA, you can also pass them when building docker images.
An example to build an image with PyTorch 1.11 and CUDA 11.3.
```bash
docker build -t mmcv -f docker/release/Dockerfile \
--build-arg PYTORCH=1.9.0 \
--build-arg CUDA=11.1 \
--build-arg CUDNN=8 \
--build-arg MMCV=2.0.0rc1 .
```
More available versions of PyTorch and CUDA can be found at [dockerhub/pytorch](https://hub.docker.com/r/pytorch/pytorch/tags).
### Build with mmcv development environment
If you want to build an docker image with the mmcv development environment, you can use the following command
```bash
git clone https://github.com/open-mmlab/mmcv.git && cd mmcv
docker build -t mmcv -f docker/dev/Dockerfile --build-arg CUDA_ARCH=7.5 .
```
Note that `CUDA_ARCH` is the cumpute capability of your GPU and you can find it at [Compute Capability](https://developer.nvidia.com/cuda-gpus#compute).
The building process may take 10 minutes or more.
## Run images
```bash
docker run --gpus all --shm-size=8g -it mmcv
```
See [docker run](https://docs.docker.com/engine/reference/commandline/run/) for more usages.
ARG PYTORCH="1.8.1"
ARG CUDA="10.2"
ARG CUDNN="7"
FROM pytorch/pytorch:${PYTORCH}-cuda${CUDA}-cudnn${CUDNN}-devel
# To fix GPG key error when running apt-get update
RUN rm /etc/apt/sources.list.d/cuda.list \
&& rm /etc/apt/sources.list.d/nvidia-ml.list \
&& apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/3bf863cc.pub \
&& apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64/7fa2af80.pub
# Install git and system dependencies for opencv-python
RUN apt-get update && apt-get install -y git \
&& apt-get update && apt-get install -y libgl1 libglib2.0-0
# Install system dependencies for unit tests
RUN apt-get install -y ffmpeg libturbojpeg \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# build mmcv from source with develop mode
ARG HTTPS_PROXY=""
ENV https_proxy=${HTTPS_PROXY}
ENV FORCE_CUDA="1"
ARG CUDA_ARCH=""
ENV TORCH_CUDA_ARCH_LIST=${CUDA_ARCH}
RUN git clone https://github.com/open-mmlab/mmcv.git /mmcv
WORKDIR /mmcv
RUN git checkout 2.x && git rev-parse --short HEAD
RUN pip install --no-cache-dir -e .[all] -v && pip install pre-commit && pre-commit install
ARG PYTORCH="1.8.1"
ARG CUDA="10.2"
ARG CUDNN="7"
FROM pytorch/pytorch:${PYTORCH}-cuda${CUDA}-cudnn${CUDNN}-devel
# To fix GPG key error when running apt-get update
RUN rm /etc/apt/sources.list.d/cuda.list \
&& rm /etc/apt/sources.list.d/nvidia-ml.list \
&& apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/cuda/repos/ubuntu1804/x86_64/3bf863cc.pub \
&& apt-key adv --fetch-keys https://developer.download.nvidia.com/compute/machine-learning/repos/ubuntu1804/x86_64/7fa2af80.pub
# Install system dependencies for opencv-python
RUN apt-get update && apt-get install -y libgl1 libglib2.0-0 \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
# Install mmcv
ARG MMCV=""
RUN if [ "${MMCV}" = "" ]; then pip install -U openmim && mim install 'mmcv>=2.0.0rc1'; else pip install -U openmim && mim install mmcv==${MMCV}; fi
# Verify the installation
RUN python -c 'import mmcv;print(mmcv.__version__)'
...@@ -4,7 +4,3 @@ ...@@ -4,7 +4,3 @@
height: 40px; height: 40px;
width: 85px; width: 85px;
} }
table.colwidths-auto td {
width: 50%
}
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