Skip to content

Commit ecb8c68

Browse files
committed
build wheels
1 parent 0b9019d commit ecb8c68

File tree

21 files changed

+424
-151
lines changed

21 files changed

+424
-151
lines changed

.travis.yml

Lines changed: 81 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,90 @@
1+
language: shell
2+
3+
os:
4+
- linux
5+
- osx
6+
- windows
7+
8+
env:
9+
global:
10+
- CUDA_HOME=/usr/local/cuda
11+
jobs:
12+
- TORCH_VERSION=1.4.0 PYTHON_VERSION=3.8 IDX=cpu
13+
- TORCH_VERSION=1.4.0 PYTHON_VERSION=3.8 IDX=cu92
14+
- TORCH_VERSION=1.4.0 PYTHON_VERSION=3.8 IDX=cu100
15+
- TORCH_VERSION=1.4.0 PYTHON_VERSION=3.8 IDX=cu101
16+
- TORCH_VERSION=1.4.0 PYTHON_VERSION=3.7 IDX=cpu
17+
- TORCH_VERSION=1.4.0 PYTHON_VERSION=3.7 IDX=cu92
18+
- TORCH_VERSION=1.4.0 PYTHON_VERSION=3.7 IDX=cu100
19+
- TORCH_VERSION=1.4.0 PYTHON_VERSION=3.7 IDX=cu101
20+
- TORCH_VERSION=1.4.0 PYTHON_VERSION=3.6 IDX=cpu
21+
- TORCH_VERSION=1.4.0 PYTHON_VERSION=3.6 IDX=cu92
22+
- TORCH_VERSION=1.4.0 PYTHON_VERSION=3.6 IDX=cu100
23+
- TORCH_VERSION=1.4.0 PYTHON_VERSION=3.6 IDX=cu101
24+
125
jobs:
2-
include:
3-
- os: linux
4-
language: python
5-
python: 3.7
6-
addons:
7-
apt:
8-
sources:
9-
- ubuntu-toolchain-r-test
10-
packages:
11-
- gcc-5
12-
- g++-5
13-
env:
14-
- CC=gcc-5
15-
- CXX=g++-5
26+
exclude: # Exclude *all* macOS CUDA jobs and Windows CUDA 9.2/10.0 jobs.
27+
- os: osx
28+
env: TORCH_VERSION=1.4.0 PYTHON_VERSION=3.8 IDX=cu92
29+
- os: osx
30+
env: TORCH_VERSION=1.4.0 PYTHON_VERSION=3.8 IDX=cu100
31+
- os: osx
32+
env: TORCH_VERSION=1.4.0 PYTHON_VERSION=3.8 IDX=cu101
33+
- os: osx
34+
env: TORCH_VERSION=1.4.0 PYTHON_VERSION=3.7 IDX=cu92
35+
- os: osx
36+
env: TORCH_VERSION=1.4.0 PYTHON_VERSION=3.7 IDX=cu100
37+
- os: osx
38+
env: TORCH_VERSION=1.4.0 PYTHON_VERSION=3.7 IDX=cu101
39+
- os: osx
40+
env: TORCH_VERSION=1.4.0 PYTHON_VERSION=3.6 IDX=cu92
41+
- os: osx
42+
env: TORCH_VERSION=1.4.0 PYTHON_VERSION=3.6 IDX=cu100
43+
- os: osx
44+
env: TORCH_VERSION=1.4.0 PYTHON_VERSION=3.6 IDX=cu101
45+
- os: windows
46+
env: TORCH_VERSION=1.4.0 PYTHON_VERSION=3.8 IDX=cu92
47+
- os: windows
48+
env: TORCH_VERSION=1.4.0 PYTHON_VERSION=3.8 IDX=cu100
49+
- os: windows
50+
env: TORCH_VERSION=1.4.0 PYTHON_VERSION=3.7 IDX=cu92
51+
- os: windows
52+
env: TORCH_VERSION=1.4.0 PYTHON_VERSION=3.7 IDX=cu100
53+
- os: windows
54+
env: TORCH_VERSION=1.4.0 PYTHON_VERSION=3.6 IDX=cu92
55+
- os: windows
56+
env: TORCH_VERSION=1.4.0 PYTHON_VERSION=3.6 IDX=cu100
57+
58+
1659
install:
17-
- pip install numpy
18-
- pip install --pre torch torchvision -f https://download.pytorch.org/whl/nightly/cpu/torch_nightly.html
19-
- pip install pycodestyle
20-
- pip install flake8
21-
- pip install codecov
22-
- pip install torch-scatter
60+
- source script/cuda.sh
61+
- source script/conda.sh
62+
- conda create --yes -n test python="${PYTHON_VERSION}"
63+
- source activate test
64+
- conda install pytorch=${TORCH_VERSION} ${TOOLKIT} -c pytorch --yes
65+
- source script/torch.sh
66+
- pip install torch-scatter==latest+${IDX} -f http://pytorch-scatter.s3-website.eu-central-1.amazonaws.com/whl/torch-${TORCH_VERSION}.html --trusted-host pytorch-scatter.s3-website.eu-central-1.amazonaws.com
67+
- pip install flake8 codecov
68+
- python setup.py install
2369
script:
24-
- python -c "import torch; print(torch.__version__)"
25-
- pycodestyle --ignore=E731,W504 .
2670
- flake8 .
27-
- python setup.py install
2871
- python setup.py test
2972
after_success:
73+
- python setup.py bdist_wheel --dist-dir=dist/torch-${TORCH_VERSION}
74+
- python script/rename_wheel.py ${IDX}
3075
- codecov
76+
deploy:
77+
provider: s3
78+
region: eu-central-1
79+
edge: true
80+
access_key_id: AKIAJB7S6NJ5OM5MAAGA
81+
secret_access_key: ${S3_SECRET_ACCESS_KEY}
82+
bucket: pytorch-sparse
83+
local_dir: dist/torch-${TORCH_VERSION}
84+
upload_dir: whl/torch-${TORCH_VERSION}
85+
acl: public_read
86+
on:
87+
repo: rusty1s/pytorch_sparse
88+
branch: master
3189
notifications:
3290
email: false

