Build Wheels (ROCm) (Linux) #17
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 (ROCm) (Linux) | |
on: workflow_dispatch | |
permissions: | |
contents: write | |
jobs: | |
define_matrix: | |
name: Define Build Matrix | |
runs-on: ubuntu-latest | |
outputs: | |
matrix: ${{ steps.set-matrix.outputs.matrix }} | |
steps: | |
- name: Define Job Output | |
id: set-matrix | |
run: | | |
matrix=$(cat << 'EOL' | |
{"os":["ubuntu-22.04"],"pyver":["3.11"],"rocm":["6.0.2"],"releasetag":["basic"]} | |
EOL | |
) | |
echo "matrix=$matrix" >> $GITHUB_OUTPUT | |
shell: bash | |
build_wheels: | |
name: Build Wheel ${{ matrix.os }} ${{ matrix.pyver }} ROCm ${{ matrix.rocm }} ${{ matrix.releasetag }} | |
needs: define_matrix | |
runs-on: ${{ matrix.os }} | |
container: rocm/dev-ubuntu-22.04:${{ matrix.rocm }} | |
strategy: | |
matrix: ${{ fromJSON(needs.define_matrix.outputs.matrix) }} | |
env: | |
ROCMVER: ${{ matrix.rocm }} | |
AVXVER: ${{ matrix.releasetag }} | |
steps: | |
- name: Install git on container | |
run: | | |
apt update | |
apt install -y git\ | |
- name: Install lsb-release | |
run: sudo apt-get update && sudo apt-get install -y lsb-release | |
- uses: actions/checkout@v4 | |
with: | |
submodules: "recursive" | |
- name: Setup Python | |
uses: actions/setup-python@v5 | |
continue-on-error: true | |
id: setup-python | |
with: | |
python-version: ${{ matrix.pyver }} | |
cache: "pip" | |
- name: Debug Python installation | |
if: always() | |
run: | | |
echo "Python setup exit code: ${{ steps.setup-python.outcome }}" | |
echo "Python location: ${{ env.pythonLocation }}" | |
ls -la ${{ env.pythonLocation }}/bin | |
${{ env.pythonLocation }}/bin/python --version | |
${{ env.pythonLocation }}/bin/pip --version || echo "Pip not found" | |
echo "PATH: $PATH" | |
- name: Examine pip file | |
if: always() | |
run: | | |
cat /__t/Python/3.11.9/x64/bin/pip | |
- name: Reinstall pip | |
if: always() | |
run: | | |
/__t/Python/3.11.9/x64/bin/python -m ensurepip --upgrade | |
/__t/Python/3.11.9/x64/bin/python -m pip --version | |
- name: Install pip manually | |
if: failure() | |
run: | | |
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py | |
/__t/Python/3.11.9/x64/bin/python get-pip.py | |
/__t/Python/3.11.9/x64/bin/python -m pip --version | |
- name: Install Dependencies | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y build-essential git cmake rocblas-dev hipblas-dev | |
- name: Set up ROCm environment | |
run: | | |
export ROCM_PATH=/opt/rocm | |
export HIP_PATH=$ROCM_PATH/hip | |
export PATH=$ROCM_PATH/bin:$PATH | |
export LD_LIBRARY_PATH=$ROCM_PATH/lib:$LD_LIBRARY_PATH | |
echo "ROCM_PATH=$ROCM_PATH" >> $GITHUB_ENV | |
echo "HIP_PATH=$HIP_PATH" >> $GITHUB_ENV | |
echo "PATH=$PATH" >> $GITHUB_ENV | |
echo "LD_LIBRARY_PATH=$LD_LIBRARY_PATH" >> $GITHUB_ENV | |
- name: Build Wheel with native CMake HIP support | |
run: | | |
export VERBOSE=1 | |
export CMAKE_BUILD_PARALLEL_LEVEL=$(nproc) | |
# Use command substitution to get the HIP compiler path | |
HIP_COMPILER_PATH=$(hipconfig -l)/clang | |
# Use the variable in CMAKE_ARGS | |
export CMAKE_ARGS="-DGGML_HIPBLAS=ON -DCMAKE_HIP_COMPILER=${HIP_COMPILER_PATH}" | |
export CMAKE_ARGS="$CMAKE_ARGS -DGGML_AVX2=OFF -DGGML_FMA=OFF -DGGML_F16C=OFF" | |
# Print CMAKE_ARGS for debugging | |
echo "CMAKE_ARGS: $CMAKE_ARGS" | |
# cmake -B build -S . $CMAKE_ARGS | |
# cmake --build build --config Release -j $(nproc) | |
python -m build --wheel | |
# - name: Build Wheel with legacy HIP support | |
# run: | | |
# export VERBOSE=1 | |
# export CMAKE_BUILD_PARALLEL_LEVEL=$(nproc) | |
# export CMAKE_ARGS='-DGGML_HIPBLAS=ON -DCMAKE_C_COMPILER=hipcc -DCMAKE_CXX_COMPILER=hipcc' | |
# export CMAKE_ARGS="$CMAKE_ARGS -DGGML_AVX2=OFF -DGGML_FMA=OFF -DGGML_F16C=OFF" | |
# cmake -B build2 -S . $CMAKE_ARGS | |
# cmake --build build2 --config Release -j $(nproc) | |
# python -m build --wheel | |
- name: Prepare Release | |
run: | | |
ROCM_VERSION=$(echo $ROCMVER | tr -d '.') | |
echo "ROCM_VERSION=$ROCM_VERSION" >> $GITHUB_ENV | |
- uses: softprops/action-gh-release@v2 | |
with: | |
files: dist/* | |
tag_name: ${{ github.ref_name }}-rocm${{ env.ROCM_VERSION }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
# name: Build Wheels (ROCm) (Linux) | |
# on: workflow_dispatch | |
# permissions: | |
# contents: write | |
# jobs: | |
# define_matrix: | |
# name: Define Build Matrix | |
# runs-on: ubuntu-latest | |
# outputs: | |
# matrix: ${{ steps.set-matrix.outputs.matrix }} | |
# defaults: | |
# run: | |
# shell: pwsh | |
# steps: | |
# - name: Define Job Output | |
# id: set-matrix | |
# run: | | |
# $matrix = @{ | |
# 'os' = @('ubuntu-22.04') | |
# 'pyver' = @("3.7", "3.8", "3.9", "3.10", "3.11", "3.12") | |
# 'rocm' = @("6.0.2") | |
# 'releasetag' = @("basic") | |
# } | |
# $matrixOut = ConvertTo-Json $matrix -Compress | |
# Write-Output ('matrix=' + $matrixOut) >> $env:GITHUB_OUTPUT | |
# build_wheels: | |
# name: Build Wheel ${{ matrix.os }} ${{ matrix.pyver }} ROCm ${{ matrix.rocm }} ${{ matrix.releasetag }} | |
# needs: define_matrix | |
# runs-on: ${{ matrix.os }} | |
# container: rocm/dev-ubuntu-22.04:${{ matrix.rocm }} | |
# strategy: | |
# matrix: ${{ fromJSON(needs.define_matrix.outputs.matrix) }} | |
# defaults: | |
# run: | |
# shell: bash | |
# env: | |
# ROCMVER: ${{ matrix.rocm }} | |
# AVXVER: ${{ matrix.releasetag }} | |
# steps: | |
# - uses: actions/checkout@v4 | |
# with: | |
# submodules: "recursive" | |
# - name: Setup Python | |
# run: | | |
# python3 -m pip install --upgrade pip | |
# python3 -m pip install build wheel | |
# - name: Install Dependencies | |
# run: | | |
# apt-get update | |
# apt-get install -y build-essential git cmake rocblas-dev hipblas-dev | |
# - name: Build Wheel | |
# run: | | |
# export ROCM_PATH=/opt/rocm | |
# export HIP_PATH=$ROCM_PATH/hip | |
# export PATH=$ROCM_PATH/bin:$PATH | |
# export LD_LIBRARY_PATH=$ROCM_PATH/lib:$LD_LIBRARY_PATH | |
# export VERBOSE=1 | |
# export CMAKE_BUILD_PARALLEL_LEVEL=$(nproc) | |
# export CMAKE_ARGS='-DGGML_HIPBLAS=ON -DCMAKE_HIP_COMPILER="$(hipconfig -l)/clang"' | |
# export CMAKE_ARGS="$CMAKE_ARGS -DGGML_AVX2=OFF -DGGML_FMA=OFF -DGGML_F16C=OFF" | |
# python3 -m build --wheel | |
# - name: Extract ROCm Version | |
# run: | | |
# ROCM_VERSION=$(echo $ROCMVER | sed 's/\.//g') | |
# echo "ROCM_VERSION=$ROCM_VERSION" >> $GITHUB_ENV | |
# - uses: softprops/action-gh-release@v2 | |
# with: | |
# files: dist/* | |
# tag_name: ${{ github.ref_name }}-rocm${{ env.ROCM_VERSION }} | |
# env: | |
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |