-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Try to build CUDA wheels #106
base: main
Are you sure you want to change the base?
Changes from 75 commits
faa582d
52aea84
72e4fec
c52e0d0
2dee430
90d1691
a614ea2
3d8899d
6cc261c
b679bb2
00a045a
f5aa849
bd29242
de679c0
47544b1
194acac
5af3030
e7f0b28
3a5bb19
fb56feb
b6ffd8b
6eab11b
d423094
347910f
4836d45
76c745e
23312f9
5540e6b
3e2237c
cf3b46f
ed4995f
e346ac8
de1a880
958e30c
31665af
a1961df
0d43033
f499acc
4080c74
9220348
e2f12e8
a76a784
1f6018c
2a3a8bb
e484c6e
4eaf83a
2954252
248094f
d6c896a
60b393f
3967c79
6cbbfb1
4d9c9a5
db72817
4f1d087
772530a
c4b2434
de8770b
484fefb
508351b
e514149
61ecc74
a9edab7
165d583
b12db15
5c26471
912187e
b0c1f20
c79908a
92bc818
3ab255d
1568d77
f81b3db
276ecf6
a94ec4f
db46abf
59682f6
a7a1f1e
eb9c257
2fa074e
efe5e7f
0939da0
25a905d
b38974e
9a7bb6a
d4083fe
b7d49fc
01ccc37
42cda7f
26110ca
0438400
0a787dc
3aab1b8
6fa992e
364e13f
2647254
22808b3
cb7b3e2
21da7f1
bcef36d
f6c1fe5
8db9115
3f2eafa
4ab5734
de1e330
5615f36
74fb5e7
e4f2b6f
4955a48
5e2daf5
5b8856c
8487603
5612be8
7d4f43b
052d434
8de8169
bdf55a9
201db81
dd80dec
3abd603
0136bd7
395da79
f96fb0d
cdfc7bc
f5c99e8
b18a95c
02e7ec6
f4eac49
8a3437e
1f05b8e
6f32cc2
b8b1cd7
381990e
c6e6678
cc79ddd
9bbc797
9fccacb
7f1bd93
8404ccd
af044b9
cc41d19
316e818
29a5a63
b16ee48
58c0ed6
c8bd01b
bcd611f
5d103d2
47b7471
f86c6fb
e3a38ee
2ed8d14
18c4c83
37f3d1c
6acbbb4
b3c57f3
4a3418c
8b34def
4026bc4
8fcd1a1
ac93fa1
0099796
0edc8b6
0357482
8a5f2f7
b28653c
92aad85
892217c
6af1ed1
9b8abb5
d69de58
a8b7766
1d839d8
1886b38
313926e
fb67e95
8c69988
d282955
f6ebbbb
eea95e0
690bcbb
53e89d4
d93ec56
164acce
16d0ad2
1bc8d22
11750c0
570e756
9a7cd5f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
# 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.0.0", "2.1.0", "2.2.0"] | ||
cuda: ["11.8", "12.1"] | ||
exclude: | ||
# torch 1.13.0 does not support cuda 12.1 | ||
- os: ubuntu-20.04 | ||
torch: "1.13.1" | ||
cuda: "12.1" | ||
|
||
steps: | ||
- name: Prepare cuda_no_point variable | ||
id: prepare_cuda_no_point | ||
run: | | ||
export cuda_no_point=$(echo ${{ matrix.cuda }} | sed 's/\.//') | ||
echo ::set-output name=cuda_no_point::$cuda_no_point | ||
|
||
- 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 }} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't this also be done for the diverse sphericart (non torch) wheels? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We don't provide any CUDA functionality for our Python (NumPy) inteface |
||
CIBW_BUILD_VERBOSITY: 3 | ||
CIBW_BUILD: > | ||
bash -c 'if [[ "${{ matrix.torch }}" == "2.2.0" ]]; then | ||
echo "cp39-* cp310-* cp311-* cp312-*" | ||
else | ||
echo "cp39-* cp310-* cp311-*" | ||
fi' | ||
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${{ steps.prepare_cuda_no_point.outputs.cuda_no_point }} | ||
# 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 |
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,26 @@ | ||||||||
#!/bin/bash | ||||||||
|
||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
# Set CUDA version and architecture | ||||||||
CU_VER=${1//./-} | ||||||||
ARCH="x86_64" | ||||||||
|
||||||||
# Install CUDA compiler and libraries | ||||||||
yum install -y yum-utils | ||||||||
yum-config-manager --add-repo https://developer.download.nvidia.com/compute/cuda/repos/rhel7/${ARCH}/cuda-rhel7.repo | ||||||||
yum -y install cuda-toolkit-${CU_VER}.${ARCH} \ | ||||||||
nvidia-driver-latest-dkms | ||||||||
|
||||||||
# Clean up YUM caches | ||||||||
yum clean all | ||||||||
rm -rf /var/cache/yum/* | ||||||||
|
||||||||
# Configure dynamic linker run-time bindings | ||||||||
echo "/usr/local/cuda/lib64" >> /etc/ld.so.conf.d/999_nvidia_cuda.conf | ||||||||
|
||||||||
# Set environment variables | ||||||||
export PATH="/usr/local/cuda/bin:${PATH}" | ||||||||
export LD_LIBRARY_PATH="/usr/local/cuda/lib64:${LD_LIBRARY_PATH}" | ||||||||
export CUDA_HOME=/usr/local/cuda | ||||||||
export CUDA_ROOT=/usr/local/cuda | ||||||||
export CUDA_PATH=/usr/local/cuda | ||||||||
export CUDADIR=/usr/local/cuda |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# this is a custom Python build backend wrapping setuptool's to set a | ||
# specific torch version as a build dependency, based on an environment | ||
# variable | ||
import os | ||
|
||
from setuptools import build_meta | ||
|
||
TORCH_VERSION = os.environ.get("SPHERICART_TORCH_TORCH_VERSION") | ||
|
||
if TORCH_VERSION is not None: | ||
TORCH_DEP = f"torch =={TORCH_VERSION}" | ||
else: | ||
TORCH_DEP = "torch >=1.13" | ||
|
||
|
||
prepare_metadata_for_build_wheel = build_meta.prepare_metadata_for_build_wheel | ||
build_wheel = build_meta.build_wheel | ||
build_sdist = build_meta.build_sdist | ||
|
||
|
||
def get_requires_for_build_wheel(config_settings=None): | ||
defaults = build_meta.get_requires_for_build_wheel(config_settings) | ||
return defaults + [TORCH_DEP] | ||
|
||
|
||
get_requires_for_build_sdist = build_meta.get_requires_for_build_sdist |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we really want to build all CUDA wheels on all PR? I'm worried this will increase CI time a lot