Skip to content

fix

fix #56

Workflow file for this run

name: Build Package
on:
push:
tags:
- "v*"
jobs:
setup-release:
name: Create Release
runs-on: ubuntu-latest
steps:
- name: Get the version
id: get_version
shell: bash
run: echo ::set-output name=branch::${GITHUB_REF#refs/tags/}
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.get_version.outputs.branch }}
release_name: Release ${{ steps.get_version.outputs.branch }}
draft: false
prerelease: false
build-package:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python: ["3.10", "3.11", "3.12"]
torch: ["2.1.2", "2.2.1", "2.3.1", "2.4.1", "2.5.0"]
cuda: ["11.8.0", "12.1.1", "12.2.2", "12.4.0"]
exclude:
# Python 3.12 supports torch>=2.4.0
- python: "3.12"
torch: "2.1.2"
- python: "3.12"
torch: "2.2.1"
- python: "3.12"
torch: "2.3.1"
steps:
- name: Maximize build space
run: |
df -h
echo "-----------------------------"
sudo rm -rf /usr/share/dotnet
sudo rm -rf /usr/local/lib/android
sudo rm -rf /opt/ghc
sudo rm -rf /opt/hostedtoolcache/CodeQL
df -h
- name: Set Swap Space
uses: pierotofy/set-swap-space@master
with:
swap-size-gb: 10
- uses: actions/checkout@v4
# Setup Environment
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
- uses: Jimver/cuda-toolkit@master
id: cuda-toolkit
with:
cuda: ${{ matrix.cuda }}
linux-local-args: '["--toolkit"]'
method: "network"
- run: sudo apt-get install ninja-build
- name: Set CUDA and PyTorch versions
run: |
echo "MATRIX_CUDA_VERSION=$(echo ${{ matrix.cuda }} | awk -F \. {'print $1 $2'})" >> $GITHUB_ENV
echo "MATRIX_TORCH_VERSION=$(echo ${{ matrix.torch }} | awk -F \. {'print $1 "." $2'})" >> $GITHUB_ENV
- name: Install PyTorch ${{ matrix.torch }}+${{ matrix.cuda }}
shell: bash
run: |
pip install -U pip
pip install wheel setuptools packaging
export TORCH_CUDA_VERSION=$(python -c " \
from os import environ as env; \
support_cuda_versions = { \
'2.0': [117, 118], \
'2.1': [118, 121], \
'2.2': [118, 121], \
'2.3': [118, 121], \
'2.4': [118, 121, 124], \
'2.5': [118, 121, 124], \
}; \
target_cuda_versions = support_cuda_versions[env['MATRIX_TORCH_VERSION']]; \
cuda_version = int(env['MATRIX_CUDA_VERSION']); \
closest_version = min(target_cuda_versions, key=lambda x: abs(x - cuda_version)); \
print(closest_version) \
")
pip install --no-cache-dir torch==${{ matrix.torch }} --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
run: |
export PATH=/usr/local/nvidia/bin:/usr/local/nvidia/lib64:$PATH
export LD_LIBRARY_PATH=/usr/local/nvidia/lib64:/usr/local/cuda/lib64:$LD_LIBRARY_PATH
export TORCH_CUDA_ARCH_LIST="7.0;7.5;8.0;8.6;8.9;9.0+PTX"
MAX_JOBS=2 python setup.py bdist_wheel --dist-dir=dist
wheel_name=$(basename $(ls dist/*.whl | head -n 1))
echo "wheel_name=$wheel_name" >> $GITHUB_ENV
- name: Get the tag version
id: extract_branch
run: echo ::set-output name=branch::${GITHUB_REF#refs/tags/}
- name: Get Release with tag
id: get_current_release
uses: joutvhu/get-release@v1
with:
tag_name: ${{ steps.extract_branch.outputs.branch }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Upload Release Asset
id: upload_release_asset
uses: actions/upload-release-asset@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.get_current_release.outputs.upload_url }}
asset_path: ./dist/${{env.wheel_name}}
asset_name: ${{env.wheel_name}}
asset_content_type: application/*