Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
torch-scatter
Commits
6a7901aa
Commit
6a7901aa
authored
Dec 22, 2023
by
quyuanhao123
Browse files
Update README_HIP.md
parent
4d28cb08
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
75 additions
and
63 deletions
+75
-63
README_HIP.md
README_HIP.md
+75
-63
No files found.
README_HIP.md
View file @
6a7901aa
# <div align="center"><strong>torch-scatter-2.0.9</strong></div>
**编译安装步骤**
## 简介
torch-scatter是一个在PyTorch库中使用的Python库,它用于从张量中随机选择元素并返回一个新的张量。这个库提供了一种简单的方法来创建具有随机标签的数据集,这对于许多机器学习任务非常有用,例如数据增强或生成对抗网络(GANs)。
-
1. 安装与dtk版本对应的pytorch torchvision whl(可在光合社区下载https://developer.hpccube.com/tool/)以及其他依赖库
## 依赖安装
+
pytorch1.10或者pytorch1.13 以及对应的torchvision(建议dtk-22.04.2、dtk-23.04与dtk-23.10)
+
python 3.7-3.10
例如:
### 1、使用源码编译方式安装
pip install https://cancon.hpccube.com:65024/directlink/4/pytorch/dtk22.10/torch-1.10.0a0+git2040069.dtk2210-cp38-cp38-manylinux2014_x86_64.whl
#### 编译环境准备
pip install https://cancon.hpccube.com:65024/directlink/4/vision/dtk22.10/torchvision-0.10.0a0+e04d001.dtk2210-cp38-cp38-manylinux2014_x86_64.whl
提供2种环境准备方式:
pip install -r requirements.txt
1.
基于光源pytorch基础镜像环境:镜像下载地址:
[
https://sourcefind.cn/#/image/dcu/pytorch
](
https://sourcefind.cn/#/image/dcu/pytorch
)
,根据pytorch、python、dtk及系统下载对应的镜像版本。
-
2. 添加编译时的conda环境及部分库的环境变量
2.
基于现有python环境:安装pytorch和torchvision,whl包下载目录:
[
https://cancon.hpccube.com:65024/4/main/pytorch
](
https://cancon.hpccube.com:65024/4/main/pytorch
)
,
[
https://cancon.hpccube.com:65024/4/main/vision
](
https://cancon.hpccube.com:65024/4/main/vision
)
,根据python、dtk版本,下载对应pytorch和torchvision的whl包。安装命令如下:
```
shell
-
2.1 激活对应的conda环境:
pip
install
torch
*
(
下载的torch的whl包
)
pip
install
torchvision
*
(
下载的torchvision的whl包
)
pip
install
setuptools
==
59.5.0 wheel
source ~/miniconda3/etc/profile.d/conda.sh
```
conda activate torch1.10_py39_dtk22.10
#### 源码编译安装
-
代码下载
- 2.2 加载对应的module,包括dtk:
```
shell
git clone http://developer.hpccube.com/codes/aicomponent/torch-scatter
# 根据编译需要切换分支
```
module purge
-
源码编译(进入torch-scatter目录):
```
module load compiler/devtoolset/7.3.1 mpi/hpcx/gcc-7.3.1 compiler/dtk/22.10.1
export C_INCLUDE_PATH=/public/software/apps/DeepLearning/PyTorch_Lib/gflags-2.1.2-build/include:$C_INCLUDE_PATH
export CPLUS_INCLUDE_PATH=/public/software/apps/DeepLearning/PyTorch_Lib/gflags-2.1.2-build/include:$CPLUS_INCLUDE_PATH
module list
export C_INCLUDE_PATH=/public/software/apps/DeepLearning/PyTorch_Lib/glog-build/include:$C_INCLUDE_PATH
export CPLUS_INCLUDE_PATH=/public/software/apps/DeepLearning/PyTorch_Lib/glog-build/include:$CPLUS_INCLUDE_PATH
- 2.3 加载所需的依赖库的环境变量(根据各集群实际路径调整):
export C_INCLUDE_PATH=$ROCM_PATH/rocrand/include:$C_INCLUDE_PATH
export CPLUS_INCLUDE_PATH=$ROCM_PATH/rocrand/include:$CPLUS_INCLUDE_PATH
export LD_LIBRARY_PATH=$ROCM_PATH/rocrand/lib:$LD_LIBRARY_PATH
export C_INCLUDE_PATH=/public/software/apps/DeepLearning/PyTorch_Lib/gflags-2.1.2-build/include:$C_INCLUDE_PATH
export FORCE_ONLY_HIP=1
export CC=hipcc
export CPLUS_INCLUDE_PATH=/public/software/apps/DeepLearning/PyTorch_Lib/gflags-2.1.2-build/include:$CPLUS_INCLUDE_PATH
export CXX=hipcc
export C_INCLUDE_PATH=/public/software/apps/DeepLearning/PyTorch_Lib/glog-build/include:$C_INCLUDE_PATH
python setup.py install
```
export CPLUS_INCLUDE_PATH=/public/software/apps/DeepLearning/PyTorch_Lib/glog-build/include:$CPLUS_INCLUDE_PATH
#### 注意事项
+
若使用pip install下载安装过慢,可添加pypi清华源:-i https://pypi.tuna.tsinghua.edu.cn/simple/
export C_INCLUDE_PATH=$ROCM_PATH/rocrand/include:$C_INCLUDE_PATH
+
ROCM_PATH为dtk的路径,默认为/opt/dtk
export CPLUS_INCLUDE_PATH=$ROCM_PATH/rocrand/include:$CPLUS_INCLUDE_PATH
## 验证
export LD_LIBRARY_PATH=$ROCM_PATH/rocrand/lib:$LD_LIBRARY_PATH
```
python
import
torch
- 2.4 修改编译器环境变量:
from
torch_scatter
import
scatter_max
src
=
torch
.
tensor
([[
2
,
0
,
1
,
4
,
3
],
[
0
,
2
,
1
,
3
,
4
]])
export FORCE_ONLY_HIP=1
index
=
torch
.
tensor
([[
4
,
5
,
4
,
2
,
3
],
[
0
,
0
,
2
,
2
,
1
]])
export CC=hipcc
out
,
argmax
=
scatter_max
(
src
,
index
,
dim
=-
1
)
```
export CXX=hipcc
```
-
3. 编译安装
print(out)
tensor([[0, 0, 4, 3, 2, 0],
[2, 4, 3, 0, 0, 0]])
python setup.py install
print(argmax)
tensor([[5, 5, 3, 4, 0, 1]
[1, 4, 3, 5, 5, 5]])
```
## Known Issue
-
该库没有基于cpu环境修改,仅支持dcu,请在有dcu卡的环境运行。
-
如需完整使用所有pyg功能,请pip install torch-geometric
## 参考资料
-
[
README_ORIGIN
](
README_ORIGIN.md
)
-
[
https://pypi.org/project/torch-scatter/2.0.9/
](
https://pypi.org/project/torch-scatter/2.0.9/
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment