Skip to content

Commit

Permalink
Merge a5aaabe into 1db3967
Browse files Browse the repository at this point in the history
  • Loading branch information
defei-coder authored Mar 27, 2023
2 parents 1db3967 + a5aaabe commit 030643c
Show file tree
Hide file tree
Showing 24 changed files with 3,475 additions and 1,157 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,8 @@ wheels/
.installed.cfg
*.egg
MANIFEST
mlu-ops/
mlu-ops.*

# PyInstaller
# Usually these files are written by a python script from a template
Expand Down
57 changes: 57 additions & 0 deletions docs/en/get_started/build.md
Original file line number Diff line number Diff line change
Expand Up @@ -290,3 +290,60 @@ If you need to use PyTorch-related modules, make sure PyTorch has been successfu
```bash
python -c 'import mmcv;print(mmcv.__version__)'
```

### Build mmcv-full on Cambricon MLU Devices

#### Install torch_mlu

##### Option1: Install mmcv-full based on Cambricon docker image

Firstly, install and pull Cambricon docker image (please email service@cambricon.com for the latest release docker):

```bash
docker pull ${docker image}
```

Run and attach to the docker, [Install mmcv-full on MLU device](#install-mmcv\-full-on-cambricon-mlu-device) and [make sure you've installed mmcv-full on MLU device successfully](#test-code)

##### Option2: Install mmcv-full from compiling Cambricon PyTorch source code

Please email service@cambricon.com or contact with Cambricon engineers for a suitable version of CATCH package. After you get the suitable version of CATCH package, please follow the steps in ${CATCH-path}/CONTRIBUTING.md to install Cambricon PyTorch.

#### Install mmcv-full on Cambricon MLU device

Clone the repo

```bash
git clone https://github.com/open-mmlab/mmcv.git
```

The mlu-ops library will be downloaded to the default directory (mmcv/mlu-ops) while building MMCV. You can also set `MMCV_MLU_OPS_PATH` to an existing mlu-ops library before building as follows:

```bash
export MMCV_MLU_OPS_PATH=/xxx/xxx/mlu-ops
```

Install mmcv-full

```bash
cd mmcv
export MMCV_WITH_OPS=1
export FORCE_MLU=1
python setup.py install
```

#### Test Code

After finishing previous steps, you can run the following python code to make sure that you've installed mmcv-full on MLU device successfully
```python
import torch
import torch_mlu
from mmcv.ops import sigmoid_focal_loss
x = torch.randn(3, 10).mlu()
x.requires_grad = True
y = torch.tensor([1, 5, 3]).mlu()
w = torch.ones(10).float().mlu()
output = sigmoid_focal_loss(x, y, 2.0, 0.25, w, 'none')
print(output)
```
8 changes: 4 additions & 4 deletions docs/en/understand_mmcv/ops.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ We implement common ops used in detection, segmentation, etc.
| ---------------------------- | --- | ---- | --- | --- | ------ |
| ActiveRotatedFilter ||| | | |
| AssignScoreWithK | || | | |
| BallQuery | || | | |
| BallQuery | || | | |
| BBoxOverlaps | |||||
| BorderAlign | || | | |
| BoxIouRotated ||| | | |
Expand Down Expand Up @@ -35,7 +35,7 @@ We implement common ops used in detection, segmentation, etc.
| ModulatedDeformConv2d ||| | ||
| MultiScaleDeformableAttn | ||| | |
| NMS |||| ||
| NMSRotated ||| | ||
| NMSRotated ||| | ||
| NMSQuadri ||| | | |
| PixelGroup || | | | |
| PointsInBoxes ||| | | |
Expand All @@ -52,13 +52,13 @@ We implement common ops used in detection, segmentation, etc.
| SigmoidFocalLoss | ||| ||
| SoftmaxFocalLoss | || | ||
| SoftNMS | || | | |
| Sparse Convolution | || | | |
| Sparse Convolution | || | | |
| Synchronized BatchNorm | || | | |
| ThreeInterpolate | || | | |
| ThreeNN | ||| | |
| TINShift | ||| | |
| UpFirDn2d | || | | |
| Voxelization ||| | ||
| Voxelization ||| | ||
| PrRoIPool | || | | |
| BezierAlign ||| | | |
| BiasAct | || | | |
Expand Down
56 changes: 56 additions & 0 deletions docs/zh_cn/get_started/build.md
Original file line number Diff line number Diff line change
Expand Up @@ -298,3 +298,59 @@ mmcv 有两个版本:
```bash
python -c 'import mmcv;print(mmcv.__version__)'
```

### 在寒武纪 MLU 机器编译 mmcv-full

#### 安装 torch_mlu

##### 选项1: 基于寒武纪 docker image 安装

首先请下载并且拉取寒武纪 docker (请向 service@cambricon.com 发邮件以获得最新的寒武纪 pytorch 发布 docker)。

```
docker pull ${docker image}
```

进入 docker, [编译 MMCV MLU](#编译mmcv-mlu) 并[进行验证](#验证是否成功安装)。

##### 选项2:基于 cambricon pytorch 源码编译安装

请向 service@cambricon.com 发送邮件或联系 Cambricon 工程师以获取合适版本的 CATCH 软件包,在您获得合适版本的 CATCH 软件包后,请参照 ${CATCH-path}/CONTRIBUTING.md 中的步骤安装 CATCH。

#### 编译 MMCV

克隆代码仓库

```bash
git clone https://github.com/open-mmlab/mmcv.git
```

算子库 mlu-ops 在编译 MMCV 时自动下载到默认路径(mmcv/mlu-ops),你也可以在编译前设置环境变量 MMCV_MLU_OPS_PATH 指向已经存在的 mlu-ops 算子库路径。

```bash
export MMCV_MLU_OPS_PATH=/xxx/xxx/mlu-ops
```

开始编译

```bash
cd mmcv
export MMCV_WITH_OPS=1
export FORCE_MLU=1
python setup.py install
```

#### 验证是否成功安装

完成上述安装步骤之后,您可以尝试运行下面的 Python 代码以测试您是否成功在 MLU 设备上安装了 mmcv-full

```python
import torch
import torch_mlu
from mmcv.ops import sigmoid_focal_loss
x = torch.randn(3, 10).mlu()
x.requires_grad = True
y = torch.tensor([1, 5, 3]).mlu()
w = torch.ones(10).float().mlu()
output = sigmoid_focal_loss(x, y, 2.0, 0.25, w, 'none')
```
8 changes: 4 additions & 4 deletions docs/zh_cn/understand_mmcv/ops.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ MMCV 提供了检测、分割等任务中常用的算子
| ---------------------------- | --- | ---- | --- | --- | ------ |
| ActiveRotatedFilter ||| | | |
| AssignScoreWithK | || | | |
| BallQuery | || | | |
| BallQuery | || | | |
| BBoxOverlaps | |||||
| BorderAlign | || | | |
| BoxIouRotated ||| | | |
Expand Down Expand Up @@ -35,7 +35,7 @@ MMCV 提供了检测、分割等任务中常用的算子
| ModulatedDeformConv2d ||| | ||
| MultiScaleDeformableAttn | ||| | |
| NMS |||| ||
| NMSRotated ||| | ||
| NMSRotated ||| | ||
| NMSQuadri ||| | | |
| PixelGroup || | | | |
| PointsInBoxes ||| | | |
Expand All @@ -52,13 +52,13 @@ MMCV 提供了检测、分割等任务中常用的算子
| SigmoidFocalLoss | ||| ||
| SoftmaxFocalLoss | || | ||
| SoftNMS | || | | |
| Sparse Convolution | || | | |
| Sparse Convolution | || | | |
| Synchronized BatchNorm | || | | |
| ThreeInterpolate | || | | |
| ThreeNN | ||| | |
| TINShift | ||| | |
| UpFirDn2d | || | | |
| Voxelization ||| | ||
| Voxelization ||| | ||
| PrRoIPool | || | | |
| BezierAlign ||| | | |
| BiasAct | || | | |
Expand Down
Loading

0 comments on commit 030643c

Please sign in to comment.