mirror of
https://github.com/BillyOutlast/flash-attention-prebuild-wheels-rocm.git
synced 2026-07-01 01:37:53 -04:00
feat: add auditwheel for manylinux
This commit is contained in:
@@ -65,7 +65,7 @@ jobs:
|
||||
- name: Install build dependencies
|
||||
run: |
|
||||
sudo apt install -y ninja-build clang time
|
||||
pip install -U pip setuptools==75.8.0 wheel packaging psutil
|
||||
pip install -U pip setuptools==75.8.0 wheel packaging psutil auditwheel
|
||||
|
||||
- name: Build wheels
|
||||
id: build_wheels
|
||||
@@ -75,12 +75,23 @@ jobs:
|
||||
wheel_name=$(basename $(ls flash-attention/dist/*.whl | head -n 1))
|
||||
echo "WHEEL_NAME=$wheel_name" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Apply auditwheel repair
|
||||
run: |
|
||||
auditwheel show flash-attention/dist/${{ steps.build_wheels.outputs.WHEEL_NAME }}
|
||||
auditwheel repair flash-attention/dist/${{ steps.build_wheels.outputs.WHEEL_NAME }} -w flash-attention/dist_manylinux
|
||||
wheel_name=$(basename $(ls flash-attention/dist_manylinux/*.whl | head -n 1))
|
||||
echo "WHEEL_NAME_MANYLINUX=$wheel_name" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Install Test
|
||||
run: |
|
||||
pip uninstall -y flash-attn > /dev/null 2>&1
|
||||
pip install --no-cache-dir flash-attention/dist/${{ steps.build_wheels.outputs.WHEEL_NAME }}
|
||||
python -c "import flash_attn; print(flash_attn.__version__)"
|
||||
|
||||
pip uninstall -y flash-attn > /dev/null 2>&1
|
||||
pip install --no-cache-dir flash-attention/dist_manylinux/${{ steps.build_wheels.outputs.WHEEL_NAME_MANYLINUX }}
|
||||
python -c "import flash_attn; print(flash_attn.__version__)"
|
||||
|
||||
- name: Upload Release Asset
|
||||
if: ${{ inputs.is-upload }}
|
||||
env:
|
||||
@@ -88,12 +99,18 @@ jobs:
|
||||
run: |
|
||||
tag_name=${{ github.ref_name }}
|
||||
wheel_path="flash-attention/dist/${{ steps.build_wheels.outputs.WHEEL_NAME }}"
|
||||
wheel_path_manylinux="flash-attention/dist_manylinux/${{ steps.build_wheels.outputs.WHEEL_NAME_MANYLINUX }}"
|
||||
|
||||
# Check if the file exists
|
||||
if [ ! -f "$wheel_path" ]; then
|
||||
echo "Error: Wheel file not found at $wheel_path"
|
||||
exit 1
|
||||
fi
|
||||
if [ ! -f "$wheel_path_manylinux" ]; then
|
||||
echo "Error: Wheel file not found at $wheel_path_manylinux"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Upload the release asset using GitHub CLI
|
||||
gh release upload "$tag_name" "$wheel_path" --clobber
|
||||
gh release upload "$tag_name" "$wheel_path_manylinux" --clobber
|
||||
|
||||
@@ -230,7 +230,7 @@ jobs:
|
||||
shell: bash
|
||||
run: |
|
||||
sudo apt install -y ninja-build clang
|
||||
pip install -U pip setuptools==75.8.0 wheel packaging psutil
|
||||
pip install -U pip setuptools==75.8.0 wheel packaging psutil auditwheel
|
||||
|
||||
- name: Build wheels
|
||||
timeout-minutes: 2160
|
||||
@@ -242,6 +242,13 @@ jobs:
|
||||
wheel_name=$(basename $(ls flash-attention/dist/*.whl | head -n 1))
|
||||
echo "WHEEL_NAME=$wheel_name" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Apply auditwheel repair
|
||||
run: |
|
||||
auditwheel show flash-attention/dist/${{ steps.build_wheels.outputs.WHEEL_NAME }}
|
||||
auditwheel repair flash-attention/dist/${{ steps.build_wheels.outputs.WHEEL_NAME }} -w flash-attention/dist_manylinux
|
||||
wheel_name=$(basename $(ls flash-attention/dist_manylinux/*.whl | head -n 1))
|
||||
echo "WHEEL_NAME_MANYLINUX=$wheel_name" >> $GITHUB_OUTPUT
|
||||
|
||||
- name: Install Test
|
||||
shell: bash
|
||||
run: |
|
||||
@@ -249,6 +256,10 @@ jobs:
|
||||
pip install --no-cache-dir flash-attention/dist/${{ steps.build_wheels.outputs.WHEEL_NAME }}
|
||||
python -c "import flash_attn; print(flash_attn.__version__)"
|
||||
|
||||
pip uninstall -y flash-attn > /dev/null 2>&1
|
||||
pip install --no-cache-dir flash-attention/dist_manylinux/${{ steps.build_wheels.outputs.WHEEL_NAME_MANYLINUX }}
|
||||
python -c "import flash_attn; print(flash_attn.__version__)"
|
||||
|
||||
- name: Upload Release Asset
|
||||
if: ${{ inputs.is-upload }}
|
||||
shell: bash
|
||||
@@ -257,15 +268,21 @@ jobs:
|
||||
run: |
|
||||
tag_name=${{ github.ref_name }}
|
||||
wheel_path="flash-attention/dist/${{ steps.build_wheels.outputs.WHEEL_NAME }}"
|
||||
wheel_path_manylinux="flash-attention/dist_manylinux/${{ steps.build_wheels.outputs.WHEEL_NAME_MANYLINUX }}"
|
||||
|
||||
# Check if the file exists
|
||||
if [ ! -f "$wheel_path" ]; then
|
||||
echo "Error: Wheel file not found at $wheel_path"
|
||||
exit 1
|
||||
fi
|
||||
if [ ! -f "$wheel_path_manylinux" ]; then
|
||||
echo "Error: Wheel file not found at $wheel_path_manylinux"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Upload the release asset using GitHub CLI
|
||||
gh release upload "$tag_name" "$wheel_path" --clobber
|
||||
gh release upload "$tag_name" "$wheel_path_manylinux" --clobber
|
||||
|
||||
- name: Clean up
|
||||
shell: bash
|
||||
|
||||
@@ -122,24 +122,23 @@ Please note that depending on the combination of versions, it may not be possibl
|
||||
In some version combinations, you cannot build wheels on GitHub-hosted runners due to job time limitations.
|
||||
To build the wheels for these versions, you can use self-hosted runners.
|
||||
|
||||
#### Setup x86_64 Runner
|
||||
|
||||
Clone the repository and navigate to the self-hosted-runner directory.
|
||||
|
||||
```bash
|
||||
git clone https://github.com/mjun0812/flash-attention-prebuild-wheels.git
|
||||
cd flash-attention-prebuild-wheels/self-hosted-runner
|
||||
```
|
||||
|
||||
Install qemu-user-static for ARM64 support.
|
||||
|
||||
```bash
|
||||
sudo apt install qemu-user-static
|
||||
```
|
||||
|
||||
Edit `env` and `env.arm` files to set the environment variables.
|
||||
Create the environment file from the template.
|
||||
|
||||
```bash
|
||||
cp env.template env
|
||||
cp env.template env.arm
|
||||
```
|
||||
|
||||
Edit the `env` file to set the environment variables.
|
||||
|
||||
```bash
|
||||
# Registry Token for GitHub Personal Access Token
|
||||
PERSONAL_ACCESS_TOKEN=[Github Personal Access Token]
|
||||
@@ -150,7 +149,7 @@ REGISTRY_TOKEN=[Runner Registry Token]
|
||||
RUNNER_LABELS=Linux,self-hosted
|
||||
```
|
||||
|
||||
Edit compose.yml file if you use repository folked from this repository.
|
||||
Edit the `compose.yml` file if you use a repository forked from this repository.
|
||||
|
||||
```yaml
|
||||
services:
|
||||
@@ -170,6 +169,40 @@ services:
|
||||
args:
|
||||
GH_RUNNER_VERSION: 2.329.0
|
||||
TARGET_ARCH: x64
|
||||
```
|
||||
|
||||
Build and run the docker container.
|
||||
|
||||
```bash
|
||||
# Build and run
|
||||
docker compose build runner
|
||||
docker compose up -d runner
|
||||
```
|
||||
|
||||
#### (Optional) Setup ARM64 Runner
|
||||
|
||||
If you also want to build wheels for ARM64 architecture, follow these additional steps.
|
||||
|
||||
Install qemu-user-static for ARM64 support.
|
||||
|
||||
```bash
|
||||
sudo apt install qemu-user-static
|
||||
```
|
||||
|
||||
Create the environment file for ARM64 runner.
|
||||
|
||||
```bash
|
||||
cp env.template env.arm
|
||||
```
|
||||
|
||||
Edit the `env.arm` file with the same configuration as the `env` file.
|
||||
|
||||
Add the ARM64 runner service to your `compose.yml` file.
|
||||
|
||||
```yaml
|
||||
services:
|
||||
runner:
|
||||
# ... (existing x86_64 runner configuration)
|
||||
|
||||
runner-arm:
|
||||
privileged: true
|
||||
@@ -178,7 +211,7 @@ services:
|
||||
- .env.arm
|
||||
environment:
|
||||
REPOSITORY_URL: https://github.com/[OWNER]/[REPOSITORY]
|
||||
RUNNER_NAME: self-hosted-runner
|
||||
RUNNER_NAME: self-hosted-runner-arm
|
||||
RUNNER_GROUP: default
|
||||
TARGET_ARCH: arm64
|
||||
build:
|
||||
@@ -190,12 +223,12 @@ services:
|
||||
PLATFORM: linux/arm64
|
||||
```
|
||||
|
||||
Then, build and run the docker container.
|
||||
Build and run the ARM64 runner container.
|
||||
|
||||
```bash
|
||||
# Build and run
|
||||
docker compose build
|
||||
docker compose up -d
|
||||
# Build and run both x86_64 and ARM64 runners
|
||||
docker compose build runner-arm
|
||||
docker compose up -d runner-arm
|
||||
```
|
||||
|
||||
### Getting One-Time Registry Token for GitHub Actions Runner
|
||||
|
||||
Reference in New Issue
Block a user