README.md 2.53 KB
Newer Older
yangzhong's avatar
yangzhong committed
1
2
# <div align="center"><strong>PyTorch Cluster</strong></div>
## 简介
limm's avatar
limm committed
3
PyTorch Cluster是一个小型的扩展库,其中包含了高度优化的图聚类算法,用于在PyTorch中使用。该包包括以下聚类算法:Graclus,Voxel Grid Pooling,迭代最远点采样,k-NN和Radius图生成,基于最近点的聚类,随机游走采样等。DAS软件栈中的PyTorch Cluster版本,不仅保证了组件核心功能在DCU加速卡的可用性,还针对DCU特有的硬件架构进行了深度定制优化。这使得开发者能够以极低的成本,轻松实现应用程序在DCU加速卡上的快速迁移和性能提升。目前支持Pytorch1.13 Pyotrch2.1 Pytorch2.4.1 Pytorch2.5.1
yangzhong's avatar
yangzhong committed
4
5
6
7

## 安装

### 使用pip方式安装
limm's avatar
limm committed
8
pytorch-cluster whl包下载目录:[https://das.sourcefind.cn:55011/portal/#/installation?id=2083b36e-6c1b-11ef-bb3e-005056904552&type=frame](https://das.sourcefind.cn:55011/portal/#/installation?id=2083b36e-6c1b-11ef-bb3e-005056904552&type=frame).
yangzhong's avatar
yangzhong committed
9
10
11
12
13
14
15
16
17
18
19
20
21
```shell
pip install torch_cluster* (下载的torch_cluster的whl包)
```
### 使用源码编译方式安装

#### 编译环境准备
- 安装相关依赖
```shell
pip install numpy
pip install 'urllib3==1.26.14' 
pip install pytest
pip install wheel 
```
limm's avatar
limm committed
22
- 在首页 | 光合开发者社区下载 dtk25.04 解压至 /opt/ 路径下,并建立软链接
yangzhong's avatar
yangzhong committed
23
```shell
limm's avatar
limm committed
24
25
26
cd /opt && ln -s dtk-25.04 dtk

- 安装pytorch,pytorch whl包下载目录:[http://10.16.4.1:8000/debug/pytorch/dtk25.04/](http://10.16.4.1:8000/debug/pytorch/dtk25.04/),根据python、dtk版本,下载对应pytorch的whl包。安装命令如下:
yangzhong's avatar
yangzhong committed
27
pip install torch* (下载的torch的whl包)
limm's avatar
limm committed
28

limm's avatar
limm committed
29
- 安装fastpt,fastpt whl包下载目录:[https://das.sourcefind.cn:55011/portal/#/home](https://das.sourcefind.cn:55011/portal/#/home).
limm's avatar
limm committed
30
31
pip install fastpt*

yangzhong's avatar
yangzhong committed
32
33
```
#### 源码编译安装
limm's avatar
limm committed
34

yangzhong's avatar
yangzhong committed
35
```shell
limm's avatar
limm committed
36
37
38
39
git clone -b 1.6.3-fastpt http://developer.hpccube.com/codes/aicomponent/torch-cluster.git
export FORCE_CUDA=1
source /usr/local/bin/fastpt -C

yangzhong's avatar
yangzhong committed
40
41
42
cd pytorch_cluster
python setup.py bdist_wheel
pip install dist/*.whl
limm's avatar
limm committed
43

yangzhong's avatar
yangzhong committed
44
```
yangzhong's avatar
yangzhong committed
45
46
47
## 单测
```shell
cd pytorch_cluster
yangzhong's avatar
yangzhong committed
48
49
pytest
```
yangzhong's avatar
yangzhong committed
50
51
## Known Issue
完成安装进行单测时,会报错ImportError: Could not find module '_version_cpu' ~,在根目录/下查找一下,然后把库文件目录添加一下软链接即可。
yangzhong's avatar
yangzhong committed
52
53

```
yangzhong's avatar
yangzhong committed
54
55
56
find / -name "_version_cpu.so"
cd /pytorch_cluster/torch_cluster
ln -s /usr/local/lib/python3.8/site-packages/torch_cluster/* .
yangzhong's avatar
yangzhong committed
57
58
```

yangzhong's avatar
yangzhong committed
59
## 参考资料
quyuanhao123's avatar
quyuanhao123 committed
60

limm's avatar
limm committed
61
PyTorch Cluster官方github地址:[https://github.com/rusty1s/pytorch_cluster](https://github.com/rusty1s/pytorch_cluster)