MANIFEST.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
1+
include README.md
12
include LICENSE
3+
4+
recursive-exclude test *
25
recursive-include csrc *

README.md

Lines changed: 45 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313

1414
--------------------------------------------------------------------------------
1515

16-
[PyTorch](http://pytorch.org/) completely lacks autograd support and operations such as sparse sparse matrix multiplication, but is heavily working on improvement (*cf.* [this issue](https://github.com/pytorch/pytorch/issues/9674)).
17-
In the meantime, this package consists of a small extension library of optimized sparse matrix operations with autograd support.
16+
This package consists of a small extension library of optimized sparse matrix operations with autograd support.
1817
This package currently consists of the following methods:
1918

2019
* **[Coalesce](#coalesce)**
@@ -28,6 +27,26 @@ Note that only `value` comes with autograd support, as `index` is discrete and t
2827

2928
## Installation
3029

30+
### Binaries
31+
32+
We provide pip wheels for all major OS/PyTorch/CUDA combinations, see [here](http://pytorch-sparse.s3-website.eu-central-1.amazonaws.com/whl).
33+
To install from binaries, simply run
34+
35+
```
36+
pip install torch-scatter==latest+${CUDA} -f http://pytorch-scatter.s3-website.eu-central-1.amazonaws.com/whl/torch-1.4.0.html --trusted-host pytorch-scatter.s3-website.eu-central-1.amazonaws.com
37+
pip install torch-sparse==latest+${CUDA} -f http://pytorch-sparse.s3-website.eu-central-1.amazonaws.com/whl/torch-1.4.0.html --trusted-host pytorch-sparse.s3-website.eu-central-1.amazonaws.com
38+
```
39+
40+
where `${CUDA}` should be replaced by either `cpu`, `cu92`, `cu100` or `cu101` depending on your PyTorch installation.
41+
42+
| | `cpu` | `cu92` | `cu100` | `cu101` |
43+
|-------------|-------|--------|---------|---------|
44+
| **Linux** |||||
45+
| **Windows** |||||
46+
| **macOS** |||||
47+
48+
### From source
49+
3150
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.*:
3251

3352
```
@@ -47,10 +66,16 @@ Then run:
4766
pip install torch-scatter torch-sparse
4867
```
4968

50-
If you are running into any installation problems, please create an [issue](https://github.com/rusty1s/pytorch_sparse/issues).
51-
Be sure to import `torch` first before using this package to resolve symbols the dynamic linker must see.
69+
When running in a docker container without nvidia driver, PyTorch needs to evaluate the compute capabilities and may fail.
70+
In this case, ensure that the compute capabilities are set via `TORCH_CUDA_ARCH_LIST`, *e.g.*:
71+
72+
```
73+
export TORCH_CUDA_ARCH_LIST = "6.0 6.1 7.2+PTX 7.5+PTX"
74+
```
75+
76+
## Functions
5277

53-
## Coalesce
78+
### Coalesce
5479

5580
```
5681
torch_sparse.coalesce(index, value, m, n, op="add") -> (torch.LongTensor, torch.Tensor)
@@ -60,20 +85,20 @@ Row-wise sorts `index` and removes duplicate entries.
6085
Duplicate entries are removed by scattering them together.
6186
For scattering, any operation of [`torch_scatter`](https://github.com/rusty1s/pytorch_scatter) can be used.
6287

63-
### Parameters
88+
#### Parameters
6489

6590
* **index** *(LongTensor)* - The index tensor of sparse matrix.
6691
* **value** *(Tensor)* - The value tensor of sparse matrix.
6792
* **m** *(int)* - The first dimension of corresponding dense matrix.
6893
* **n** *(int)* - The second dimension of corresponding dense matrix.
6994
* **op** *(string, optional)* - The scatter operation to use. (default: `"add"`)
7095

71-
### Returns
96+
#### Returns
7297

7398
* **index** *(LongTensor)* - The coalesced index tensor of sparse matrix.
7499
* **value** *(Tensor)* - The coalesced value tensor of sparse matrix.
75100

76-
### Example
101+
#### Example
77102

78103
```python
79104
import torch
@@ -97,28 +122,28 @@ tensor([[6.0, 8.0],
97122
[5.0, 6.0]])
98123
```
99124

100-
## Transpose
125+
### Transpose
101126

102127
```
103128
torch_sparse.transpose(index, value, m, n) -> (torch.LongTensor, torch.Tensor)
104129
```
105130

106131
Transposes dimensions 0 and 1 of a sparse matrix.
107132

108-
### Parameters
133+
#### Parameters
109134

110135
* **index** *(LongTensor)* - The index tensor of sparse matrix.
111136
* **value** *(Tensor)* - The value tensor of sparse matrix.
112137
* **m** *(int)* - The first dimension of corresponding dense matrix.
113138
* **n** *(int)* - The second dimension of corresponding dense matrix.
114139
* **coalesced** *(bool, optional)* - If set to `False`, will not coalesce the output. (default: `True`)
115140

116-
### Returns
141+
#### Returns
117142

118143
* **index** *(LongTensor)* - The transposed index tensor of sparse matrix.
119144
* **value** *(Tensor)* - The transposed value tensor of sparse matrix.
120145

121-
### Example
146+
#### Example
122147

123148
```python
124149
import torch
@@ -142,27 +167,27 @@ tensor([[7.0, 9.0],
142167
[3.0, 4.0]])
143168
```
144169

145-
## Sparse Dense Matrix Multiplication
170+
### Sparse Dense Matrix Multiplication
146171

147172
```
148173
torch_sparse.spmm(index, value, m, n, matrix) -> torch.Tensor
149174
```
150175

151176
Matrix product of a sparse matrix with a dense matrix.
152177

153-
### Parameters
178+
#### Parameters
154179

155180
* **index** *(LongTensor)* - The index tensor of sparse matrix.
156181
* **value** *(Tensor)* - The value tensor of sparse matrix.
157182
* **m** *(int)* - The first dimension of corresponding dense matrix.
158183
* **n** *(int)* - The second dimension of corresponding dense matrix.
159184
* **matrix** *(Tensor)* - The dense matrix.
160185

161-
### Returns
186+
#### Returns
162187

163188
* **out** *(Tensor)* - The dense output matrix.
164189

165-
### Example
190+
#### Example
166191

167192
```python
168193
import torch
@@ -183,7 +208,7 @@ tensor([[7.0, 16.0],
183208
[7.0, 19.0]])
184209
```
185210

186-
## Sparse Sparse Matrix Multiplication
211+
### Sparse Sparse Matrix Multiplication
187212

188213
```
189214
torch_sparse.spspmm(indexA, valueA, indexB, valueB, m, k, n) -> (torch.LongTensor, torch.Tensor)
@@ -192,7 +217,7 @@ torch_sparse.spspmm(indexA, valueA, indexB, valueB, m, k, n) -> (torch.LongTenso
192217
Matrix product of two sparse tensors.
193218
Both input sparse matrices need to be **coalesced** (use the `coalesced` attribute to force).
194219

195-
### Parameters
220+
#### Parameters
196221

197222
* **indexA** *(LongTensor)* - The index tensor of first sparse matrix.
198223
* **valueA** *(Tensor)* - The value tensor of first sparse matrix.
@@ -203,12 +228,12 @@ Both input sparse matrices need to be **coalesced** (use the `coalesced` attribu
203228
* **n** *(int)* - The second dimension of second corresponding dense matrix.
204229
* **coalesced** *(bool, optional)*: If set to `True`, will coalesce both input sparse matrices. (default: `False`)
205230

206-
### Returns
231+
#### Returns
207232

208233
* **index** *(LongTensor)* - The output index tensor of sparse matrix.
209234
* **value** *(Tensor)* - The output value tensor of sparse matrix.
210235

211-
### Example
236+
#### Example
212237

213238
```python
214239
import torch

csrc/version.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#include <Python.h>
2+
#include <torch/script.h>
3+
4+
#ifdef WITH_CUDA
5+
#include <cuda.h>
6+
#endif
7+
8+
#ifdef _WIN32
9+
PyMODINIT_FUNC PyInit__version(void) { return NULL; }
10+
#endif
11+
12+
int64_t cuda_version() {
13+
#ifdef WITH_CUDA
14+
return CUDA_VERSION;
15+
#else
16+
return -1;
17+
#endif
18+
}
19+
20+
static auto registry =
21+
torch::RegisterOperators().op("torch_scatter::cuda_version", &cuda_version);

script/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.html

script/conda.sh

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
#!/bin/bash
2+
3+
if [ "${TRAVIS_OS_NAME}" = "linux" ]; then
4+
wget -nv https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh
5+
chmod +x miniconda.sh
6+
./miniconda.sh -b
7+
PATH=/home/travis/miniconda3/bin:${PATH}
8+
fi
9+
10+
if [ "${TRAVIS_OS_NAME}" = "osx" ]; then
11+
wget -nv https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh -O miniconda.sh
12+
chmod +x miniconda.sh
13+
./miniconda.sh -b
14+
PATH=/Users/travis/miniconda3/bin:${PATH}
15+
fi
16+
17+
18+
if [ "${TRAVIS_OS_NAME}" = "windows" ]; then
19+
choco install openssl.light
20+
choco install miniconda3
21+
PATH=/c/tools/miniconda3/Scripts:$PATH
22+
fi
23+
24+
conda update --yes conda
25+
26+
conda create --yes -n test python="${PYTHON_VERSION}"

0 commit comments

Comments
 (0)