Support torch 2.3.0 (#99)

This commit is contained in:
Fangjun Kuang 2024-04-25 21:28:17 +08:00 committed by GitHub
parent 843763fd05
commit 40cc0a4a2c
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 76 additions and 8 deletions

View File

@ -36,7 +36,7 @@ jobs:
build_wheels_macos_cpu: build_wheels_macos_cpu:
needs: generate_build_matrix needs: generate_build_matrix
name: ${{ matrix.torch }} ${{ matrix.python-version }} name: ${{ matrix.torch }} ${{ matrix.python-version }}
runs-on: macos-latest runs-on: macos-14
strategy: strategy:
fail-fast: false fail-fast: false
matrix: matrix:
@ -48,14 +48,14 @@ jobs:
fetch-depth: 0 fetch-depth: 0
- name: Setup Python - name: Setup Python
uses: actions/setup-python@v2 uses: actions/setup-python@v5
with: with:
python-version: ${{ matrix.python-version }} python-version: ${{ matrix.python-version }}
- name: Install dependencies - name: Install dependencies
shell: bash shell: bash
run: | run: |
pip install -q torch==${{ matrix.torch}} cmake numpy wheel twine setuptools pip install -q torch==${{ matrix.torch}} cmake numpy wheel>=0.40.0 twine setuptools
- name: Build wheel - name: Build wheel
shell: bash shell: bash
@ -64,13 +64,27 @@ jobs:
mkdir wheelhouse mkdir wheelhouse
cp -v dist/* wheelhouse cp -v dist/* wheelhouse
- name: Display wheels - name: Display wheels (before fix)
shell: bash
run: |
ls -lh ./wheelhouse/
- name: Fix wheel platform tag
run: |
# See https://github.com/glencoesoftware/zeroc-ice-py-macos-x86_64/pull/3/files
# See:
# * https://github.com/pypa/wheel/issues/406
python -m wheel tags \
--platform-tag=macosx_11_0_arm64 \
--remove wheelhouse/*.whl
- name: Display wheels (after fix)
shell: bash shell: bash
run: | run: |
ls -lh ./wheelhouse/ ls -lh ./wheelhouse/
- name: Upload Wheel - name: Upload Wheel
uses: actions/upload-artifact@v2 uses: actions/upload-artifact@v3
with: with:
name: torch-${{ matrix.torch }}-python-${{ matrix.python-version }}-macos-latest-cpu name: torch-${{ matrix.torch }}-python-${{ matrix.python-version }}-macos-latest-cpu
path: wheelhouse/*.whl path: wheelhouse/*.whl

View File

@ -72,6 +72,18 @@ python3 -m pip install bs4 requests tqdm auditwheel
echo "Installing torch" echo "Installing torch"
./install_torch.sh ./install_torch.sh
# -- Autodetected CUDA architecture(s): 5.0;8.0;8.6;8.9;9.0;9.0a
# CMake Error at /Python-3.8.2/py-3.8/lib/python3.8/site-packages/torch/share/cmake/Caffe2/Modules_CUDA_fix/upstream/FindCUDA/select_compute_arch.cmake:227 (message):
# Unknown CUDA Architecture Name 9.0a in CUDA_SELECT_NVCC_ARCH_FLAGS
# Call Stack (most recent call first):
# /Python-3.8.2/py-3.8/lib/python3.8/site-packages/torch/share/cmake/Caffe2/public/utils.cmake:401 (cuda_select_nvcc_arch_flags)
# /Python-3.8.2/py-3.8/lib/python3.8/site-packages/torch/share/cmake/Caffe2/public/cuda.cmake:342 (torch_cuda_get_nvcc_gencode_flag)
# /Python-3.8.2/py-3.8/lib/python3.8/site-packages/torch/share/cmake/Caffe2/Caffe2Config.cmake:87 (include)
# /Python-3.8.2/py-3.8/lib/python3.8/site-packages/torch/share/cmake/Torch/TorchConfig.cmake:68 (find_package)
# cmake/torch.cmake:14 (find_package)
# CMakeLists.txt:62 (include)
sed -i.bak /9.0a/d /Python-*/py-3.*/lib/python3.*/site-packages/torch/share/cmake/Caffe2/Modules_CUDA_fix/upstream/FindCUDA/select_compute_arch.cmake
rm -rf ~/.cache/pip >/dev/null 2>&1 rm -rf ~/.cache/pip >/dev/null 2>&1
yum clean all >/dev/null 2>&1 yum clean all >/dev/null 2>&1
@ -96,13 +108,33 @@ auditwheel --verbose repair \
--exclude libtorch_cuda.so \ --exclude libtorch_cuda.so \
--exclude libtorch_python.so \ --exclude libtorch_python.so \
\ \
--exclude libcudnn.so.8 \ --exclude libcublas.so \
--exclude libcublas.so.11 \ --exclude libcublas.so.11 \
--exclude libcublas.so.12 \
--exclude libcublasLt.so \
--exclude libcublasLt.so.11 \ --exclude libcublasLt.so.11 \
--exclude libcublasLt.so.12 \
--exclude libcudart.so.11.0 \ --exclude libcudart.so.11.0 \
--exclude libcudart.so.12 \
--exclude libcudnn.so.8 \
--exclude libcufft.so \
--exclude libcufft.so.11 \
--exclude libcupti.so \
--exclude libcupti.so.12 \
--exclude libcurand.so \
--exclude libcurand.so.10 \
--exclude libcusparse.so \
--exclude libcusparse.so.12 \
--exclude libnccl.so \
--exclude libnccl.so.2 \
--exclude libnvJitLink.so \
--exclude libnvJitLink.so.12 \
--exclude libnvrtc.so \
--exclude libnvrtc.so.11.2 \ --exclude libnvrtc.so.11.2 \
--exclude libtorch_cuda_cu.so \ --exclude libnvrtc.so.12 \
--exclude libshm.so \
--exclude libtorch_cuda_cpp.so \ --exclude libtorch_cuda_cpp.so \
--exclude libtorch_cuda_cu.so \
--plat manylinux_2_17_x86_64 \ --plat manylinux_2_17_x86_64 \
-w /var/www/wheelhouse \ -w /var/www/wheelhouse \
dist/*.whl dist/*.whl

View File

@ -195,10 +195,16 @@ def generate_build_matrix(enable_cuda, for_windows, for_macos, test_only_latest_
if not for_windows if not for_windows
else ["11.8.0", "12.1.0"], else ["11.8.0", "12.1.0"],
}, },
"2.3.0": {
"python-version": ["3.8", "3.9", "3.10", "3.11", "3.12"],
"cuda": ["11.8", "12.1"] # default 12.1
if not for_windows
else ["11.8.0", "12.1.0"],
},
# https://github.com/Jimver/cuda-toolkit/blob/master/src/links/windows-links.ts # https://github.com/Jimver/cuda-toolkit/blob/master/src/links/windows-links.ts
} }
if test_only_latest_torch: if test_only_latest_torch:
latest = "2.2.2" latest = "2.3.0"
matrix = {latest: matrix[latest]} matrix = {latest: matrix[latest]}
if for_windows or for_macos: if for_windows or for_macos:
@ -234,6 +240,9 @@ def generate_build_matrix(enable_cuda, for_windows, for_macos, test_only_latest_
for p in python_versions: for p in python_versions:
if p in excluded_python_versions: if p in excluded_python_versions:
continue continue
if for_macos and p in ["3.8", "3.9"]:
# macOS arm64 in github actions does not support python 3.8 or 3.9
continue
if for_windows: if for_windows:
p = "cp" + "".join(p.split(".")) p = "cp" + "".join(p.split("."))

View File

@ -198,6 +198,19 @@ case ${torch} in
;; ;;
esac esac
;; ;;
2.3.*)
case ${cuda} in
11.8)
package="torch==${torch}+cu118"
url=https://download.pytorch.org/whl/torch_stable.html
;;
12.1)
package="torch==${torch}"
# Leave it empty to use PyPI.
url=
;;
esac
;;
*) *)
echo "Unsupported PyTorch version: ${torch}" echo "Unsupported PyTorch version: ${torch}"
exit 1 exit 1