From 7d22892fb47626d2c5b0171769d44bdc8edd606c Mon Sep 17 00:00:00 2001 From: Matthias Fey Date: Thu, 5 Oct 2023 22:16:49 +0200 Subject: [PATCH] Add PyTorch 2.1.0 support (#344) * update * update --- .github/workflows/building-conda.yml | 28 ++++++++-------- .github/workflows/building.yml | 36 +++++++++------------ .github/workflows/cuda/cu117-Linux.sh | 2 +- .github/workflows/cuda/cu118-Linux.sh | 2 +- .github/workflows/cuda/cu121-Linux-env.sh | 8 +++++ .github/workflows/cuda/cu121-Linux.sh | 15 +++++++++ .github/workflows/cuda/cu121-Windows-env.sh | 8 +++++ .github/workflows/cuda/cu121-Windows.sh | 18 +++++++++++ .github/workflows/testing.yml | 4 +-- CMakeLists.txt | 2 +- README.md | 22 ++++++------- conda/pytorch-sparse/README.md | 2 +- conda/pytorch-sparse/build_conda.sh | 3 ++ conda/pytorch-sparse/meta.yaml | 3 +- setup.cfg | 2 +- setup.py | 7 ++-- torch_sparse/__init__.py | 2 +- 17 files changed, 104 insertions(+), 60 deletions(-) create mode 100644 .github/workflows/cuda/cu121-Linux-env.sh create mode 100755 .github/workflows/cuda/cu121-Linux.sh create mode 100644 .github/workflows/cuda/cu121-Windows-env.sh create mode 100755 .github/workflows/cuda/cu121-Windows.sh diff --git a/.github/workflows/building-conda.yml b/.github/workflows/building-conda.yml index c13b26ce..816cb86f 100644 --- a/.github/workflows/building-conda.yml +++ b/.github/workflows/building-conda.yml @@ -11,22 +11,21 @@ jobs: fail-fast: false matrix: # We have trouble building for Windows - drop for now. - os: [ubuntu-18.04, macos-10.15] # windows-2019 - python-version: ['3.7', '3.8', '3.9', '3.10', '3.11'] - torch-version: [1.13.0, 2.0.0] - # We have trouble building for `cu116` due to PyTorch 1.13.0 bugs - cuda-version: ['cpu', 'cu117', 'cu118'] + os: [ubuntu-20.04, macos-11] # windows-2019 + python-version: ['3.8', '3.9', '3.10', '3.11'] + torch-version: [2.0.0, 2.1.0] + cuda-version: ['cpu', 'cu117', 'cu118', 'cu121'] exclude: - - torch-version: 1.13.0 - python-version: '3.11' - torch-version: 2.0.0 - python-version: '3.7' - - torch-version: 1.13.0 - cuda-version: 'cu118' - - os: macos-10.15 + cuda-version: 'cu121' + - torch-version: 2.1.0 + cuda-version: 'cu117' + - os: macos-11 cuda-version: 'cu117' - - os: macos-10.15 + - os: macos-11 cuda-version: 'cu118' + - os: macos-11 + cuda-version: 'cu121' steps: - uses: actions/checkout@v2 @@ -38,10 +37,9 @@ jobs: with: python-version: ${{ matrix.python-version }} - - name: Free up disk space + - name: Free Disk Space (Ubuntu) if: ${{ runner.os == 'Linux' }} - run: | - sudo rm -rf /usr/share/dotnet + uses: jlumbroso/free-disk-space@main - name: Install Conda packages run: | diff --git a/.github/workflows/building.yml b/.github/workflows/building.yml index 362c3f44..5325a816 100644 --- a/.github/workflows/building.yml +++ b/.github/workflows/building.yml @@ -10,25 +10,21 @@ jobs: strategy: fail-fast: false matrix: - os: [ubuntu-18.04, macos-10.15, windows-2019] - python-version: ['3.7', '3.8', '3.9', '3.10', '3.11'] - torch-version: [1.13.0, 2.0.0] - cuda-version: ['cpu', 'cu116', 'cu117', 'cu118'] + os: [ubuntu-20.04, macos-11, windows-2019] + python-version: ['3.8', '3.9', '3.10', '3.11'] + torch-version: [2.0.0, 2.1.0] + cuda-version: ['cpu', 'cu117', 'cu118', 'cu121'] exclude: - - torch-version: 1.13.0 - python-version: '3.11' - torch-version: 2.0.0 - python-version: '3.7' - - torch-version: 1.13.0 - cuda-version: 'cu118' - - torch-version: 2.0.0 - cuda-version: 'cu116' - - os: macos-10.15 - cuda-version: 'cu116' - - os: macos-10.15 + cuda-version: 'cu121' + - torch-version: 2.1.0 cuda-version: 'cu117' - - os: macos-10.15 + - os: macos-11 + cuda-version: 'cu117' + - os: macos-11 cuda-version: 'cu118' + - os: macos-11 + cuda-version: 'cu121' steps: - uses: actions/checkout@v2 @@ -43,11 +39,11 @@ jobs: - name: Upgrade pip run: | pip install --upgrade setuptools + pip install scipy==1.10.1 # Python 3.8 support - - name: Free up disk space + - name: Free Disk Space (Ubuntu) if: ${{ runner.os == 'Linux' }} - run: | - sudo rm -rf /usr/share/dotnet + uses: jlumbroso/free-disk-space@main - name: Install CUDA ${{ matrix.cuda-version }} if: ${{ matrix.cuda-version != 'cpu' }} @@ -89,7 +85,7 @@ jobs: - name: Install main package for CPU if: ${{ matrix.cuda-version == 'cpu' }} run: | - FORCE_ONLY_CPU=1 WITH_METIS=1 pip install -e . + FORCE_ONLY_CPU=1 WITH_METIS=1 python setup.py develop shell: bash @@ -97,7 +93,7 @@ jobs: if: ${{ matrix.cuda-version != 'cpu' }} run: | source .github/workflows/cuda/${{ matrix.cuda-version }}-${{ runner.os }}-env.sh - WITH_METIS=1 pip install -e . + WITH_METIS=1 python setup.py develop shell: bash diff --git a/.github/workflows/cuda/cu117-Linux.sh b/.github/workflows/cuda/cu117-Linux.sh index 0593f694..d521965b 100755 --- a/.github/workflows/cuda/cu117-Linux.sh +++ b/.github/workflows/cuda/cu117-Linux.sh @@ -1,6 +1,6 @@ #!/bin/bash -OS=ubuntu1804 +OS=ubuntu2004 wget -nv https://developer.download.nvidia.com/compute/cuda/repos/${OS}/x86_64/cuda-${OS}.pin sudo mv cuda-${OS}.pin /etc/apt/preferences.d/cuda-repository-pin-600 diff --git a/.github/workflows/cuda/cu118-Linux.sh b/.github/workflows/cuda/cu118-Linux.sh index 000a3bd3..46b66e7d 100755 --- a/.github/workflows/cuda/cu118-Linux.sh +++ b/.github/workflows/cuda/cu118-Linux.sh @@ -1,6 +1,6 @@ #!/bin/bash -OS=ubuntu1804 +OS=ubuntu2004 wget -nv https://developer.download.nvidia.com/compute/cuda/repos/${OS}/x86_64/cuda-${OS}.pin sudo mv cuda-${OS}.pin /etc/apt/preferences.d/cuda-repository-pin-600 diff --git a/.github/workflows/cuda/cu121-Linux-env.sh b/.github/workflows/cuda/cu121-Linux-env.sh new file mode 100644 index 00000000..b15ae52d --- /dev/null +++ b/.github/workflows/cuda/cu121-Linux-env.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +CUDA_HOME=/usr/local/cuda-12.1 +LD_LIBRARY_PATH=${CUDA_HOME}/lib64:${LD_LIBRARY_PATH} +PATH=${CUDA_HOME}/bin:${PATH} + +export FORCE_CUDA=1 +export TORCH_CUDA_ARCH_LIST="5.0+PTX;6.0;7.0;7.5;8.0;8.6;9.0" diff --git a/.github/workflows/cuda/cu121-Linux.sh b/.github/workflows/cuda/cu121-Linux.sh new file mode 100755 index 00000000..dd8db12e --- /dev/null +++ b/.github/workflows/cuda/cu121-Linux.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +OS=ubuntu2004 + +wget -nv https://developer.download.nvidia.com/compute/cuda/repos/${OS}/x86_64/cuda-${OS}.pin +sudo mv cuda-${OS}.pin /etc/apt/preferences.d/cuda-repository-pin-600 +wget -nv https://developer.download.nvidia.com/compute/cuda/12.1.1/local_installers/cuda-repo-${OS}-12-1-local_12.1.1-530.30.02-1_amd64.deb +sudo dpkg -i cuda-repo-${OS}-12-1-local_12.1.1-530.30.02-1_amd64.deb +sudo cp /var/cuda-repo-${OS}-12-1-local/cuda-*-keyring.gpg /usr/share/keyrings/ + +sudo apt-get -qq update +sudo apt install cuda-nvcc-12-1 cuda-libraries-dev-12-1 +sudo apt clean + +rm -f https://developer.download.nvidia.com/compute/cuda/12.1.0/local_installers/cuda-repo-${OS}-12-1-local_12.1.1-530.30.02-1_amd64.deb diff --git a/.github/workflows/cuda/cu121-Windows-env.sh b/.github/workflows/cuda/cu121-Windows-env.sh new file mode 100644 index 00000000..c55a0356 --- /dev/null +++ b/.github/workflows/cuda/cu121-Windows-env.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +CUDA_HOME=/c/Program\ Files/NVIDIA\ GPU\ Computing\ Toolkit/CUDA/v12.1 +PATH=${CUDA_HOME}/bin:$PATH +PATH=/c/Program\ Files\ \(x86\)/Microsoft\ Visual\ Studio/2017/BuildTools/MSBuild/15.0/Bin:$PATH + +export FORCE_CUDA=1 +export TORCH_CUDA_ARCH_LIST="6.0+PTX" diff --git a/.github/workflows/cuda/cu121-Windows.sh b/.github/workflows/cuda/cu121-Windows.sh new file mode 100755 index 00000000..7df067fb --- /dev/null +++ b/.github/workflows/cuda/cu121-Windows.sh @@ -0,0 +1,18 @@ +#!/bin/bash + +# Install NVIDIA drivers, see: +# https://github.com/pytorch/vision/blob/master/packaging/windows/internal/cuda_install.bat#L99-L102 +curl -k -L "https://drive.google.com/u/0/uc?id=1injUyo3lnarMgWyRcXqKg4UGnN0ysmuq&export=download" --output "/tmp/gpu_driver_dlls.zip" +7z x "/tmp/gpu_driver_dlls.zip" -o"/c/Windows/System32" + +export CUDA_SHORT=12.1 +export CUDA_URL=https://developer.download.nvidia.com/compute/cuda/${CUDA_SHORT}.1/local_installers +export CUDA_FILE=cuda_${CUDA_SHORT}.1_531.14_windows.exe + +# Install CUDA: +curl -k -L "${CUDA_URL}/${CUDA_FILE}" --output "${CUDA_FILE}" +echo "" +echo "Installing from ${CUDA_FILE}..." +PowerShell -Command "Start-Process -FilePath \"${CUDA_FILE}\" -ArgumentList \"-s nvcc_${CUDA_SHORT} cuobjdump_${CUDA_SHORT} nvprune_${CUDA_SHORT} cupti_${CUDA_SHORT} cublas_dev_${CUDA_SHORT} cudart_${CUDA_SHORT} cufft_dev_${CUDA_SHORT} curand_dev_${CUDA_SHORT} cusolver_dev_${CUDA_SHORT} cusparse_dev_${CUDA_SHORT} thrust_${CUDA_SHORT} npp_dev_${CUDA_SHORT} nvrtc_dev_${CUDA_SHORT} nvml_dev_${CUDA_SHORT}\" -Wait -NoNewWindow" +echo "Done!" +rm -f "${CUDA_FILE}" diff --git a/.github/workflows/testing.yml b/.github/workflows/testing.yml index 8e412cb4..b6dcf421 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/testing.yml @@ -16,7 +16,7 @@ jobs: matrix: os: [ubuntu-latest, windows-2019] python-version: [3.8] - torch-version: [1.13.0, 2.0.0] + torch-version: [2.0.0, 2.1.0] steps: - uses: actions/checkout@v2 @@ -48,7 +48,7 @@ jobs: - name: Install main package run: | - pip install scipy + pip install scipy==1.10.1 # Python 3.8 support python setup.py develop env: WITH_METIS: 1 diff --git a/CMakeLists.txt b/CMakeLists.txt index a6f95b0f..62b448a2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.10) project(torchsparse) set(CMAKE_CXX_STANDARD 14) -set(TORCHSPARSE_VERSION 0.6.17) +set(TORCHSPARSE_VERSION 0.6.18) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake) option(WITH_CUDA "Enable CUDA support" OFF) diff --git a/README.md b/README.md index 954ea459..12a9b18b 100644 --- a/README.md +++ b/README.md @@ -43,39 +43,39 @@ conda install pytorch-sparse -c pyg We alternatively provide pip wheels for all major OS/PyTorch/CUDA combinations, see [here](https://data.pyg.org/whl). -#### PyTorch 2.0 +#### PyTorch 2.1 -To install the binaries for PyTorch 2.0.0, simply run +To install the binaries for PyTorch 2.1.0, simply run ``` -pip install torch-scatter torch-sparse -f https://data.pyg.org/whl/torch-2.0.0+${CUDA}.html +pip install torch-scatter torch-sparse -f https://data.pyg.org/whl/torch-2.1.0+${CUDA}.html ``` -where `${CUDA}` should be replaced by either `cpu`, `cu117`, or `cu118` depending on your PyTorch installation. +where `${CUDA}` should be replaced by either `cpu`, `cu118`, or `cu121` depending on your PyTorch installation. -| | `cpu` | `cu117` | `cu118` | +| | `cpu` | `cu118` | `cu121` | |-------------|-------|---------|---------| | **Linux** | ✅ | ✅ | ✅ | | **Windows** | ✅ | ✅ | ✅ | | **macOS** | ✅ | | | -#### PyTorch 1.13 +#### PyTorch 2.0 -To install the binaries for PyTorch 1.13.0, simply run +To install the binaries for PyTorch 2.0.0, simply run ``` -pip install torch-scatter torch-sparse -f https://data.pyg.org/whl/torch-1.13.0+${CUDA}.html +pip install torch-scatter torch-sparse -f https://data.pyg.org/whl/torch-2.0.0+${CUDA}.html ``` -where `${CUDA}` should be replaced by either `cpu`, `cu116`, or `cu117` depending on your PyTorch installation. +where `${CUDA}` should be replaced by either `cpu`, `cu117`, or `cu118` depending on your PyTorch installation. -| | `cpu` | `cu116` | `cu117` | +| | `cpu` | `cu117` | `cu118` | |-------------|-------|---------|---------| | **Linux** | ✅ | ✅ | ✅ | | **Windows** | ✅ | ✅ | ✅ | | **macOS** | ✅ | | | -**Note:** Binaries of older versions are also provided for PyTorch 1.4.0, PyTorch 1.5.0, PyTorch 1.6.0, PyTorch 1.7.0/1.7.1, PyTorch 1.8.0/1.8.1, PyTorch 1.9.0, PyTorch 1.10.0/1.10.1/1.10.2, PyTorch 1.11.0 and PyTorch 1.12.0/1.12.1 (following the same procedure). +**Note:** Binaries of older versions are also provided for PyTorch 1.4.0, PyTorch 1.5.0, PyTorch 1.6.0, PyTorch 1.7.0/1.7.1, PyTorch 1.8.0/1.8.1, PyTorch 1.9.0, PyTorch 1.10.0/1.10.1/1.10.2, PyTorch 1.11.0, PyTorch 1.12.0/1.12.1 and PyTorch 1.13.0/1.13.1 (following the same procedure). For older versions, you need to explicitly specify the latest supported version number or install via `pip install --no-index` in order to prevent a manual installation from source. You can look up the latest supported version number [here](https://data.pyg.org/whl). diff --git a/conda/pytorch-sparse/README.md b/conda/pytorch-sparse/README.md index 6207e22a..68162091 100644 --- a/conda/pytorch-sparse/README.md +++ b/conda/pytorch-sparse/README.md @@ -1,3 +1,3 @@ ``` -./build_conda.sh 3.9 2.0.0 cu117 # python, pytorch and cuda version +./build_conda.sh 3.9 2.1.0 cu118 # python, pytorch and cuda version ``` diff --git a/conda/pytorch-sparse/build_conda.sh b/conda/pytorch-sparse/build_conda.sh index 33ea72db..084d3bfa 100755 --- a/conda/pytorch-sparse/build_conda.sh +++ b/conda/pytorch-sparse/build_conda.sh @@ -10,6 +10,9 @@ if [ "${CUDA_VERSION}" = "cpu" ]; then export CONDA_CUDATOOLKIT_CONSTRAINT="cpuonly # [not osx]" else case $CUDA_VERSION in + cu121) + export CONDA_CUDATOOLKIT_CONSTRAINT="pytorch-cuda==12.1.*" + ;; cu118) export CONDA_CUDATOOLKIT_CONSTRAINT="pytorch-cuda==11.8.*" ;; diff --git a/conda/pytorch-sparse/meta.yaml b/conda/pytorch-sparse/meta.yaml index 976e3c0a..94501000 100644 --- a/conda/pytorch-sparse/meta.yaml +++ b/conda/pytorch-sparse/meta.yaml @@ -1,6 +1,6 @@ package: name: pytorch-sparse - version: 0.6.17 + version: 0.6.18 source: path: ../.. @@ -24,7 +24,6 @@ requirements: build: string: py{{ environ.get('PYTHON_VERSION').replace('.', '') }}_torch_{{ environ['TORCH_VERSION'] }}_{{ environ['CUDA_VERSION'] }} - number: 1 script_env: - FORCE_CUDA - TORCH_CUDA_ARCH_LIST diff --git a/setup.cfg b/setup.cfg index 40fedbd7..1947cbd2 100644 --- a/setup.cfg +++ b/setup.cfg @@ -6,10 +6,10 @@ classifiers = Development Status :: 5 - Production/Stable License :: OSI Approved :: MIT License Programming Language :: Python - Programming Language :: Python :: 3.7 Programming Language :: Python :: 3.8 Programming Language :: Python :: 3.9 Programming Language :: Python :: 3.10 + Programming Language :: Python :: 3.11 Programming Language :: Python :: 3 :: Only [aliases] diff --git a/setup.py b/setup.py index 5fc19f20..a54f3e1a 100644 --- a/setup.py +++ b/setup.py @@ -15,7 +15,7 @@ CUDAExtension, ) -__version__ = '0.6.17' +__version__ = '0.6.18' URL = 'https://github.com/rusty1s/pytorch_sparse' WITH_CUDA = False @@ -159,15 +159,14 @@ def get_extensions(): 'sparse-matrices', 'autograd', ], - python_requires='>=3.7', + python_requires='>=3.8', install_requires=install_requires, extras_require={ 'test': test_requires, }, ext_modules=get_extensions() if not BUILD_DOCS else [], cmdclass={ - 'build_ext': - BuildExtension.with_options(no_python_abi_suffix=True) + 'build_ext': BuildExtension.with_options(no_python_abi_suffix=True) }, packages=find_packages(), include_package_data=include_package_data, diff --git a/torch_sparse/__init__.py b/torch_sparse/__init__.py index cc7027d9..b5305086 100644 --- a/torch_sparse/__init__.py +++ b/torch_sparse/__init__.py @@ -3,7 +3,7 @@ import torch -__version__ = '0.6.17' +__version__ = '0.6.18' for library in [ '_version', '_convert', '_diag', '_spmm', '_metis', '_rw', '_saint',