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-sparse
Commits
b9ee8efb
Commit
b9ee8efb
authored
May 30, 2025
by
limm
Browse files
update README.md
parent
a43bd4e4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
46 additions
and
19 deletions
+46
-19
README.md
README.md
+46
-19
No files found.
README.md
View file @
b9ee8efb
...
...
@@ -2,45 +2,72 @@
## 简介
Pytorch Sparce 是 个包包含了一个小型扩展库,用于优化支持自动微分的稀疏矩阵操作。目前,这个包包括以下方法:Coalesce,Transpose,Sparse Dense Matrix Multiplication,Sparse Sparse Matrix Multiplication 所有包含的操作都支持不同类型的数据,并且既在CPU上也在GPU上实现了。DAS软件栈中的PyTorch Sparce版本,不仅保证了组件核心功能在DCU加速卡的可用性,还针对DCU特有的硬件架构进行了深度定制优化。这使得开发者能够以极低的成本,轻松实现应用程序在DCU加速卡上的快速迁移和性能提升。目前支持Pytorch1.13 Pyotrch2.1 Pytorch2.4.1 Pytorch2.5.1
### 使用pip方式安装
torch-sparce whl包下载目录:
[
光合开发者社区
](
https://das.sourcefind.cn:55011/portal/#/home
)
. 目前只提供有python.10版本的安装包 (如果为空需要自己按照下面步骤编译)
```
shell
pip
install
torch_sparse
*
(
下载的torch_sparse的whl包
)
```
### 使用源码编译方式安装
## 安装
组件支持组合
| PyTorch版本 | fastpt版本 |pytorch_Sparse版本 | DTK版本 | Python版本 | 推荐编译方式 |
| ----------- | ----------- | -------------------- | ------------ | ---------------- | ------------ |
| 2.5.1 | 2.1.0 |1.6.3 | >= 25.04 | 3.8、3.10、3.11 | fastpt不转码 |
| 2.4.1 | 2.0.1 |1.6.3 | >= 25.04 | 3.8、3.10、3.11 | fastpt不转码 |
| 其他 | 其他 | 其他 | 其他 | 3.8、3.10、3.11 | hip转码 |
+
pytorch版本大于2.4.1 && dtk版本大于25.04 推荐使用fastpt不转码编译。
#### 编译环境准备
-
安装相关依赖
```
shell
pip
install
numpy
pip
install
'urllib3==1.26.14'
pip
install
pytest
pip
install
wheel
pip
install
numpy
```
-
在首页 | 光合开发者社区下载 dtk25.04 解压在 /opt/ 路径下,并建立软连接,例如:
### 1、使用pip方式安装
pytorch-sparse whl包下载目录:
[
光和开发者社区
](
https://download.sourcefind.cn:65024/4/main/torch_sparse
)
,选择对应的pytorch版本和python版本下载对应torch_sparse的whl包
```
shell
cd
/opt &
ln
-s
dtk-25.04 dtk
pip
install
torch
*
(
下载torch的whl包
)
pip
install
fastpt
*
--no-deps
(
下载fastpt的whl包
)
source
/usr/local/bin/fastpt
-E
pip
install
torch_sparse
*
(
下载的torch_sparse-fastpt的whl包
)
```
### 2、使用源码编译方式安装
#### 编译环境准备
提供基于fastpt不转码编译:
-
安装pytorch. pytorch whl包下载目录:
[
光合开发者社区
](
https://das.sourcefind.cn:55011/portal/#/home
)
. 根据需求下载对应系统下的版本,安装如下:
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包。安装命令如下:
```
shell
pip
install
torch
*
(
下载的torch的whl包
)
pip
install
torch
*
(
下载torch的whl包
)
pip
install
fastpt
*
--no-deps
(
下载fastpt的whl包, 安装顺序,先安装torch,后安装fastpt
)
```
-
安装fastpt. fastpt whl包下载目录:
[
光合开发者社区
](
https://das.sourcefind.cn:55011/portal/#/home
)
. 根据需求下载对应系统下的版本,安装如下:
#### 源码编译安装
```
shell
pip
install
fastpt
*
(
下载的fastpt的whl包
)
git clone http://developer.sourcefind.cn/codes/OpenDAS/torch-sparce.git
# 根据编译需要切换分支
```
#### 源码下载编译安装
-
提供2种源码编译方式(进入torch-sparce目录):
1.
设置不转码编译环境变量
```
shell
git clone
-b
0.6.16-fastpt http://developer.hpccube.com/codes/aicomponent/torch-sparce.git
export
FORCE_CUDA
=
1
source
/usr/local/bin/fastpt
-C
cd
torch-sparce
```
2.
编译whl包并安装
```
shell
cd
pytorch_sparce
||
torch-sparce
python setup.py bdist_wheel
pip
install
dist/
*
.whl
```
3.
源码编译安装
```
shell
python3 setup.py
install
```
#### 注意事项
+
若使用pip install下载安装过慢,可添加pypi清华源:-i https://pypi.tuna.tsinghua.edu.cn/simple/
+
ROCM_PATH为dtk的路径,默认为/opt/dtk
## 验证
python -c "import torch_sparse; torch_sparse.
\_\_
version__",版本号与官方版本同步,查询该软件的版本号,例如0.6.16
## 单侧
```
shell
...
...
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