Build AutoGPTQ Wheels with CUDA #1
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 AutoGPTQ Wheels with CUDA | |
on: | |
workflow_dispatch: | |
inputs: | |
version: | |
description: 'Version tag of AutoGPTQ to build: v0.5.1' | |
default: 'main' | |
required: true | |
type: string | |
rocm: | |
description: 'Build ROCm wheels as well? 1 = yes, 0 = no' | |
default: '1' | |
required: true | |
type: string | |
permissions: | |
contents: write | |
jobs: | |
build_wheels: | |
name: Build wheels for ${{ matrix.os }} and Python ${{ matrix.python }} and CUDA ${{ matrix.cuda }} | |
runs-on: ${{ matrix.os }} | |
strategy: | |
matrix: | |
os: [ubuntu-20.04, windows-latest] | |
pyver: ["3.8", "3.9", "3.10", "3.11"] | |
cuda: ["11.7.0", "11.8.0", "12.1.1"] | |
defaults: | |
run: | |
shell: pwsh | |
env: | |
CUDAVER: ${{ matrix.cuda }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
repository: 'PanQiWei/AutoGPTQ' | |
ref: ${{ inputs.version }} | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: ${{ matrix.pyver }} | |
- name: Setup Mamba | |
uses: conda-incubator/setup-miniconda@v2.2.0 | |
with: | |
activate-environment: "build" | |
python-version: ${{ matrix.pyver }} | |
miniforge-variant: Mambaforge | |
miniforge-version: latest | |
use-mamba: true | |
add-pip-as-python-dependency: true | |
auto-activate-base: false | |
- name: Install Dependencies | |
run: | | |
$cudaVersion = $env:CUDAVER | |
$cudaVersionPytorch = $env:CUDAVER.Remove($env:CUDAVER.LastIndexOf('.')).Replace('.','') | |
$cudaChannels = '' | |
$cudaNum = [int]$cudaVersion.substring($cudaVersion.LastIndexOf('.')+1) | |
while ($cudaNum -ge 0) { $cudaChannels += '-c nvidia/label/cuda-' + $cudaVersion.Remove($cudaVersion.LastIndexOf('.')+1) + $cudaNum + ' '; $cudaNum-- } | |
mamba install -y 'cuda' $cudaChannels.TrimEnd().Split() | |
if (!(mamba list cuda)[-1].contains('cuda')) {sleep -s 10; mamba install -y 'cuda' $cudaChannels.TrimEnd().Split()} | |
if (!(mamba list cuda)[-1].contains('cuda')) {throw 'CUDA Toolkit failed to install!'} | |
if ([version]$env:CUDAVER -lt [version]'11.8.0') {$torch = "torch==2.0.1"} else {$torch = "torch==2.1.0"} | |
python -m pip install --upgrade build setuptools wheel ninja numpy gekko pandas $torch --extra-index-url "https://download.pytorch.org/whl/cu$cudaVersionPytorch" | |
- name: Build Wheel | |
id: build-wheel | |
run: | | |
if ($(Get-Content 'setup.py' -raw) -match '"version": "(\d+\.(?:\d+\.?(?:dev\d+)?)*)",') | |
{ | |
Write-Output $('::notice file=build-wheels-release.yml,title=Package Version::Detected package version is: {0}' -f $Matches[1]) | |
Write-Output "PACKAGE_VERSION=$($Matches[1])" >> "$env:GITHUB_OUTPUT" | |
} else { | |
Write-Output '::error file=build-wheels-release.yml::Could not parse version from setup.py! You must upload wheels manually!' | |
Write-Output "PACKAGE_VERSION=None" >> "$env:GITHUB_OUTPUT" | |
} | |
$env:CUDA_PATH = $env:CONDA_PREFIX | |
$env:CUDA_HOME = $env:CONDA_PREFIX | |
if ($IsLinux) {$env:LD_LIBRARY_PATH = $env:CONDA_PREFIX + '/lib:' + $env:LD_LIBRARY_PATH} | |
$env:TORCH_CUDA_ARCH_LIST = if ([version]$env:CUDAVER -lt [version]'11.8.0') {'6.0 6.1 7.0 7.5 8.0 8.6+PTX'} else {'6.0 6.1 7.0 7.5 8.0 8.6 8.9 9.0+PTX'} | |
$env:CUDA_VERSION = $env:CUDAVER.Remove($env:CUDAVER.LastIndexOf('.')).Replace('.','') | |
python setup.py sdist bdist_wheel | |
- uses: actions/upload-artifact@v3 | |
if: runner.os == 'Linux' | |
with: | |
name: 'linux-cuda-wheels' | |
path: ./dist/*.whl | |
- uses: actions/upload-artifact@v3 | |
if: runner.os == 'Windows' | |
with: | |
name: 'windows-cuda-wheels' | |
path: ./dist/*.whl | |
- name: Upload files to a GitHub release | |
if: steps.build-wheel.outputs.PACKAGE_VERSION != 'None' && !contains( 'dev', steps.build-wheel.outputs.PACKAGE_VERSION ) | |
uses: svenstaro/upload-release-action@2.6.1 | |
continue-on-error: true | |
with: | |
file: ./dist/*.whl | |
tag: ${{ format('v{0}', steps.build-wheel.outputs.PACKAGE_VERSION) }} | |
file_glob: true | |
overwrite: true | |
release_name: ${{ format('v{0}', steps.build-wheel.outputs.PACKAGE_VERSION) }} | |
build_rocm: | |
name: Build ROCm Wheels & Release | |
if: inputs.rocm == '1' | |
needs: build_wheels | |
uses: ./.github/workflows/build_wheels_rocm.yml | |
with: | |
version: ${{ inputs.version }} |