sta packaging test #13
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build wheels and deploy | |
on: | |
push: | |
branches: | |
- you-pypi-packaging-1 # Runs only when pushing to main | |
paths: | |
- "csrc/sliding_tile_attention/**" | |
- ".github/workflows/publish.yml" | |
jobs: | |
# setup_release: | |
# name: Create Release | |
# runs-on: ubuntu-latest | |
# steps: | |
# - name: Get the tag version | |
# id: extract_branch | |
# run: echo ::set-output name=branch::${GITHUB_REF#refs/tags/} | |
# shell: bash | |
# - name: Create Release | |
# id: create_release | |
# uses: actions/create-release@v1 | |
# env: | |
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
# with: | |
# tag_name: ${{ steps.extract_branch.outputs.branch }} | |
# release_name: ${{ steps.extract_branch.outputs.branch }} | |
build_wheels: | |
name: Build Wheel | |
#needs: setup_release | |
runs-on: ${{ matrix.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
# Using ubuntu-20.04 instead of 22.04 for more compatibility (glibc). Ideally we'd use the | |
# manylinux docker image, but I haven't figured out how to install CUDA on manylinux. | |
os: [ubuntu-22.04] | |
python-version: ['3.10', '3.11', '3.12', '3.13'] | |
torch-version: ['2.5.1', '2.6.0'] | |
cuda-version: ['12.4.1', '12.5.1', '12.6.3'] | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install CUDA ${{ matrix.cuda-version }} | |
uses: Jimver/[email protected] | |
id: cuda-toolkit | |
with: | |
cuda: ${{ matrix.cuda-version }} | |
linux-local-args: '["--toolkit"]' | |
method: 'network' | |
#sub-packages: '["nvcc", "cusparse"]' | |
- name: Install dependencies (GCC, Clang, CUDA Paths, Git) | |
run: | | |
sudo apt update | |
sudo apt install -y git patchelf gcc-11 g++-11 clang-11 | |
sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-11 100 --slave /usr/bin/g++ g++ /usr/bin/g++-11 | |
# Allow Git to Access Safe Directory | |
git config --global --add safe.directory /__w/FastVideo/FastVideo | |
# Set CUDA environment variables | |
export CUDA_HOME=/usr/local/cuda-${{ matrix.cuda-version }} | |
export PATH=${CUDA_HOME}/bin:${PATH} | |
export LD_LIBRARY_PATH=${CUDA_HOME}/lib64:$LD_LIBRARY_PATH | |
# Verify installation | |
gcc --version | |
g++ --version | |
clang-11 --version | |
nvcc --version | |
- name: Install PyTorch ${{ matrix.torch-version }}+cu${{ matrix.cuda-version }} | |
run: | | |
pip install --upgrade pip | |
# With python 3.13 and torch 2.5.1, unless we update typing-extensions, we get error | |
# AttributeError: attribute '__default__' of 'typing.ParamSpec' objects is not writable | |
pip install typing-extensions==4.12.2 | |
# We want to figure out the CUDA version to download pytorch | |
# e.g. we can have system CUDA version being 11.7 but if torch==1.12 then we need to download the wheel from cu116 | |
# see https://github.com/pytorch/pytorch/blob/main/RELEASE.md#release-compatibility-matrix | |
export TORCH_CUDA_VERSION=124 | |
pip install --no-cache-dir torch==${{ matrix.torch-version }} --index-url https://download.pytorch.org/whl/cu${TORCH_CUDA_VERSION} | |
nvcc --version | |
python --version | |
python -c "import torch; print('PyTorch:', torch.__version__)" | |
python -c "import torch; print('CUDA:', torch.version.cuda)" | |
python -c "from torch.utils import cpp_extension; print (cpp_extension.CUDA_HOME)" | |
- name: Build wheel | |
run: | | |
# We want setuptools >= 49.6.0 otherwise we can't compile the extension if system CUDA version is 11.7 and pytorch cuda version is 11.6 | |
# https://github.com/pytorch/pytorch/blob/664058fa83f1d8eede5d66418abff6e20bd76ca8/torch/utils/cpp_extension.py#L810 | |
# However this still fails so I'm using a newer version of setuptools | |
pip install setuptools==75.8.0 | |
pip install ninja packaging wheel | |
cd csrc/sliding_tile_attention # Move into the correct folder | |
git submodule update --init --recursive tk # Ensure ThunderKittens submodule is initialized | |
python setup.py bdist_wheel --dist-dir=dist |