forked from mit-han-lab/torchsparse
-
-
Notifications
You must be signed in to change notification settings - Fork 5
175 lines (150 loc) · 6.05 KB
/
build-windows-wheels.yml
File metadata and controls
175 lines (150 loc) · 6.05 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
name: Build Cross-Platform Wheels
on:
push:
tags:
- 'v*'
workflow_dispatch:
inputs:
cuda_versions:
description: 'CUDA versions to build for (comma-separated)'
required: false
default: '11.8,12.1'
pytorch_version:
description: 'PyTorch version to install (e.g., "2.1.0", "latest")'
required: false
default: 'latest'
platforms:
description: 'Platforms to build for (comma-separated: windows,linux)'
required: false
default: 'windows,linux'
jobs:
build_wheels:
name: Build wheels on ${{ matrix.platform.name }} for CUDA ${{ matrix.cuda_version }}
runs-on: ${{ matrix.platform.os }}
strategy:
fail-fast: false
matrix:
platform:
- name: linux
os: ubuntu-22.04
- name: windows
os: windows-2022
cuda_version: ['11.8', '12.1', '12.4', '12.6', '12.8']
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install CUDA Toolkit ${{ matrix.cuda_version }} (Windows)
if: matrix.platform.os == 'windows-2022'
uses: Jimver/cuda-toolkit@v0.2.23
with:
cuda: ${{ matrix.cuda_version }}.0
method: 'network'
sub-packages: '["nvcc", "cudart", "cublas", "curand", "cufft", "cusparse", "cusolver"]'
- name: Setup Visual Studio environment (Windows)
if: matrix.platform.os == 'windows-2022'
uses: ilammy/msvc-dev-cmd@v1
with:
arch: x64
- name: Build wheels
uses: pypa/cibuildwheel@v3.0.0
env:
# Pass matrix and input variables to cibuildwheel's environment
PYTORCH_VERSION: ${{ github.event.inputs.pytorch_version || 'latest' }}
CUDA_VERSION: ${{ matrix.cuda_version }}
# Configure cibuildwheel
CIBW_BUILD_FRONTEND: "pip; args: --no-build-isolation"
CIBW_BUILD: "cp38-* cp39-* cp310-* cp311-* cp312-*"
CIBW_SKIP: ${{ matrix.cuda_version == '11.8' && 'cp312-*' || '' }}
CIBW_BEFORE_BUILD_LINUX: |
set -euxo pipefail
dnf install -y gcc-c++ sparsehash-devel
bash .github/tools/install_pytorch.sh
CIBW_BEFORE_BUILD_WINDOWS: |
powershell -Command "Invoke-WebRequest -Uri https://github.com/sparsehash/sparsehash/archive/refs/tags/sparsehash-2.0.4.zip -OutFile sparsehash.zip"
powershell -Command "Expand-Archive -Path sparsehash.zip -DestinationPath C:\"
powershell -Command "Rename-Item C:\sparsehash-sparsehash-2.0.4 C:\sparsehash"
powershell -ExecutionPolicy Bypass -File .github/tools/install_pytorch.ps1
CIBW_ENVIRONMENT_LINUX: >
CXXFLAGS="-O2 -fopenmp"
CFLAGS="-O2"
FORCE_CUDA=1
TORCH_CUDA_ARCH_LIST="7.5;8.0;8.6;8.9"
MAX_JOBS=4
CIBW_ENVIRONMENT_WINDOWS: >
CL="/O1 /MP4"
DISTUTILS_USE_SDK=1
MSSdk=1
FORCE_CUDA=1
TORCH_CUDA_ARCH_LIST="7.5;8.0;8.6;8.9"
INCLUDE="$INCLUDE;C:\sparsehash\src"
CIBW_BEFORE_TEST_LINUX: |
bash .github/tools/install_pytorch.sh
CIBW_BEFORE_TEST_WINDOWS: |
powershell -ExecutionPolicy Bypass -File .github/tools/install_pytorch.ps1
CIBW_TEST_COMMAND_WINDOWS: "python -c \"import torch; import torchsparse; print(f'TorchSparse version: {torchsparse.__version__}')\""
CIBW_TEST_COMMAND_LINUX: "python -c 'import torch; import torchsparse; print(f\"TorchSparse version: {torchsparse.__version__}\")'"
CIBW_BUILD_VERBOSITY: 1
- name: Upload wheel artifacts
uses: actions/upload-artifact@v4
with:
name: wheels-${{ matrix.platform.name }}-cuda${{ matrix.cuda_version }}
path: ./wheelhouse/*.whl
create-release:
needs: build_wheels
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/')
steps:
- name: Download all wheel artifacts
uses: actions/download-artifact@v4
with:
path: wheels
pattern: wheels-*
merge-multiple: true
- name: Organize wheels and create release
run: |
mkdir -p release
find wheels -name "*.whl" -exec cp {} release/ \;
ls -la release/
gh release create ${{ github.ref_name }} --generate-notes --title "TorchSparse ${{ github.ref_name }} - Cross-Platform Release" release/*.whl
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
test-wheels:
needs: build_wheels
strategy:
fail-fast: false
matrix:
platform:
- name: linux
os: ubuntu-22.04
- name: windows
os: windows-2022
python-version: ['3.10']
cuda-version: ['12.1']
runs-on: ${{ matrix.platform.os }}
steps:
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Set up python-version-nodot
id: py-ver
run: echo "nodot=$(echo ${{ matrix.python-version }} | tr -d .)" >> $GITHUB_ENV
- name: Install CUDA Toolkit (if needed for testing runtime)
if: matrix.platform.os == 'windows-2022'
uses: Jimver/cuda-toolkit@v0.2.23
with:
cuda: ${{ matrix.cuda_version }}.0
method: 'network'
- name: Download wheel artifacts
uses: actions/download-artifact@v4
with:
name: wheels-${{ matrix.platform.name }}-cuda${{ matrix.cuda_version }}
path: wheels
- name: Install PyTorch (for testing)
run: pip install torch==2.1.0+cu121 torchvision==0.16.0+cu121 --index-url https://download.pytorch.org/whl/cu121
- name: Test wheel installation and functionality
shell: bash
run: |
wheel_file=$(find wheels -name "*cp${{ env.nodot }}*.whl" | head -1)
pip install "$wheel_file"
python -c "import torch; import torchsparse; print('TorchSparse version:', torchsparse.__version__); print('PyTorch version:', torch.__version__); print('CUDA available:', torch.cuda.is_available())"