Skip to content

Try to build CUDA wheels #47

Try to build CUDA wheels

Try to build CUDA wheels #47

# inspired by https://github.com/AutoGPTQ/AutoGPTQ/blob/main/.github/workflows/build_wheels_cuda.yml
name: Build Python wheels with CUDA
on:
push:
branches: [main]
tags: ["*"]
pull_request:
# Check all PR
env:
SPHERICART_NO_LOCAL_DEPS: "1"
jobs:
build_wheels:
name: ${{ matrix.os }}, torch ${{ matrix.torch }}, cuda ${{ matrix.cuda }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-20.04]
torch: ["2.2.0"]
cuda: ["11.8", "12.1"]
defaults:
run:
shell: pwsh
env:
CUDA_VERSION: ${{ matrix.cuda }}
steps:
- name: free disk space
run: sudo rm -rf /usr/share/dotnet /usr/local/lib/android || true
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.10"
- name: Install cibuildwheel
run: python -m pip install cibuildwheel build
- name: Build sphericart wheels
run: |
# ensure we build the wheel from the sdist, not the checkout
python -m build --sdist . --outdir dist
python -m cibuildwheel dist/*.tar.gz --output-dir dist
env:
CIBW_BUILD_VERBOSITY: 3
# build wheels on CPython 3.10
CIBW_BUILD: cp39-* cp310-* cp311-* cp312-*
# skip musl and 32-bit builds
CIBW_SKIP: "*-musllinux* *-win32 *-manylinux_i686"
# on macOS, build both Intel & Apple Silicon versions
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014
# do not build wheels with -march=native
CIBW_ENVIRONMENT: SPHERICART_ARCH_NATIVE=OFF
- name: Build sphericart-torch wheels
run: |
# ensure we build the wheel from the sdist, not the checkout
python -m build --sdist sphericart-torch --outdir sphericart-torch/dist
python -m cibuildwheel sphericart-torch/dist/*.tar.gz --output-dir sphericart-torch/dist
env:
CIBW_BEFORE_ALL: bash /host/home/runner/work/sphericart/sphericart/scripts/cibw-cuda-setup.sh ${{ matrix.cuda }} && echo "CUDA_HOME=$CUDA_HOME" && echo "CUDACXX=$CUDACXX" && echo "TORCH_CUDA_ARCH_LIST=$TORCH_CUDA_ARCH_LIST" && echo "CUDAARCHS=$CUDAARCHS" && echo "SPHERICART_TORCH_TORCH_VERSION=$SPHERICART_TORCH_TORCH_VERSION" && echo "PIP_EXTRA_INDEX_URL=$PIP_EXTRA_INDEX_URL
CIBW_BUILD_VERBOSITY: 3
CIBW_BUILD: cp39-* cp310-* cp311-* cp312-*
CIBW_SKIP: "*-musllinux* *-win32 *-manylinux_i686"
CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014
# set environment variables for sphericart-torch build
CIBW_ENVIRONMENT: SPHERICART_ARCH_NATIVE=OFF CUDACXX=/usr/local/cuda/bin/nvcc TORCH_CUDA_ARCH_LIST=All CUDAARCHS=all SPHERICART_TORCH_TORCH_VERSION=${{ matrix.torch }} PIP_EXTRA_INDEX_URL=https://download.pytorch.org/whl/cu${${{ matrix.cuda }}//./}
# do not complain for missing libtorch.so in sphericart-torch wheel
CIBW_REPAIR_WHEEL_COMMAND_LINUX: |
auditwheel repair --exclude libtorch.so --exclude libtorch_cpu.so --exclude libtorch_cuda.so --exclude libc10.so --exclude libc10_cuda.so -w {dest_dir} {wheel}
# - name: Build sphericart-jax wheels
# run: |
# # ensure we build the wheel from the sdist, not the checkout
# python -m build --sdist sphericart-jax --outdir sphericart-jax/dist
# python -m cibuildwheel sphericart-jax/dist/*.tar.gz --output-dir sphericart-jax/dist
# env:
# CIBW_BUILD_VERBOSITY: 3
# CIBW_BUILD: cp310-*
# CIBW_SKIP: "*-musllinux* *-win32 *-manylinux_i686"
# CIBW_MANYLINUX_X86_64_IMAGE: manylinux2014
# CIBW_ENVIRONMENT: SPHERICART_ARCH_NATIVE=OFF