Skip to content

Commit dfa5e1d

Browse files
authored
Merge pull request #115 from rusty1s/travis
Travis
2 parents e53717b + 52d39ac commit dfa5e1d

21 files changed

+430
-142
lines changed

.travis.yml

Lines changed: 81 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,35 +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 sphinx
23-
- pip install sphinx_rtd_theme
24-
- pip install sphinx-autodoc-typehints
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 flake8 codecov
67+
- python setup.py install
68+
2569
script:
26-
- python -c "import torch; print(torch.__version__)"
27-
- pycodestyle .
2870
- flake8 .
29-
- python setup.py install
3071
- python setup.py test
31-
- cd docs && make clean && make html && make doctest && cd ..
3272
after_success:
73+
- python setup.py bdist_wheel --dist-dir=dist/torch-${TORCH_VERSION}
74+
- python script/rename_wheel.py ${IDX}
3375
- 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-scatter
83+
local_dir: dist/torch-${TORCH_VERSION}
84+
upload_dir: whl/torch-${TORCH_VERSION}
85+
acl: public_read
86+
on:
87+
repo: rusty1s/pytorch_scatter
88+
tags: true
3489
notifications:
3590
email: false

MANIFEST.in

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
include README.md
12
include LICENSE
23

4+
recursive-exclude test *
35
recursive-include csrc *

README.md

Lines changed: 32 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,26 @@ In addition, we provide the following **composite functions** which make use of
3636

3737
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.
3838

