README_HIP.md 1.86 KB
Newer Older
flyingdown's avatar
flyingdown committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
# APEX

## 安装

### System Requirements

- Linux.

- Python 3.7, 3.8, 3.9

- (**推荐**) Upgrade pip

  ```
  python3 -m pip install --upgrade pip #--user
  ```

### 使用pip安装(以dtk-23.04版本为例)
可以在光合[光合开发者社区](https://developer.hpccube.com/tool/#sdk) AI 生态包中获取最新的 apex Release 版本(需对应 DCU Toolkit 版本与 python 版本)
```bash 
python3 -m pip install apex-0.1+git2d8b360.abi0.dtk2304-cp37-cp37m-linux_x86_64.whl
```

### 使用源码安装

#### 编译环境准备(以dtk-23.04版本为例)

- 拉取 apex 代码

  ```
  git clone -b dtk-23.04 http://developer.hpccube.com/codes/aicomponent/apex.git
  ```

-[开发者社区](https://developer.hpccube.com/tool/#sdk) DCU Toolkit 中下载 DTK-23.04 解压至 /opt/ 路径下,并建立软链接

  ```
  cd /opt && ln -s dtk-23.04 dtk
  ```

- 在光合[光合开发者社区](https://developer.hpccube.com/tool/#sdk) AI 生态包中获取对应的 pytorch Release 版本(需对应 DCU Toolkit 版本与 python 版本)
  ```bash
  python3 -m pip install torch-1.13.1a0+git4c8a1fe.abi0.dtk2304-cp37-cp37m-linux_x86_64.whl
  ```

- 导入环境变量以及安装必要依赖库

  ```bash
  source /opt/dtk/env.sh

  export PYTORCH_ROCM_ARCH="gfx906;gfx926"

  MAX_JOBS=16
  sha=`git rev-parse HEAD`
  sed -i  "/version=/{s/\(.*=\)['\"]\(.*\)['\"]/\1'\2\+git${sha:0:7}\.abi0.dtk23.04'/}" setup.py
  pip3 install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple --trusted-host pypi.tuna.tsinghua.edu.cn
  pip3 install wheel -i https://pypi.tuna.tsinghua.edu.cn/simple --trusted-host pypi.tuna.tsinghua.edu.cn
  ```


#### 编译安装

- 执行编译命令
  ```shell
  cd apex
  CXX=hipcc CC=hipcc python3 setup.py --cpp_ext --cuda_ext  bdist_wheel
  pip install dist/apex*
  ```