README.md 2.9 KB
Newer Older
fengzch-das's avatar
fengzch-das committed
1
2
3
# <div align="center"><strong>APEX</strong></div>

## 1 简介
JR_ZZU's avatar
JR_ZZU committed
4

fengzch-das's avatar
fengzch-das committed
5
DAS软件栈提供DCU适配版的apex深度学习框架。得益于DAS软件栈对apex特性功能的支持,开发者针对DCU加速卡开发应用时,可以便捷调用apex用于简化Pytorch中的混合精度和分布式训练等功能。
JR_ZZU's avatar
JR_ZZU committed
6

fengzch-das's avatar
fengzch-das committed
7
## 2 安装
JR_ZZU's avatar
JR_ZZU committed
8

fengzch-das's avatar
fengzch-das committed
9
组件支持组合
JR_ZZU's avatar
JR_ZZU committed
10

fengzch-das's avatar
fengzch-das committed
11
| PyTorch版本 | fastpt版本 | apex 版本     | DTK版本  | Python版本      | 推荐编译方式 |
fengzch-das's avatar
fengzch-das committed
12
| ----------- | ---------- | ------------- | -------- | --------------- | ------------ |
fengzch-das's avatar
fengzch-das committed
13
14
| 2.5.1       | 2.1.0      | 24.04.1-fastpt | >= 25.04 | 3.8、3.10、3.11 | fastpt不转码 |
| 2.4.1       | 2.0.1      | 24.04.1-fastpt | >= 25.04 | 3.8、3.10、3.11 | fastpt不转码 |
JR_ZZU's avatar
JR_ZZU committed
15

fengzch-das's avatar
fengzch-das committed
16
+ pytorch 版本大于 2.4.1 && dtk 版本大于 25.04 推荐使用 fastpt 不转码编译。
JR_ZZU's avatar
JR_ZZU committed
17

fengzch-das's avatar
fengzch-das committed
18
### 2.1 使用pip方式安装
JR_ZZU's avatar
JR_ZZU committed
19

fengzch-das's avatar
fengzch-das committed
20
apex whl 包下载目录:[光和开发者社区](https://download.sourcefind.cn:65024/4/main),选择对应的 pytorch 版本和 python 版本下载对应 apex 的 whl 包: 
JR_ZZU's avatar
JR_ZZU committed
21

fengzch-das's avatar
fengzch-das committed
22
23
24
25
26
27
```shell
pip install torch* # 下载 torch 的 whl 包
pip install fastpt* --no-deps # 下载 fastpt 的 whl 包
source  /usr/local/bin/fastpt -E
pip install apex* # 下载的 apex-fastpt 的 whl 包
```
JR_ZZU's avatar
JR_ZZU committed
28

fengzch-das's avatar
fengzch-das committed
29
30
31
32
33
### 2.2 使用源码编译方式安装

#### 2.2.1 编译环境准备

提供基于 fastpt 不转码编译:
JR_ZZU's avatar
JR_ZZU committed
34

fengzch-das's avatar
fengzch-das committed
35
36
1. 基于光源 pytorch 基础镜像环境:镜像下载地址:[光合开发者社区](https://sourcefind.cn/#/image/dcu/pytorch),根据 pytorch、python、dtk 及系统下载对应的镜像版本。
2. 基于现有 python 环境:安装 pytorch,fastpt whl 包下载目录:[光合开发者社区](https://sourcefind.cn/#/image/dcu/pytorch),根据 python、dtk 版本,下载对应 pytorch 的 whl 包。安装命令如下:
JR_ZZU's avatar
JR_ZZU committed
37

fengzch-das's avatar
fengzch-das committed
38
39
40
41
```shell
pip install torch* # 下载torch的whl包
pip install fastpt* --no-deps # 下载fastpt的whl包, 安装顺序,先安装torch,后安装fastpt
pip install setuptools==59.5.0 wheel pytest
limm's avatar
limm committed
42
```
fengzch-das's avatar
fengzch-das committed
43
44
45
46
47
48
49

#### 2.2.2 源码编译安装

- 代码下载

```shell
git clone http://developer.sourcefind.cn/codes/OpenDAS/apex.git # 根据编译需要切换分支
fengzch-das's avatar
fengzch-das committed
50
```
fengzch-das's avatar
fengzch-das committed
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
- whl 包构建安装:

    ```bash
    pip install wheel
    pip install pytest

    source /usr/local/bin/fastpt -C

    python3 setup.py --cpp_ext --cuda_ext --peer_memory --nccl_p2p --fast_bottleneck bdist_wheel # 编译指令
    pip install dist/apex-0.1-cp310-cp310-linux_x86_64.whl
    ```
#### 2.2.3 注意事项

+ ROCM_PATH 为 dtk 的路径,默认为 /opt/dtk;
+ 在 pytorch2.5.1 环境下编译需要支持 c++17 语法,打开setup.py文件,把文件中的 -std=c++14 修改为 -std=c++17。

## 3 验证
- 执行下面的命令测试组件:

fengzch-das's avatar
fengzch-das committed
70
71
```bash
pip install expecttest
JR_ZZU's avatar
JR_ZZU committed
72

fengzch-das's avatar
fengzch-das committed
73
source /usr/local/bin/fastpt -E
limm's avatar
limm committed
74

fengzch-das's avatar
fengzch-das committed
75
76
cd tests/L0
python run_test.py
limm's avatar
limm committed
77
```
fengzch-das's avatar
fengzch-das committed
78
79
80
81
82
83
84
85
86

## 4 Known Issue

-

## 5 参考资料

- [README_ORIGIN](README_ORIGIN.md)
- [https://github.com/NVIDIA/apex.git](https://github.com/NVIDIA/apex.git)