Commit 97d118a3 authored by yangzhong's avatar yangzhong
Browse files

修改README格式

parent eadbf875
[pypi-image]: https://badge.fury.io/py/torch-scatter.svg # <div align="center"><strong>PyTorch Scatter</strong></div>
[pypi-url]: https://pypi.python.org/pypi/torch-scatter ## 简介
[testing-image]: https://github.com/rusty1s/pytorch_scatter/actions/workflows/testing.yml/badge.svg PyTorch Scatter由一个小型扩展库组成,该扩展库包含用于PyTorch的高度优化的稀疏更新(分散和分段)操作,这些操作在主包中丢失。分散和分段运算可以粗略地描述为基于给定“群索引”张量的归约运算。分段运算需要对“组索引”张量进行排序,而分散运算则不受这些要求的约束。PyTorch Scatter官方github地址:[https://github.com/rusty1s/pytorch_scatter](https://github.com/rusty1s/pytorch_scatter)
[testing-url]: https://github.com/rusty1s/pytorch_scatter/actions/workflows/testing.yml
[linting-image]: https://github.com/rusty1s/pytorch_scatter/actions/workflows/linting.yml/badge.svg ## 安装
[linting-url]: https://github.com/rusty1s/pytorch_scatter/actions/workflows/linting.yml
[docs-image]: https://readthedocs.org/projects/pytorch-scatter/badge/?version=latest ### 使用pip方式安装
[docs-url]: https://pytorch-scatter.readthedocs.io/en/latest/?badge=latest pytorch-scatter whl包下载目录:[http://10.6.10.68:8000/customized/torch-scatter/dtk2310](http://10.6.10.68:8000/customized/torch-scatter/dtk2310),目前只提供有python3.8版本的whl包。
[coverage-image]: https://codecov.io/gh/rusty1s/pytorch_scatter/branch/master/graph/badge.svg ```shell
[coverage-url]: https://codecov.io/github/rusty1s/pytorch_scatter?branch=master pip install torch_scatter* (下载的torch_scatter的whl包)
```
# PyTorch Scatter ### 使用源码编译方式安装
[![PyPI Version][pypi-image]][pypi-url] #### 编译环境准备
[![Testing Status][testing-image]][testing-url] - 安装相关依赖
[![Linting Status][linting-image]][linting-url] ```shell
[![Docs Status][docs-image]][docs-url] pip install -r requirements.txt
[![Code Coverage][coverage-image]][coverage-url] ```
- 在首页 | 光合开发者社区下载 dtk23.10 解压至 /opt/ 路径下,并建立软链接
<p align="center"> ```shell
<img width="50%" src="https://raw.githubusercontent.com/rusty1s/pytorch_scatter/master/docs/source/_figures/add.svg?sanitize=true" /> cd /opt && ln -s dtk-23.10 dtk
</p> source /opt/dtk/env.sh
```
-------------------------------------------------------------------------------- - 安装pytorch,pytorch whl包下载目录:[http://10.6.10.68:8000/debug/pytorch/dtk23.10/hipify/](http://10.6.10.68:8000/debug/pytorch/dtk23.10/hipify/),根据python、dtk版本,下载对应pytorch的whl包。安装命令如下:
```shell
**[Documentation](https://pytorch-scatter.readthedocs.io)** pip install torch* (下载的torch的whl包)
```
This package consists of a small extension library of highly optimized sparse update (scatter and segment) operations for the use in [PyTorch](http://pytorch.org/), which are missing in the main package. #### 源码编译安装
Scatter and segment operations can be roughly described as reduce operations based on a given "group-index" tensor. ```shell
Segment operations require the "group-index" tensor to be sorted, whereas scatter operations are not subject to these requirements. git clone -b 2.0.9-release http://developer.hpccube.com/codes/aicomponent/torch-scatter.git
cd torch-scatter
The package consists of the following operations with reduction types `"sum"|"mean"|"min"|"max"`: python pymap_script.py /path/to/torch-scatter
python setup.py bdist_wheel
* [**scatter**](https://pytorch-scatter.readthedocs.io/en/latest/functions/scatter.html) based on arbitrary indices pip install dist/*.whl
* [**segment_coo**](https://pytorch-scatter.readthedocs.io/en/latest/functions/segment_coo.html) based on sorted indices
* [**segment_csr**](https://pytorch-scatter.readthedocs.io/en/latest/functions/segment_csr.html) based on compressed indices via pointers
In addition, we provide the following **composite functions** which make use of `scatter_*` operations under the hood: `scatter_std`, `scatter_logsumexp`, `scatter_softmax` and `scatter_log_softmax`.
All included operations are broadcastable, work on varying data types, are implemented both for CPU and GPU with corresponding backward implementations, and are fully traceable.
## Installation
### Anaconda
**Update:** You can now install `pytorch-scatter` via [Anaconda](https://anaconda.org/pyg/pytorch-scatter) for all major OS/PyTorch/CUDA combinations 🤗
Given that you have [`pytorch >= 1.8.0` installed](https://pytorch.org/get-started/locally/), simply run
```
conda install pytorch-scatter -c pyg
```
### Binaries
We alternatively provide pip wheels for all major OS/PyTorch/CUDA combinations, see [here](https://data.pyg.org/whl).
#### PyTorch 1.9.0
To install the binaries for PyTorch 1.9.0, simply run
```
pip install torch-scatter -f https://data.pyg.org/whl/torch-1.9.0+${CUDA}.html
```
where `${CUDA}` should be replaced by either `cpu`, `cu102`, or `cu111` depending on your PyTorch installation.
| | `cpu` | `cu102` | `cu111` |
|-------------|-------|---------|---------|
| **Linux** | ✅ | ✅ | ✅ |
| **Windows** | ✅ | ✅ | ✅ |
| **macOS** | ✅ | | |
#### PyTorch 1.8.0/1.8.1
To install the binaries for PyTorch 1.8.0 and 1.8.1, simply run
```
pip install torch-scatter -f https://data.pyg.org/whl/torch-1.8.0+${CUDA}.html
```
where `${CUDA}` should be replaced by either `cpu`, `cu101`, `cu102`, or `cu111` depending on your PyTorch installation.
| | `cpu` | `cu101` | `cu102` | `cu111` |
|-------------|-------|---------|---------|---------|
| **Linux** | ✅ | ✅ | ✅ | ✅ |
| **Windows** | ✅ | ❌ | ✅ | ✅ |
| **macOS** | ✅ | | | |
**Note:** Binaries of older versions are also provided for PyTorch 1.4.0, PyTorch 1.5.0, PyTorch 1.6.0 and PyTorch 1.7.0/1.7.1 (following the same procedure).
### From source
Ensure that at least PyTorch 1.4.0 is installed and verify that `cuda/bin` and `cuda/include` are in your `$PATH` and `$CPATH` respectively, *e.g.*:
```
$ python -c "import torch; print(torch.__version__)"
>>> 1.4.0
$ echo $PATH
>>> /usr/local/cuda/bin:...
$ echo $CPATH
>>> /usr/local/cuda/include:...
```
Then run:
```
pip install torch-scatter
```
When running in a docker container without NVIDIA driver, PyTorch needs to evaluate the compute capabilities and may fail.
In this case, ensure that the compute capabilities are set via `TORCH_CUDA_ARCH_LIST`, *e.g.*:
```
export TORCH_CUDA_ARCH_LIST = "6.0 6.1 7.2+PTX 7.5+PTX"
```
## Example
```py
import torch
from torch_scatter import scatter_max
src = torch.tensor([[2, 0, 1, 4, 3], [0, 2, 1, 3, 4]])
index = torch.tensor([[4, 5, 4, 2, 3], [0, 0, 2, 2, 1]])
out, argmax = scatter_max(src, index, dim=-1)
```
```
print(out)
tensor([[0, 0, 4, 3, 2, 0],
[2, 4, 3, 0, 0, 0]])
print(argmax)
tensor([[5, 5, 3, 4, 0, 1]
[1, 4, 3, 5, 5, 5]])
```
## Running tests
``` ```
pip install -r requirements.txt ## 单测
```shell
cd torch-scatter
python setup.py test python setup.py test
``` ```
## Known Issue
## C++ API 完成安装进行单测时,会报错ImportError: Could not find module '_version_cpu' ~,在根目录/下查找一下,然后把库文件目录添加一下软链接即可。
`torch-scatter` also offers a C++ API that contains C++ equivalent of python models.
``` ```
mkdir build find / -name "_version_cpu.so"
cd build cd /torch-scatter/torch_scatter
# Add -DWITH_CUDA=on support for the CUDA if needed ln -s /usr/local/lib/python3.8/site-packages/torch-scatter/* .
cmake ..
make
make install
``` ```
### Compile the python library ## 参考资料
```
python setup.py bdist_wheel
pip install dist/*.whl
```
https://github.com/rusty1s/pytorch_scatter
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment