[Feature | CI] Added a github action to build wheels (#746)
This commit is contained in:
parent
0c04ce3234
commit
c393af6cd7
101
.github/workflows/publish.yml
vendored
Normal file
101
.github/workflows/publish.yml
vendored
Normal file
@ -0,0 +1,101 @@
|
|||||||
|
# This workflow will upload a Python Package to Release asset
|
||||||
|
# For more information see: https://help.github.com/en/actions/language-and-framework-guides/using-python-with-github-actions
|
||||||
|
|
||||||
|
name: Create Release
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
tags:
|
||||||
|
- v*
|
||||||
|
|
||||||
|
# Needed to create release and upload assets
|
||||||
|
permissions:
|
||||||
|
contents: write
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
release:
|
||||||
|
# Retrieve tag and create release
|
||||||
|
name: Create Release
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
outputs:
|
||||||
|
upload_url: ${{ steps.create_release.outputs.upload_url }}
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Extract branch info
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
echo "release_tag=${GITHUB_REF#refs/*/}" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Create Release
|
||||||
|
id: create_release
|
||||||
|
uses: "actions/github-script@v6"
|
||||||
|
env:
|
||||||
|
RELEASE_TAG: ${{ env.release_tag }}
|
||||||
|
with:
|
||||||
|
github-token: "${{ secrets.GITHUB_TOKEN }}"
|
||||||
|
script: |
|
||||||
|
const script = require('.github/workflows/scripts/create_release.js')
|
||||||
|
await script(github, context, core)
|
||||||
|
|
||||||
|
wheel:
|
||||||
|
name: Build Wheel
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
needs: release
|
||||||
|
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os: ['ubuntu-20.04']
|
||||||
|
python-version: ['3.8', '3.9', '3.10', '3.11']
|
||||||
|
cuda-version: ['11.8'] # Github runner can't build anything older than 11.8
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v3
|
||||||
|
|
||||||
|
- name: Set up Linux Env
|
||||||
|
if: ${{ runner.os == 'Linux' }}
|
||||||
|
run: |
|
||||||
|
bash -x .github/workflows/scripts/env.sh
|
||||||
|
|
||||||
|
- name: Set up Python
|
||||||
|
uses: actions/setup-python@v4
|
||||||
|
with:
|
||||||
|
python-version: ${{ matrix.python-version }}
|
||||||
|
|
||||||
|
- name: Install CUDA ${{ matrix.cuda-version }}
|
||||||
|
run: |
|
||||||
|
bash -x .github/workflows/scripts/cuda-install.sh ${{ matrix.cuda-version }} ${{ matrix.os }}
|
||||||
|
|
||||||
|
- name: Install PyTorch-cu${{ matrix.cuda-version }}
|
||||||
|
run: |
|
||||||
|
bash -x .github/workflows/scripts/pytorch-install.sh ${{ matrix.python-version }} ${{ matrix.cuda-version }}
|
||||||
|
|
||||||
|
- name: Build wheel
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
bash -x .github/workflows/scripts/build.sh ${{ matrix.python-version }} ${{ matrix.cuda-version }}
|
||||||
|
wheel_name=$(ls dist/*whl | xargs -n 1 basename)
|
||||||
|
asset_name=${wheel_name//"linux"/"manylinux1"}
|
||||||
|
echo "wheel_name=${wheel_name}" >> $GITHUB_ENV
|
||||||
|
echo "asset_name=${asset_name}" >> $GITHUB_ENV
|
||||||
|
|
||||||
|
- name: Upload Release Asset
|
||||||
|
uses: actions/upload-release-asset@v1
|
||||||
|
env:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
with:
|
||||||
|
upload_url: ${{ needs.release.outputs.upload_url }}
|
||||||
|
asset_path: ./dist/${{ env.wheel_name }}
|
||||||
|
asset_name: ${{ env.asset_name }}
|
||||||
|
asset_content_type: application/*
|
||||||
|
|
||||||
|
# (Danielkinz): This last step will publish the .whl to pypi. Warning: untested
|
||||||
|
# - name: Publish package
|
||||||
|
# uses: pypa/gh-action-pypi-publish@release/v1.8
|
||||||
|
# with:
|
||||||
|
# repository-url: https://test.pypi.org/legacy/
|
||||||
|
# password: ${{ secrets.PYPI_API_TOKEN }}
|
||||||
|
# skip-existing: true
|
15
.github/workflows/scripts/build.sh
vendored
Normal file
15
.github/workflows/scripts/build.sh
vendored
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
python_executable=python$1
|
||||||
|
cuda_home=/usr/local/cuda-$2
|
||||||
|
|
||||||
|
# Update paths
|
||||||
|
PATH=${cuda_home}/bin:$PATH
|
||||||
|
LD_LIBRARY_PATH=${cuda_home}/lib64:$LD_LIBRARY_PATH
|
||||||
|
|
||||||
|
# Install requirements
|
||||||
|
$python_executable -m pip install wheel packaging
|
||||||
|
$python_executable -m pip install -r requirements.txt
|
||||||
|
|
||||||
|
# Build
|
||||||
|
$python_executable setup.py bdist_wheel --dist-dir=dist
|
20
.github/workflows/scripts/create_release.js
vendored
Normal file
20
.github/workflows/scripts/create_release.js
vendored
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
// Uses Github's API to create the release and wait for result.
|
||||||
|
// We use a JS script since github CLI doesn't provide a way to wait for the release's creation and returns immediately.
|
||||||
|
|
||||||
|
module.exports = async (github, context, core) => {
|
||||||
|
try {
|
||||||
|
const response = await github.rest.repos.createRelease({
|
||||||
|
draft: false,
|
||||||
|
generate_release_notes: true,
|
||||||
|
name: process.env.RELEASE_TAG,
|
||||||
|
owner: context.repo.owner,
|
||||||
|
prerelease: false,
|
||||||
|
repo: context.repo.repo,
|
||||||
|
tag_name: process.env.RELEASE_TAG,
|
||||||
|
});
|
||||||
|
|
||||||
|
core.setOutput('upload_url', response.data.upload_url);
|
||||||
|
} catch (error) {
|
||||||
|
core.setFailed(error.message);
|
||||||
|
}
|
||||||
|
}
|
18
.github/workflows/scripts/cuda-install.sh
vendored
Normal file
18
.github/workflows/scripts/cuda-install.sh
vendored
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# Replace '.' with '-' ex: 11.8 -> 11-8
|
||||||
|
cuda_version=$(echo $1 | tr "." "-")
|
||||||
|
# Removes '-' and '.' ex: ubuntu-20.04 -> ubuntu2004
|
||||||
|
OS=$(echo $2 | tr -d ".\-")
|
||||||
|
|
||||||
|
# Installs CUDA
|
||||||
|
wget -nv https://developer.download.nvidia.com/compute/cuda/repos/${OS}/x86_64/cuda-keyring_1.1-1_all.deb
|
||||||
|
sudo dpkg -i cuda-keyring_1.1-1_all.deb
|
||||||
|
rm cuda-keyring_1.1-1_all.deb
|
||||||
|
sudo apt -qq update
|
||||||
|
sudo apt -y install cuda-${cuda_version} cuda-nvcc-${cuda_version} cuda-libraries-dev-${cuda_version}
|
||||||
|
sudo apt clean
|
||||||
|
|
||||||
|
# Test nvcc
|
||||||
|
PATH=/usr/local/cuda-$1/bin:${PATH}
|
||||||
|
nvcc --version
|
56
.github/workflows/scripts/env.sh
vendored
Normal file
56
.github/workflows/scripts/env.sh
vendored
Normal file
@ -0,0 +1,56 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# This file installs common linux environment tools
|
||||||
|
|
||||||
|
export LANG C.UTF-8
|
||||||
|
|
||||||
|
# python_version=$1
|
||||||
|
|
||||||
|
sudo apt-get update && \
|
||||||
|
sudo apt-get install -y --no-install-recommends \
|
||||||
|
software-properties-common \
|
||||||
|
|
||||||
|
sudo apt-get install -y --no-install-recommends \
|
||||||
|
build-essential \
|
||||||
|
apt-utils \
|
||||||
|
ca-certificates \
|
||||||
|
wget \
|
||||||
|
git \
|
||||||
|
vim \
|
||||||
|
libssl-dev \
|
||||||
|
curl \
|
||||||
|
unzip \
|
||||||
|
unrar \
|
||||||
|
cmake \
|
||||||
|
net-tools \
|
||||||
|
sudo \
|
||||||
|
autotools-dev \
|
||||||
|
rsync \
|
||||||
|
jq \
|
||||||
|
openssh-server \
|
||||||
|
tmux \
|
||||||
|
screen \
|
||||||
|
htop \
|
||||||
|
pdsh \
|
||||||
|
openssh-client \
|
||||||
|
lshw \
|
||||||
|
dmidecode \
|
||||||
|
util-linux \
|
||||||
|
automake \
|
||||||
|
autoconf \
|
||||||
|
libtool \
|
||||||
|
net-tools \
|
||||||
|
pciutils \
|
||||||
|
libpci-dev \
|
||||||
|
libaio-dev \
|
||||||
|
libcap2 \
|
||||||
|
libtinfo5 \
|
||||||
|
fakeroot \
|
||||||
|
devscripts \
|
||||||
|
debhelper \
|
||||||
|
nfs-common
|
||||||
|
|
||||||
|
# Remove github bloat files to free up disk space
|
||||||
|
sudo rm -rf "/usr/local/share/boost"
|
||||||
|
sudo rm -rf "$AGENT_TOOLSDIRECTORY"
|
||||||
|
sudo rm -rf "/usr/share/dotnet"
|
14
.github/workflows/scripts/pytorch-install.sh
vendored
Normal file
14
.github/workflows/scripts/pytorch-install.sh
vendored
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
python_executable=python$1
|
||||||
|
cuda_version=$2
|
||||||
|
|
||||||
|
# Install torch
|
||||||
|
$python_executable -m pip install numpy pyyaml scipy ipython mkl mkl-include ninja cython typing pandas typing-extensions dataclasses setuptools && conda clean -ya
|
||||||
|
$python_executable -m pip install torch -f https://download.pytorch.org/whl/cu${cuda_version//./}/torch_stable.html
|
||||||
|
|
||||||
|
# Print version information
|
||||||
|
$python_executable --version
|
||||||
|
$python_executable -c "import torch; print('PyTorch:', torch.__version__)"
|
||||||
|
$python_executable -c "import torch; print('CUDA:', torch.version.cuda)"
|
||||||
|
$python_executable -c "from torch.utils import cpp_extension; print (cpp_extension.CUDA_HOME)"
|
Loading…
x
Reference in New Issue
Block a user