Build ROCm Wheels & Release #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 ROCm Wheels & Release | |
on: | |
workflow_dispatch: | |
workflow_call: | |
permissions: | |
contents: write | |
jobs: | |
build_wheels: | |
name: Build ROCm ${{ matrix.rocm }} wheel for Python ${{ matrix.pyver }} | |
runs-on: ubuntu-20.04 | |
strategy: | |
matrix: | |
pyver: ["3.8", "3.9", "3.10", "3.11"] | |
rocm: ['5.4.2', '5.5', '5.6'] | |
defaults: | |
run: | |
shell: pwsh | |
env: | |
ROCM_VERSION: ${{ matrix.rocm }} | |
steps: | |
- name: Free Disk Space | |
uses: jlumbroso/[email protected] | |
with: | |
tool-cache: false | |
android: true | |
dotnet: true | |
haskell: true | |
large-packages: false | |
swap-storage: false | |
- uses: actions/checkout@v3 | |
- name: Install ROCm SDK | |
shell: bash | |
run: | | |
[ ! -d /etc/apt/keyrings ] && sudo mkdir --parents --mode=0755 /etc/apt/keyrings | |
wget https://repo.radeon.com/rocm/rocm.gpg.key -O - | gpg --dearmor | sudo tee /etc/apt/keyrings/rocm.gpg > /dev/null | |
echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/rocm.gpg] https://repo.radeon.com/rocm/apt/$ROCM_VERSION focal main" | sudo tee --append /etc/apt/sources.list.d/rocm.list | |
echo -e 'Package: *\nPin: release o=repo.radeon.com\nPin-Priority: 600' | sudo tee /etc/apt/preferences.d/rocm-pin-600 | |
sudo apt update | |
sudo apt install rocm-dev rocsparse-dev rocprim-dev rocthrust-dev rocblas-dev hipblas-dev hipcub-dev hipsparse-dev -y | |
echo "/opt/rocm/bin" >> $GITHUB_PATH | |
echo "ROCM_PATH=/opt/rocm" >> $GITHUB_ENV | |
echo "USE_ROCM=1" >> $GITHUB_ENV | |
- uses: actions/setup-python@v3 | |
with: | |
python-version: ${{ matrix.pyver }} | |
- name: Install Dependencies | |
run: | | |
$packages = 'build wheel safetensors sentencepiece ninja' | |
$torver = if ([version]$env:ROCM_VERSION -lt [version]'5.5') {'2.0.1'} else {'2.1.0'} | |
$packages += " torch==$torver+rocm$env:ROCM_VERSION torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/rocm$env:ROCM_VERSION" | |
pip3 install $packages.split(' ') | |
- name: Build Wheel | |
id: build-wheel | |
run: | | |
if ($(Get-Content 'setup.py' -raw) -match 'version = "(\d+\.(?:\d+\.?)*)" \+ \(') {Write-Output $('::notice file=build-wheels-release-rocm.yml,line=54,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,line=41::Could not parse version from setup.py! You must upload wheels manually!'; Write-Output "PACKAGE_VERSION=None" >> "$env:GITHUB_OUTPUT"} | |
$env:PYTORCH_ROCM_ARCH = 'gfx803;gfx900;gfx906:xnack-;gfx908:xnack-;gfx90a:xnack+;gfx90a:xnack-;gfx1010;gfx1012;gfx1030;gfx1100;gfx1101;gfx1102' | |
if ([version]$env:ROCM_VERSION -lt [version]'5.5') {$env:PYTORCH_ROCM_ARCH = 'gfx803;gfx900;gfx906:xnack-;gfx908:xnack-;gfx90a:xnack+;gfx90a:xnack-;gfx1010;gfx1012;gfx1030'} | |
python3 -m build -n --wheel | |
- uses: actions/upload-artifact@v3 | |
with: | |
name: 'wheels' | |
path: ./dist/*.whl | |
- name: Upload files to a GitHub release | |
if: steps.build-wheel.outputs.PACKAGE_VERSION != 'None' | |
uses: svenstaro/[email protected] | |
with: | |
file: ./dist/*.whl | |
tag: ${{ steps.build-wheel.outputs.PACKAGE_VERSION }} | |
file_glob: true | |
overwrite: true | |
release_name: ${{ steps.build-wheel.outputs.PACKAGE_VERSION }} |