Skip to content
Merged
Show file tree
Hide file tree
Changes from 7 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。


### 在昇腾 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 setup.py build_ext
```

安装:

```bash
MMCV_WITH_OPS=1 FORCE_NPU=1 python setup.py 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')
```

使用说明:

```{note}
将 tensor 末尾加上 .npu() 就可以调用到npu算子
```
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