Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Docs] Add steps to install mmcv-full on NPU machine #2363

Merged
merged 10 commits into from
Oct 31, 2022
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions docs/zh_cn/get_started/build.md
Original file line number Diff line number Diff line change
Expand Up @@ -341,3 +341,45 @@ mmcv-full 有两个版本:
1. 编译 mmcv

2. 参考 [IPU PyTorch document](https://docs.graphcore.ai/projects/poptorch-user-guide/en/latest/installation.html) 安装 sdk。

zhouzaida marked this conversation as resolved.
Show resolved Hide resolved

### 在昇腾 NPU 机器编译 mmcv-full

#### 1. 安装 torch_npu

- torch_npu 完整安装教程详见 [PyTorch安装指南](https://gitee.com/ascend/pytorch/blob/master/docs/zh/PyTorch%E5%AE%89%E8%A3%85%E6%8C%87%E5%8D%97/PyTorch%E5%AE%89%E8%A3%85%E6%8C%87%E5%8D%97.md#pytorch%E5%AE%89%E8%A3%85%E6%8C%87%E5%8D%97)

#### 2. 编译 MMCV NPU

拉取 [MMCV 源码](https://github.com/open-mmlab/mmcv/tree/master)进行编译安装

编译:

```bash
MMCV_WITH_OPS=1 MAX_JOBS=8 FORCE_NPU=1 python set_up.py build_ext
```

安装

```bash
MMCV_WITH_OPS=1 FORCE_NPU=1 python set_up develop
```

验证:

```python
import torch
import torch_npu
from mmcv.ops import softmax_focal_loss
x = torch.randn(3, 10).npu()
x.requires_grad = True
y = torch.tensor([1, 5, 3]).npu()
w = torch.ones(10).float().npu()
output = softmax_focal_loss(x, y, 2.0, 0.25, w, 'none')
```

使用说明:

```bash
将 tensor 末尾加上 .npu() 就可以调用到npu算子
zhouzaida marked this conversation as resolved.
Show resolved Hide resolved
```
zhouzaida marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ default_section = THIRDPARTY
# than "BA"
[codespell]
quiet-level = 3
ignore-words-list = inout,hist,ba,inh,ro,tne,warmup,warpped,warpping
ignore-words-list = inout,hist,ba,inh,ro,tne,warmup,warpped,warpping,cann
zhouzaida marked this conversation as resolved.
Show resolved Hide resolved