Skip to content

Commit a0c4bfc

Browse files
authored
chore: support torch2.10 and more cuda versions (#890)
* add torch2.10, eliminate 2.7 * add torch2.10, eliminate 2.7 * done * bump the version * debugging
1 parent 7fa4f60 commit a0c4bfc

8 files changed

Lines changed: 78 additions & 101 deletions

.github/workflows/nightly-build.yaml

Lines changed: 24 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,15 @@ jobs:
7676
if: needs.tag.outputs.need_build == 'true' && github.repository == 'nunchaku-ai/nunchaku'
7777
strategy:
7878
matrix:
79-
python: ["3.10", "3.11", "3.12", "3.13"]
80-
torch: ["2.7", "2.8", "2.9", "pre"]
79+
# python: ["3.10", "3.11", "3.12", "3.13"]
80+
# torch: ["2.8", "2.9", "2.10", "pre"]
81+
# cuda: ["12.8", "13.0"]
82+
python: ["3.10"]
83+
torch: ["2.8"]
84+
cuda: ["12.8", "13.0"]
85+
exclude:
86+
- torch: "2.8"
87+
cuda: "13.0"
8188
steps:
8289
- name: Checkout to the tag
8390
uses: actions/checkout@v4
@@ -89,17 +96,10 @@ jobs:
8996
run: git log -1 --oneline
9097
- name: Build wheels
9198
run: |
92-
if [[ "${{ matrix.torch }}" == "2.7" || "${{ matrix.torch }}" == "2.8" ]]; then
93-
cuda_version="12.8"
94-
elif [[ "${{ matrix.torch }}" == "2.9" ]]; then
95-
cuda_version="13.0"
96-
else
97-
cuda_version="12.4"
98-
fi
9999
if [[ "${{ matrix.torch }}" == "pre" ]]; then
100-
bash scripts/build_linux_wheel_torch_nightly.sh ${{ matrix.python }} ${{ matrix.torch }} 13.0
100+
bash scripts/build_linux_wheel_torch_nightly.sh ${{ matrix.python }} ${{ matrix.torch }} ${{ matrix.cuda }}
101101
else
102-
bash scripts/build_linux_wheel.sh ${{ matrix.python }} ${{ matrix.torch }} $cuda_version
102+
bash scripts/build_linux_wheel.sh ${{ matrix.python }} ${{ matrix.torch }} ${{ matrix.cuda }}
103103
fi
104104
- name: Upload wheels to GitHub Release
105105
uses: softprops/action-gh-release@v2
@@ -120,8 +120,15 @@ jobs:
120120
if: needs.tag.outputs.need_build == 'true' && github.repository == 'nunchaku-tech/nunchaku'
121121
strategy:
122122
matrix:
123-
python: ["3.10", "3.11", "3.12", "3.13"]
124-
torch: ["2.9", "pre"]
123+
# python: ["3.10", "3.11", "3.12", "3.13"]
124+
# torch: ["2.8", "2.9", "2.10", "pre"]
125+
# cuda: ["12.8", "13.0"]
126+
python: ["3.10"]
127+
torch: ["2.8"]
128+
cuda: ["12.8", "13.0"]
129+
exclude:
130+
- torch: "2.8"
131+
cuda: "13.0"
125132
steps:
126133
- name: Checkout to the tag
127134
uses: actions/checkout@v4
@@ -134,24 +141,11 @@ jobs:
134141
- name: Build wheels
135142
shell: cmd
136143
run: |
137-
SET TORCH_VERSION=${{ matrix.torch }}
138-
SET PYTHON_VERSION=${{ matrix.python }}
139-
IF "%TORCH_VERSION%"=="2.7" (
140-
SET CUDA_VERSION=12.8
141-
) ELSE IF "%TORCH_VERSION%"=="2.8" (
142-
SET CUDA_VERSION=12.8
143-
) ELSE IF "%TORCH_VERSION%"=="2.9" (
144-
SET CUDA_VERSION=13.0
145-
) ELSE IF "%TORCH_VERSION%"=="pre" (
146-
SET CUDA_VERSION=13.0
147-
) ELSE (
148-
SET CUDA_VERSION=12.4
149-
)
150-
call C:\Users\muyangl\miniconda3\condabin\activate.bat activate
151-
IF "%TORCH_VERSION%"=="pre" (
152-
call scripts\build_windows_wheel_torch_nightly.cmd %PYTHON_VERSION% %TORCH_VERSION% %CUDA_VERSION%
144+
call C:\Users\nunchaku\miniconda3\condabin\activate.bat activate
145+
IF "${{ matrix.torch }}"=="pre" (
146+
call scripts\build_windows_wheel_torch_nightly.cmd ${{ matrix.python }} ${{ matrix.torch }} ${{ matrix.cuda }}
153147
) ELSE (
154-
call scripts\build_windows_wheel.cmd %PYTHON_VERSION% %TORCH_VERSION% %CUDA_VERSION%
148+
call scripts\build_windows_wheel.cmd ${{ matrix.python }} ${{ matrix.torch }} ${{ matrix.cuda }}
155149
)
156150
- name: Upload wheels to GitHub Release
157151
uses: softprops/action-gh-release@v2

.github/workflows/release-build.yaml

Lines changed: 17 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,11 @@ jobs:
5151
strategy:
5252
matrix:
5353
python: ["3.10", "3.11", "3.12", "3.13"]
54-
torch: ["2.7", "2.8", "2.9", "pre"]
54+
torch: ["2.8", "2.9", "2.10", "pre"]
55+
cuda: ["12.8", "13.0"]
56+
exclude:
57+
- torch: "2.8"
58+
cuda: "13.0"
5559
steps:
5660
- name: Checkout to the tag
5761
uses: actions/checkout@v4
@@ -63,17 +67,10 @@ jobs:
6367
run: git log -1 --oneline
6468
- name: Build wheels
6569
run: |
66-
if [[ "${{ matrix.torch }}" == "2.7" || "${{ matrix.torch }}" == "2.8" ]]; then
67-
cuda_version="12.8"
68-
elif [[ "${{ matrix.torch }}" == "2.9" ]]; then
69-
cuda_version="13.0"
70-
else
71-
cuda_version="12.4"
72-
fi
7370
if [[ "${{ matrix.torch }}" == "pre" ]]; then
74-
bash scripts/build_linux_wheel_torch_nightly.sh ${{ matrix.python }} ${{ matrix.torch }} 13.0
71+
bash scripts/build_linux_wheel_torch_nightly.sh ${{ matrix.python }} ${{ matrix.torch }} ${{ matrix.cuda }}
7572
else
76-
bash scripts/build_linux_wheel.sh ${{ matrix.python }} ${{ matrix.torch }} $cuda_version
73+
bash scripts/build_linux_wheel.sh ${{ matrix.python }} ${{ matrix.torch }} ${{ matrix.cuda }}
7774
fi
7875
- name: Upload wheels to GitHub Release
7976
uses: softprops/action-gh-release@v2
@@ -106,7 +103,11 @@ jobs:
106103
strategy:
107104
matrix:
108105
python: ["3.10", "3.11", "3.12", "3.13"]
109-
torch: ["2.9", "pre"]
106+
torch: ["2.8", "2.9", "2.10", "pre"]
107+
cuda: ["12.8", "13.0"]
108+
exclude:
109+
- torch: "2.8"
110+
cuda: "13.0"
110111
steps:
111112
- name: Checkout to the tag
112113
uses: actions/checkout@v4
@@ -119,24 +120,11 @@ jobs:
119120
- name: Build wheels
120121
shell: cmd
121122
run: |
122-
SET TORCH_VERSION=${{ matrix.torch }}
123-
SET PYTHON_VERSION=${{ matrix.python }}
124-
IF "%TORCH_VERSION%"=="2.7" (
125-
SET CUDA_VERSION=12.8
126-
) ELSE IF "%TORCH_VERSION%"=="2.8" (
127-
SET CUDA_VERSION=12.8
128-
) ELSE IF "%TORCH_VERSION%"=="2.9" (
129-
SET CUDA_VERSION=13.0
130-
) ELSE IF "%TORCH_VERSION%"=="pre" (
131-
SET CUDA_VERSION=13.0
132-
) ELSE (
133-
SET CUDA_VERSION=12.4
134-
)
135-
call C:\Users\muyangl\miniconda3\condabin\activate.bat activate
136-
IF "%TORCH_VERSION%"=="pre" (
137-
call scripts\build_windows_wheel_torch_nightly.cmd %PYTHON_VERSION% %TORCH_VERSION% %CUDA_VERSION%
123+
call C:\Users\nunchaku\miniconda3\condabin\activate.bat activate
124+
IF "${{ matrix.torch }}"=="pre" (
125+
call scripts\build_windows_wheel_torch_nightly.cmd ${{ matrix.python }} ${{ matrix.torch }} ${{ matrix.cuda }}
138126
) ELSE (
139-
call scripts\build_windows_wheel.cmd %PYTHON_VERSION% %TORCH_VERSION% %CUDA_VERSION%
127+
call scripts\build_windows_wheel.cmd ${{ matrix.python }} ${{ matrix.torch }} ${{ matrix.cuda }}
140128
)
141129
- name: Upload wheels to GitHub Release
142130
uses: softprops/action-gh-release@v2
@@ -152,7 +140,7 @@ jobs:
152140
# env:
153141
# HF_TOKEN: ${{ secrets.HF_WHEEL_UPLOAD_TOKEN }}
154142
# run: |
155-
# call C:\Users\muyangl\miniconda3\condabin\activate.bat activate
143+
# call C:\Users\nunchaku\miniconda3\condabin\activate.bat activate
156144
# pip install huggingface_hub
157145
# for %%w in (dist\*.whl) do (
158146
# hf upload nunchaku-tech/nunchaku "%%w"

nunchaku/__version__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "1.2.0"
1+
__version__ = "1.2.1dev"

scripts/build_linux_wheel.sh

Lines changed: 11 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,30 +7,21 @@ CUDA_VERSION=$3
77
MAX_JOBS=${4:-} # optional
88
PYTHON_ROOT_PATH=/opt/python/cp${PYTHON_VERSION//.}-cp${PYTHON_VERSION//.}
99

10-
# Check if TORCH_VERSION is 2.5 or 2.6 and set the corresponding versions for TORCHVISION and TORCHAUDIO
11-
if [ "$TORCH_VERSION" == "2.5" ]; then
12-
TORCHVISION_VERSION="0.20"
13-
TORCHAUDIO_VERSION="2.5"
14-
echo "TORCH_VERSION is 2.5, setting TORCHVISION_VERSION to $TORCHVISION_VERSION and TORCHAUDIO_VERSION to $TORCHAUDIO_VERSION"
15-
elif [ "$TORCH_VERSION" == "2.6" ]; then
16-
TORCHVISION_VERSION="0.21"
17-
TORCHAUDIO_VERSION="2.6"
18-
echo "TORCH_VERSION is 2.6, setting TORCHVISION_VERSION to $TORCHVISION_VERSION and TORCHAUDIO_VERSION to $TORCHAUDIO_VERSION"
19-
elif [ "$TORCH_VERSION" == "2.7" ]; then
20-
TORCHVISION_VERSION="0.22"
21-
TORCHAUDIO_VERSION="2.7"
22-
echo "TORCH_VERSION is 2.7, setting TORCHVISION_VERSION to $TORCHVISION_VERSION and TORCHAUDIO_VERSION to $TORCHAUDIO_VERSION"
23-
elif [ "$TORCH_VERSION" == "2.8" ]; then
10+
# Set the corresponding versions for TORCHVISION and TORCHAUDIO
11+
if [ "$TORCH_VERSION" == "2.8" ]; then
2412
TORCHVISION_VERSION="0.23"
2513
TORCHAUDIO_VERSION="2.8"
26-
echo "TORCH_VERSION is 2.8, setting TORCHVISION_VERSION to $TORCHVISION_VERSION and TORCHAUDIO_VERSION to $TORCHAUDIO_VERSION"
2714
elif [ "$TORCH_VERSION" == "2.9" ]; then
2815
TORCHVISION_VERSION="0.24"
2916
TORCHAUDIO_VERSION="2.9"
30-
echo "TORCH_VERSION is 2.9, setting TORCHVISION_VERSION to $TORCHVISION_VERSION and TORCHAUDIO_VERSION to $TORCHAUDIO_VERSION"
17+
elif [ "$TORCH_VERSION" == "2.10" ]; then
18+
TORCHVISION_VERSION="0.25"
19+
TORCHAUDIO_VERSION="2.10"
3120
else
32-
echo "TORCH_VERSION is not 2.5, 2.6, 2.7, 2.8 or 2.9, no changes to versions."
21+
echo "Unsupported TORCH_VERSION: $TORCH_VERSION"
22+
exit 1
3323
fi
24+
echo "TORCH_VERSION is $TORCH_VERSION, setting TORCHVISION_VERSION to $TORCHVISION_VERSION and TORCHAUDIO_VERSION to $TORCHAUDIO_VERSION"
3425

3526
docker run --rm \
3627
-v "$(pwd)":/nunchaku \
@@ -39,8 +30,9 @@ docker run --rm \
3930
cd /nunchaku && \
4031
rm -rf build && \
4132
gcc --version && g++ --version && \
42-
${PYTHON_ROOT_PATH}/bin/pip install --no-cache-dir torch==${TORCH_VERSION} torchvision==${TORCHVISION_VERSION} torchaudio==${TORCHAUDIO_VERSION} --index-url https://download.pytorch.org/whl/cu${CUDA_VERSION//.} && \
43-
${PYTHON_ROOT_PATH}/bin/pip install build ninja wheel setuptools && \
33+
${PYTHON_ROOT_PATH}/bin/pip install uv && \
34+
${PYTHON_ROOT_PATH}/bin/uv pip install --no-cache-dir torch==${TORCH_VERSION} torchvision==${TORCHVISION_VERSION} torchaudio==${TORCHAUDIO_VERSION} --index-url https://download.pytorch.org/whl/cu${CUDA_VERSION//.} && \
35+
${PYTHON_ROOT_PATH}/bin/uv pip install build ninja wheel setuptools && \
4436
export NUNCHAKU_INSTALL_MODE=ALL && \
4537
export NUNCHAKU_BUILD_WHEELS=1 && \
4638
export MAX_JOBS=${MAX_JOBS} && \

scripts/build_linux_wheel_torch_nightly.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,9 @@ docker run --rm \
2222
cd /nunchaku && \
2323
rm -rf build && \
2424
gcc --version && g++ --version && \
25-
${PYTHON_ROOT_PATH}/bin/pip install --pre --no-cache-dir torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/cu${CUDA_VERSION//.} && \
26-
${PYTHON_ROOT_PATH}/bin/pip install build ninja wheel setuptools && \
25+
${PYTHON_ROOT_PATH}/bin/pip install uv && \
26+
${PYTHON_ROOT_PATH}/bin/uv pip install --pre --no-cache-dir torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/cu${CUDA_VERSION//.} && \
27+
${PYTHON_ROOT_PATH}/bin/uv pip install build ninja wheel setuptools && \
2728
export NUNCHAKU_INSTALL_MODE=ALL && \
2829
export NUNCHAKU_BUILD_WHEELS=1 && \
2930
export MAX_JOBS=${MAX_JOBS} && \

scripts/build_windows_wheel.cmd

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,18 @@ set CUDA_SHORT_VERSION=%CUDA_VERSION:.=%
1010
echo %CUDA_SHORT_VERSION%
1111

1212
:: setup some variables
13-
if "%TORCH_VERSION%"=="2.5" (
14-
set TORCHVISION_VERSION=0.20
15-
set TORCHAUDIO_VERSION=2.5
16-
) else if "%TORCH_VERSION%"=="2.6" (
17-
set TORCHVISION_VERSION=0.21
18-
set TORCHAUDIO_VERSION=2.6
19-
) else if "%TORCH_VERSION%"=="2.7" (
20-
set TORCHVISION_VERSION=0.22
21-
set TORCHAUDIO_VERSION=2.7
22-
) else if "%TORCH_VERSION%"=="2.8" (
13+
if "%TORCH_VERSION%"=="2.8" (
2314
set TORCHVISION_VERSION=0.23
2415
set TORCHAUDIO_VERSION=2.8
2516
) else if "%TORCH_VERSION%"=="2.9" (
2617
set TORCHVISION_VERSION=0.24
2718
set TORCHAUDIO_VERSION=2.9
19+
) else if "%TORCH_VERSION%"=="2.10" (
20+
set TORCHVISION_VERSION=0.25
21+
set TORCHAUDIO_VERSION=2.10
2822
) else (
29-
echo TORCH_VERSION is not 2.5, 2.6, 2.7, 2.8 or 2.9, no changes to versions.
23+
echo Unsupported TORCH_VERSION: %TORCH_VERSION%
24+
exit /b 1
3025
)
3126
echo setting TORCHVISION_VERSION to %TORCHVISION_VERSION% and TORCHAUDIO_VERSION to %TORCHAUDIO_VERSION%
3227

@@ -39,19 +34,22 @@ call conda create -y -n %ENV_NAME% python=%PYTHON_VERSION%
3934
call conda activate %ENV_NAME%
4035

4136
:: install dependencies
42-
call pip install ninja setuptools wheel build
43-
call pip install --no-cache-dir torch==%TORCH_VERSION% torchvision==%TORCHVISION_VERSION% torchaudio==%TORCHAUDIO_VERSION% --index-url "https://download.pytorch.org/whl/cu%CUDA_SHORT_VERSION%/"
37+
call pip install uv
38+
call uv pip install ninja setuptools wheel build
39+
call uv pip install --no-cache-dir torch==%TORCH_VERSION% torchvision==%TORCHVISION_VERSION% torchaudio==%TORCHAUDIO_VERSION% --index-url "https://download.pytorch.org/whl/cu%CUDA_SHORT_VERSION%/"
4440

4541
:: set environment variables
4642
set NUNCHAKU_INSTALL_MODE=ALL
4743
set NUNCHAKU_BUILD_WHEELS=1
44+
set NVCC_PREPEND_FLAGS=-allow-unsupported-compiler
45+
set CUDA_HOME=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v%CUDA_VERSION%
4846

4947
:: cd to the parent directory
5048
cd /d "%~dp0.."
5149
if exist build rd /s /q build
5250

5351
:: set up Visual Studio compilation environment
54-
call "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\Common7\Tools\VsDevCmd.bat" -startdir=none -arch=x64 -host_arch=x64
52+
call "C:\Program Files (x86)\Microsoft Visual Studio\18\BuildTools\Common7\Tools\VsDevCmd.bat" -startdir=none -arch=x64 -host_arch=x64
5553
set DISTUTILS_USE_SDK=1
5654

5755
:: build wheels

scripts/build_windows_wheel_torch_nightly.cmd

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,20 +18,22 @@ call conda create -y -n %ENV_NAME% python=%PYTHON_VERSION%
1818
call conda activate %ENV_NAME%
1919

2020
:: install dependencies
21-
call pip install ninja setuptools wheel build
22-
23-
call pip install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/cu%CUDA_SHORT_VERSION%
21+
call pip install uv
22+
call uv pip install ninja setuptools wheel build
23+
call uv pip install --pre torch torchvision torchaudio --index-url https://download.pytorch.org/whl/nightly/cu%CUDA_SHORT_VERSION%
2424

2525
:: set environment variables
2626
set NUNCHAKU_INSTALL_MODE=ALL
2727
set NUNCHAKU_BUILD_WHEELS=1
28+
set NVCC_PREPEND_FLAGS=-allow-unsupported-compiler
29+
set CUDA_HOME=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v%CUDA_VERSION%
2830

2931
:: cd to the parent directory
3032
cd /d "%~dp0.."
3133
if exist build rd /s /q build
3234

3335
:: set up Visual Studio compilation environment
34-
call "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\Common7\Tools\VsDevCmd.bat" -startdir=none -arch=x64 -host_arch=x64
36+
call "C:\Program Files (x86)\Microsoft Visual Studio\18\BuildTools\Common7\Tools\VsDevCmd.bat" -startdir=none -arch=x64 -host_arch=x64
3537
set DISTUTILS_USE_SDK=1
3638

3739
:: build wheels

setup.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,11 @@ def get_sm_targets() -> list[str]:
7070

7171
torch_version = torch.__version__.split("+")[0]
7272
torch_major_minor_version = ".".join(torch_version.split(".")[:2])
73+
cuda_version = torch.version.cuda # e.g., "12.4"
7374
if "dev" in version:
74-
version = version + date.today().strftime("%Y%m%d") # data
75-
version = version + "+torch" + torch_major_minor_version
75+
version = version + date.today().strftime("%Y%m%d")
76+
# Version format: 1.2.0+cu12.4torch2.4
77+
version = f"{version}+cu{cuda_version}torch{torch_major_minor_version}"
7678

7779
ROOT_DIR = os.path.dirname(__file__)
7880

0 commit comments

Comments
 (0)