Skip to content

Commit 4f90963

Browse files
committed
Upload workflows
1 parent 7c186b8 commit 4f90963

File tree

4 files changed

+295
-0
lines changed

4 files changed

+295
-0
lines changed
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: Build ROCm 5.4.2 Wheels & Release
2+
3+
on:
4+
workflow_dispatch:
5+
workflow_call:
6+
7+
permissions:
8+
contents: write
9+
10+
jobs:
11+
build_wheels:
12+
name: Build ROCm wheel for Python ${{ matrix.pyver }}
13+
runs-on: ubuntu-20.04
14+
strategy:
15+
matrix:
16+
pyver: ["3.8", "3.9", "3.10"]
17+
18+
steps:
19+
- name: Free Disk Space
20+
uses: jlumbroso/free-disk-space@v1.2.0
21+
with:
22+
tool-cache: false
23+
android: true
24+
dotnet: true
25+
haskell: true
26+
large-packages: false
27+
swap-storage: false
28+
29+
- uses: actions/checkout@v3
30+
31+
- name: Install ROCm SDK
32+
run: |
33+
[ ! -d /etc/apt/keyrings ] && sudo mkdir --parents --mode=0755 /etc/apt/keyrings
34+
wget https://repo.radeon.com/rocm/rocm.gpg.key -O - | gpg --dearmor | sudo tee /etc/apt/keyrings/rocm.gpg > /dev/null
35+
echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/rocm.gpg] https://repo.radeon.com/rocm/apt/5.4.2 focal main" | sudo tee --append /etc/apt/sources.list.d/rocm.list
36+
echo -e 'Package: *\nPin: release o=repo.radeon.com\nPin-Priority: 600' | sudo tee /etc/apt/preferences.d/rocm-pin-600
37+
sudo apt update
38+
sudo apt install rocm-dev rocsparse-dev rocprim-dev rocthrust-dev rocblas-dev hipblas-dev hipcub-dev hipsparse-dev -y
39+
echo "/opt/rocm/bin" >> $GITHUB_PATH
40+
echo "ROCM_PATH=/opt/rocm" >> $GITHUB_ENV
41+
echo "ROCM_VERSION=5.4.2" >> $GITHUB_ENV
42+
echo "USE_ROCM=1" >> $GITHUB_ENV
43+
44+
- uses: actions/setup-python@v3
45+
with:
46+
python-version: ${{ matrix.pyver }}
47+
48+
- name: Install Dependencies
49+
run: |
50+
pip3 install build wheel safetensors sentencepiece ninja torch==2.0.1+rocm5.4.2 torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/rocm5.4.2
51+
52+
- name: Build Wheel
53+
id: build-wheel
54+
run: |
55+
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"}
56+
python3 -m build -n --wheel
57+
shell: pwsh
58+
59+
- uses: actions/upload-artifact@v3
60+
with:
61+
name: 'wheels'
62+
path: ./dist/*.whl
63+
64+
- name: Upload files to a GitHub release
65+
if: steps.build-wheel.outputs.PACKAGE_VERSION != 'None'
66+
uses: svenstaro/upload-release-action@2.6.1
67+
with:
68+
file: ./dist/*.whl
69+
tag: ${{ steps.build-wheel.outputs.PACKAGE_VERSION }}
70+
file_glob: true
71+
overwrite: true
72+
release_name: ${{ steps.build-wheel.outputs.PACKAGE_VERSION }}
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
name: Build Wheels & Release
2+
3+
on: workflow_dispatch
4+
5+
permissions:
6+
contents: write
7+
8+
jobs:
9+
build_wheels:
10+
name: ${{ matrix.os }} Python ${{ matrix.pyver }} CUDA ${{ matrix.cuda }}
11+
runs-on: ${{ matrix.os }}
12+
strategy:
13+
matrix:
14+
os: [ubuntu-20.04, windows-latest]
15+
pyver: ["3.8", "3.9", "3.10"]
16+
cuda: ["11.7.0", "11.8.0", "12.1.1"]
17+
defaults:
18+
run:
19+
shell: pwsh
20+
env:
21+
CUDAVER: ${{ matrix.cuda }}
22+
23+
steps:
24+
- name: Free Disk Space
25+
uses: jlumbroso/free-disk-space@v1.2.0
26+
if: runner.os == 'Linux'
27+
with:
28+
tool-cache: false
29+
android: true
30+
dotnet: true
31+
haskell: true
32+
large-packages: false
33+
swap-storage: false
34+
35+
- uses: actions/checkout@v3
36+
- uses: actions/setup-python@v3
37+
with:
38+
python-version: ${{ matrix.pyver }}
39+
40+
- name: Setup Mamba
41+
uses: conda-incubator/setup-miniconda@v2.2.0
42+
with:
43+
activate-environment: "build"
44+
python-version: ${{ matrix.pyver }}
45+
miniforge-variant: Mambaforge
46+
miniforge-version: latest
47+
use-mamba: true
48+
add-pip-as-python-dependency: true
49+
auto-activate-base: false
50+
51+
- name: Install Dependencies
52+
run: |
53+
$cudaVersion = $env:CUDAVER
54+
$cudaVersionPytorch = $env:CUDAVER.Remove($env:CUDAVER.LastIndexOf('.')).Replace('.','')
55+
$cudaChannels = ''
56+
$cudaNum = [int]$cudaVersion.substring($cudaVersion.LastIndexOf('.')+1)
57+
while ($cudaNum -ge 0) { $cudaChannels += '-c nvidia/label/cuda-' + $cudaVersion.Remove($cudaVersion.LastIndexOf('.')+1) + $cudaNum + ' '; $cudaNum-- }
58+
mamba install -y 'cuda' $cudaChannels.TrimEnd().Split()
59+
if ([version]$env:CUDAVER -gt [version]'11.8.0') {$torchver = "--pre --index-url https://download.pytorch.org/whl/nightly/cu$cudaVersionPytorch"} else {$torchver = "--index-url https://download.pytorch.org/whl/cu$cudaVersionPytorch"}
60+
python -m pip install torch $torchver.split()
61+
python -m pip install build wheel safetensors sentencepiece ninja
62+
63+
- name: Build Wheel
64+
id: build-wheel
65+
run: |
66+
if ($(Get-Content 'setup.py' -raw) -match 'version = "(\d+\.(?:\d+\.?)*)" \+ \(') {Write-Output $('::notice file=build-wheels-release.yml,line=53,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"}
67+
$env:CUDA_PATH = $env:CONDA_PREFIX
68+
$env:CUDA_HOME = $env:CONDA_PREFIX
69+
if ($IsLinux) {$env:LD_LIBRARY_PATH = $env:CONDA_PREFIX + '/lib:' + $env:LD_LIBRARY_PATH}
70+
$env:TORCH_CUDA_ARCH_LIST = if ([version]$env:CUDAVER -lt [version]'11.8') {'3.5 3.7 5.0 5.2 6.0 6.1 7.0 7.5 8.0 8.6+PTX'} else {'3.5 3.7 5.0 5.2 6.0 6.1 7.0 7.5 8.0 8.6 8.9 9.0+PTX'}
71+
python -m build -n --wheel
72+
73+
- uses: actions/upload-artifact@v3
74+
with:
75+
name: 'wheels'
76+
path: ./dist/*.whl
77+
78+
- name: Upload files to a GitHub release
79+
if: steps.build-wheel.outputs.PACKAGE_VERSION != 'None'
80+
uses: svenstaro/upload-release-action@2.6.1
81+
with:
82+
file: ./dist/*.whl
83+
tag: ${{ steps.build-wheel.outputs.PACKAGE_VERSION }}
84+
file_glob: true
85+
overwrite: true
86+
release_name: ${{ steps.build-wheel.outputs.PACKAGE_VERSION }}
87+
88+
build_rocm:
89+
name: Build ROCm Wheels & Release
90+
needs: build_wheels
91+
uses: ./.github/workflows/build-wheels-release-rocm.yml
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
name: Build ROCm 5.4.2 Wheels
2+
3+
on:
4+
workflow_dispatch:
5+
workflow_call:
6+
7+
jobs:
8+
build_wheels:
9+
name: Build ROCm wheel for Python ${{ matrix.pyver }}
10+
runs-on: ubuntu-20.04
11+
strategy:
12+
matrix:
13+
pyver: ["3.8", "3.9", "3.10"]
14+
15+
steps:
16+
- name: Free Disk Space
17+
uses: jlumbroso/free-disk-space@v1.2.0
18+
with:
19+
tool-cache: false
20+
android: true
21+
dotnet: true
22+
haskell: true
23+
large-packages: false
24+
swap-storage: false
25+
26+
- uses: actions/checkout@v3
27+
28+
- name: Install ROCm SDK
29+
run: |
30+
[ ! -d /etc/apt/keyrings ] && sudo mkdir --parents --mode=0755 /etc/apt/keyrings
31+
wget https://repo.radeon.com/rocm/rocm.gpg.key -O - | gpg --dearmor | sudo tee /etc/apt/keyrings/rocm.gpg > /dev/null
32+
echo "deb [arch=amd64 signed-by=/etc/apt/keyrings/rocm.gpg] https://repo.radeon.com/rocm/apt/5.4.2 focal main" | sudo tee --append /etc/apt/sources.list.d/rocm.list
33+
echo -e 'Package: *\nPin: release o=repo.radeon.com\nPin-Priority: 600' | sudo tee /etc/apt/preferences.d/rocm-pin-600
34+
sudo apt update
35+
sudo apt install rocm-dev rocsparse-dev rocprim-dev rocthrust-dev rocblas-dev hipblas-dev hipcub-dev hipsparse-dev -y
36+
echo "/opt/rocm/bin" >> $GITHUB_PATH
37+
echo "ROCM_PATH=/opt/rocm" >> $GITHUB_ENV
38+
echo "ROCM_VERSION=5.4.2" >> $GITHUB_ENV
39+
echo "USE_ROCM=1" >> $GITHUB_ENV
40+
41+
- uses: actions/setup-python@v3
42+
with:
43+
python-version: ${{ matrix.pyver }}
44+
45+
- name: Install Dependencies
46+
run: |
47+
pip3 install build wheel safetensors sentencepiece ninja torch==2.0.1+rocm5.4.2 torchvision torchaudio --extra-index-url https://download.pytorch.org/whl/rocm5.4.2
48+
49+
- name: Build Wheel
50+
run: |
51+
python3 -m build -n --wheel
52+
53+
- uses: actions/upload-artifact@v3
54+
with:
55+
name: 'wheels'
56+
path: ./dist/*.whl

.github/workflows/build-wheels.yml

Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: Build Wheels
2+
3+
on: workflow_dispatch
4+
5+
jobs:
6+
build_wheels:
7+
name: ${{ matrix.os }} Python ${{ matrix.pyver }} CUDA ${{ matrix.cuda }}
8+
runs-on: ${{ matrix.os }}
9+
strategy:
10+
matrix:
11+
os: [ubuntu-20.04, windows-latest]
12+
pyver: ["3.8", "3.9", "3.10"]
13+
cuda: ["11.7.0", "11.8.0", "12.1.1"]
14+
defaults:
15+
run:
16+
shell: pwsh
17+
env:
18+
CUDAVER: ${{ matrix.cuda }}
19+
20+
steps:
21+
- name: Free Disk Space
22+
uses: jlumbroso/free-disk-space@v1.2.0
23+
if: runner.os == 'Linux'
24+
with:
25+
tool-cache: false
26+
android: true
27+
dotnet: true
28+
haskell: true
29+
large-packages: false
30+
swap-storage: false
31+
32+
- uses: actions/checkout@v3
33+
- uses: actions/setup-python@v3
34+
with:
35+
python-version: ${{ matrix.pyver }}
36+
37+
- name: Setup Mamba
38+
uses: conda-incubator/setup-miniconda@v2.2.0
39+
with:
40+
activate-environment: "build"
41+
python-version: ${{ matrix.pyver }}
42+
miniforge-variant: Mambaforge
43+
miniforge-version: latest
44+
use-mamba: true
45+
add-pip-as-python-dependency: true
46+
auto-activate-base: false
47+
48+
- name: Install Dependencies
49+
run: |
50+
$cudaVersion = $env:CUDAVER
51+
$cudaVersionPytorch = $env:CUDAVER.Remove($env:CUDAVER.LastIndexOf('.')).Replace('.','')
52+
$cudaChannels = ''
53+
$cudaNum = [int]$cudaVersion.substring($cudaVersion.LastIndexOf('.')+1)
54+
while ($cudaNum -ge 0) { $cudaChannels += '-c nvidia/label/cuda-' + $cudaVersion.Remove($cudaVersion.LastIndexOf('.')+1) + $cudaNum + ' '; $cudaNum-- }
55+
mamba install -y 'cuda' $cudaChannels.TrimEnd().Split()
56+
if ([version]$env:CUDAVER -gt [version]'11.8.0') {$torchver = "--pre --index-url https://download.pytorch.org/whl/nightly/cu$cudaVersionPytorch"} else {$torchver = "--index-url https://download.pytorch.org/whl/cu$cudaVersionPytorch"}
57+
python -m pip install torch $torchver.split()
58+
python -m pip install build wheel safetensors sentencepiece ninja
59+
60+
- name: Build Wheel
61+
run: |
62+
$env:CUDA_PATH = $env:CONDA_PREFIX
63+
$env:CUDA_HOME = $env:CONDA_PREFIX
64+
if ($IsLinux) {$env:LD_LIBRARY_PATH = $env:CONDA_PREFIX + '/lib:' + $env:LD_LIBRARY_PATH}
65+
$env:TORCH_CUDA_ARCH_LIST = if ([version]$env:CUDAVER -lt [version]'11.8') {'3.5 3.7 5.0 5.2 6.0 6.1 7.0 7.5 8.0 8.6+PTX'} else {'3.5 3.7 5.0 5.2 6.0 6.1 7.0 7.5 8.0 8.6 8.9 9.0+PTX'}
66+
python -m build -n --wheel
67+
68+
- uses: actions/upload-artifact@v3
69+
with:
70+
name: 'wheels'
71+
path: ./dist/*.whl
72+
73+
build_rocm:
74+
name: Build ROCm Wheels
75+
needs: build_wheels
76+
uses: ./.github/workflows/build-wheels-rocm.yml

0 commit comments

Comments
 (0)