Skip to content

Commit c8ef9ac

Browse files
authored
[Feature | CI] Added a github action to build wheels (vllm-project#746)
1 parent 312b37c commit c8ef9ac

File tree

6 files changed

+224
-0
lines changed

6 files changed

+224
-0
lines changed

.github/workflows/publish.yml

Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
# This workflow will upload a Python Package to Release asset
2+
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions
3+
4+
name: Create Release
5+
6+
on:
7+
push:
8+
tags:
9+
- v*
10+
11+
# Needed to create release and upload assets
12+
permissions:
13+
contents: write
14+
15+
jobs:
16+
release:
17+
# Retrieve tag and create release
18+
name: Create Release
19+
runs-on: ubuntu-latest
20+
outputs:
21+
upload_url: ${{ steps.create_release.outputs.upload_url }}
22+
steps:
23+
- name: Checkout
24+
uses: actions/checkout@v3
25+
26+
- name: Extract branch info
27+
shell: bash
28+
run: |
29+
echo "release_tag=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
30+
31+
- name: Create Release
32+
id: create_release
33+
uses: "actions/github-script@v6"
34+
env:
35+
RELEASE_TAG: ${{ env.release_tag }}
36+
with:
37+
github-token: "${{ secrets.GITHUB_TOKEN }}"
38+
script: |
39+
const script = require('.github/workflows/scripts/create_release.js')
40+
await script(github, context, core)
41+
42+
wheel:
43+
name: Build Wheel
44+
runs-on: ${{ matrix.os }}
45+
needs: release
46+
47+
strategy:
48+
fail-fast: false
49+
matrix:
50+
os: ['ubuntu-20.04']
51+
python-version: ['3.8', '3.9', '3.10', '3.11']
52+
cuda-version: ['11.8'] # Github runner can't build anything older than 11.8
53+
54+
steps:
55+
- name: Checkout
56+
uses: actions/checkout@v3
57+
58+
- name: Set up Linux Env
59+
if: ${{ runner.os == 'Linux' }}
60+
run: |
61+
bash -x .github/workflows/scripts/env.sh
62+
63+
- name: Set up Python
64+
uses: actions/setup-python@v4
65+
with:
66+
python-version: ${{ matrix.python-version }}
67+
68+
- name: Install CUDA ${{ matrix.cuda-version }}
69+
run: |
70+
bash -x .github/workflows/scripts/cuda-install.sh ${{ matrix.cuda-version }} ${{ matrix.os }}
71+
72+
- name: Install PyTorch-cu${{ matrix.cuda-version }}
73+
run: |
74+
bash -x .github/workflows/scripts/pytorch-install.sh ${{ matrix.python-version }} ${{ matrix.cuda-version }}
75+
76+
- name: Build wheel
77+
shell: bash
78+
run: |
79+
bash -x .github/workflows/scripts/build.sh ${{ matrix.python-version }} ${{ matrix.cuda-version }}
80+
wheel_name=$(ls dist/*whl | xargs -n 1 basename)
81+
asset_name=${wheel_name//"linux"/"manylinux1"}
82+
echo "wheel_name=${wheel_name}" >> $GITHUB_ENV
83+
echo "asset_name=${asset_name}" >> $GITHUB_ENV
84+
85+
- name: Upload Release Asset
86+
uses: actions/upload-release-asset@v1
87+
env:
88+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
89+
with:
90+
upload_url: ${{ needs.release.outputs.upload_url }}
91+
asset_path: ./dist/${{ env.wheel_name }}
92+
asset_name: ${{ env.asset_name }}
93+
asset_content_type: application/*
94+
95+
# (Danielkinz): This last step will publish the .whl to pypi. Warning: untested
96+
# - name: Publish package
97+
# uses: pypa/gh-action-pypi-publish@release/v1.8
98+
# with:
99+
# repository-url: https://test.pypi.org/legacy/
100+
# password: ${{ secrets.PYPI_API_TOKEN }}
101+
# skip-existing: true

.github/workflows/scripts/build.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
python_executable=python$1
4+
cuda_home=/usr/local/cuda-$2
5+
6+
# Update paths
7+
PATH=${cuda_home}/bin:$PATH
8+
LD_LIBRARY_PATH=${cuda_home}/lib64:$LD_LIBRARY_PATH
9+
10+
# Install requirements
11+
$python_executable -m pip install wheel packaging
12+
$python_executable -m pip install -r requirements.txt
13+
14+
# Build
15+
$python_executable setup.py bdist_wheel --dist-dir=dist
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
// Uses Github's API to create the release and wait for result.
2+
// We use a JS script since github CLI doesn't provide a way to wait for the release's creation and returns immediately.
3+
4+
module.exports = async (github, context, core) => {
5+
try {
6+
const response = await github.rest.repos.createRelease({
7+
draft: false,
8+
generate_release_notes: true,
9+
name: process.env.RELEASE_TAG,
10+
owner: context.repo.owner,
11+
prerelease: false,
12+
repo: context.repo.repo,
13+
tag_name: process.env.RELEASE_TAG,
14+
});
15+
16+
core.setOutput('upload_url', response.data.upload_url);
17+
} catch (error) {
18+
core.setFailed(error.message);
19+
}
20+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
#!/bin/bash
2+
3+
# Replace '.' with '-' ex: 11.8 -> 11-8
4+
cuda_version=$(echo $1 | tr "." "-")
5+
# Removes '-' and '.' ex: ubuntu-20.04 -> ubuntu2004
6+
OS=$(echo $2 | tr -d ".\-")
7+
8+
# Installs CUDA
9+
wget -nv https://developer.download.nvidia.com/compute/cuda/repos/${OS}/x86_64/cuda-keyring_1.1-1_all.deb
10+
sudo dpkg -i cuda-keyring_1.1-1_all.deb
11+
rm cuda-keyring_1.1-1_all.deb
12+
sudo apt -qq update
13+
sudo apt -y install cuda-${cuda_version} cuda-nvcc-${cuda_version} cuda-libraries-dev-${cuda_version}
14+
sudo apt clean
15+
16+
# Test nvcc
17+
PATH=/usr/local/cuda-$1/bin:${PATH}
18+
nvcc --version

.github/workflows/scripts/env.sh

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
#!/bin/bash
2+
3+
# This file installs common linux environment tools
4+
5+
export LANG C.UTF-8
6+
7+
# python_version=$1
8+
9+
sudo apt-get update && \
10+
sudo apt-get install -y --no-install-recommends \
11+
software-properties-common \
12+
13+
sudo apt-get install -y --no-install-recommends \
14+
build-essential \
15+
apt-utils \
16+
ca-certificates \
17+
wget \
18+
git \
19+
vim \
20+
libssl-dev \
21+
curl \
22+
unzip \
23+
unrar \
24+
cmake \
25+
net-tools \
26+
sudo \
27+
autotools-dev \
28+
rsync \
29+
jq \
30+
openssh-server \
31+
tmux \
32+
screen \
33+
htop \
34+
pdsh \
35+
openssh-client \
36+
lshw \
37+
dmidecode \
38+
util-linux \
39+
automake \
40+
autoconf \
41+
libtool \
42+
net-tools \
43+
pciutils \
44+
libpci-dev \
45+
libaio-dev \
46+
libcap2 \
47+
libtinfo5 \
48+
fakeroot \
49+
devscripts \
50+
debhelper \
51+
nfs-common
52+
53+
# Remove github bloat files to free up disk space
54+
sudo rm -rf "/usr/local/share/boost"
55+
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
56+
sudo rm -rf "/usr/share/dotnet"
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
3+
python_executable=python$1
4+
cuda_version=$2
5+
6+
# Install torch
7+
$python_executable -m pip install numpy pyyaml scipy ipython mkl mkl-include ninja cython typing pandas typing-extensions dataclasses setuptools && conda clean -ya
8+
$python_executable -m pip install torch -f https://download.pytorch.org/whl/cu${cuda_version//./}/torch_stable.html
9+
10+
# Print version information
11+
$python_executable --version
12+
$python_executable -c "import torch; print('PyTorch:', torch.__version__)"
13+
$python_executable -c "import torch; print('CUDA:', torch.version.cuda)"
14+
$python_executable -c "from torch.utils import cpp_extension; print (cpp_extension.CUDA_HOME)"

0 commit comments

Comments
 (0)