39-
## Installation
39+
# Installation
40+
41+
### Binaries
42+
43+
We provide pip wheels for all major OS/PyTorch/CUDA combinations, see [here](http://pytorch-scatter.s3-website.eu-central-1.amazonaws.com/whl).
44+
To install from binaries, simply run
45+
46+
```
47+
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
48+
```
49+
50+
where `${CUDA}` should be replaced by either `cpu`, `cu92`, `cu100` or `cu101` depending on your PyTorch installation.
51+
52+
| | `cpu` | `cu92` | `cu100` | `cu101` |
53+
|-------------|-------|--------|---------|---------|
54+
| **Linux** |||||
55+
| **Windows** |||||
56+
| **macOS** |||||
57+
58+
### From source
4059

4160
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.*:
4261

@@ -51,19 +70,24 @@ $ echo $CPATH
5170
>>> /usr/local/cuda/include:...
5271
```
5372

54-
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`
73+
Then run
5574

5675
```
57-
export TORCH_CUDA_ARCH_LIST = "6.0 6.1 7.2+PTX 7.5+PTX"
76+
pip install torch-scatter
5877
```
5978

60-
### Windows
79+
or
80+
81+
```
82+
python setup.py install
83+
```
6184

62-
If you are installing this on Windows specifically, **you will need to point the setup to your Visual Studio installation** for some neccessary libraries and header files.
63-
To do this, add the include and library paths of your installation to the path lists in setup.py as described in the respective comments in the code.
85+
When running in a docker container without nvidia driver, PyTorch needs to evaluate the compute capabilities and may fail.
86+
In this case, ensure that the compute capabilities are set via `TORCH_CUDA_ARCH_LIST`, *e.g.*:
6487

65-
If you are running into any installation problems, please create an [issue](https://github.com/rusty1s/pytorch_scatter/issues).
66-
Be sure to import `torch` first before using this package to resolve symbols the dynamic linker must see.
88+
```
89+
export TORCH_CUDA_ARCH_LIST = "6.0 6.1 7.2+PTX 7.5+PTX"
90+
```
6791

6892
## Example
6993

csrc/scatter.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include <Python.h>
12
#include <torch/script.h>
23

34
#include "cpu/scatter_cpu.h"
@@ -7,6 +8,10 @@
78
#include "cuda/scatter_cuda.h"
89
#endif
910

11+
#ifdef _WIN32
12+
PyMODINIT_FUNC PyInit__scatter(void) { return NULL; }
13+
#endif
14+
1015
torch::Tensor broadcast(torch::Tensor src, torch::Tensor other, int64_t dim) {
1116
if (src.dim() == 1)
1217
for (auto i = 0; i < dim; i++)

csrc/segment_coo.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include <Python.h>
12
#include <torch/script.h>
23

34
#include "cpu/segment_coo_cpu.h"
@@ -7,6 +8,10 @@
78
#include "cuda/segment_coo_cuda.h"
89
#endif
910

11+
#ifdef _WIN32
12+
PyMODINIT_FUNC PyInit__segment_coo(void) { return NULL; }
13+
#endif
14+
1015
std::tuple<torch::Tensor, torch::optional<torch::Tensor>>
1116
segment_coo_fw(torch::Tensor src, torch::Tensor index,
1217
torch::optional<torch::Tensor> optional_out,

csrc/segment_csr.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include <Python.h>
12
#include <torch/script.h>
23

34
#include "cpu/segment_csr_cpu.h"
@@ -7,6 +8,10 @@
78
#include "cuda/segment_csr_cuda.h"
89
#endif
910

11+
#ifdef _WIN32
12+
PyMODINIT_FUNC PyInit__segment_csr(void) { return NULL; }
13+
#endif
14+
1015
std::tuple<torch::Tensor, torch::optional<torch::Tensor>>
1116
segment_csr_fw(torch::Tensor src, torch::Tensor indptr,
1217
torch::optional<torch::Tensor> optional_out,

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}"

script/cuda.sh

Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
#!/bin/bash
2+
3+
if [ "${TRAVIS_OS_NAME}" = "linux" ] && [ "$IDX" = "cpu" ]; then
4+
export TOOLKIT=cpuonly
5+
fi
6+
7+
if [ "${TRAVIS_OS_NAME}" = "linux" ] && [ "$IDX" = "cu92" ]; then
8+
export CUDA_SHORT=9.2
9+
export CUDA=9.2.148-1
10+
export UBUNTU_VERSION=ubuntu1604
11+
export CUBLAS=cuda-cublas-dev-9-2
12+
export TOOLKIT="cudatoolkit=${CUDA_SHORT}"
13+
fi
14+
15+
if [ "${TRAVIS_OS_NAME}" = "linux" ] && [ "$IDX" = "cu100" ]; then
16+
export CUDA_SHORT=10.0
17+
export CUDA=10.0.130-1
18+
export UBUNTU_VERSION=ubuntu1804
19+
export CUBLAS=cuda-cublas-dev-10-0
20+
export TOOLKIT="cudatoolkit=${CUDA_SHORT}"
21+
fi
22+
23+
if [ "${TRAVIS_OS_NAME}" = "linux" ] && [ "$IDX" = "cu101" ]; then
24+
export IDX=cu101
25+
export CUDA_SHORT=10.1
26+
export CUDA=10.1.105-1
27+
export UBUNTU_VERSION=ubuntu1804
28+
export CUBLAS=libcublas-dev
29+
export TOOLKIT="cudatoolkit=${CUDA_SHORT}"
30+
fi
31+
32+
if [ "${TRAVIS_OS_NAME}" = "windows" ] && [ "$IDX" = "cpu" ]; then
33+
export TOOLKIT=cpuonly
34+
fi
35+
36+
if [ "${TRAVIS_OS_NAME}" = "windows" ] && [ "$IDX" = "cu92" ]; then
37+
export CUDA_SHORT=9.2
38+
export CUDA_URL=https://developer.nvidia.com/compute/cuda/${CUDA_SHORT}/Prod2/local_installers2
39+
export CUDA_FILE=cuda_${CUDA_SHORT}.148_win10
40+
export TOOLKIT="cudatoolkit=${CUDA_SHORT}"
41+
fi
42+
43+
if [ "${TRAVIS_OS_NAME}" = "windows" ] && [ "$IDX" = "cu100" ]; then
44+
export CUDA_SHORT=10.0
45+
export CUDA_URL=https://developer.nvidia.com/compute/cuda/${CUDA_SHORT}/Prod/local_installers
46+
export CUDA_FILE=cuda_${CUDA_SHORT}.130_411.31_win10
47+
export TOOLKIT="cudatoolkit=${CUDA_SHORT}"
48+
fi
49+
50+
if [ "${TRAVIS_OS_NAME}" = "windows" ] && [ "$IDX" = "cu101" ]; then
51+
export CUDA_SHORT=10.1
52+
export CUDA_URL=https://developer.nvidia.com/compute/cuda/${CUDA_SHORT}/Prod/local_installers
53+
export CUDA_FILE=cuda_${CUDA_SHORT}.105_418.96_win10.exe
54+
export TOOLKIT="cudatoolkit=${CUDA_SHORT}"
55+
fi
56+
57+
if [ "${TRAVIS_OS_NAME}" = "osx" ] && [ "$IDX" = "cpu" ]; then
58+
export TOOLKIT=""
59+
fi
60+
61+
if [ "${IDX}" = "cpu" ]; then
62+
export FORCE_CPU=1
63+
else
64+
export FORCE_CUDA=1
65+
fi
66+
67+
if [ "${TRAVIS_OS_NAME}" = "linux" ] && [ "${IDX}" != "cpu" ]; then
68+
INSTALLER=cuda-repo-${UBUNTU_VERSION}_${CUDA}_amd64.deb
69+
wget -nv "http://developer.download.nvidia.com/compute/cuda/repos/${UBUNTU_VERSION}/x86_64/${INSTALLER}"
70+
sudo dpkg -i "${INSTALLER}"
71+
wget -nv "https://developer.download.nvidia.com/compute/cuda/repos/${UBUNTU_VERSION}/x86_64/7fa2af80.pub"
72+
sudo apt-key add 7fa2af80.pub
73+
sudo apt update -qq
74+
sudo apt install -y "cuda-core-${CUDA_SHORT/./-}" "cuda-cudart-dev-${CUDA_SHORT/./-}" "${CUBLAS}" "cuda-cusparse-dev-${CUDA_SHORT/./-}"
75+
sudo apt clean
76+
CUDA_HOME=/usr/local/cuda-${CUDA_SHORT}
77+
LD_LIBRARY_PATH=${CUDA_HOME}/lib64:${LD_LIBRARY_PATH}
78+
PATH=${CUDA_HOME}/bin:${PATH}
79+
nvcc --version
80+
fi
81+
82+
if [ "${TRAVIS_OS_NAME}" = "windows" ] && [ "${IDX}" != "cpu" ]; then
83+
wget -nv "${CUDA_URL}/${CUDA_FILE}"
84+
PowerShell -Command "Start-Process -FilePath \"${CUDA_FILE}\" -ArgumentList \"-s nvcc_${CUDA_SHORT} cublas_dev_${CUDA_SHORT} cusparse_dev_${CUDA_SHORT}\" -Wait -NoNewWindow"
85+
CUDA_HOME=/c/Program\ Files/NVIDIA\ GPU\ Computing\ Toolkit/CUDA/v${CUDA_SHORT}
86+
PATH=${CUDA_HOME}/bin:$PATH
87+
PATH=/c/Program\ Files\ \(x86\)/Microsoft\ Visual\ Studio/2017/BuildTools/MSBuild/15.0/Bin:$PATH
88+
nvcc --version
89+
fi
90+
91+
# Fix Cuda9.2 on Windows: https://github.com/pytorch/pytorch/issues/6109
92+
if [ "${TRAVIS_OS_NAME}" = "windows" ] && [ "${IDX}" = "cu92" ]; then
93+
sed -i.bak -e '129,141d' "${CUDA_HOME}/include/crt/host_config.h"
94+
fi

0 commit comments

Comments
 (0)