ubuntu cpu wheels

This commit is contained in:
Fangjun Kuang 2023-07-22 16:44:23 +08:00
parent cf70c465db
commit 9b9c16ec41
5 changed files with 233 additions and 5 deletions

View File

@ -2,10 +2,9 @@ name: build-wheels-cpu-macos
on:
push:
branches:
- wheels
tags:
- '*'
workflow_dispatch:
concurrency:
group: build-wheels-cpu-macos-${{ github.ref }}

130
.github/workflows/ubuntu-cpu-wheels.yml vendored Normal file
View File

@ -0,0 +1,130 @@
name: build-wheels-cpu-ubuntu
on:
push:
branches:
- wheels
tags:
- '*'
workflow_dispatch:
concurrency:
group: build-wheels-cpu-ubuntu-${{ github.ref }}
cancel-in-progress: true
jobs:
generate_build_matrix:
# see https://github.com/pytorch/pytorch/pull/50633
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Generating build matrix
id: set-matrix
run: |
# outputting for debugging purposes
python ./scripts/github_actions/generate_build_matrix.py
MATRIX=$(python ./scripts/github_actions/generate_build_matrix.py)
echo "::set-output name=matrix::${MATRIX}"
build-manylinux-wheels:
needs: generate_build_matrix
name: ${{ matrix.torch }} ${{ matrix.python-version }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
${{ fromJson(needs.generate_build_matrix.outputs.matrix) }}
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: display
shell: bash
run: |
function retry() {
$* || (sleep 1 && $*) || (sleep 2 && $*) || (sleep 4 && $*) || (sleep 8 && $*)
}
retry ls -lh
# see https://github.com/pytorch/test-infra/blob/9e3d392690719fac85bad0c9b67f530e48375ca1/tools/scripts/generate_binary_build_matrix.py
# https://github.com/pytorch/builder/tree/main/manywheel
# https://github.com/pytorch/builder/pull/476
# https://github.com/k2-fsa/k2/issues/733
# https://github.com/pytorch/pytorch/pull/50633 (generate build matrix)
- name: Run the build process with Docker
uses: addnab/docker-run-action@v3
with:
image: ${{ matrix.image }}
options: -v ${{ github.workspace }}:/var/www -e PYTHON_VERSION=${{ matrix.python-version }} -e TORCH_VERSION=${{ matrix.torch }}
run: |
echo "pwd: $PWD"
uname -a
id
cat /etc/*release
gcc --version
python3 --version
which python3
/var/www/scripts/github_actions/build-ubuntu-cpu.sh
- name: Display wheels
shell: bash
run: |
function retry() {
$* || (sleep 1 && $*) || (sleep 2 && $*) || (sleep 4 && $*) || (sleep 8 && $*)
}
ls -lh ./wheelhouse/
ls -lh ./wheelhouse/*.whl
- name: Upload Wheel
uses: actions/upload-artifact@v2
with:
name: torch-${{ matrix.torch }}-python-${{ matrix.python-version }}-ubuntu-latest-cpu
path: wheelhouse/*.whl
# https://huggingface.co/docs/hub/spaces-github-actions
- name: Publish to huggingface
if: github.repository_owner == 'csukuangfj'
shell: bash
env:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
run: |
git config --global user.email "csukuangfj@gmail.com"
git config --global user.name "Fangjun Kuang"
export GIT_LFS_SKIP_SMUDGE=1
git clone https://huggingface.co/csukuangfj/kaldifeat huggingface
cur_path=$PWD
function push_to_huggingface() {
cd $cur_path
rm -rf huggingface
git clone https://huggingface.co/csukuangfj/kaldifeat huggingface
cd huggingface
git pull
mkdir -p ubuntu-cpu
cp -v ../wheelhouse/*.whl ./ubuntu-cpu
git status
git lfs track "*.whl"
git add .
git commit -m "upload ubuntu-cpu wheel for torch ${{ matrix.torch }} python ${{ matrix.python-version }}"
git push https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/kaldifeat main
cd ..
rm -rf huggingface
}
function retry() {
$* || (sleep 1 && $*) || (sleep 2 && $*) || (sleep 4 && $*) || (sleep 8 && $*)
}
retry push_to_huggingface

View File

@ -2,10 +2,9 @@ name: build-wheels-cpu-win64
on:
push:
branches:
- wheels
tags:
- '*'
workflow_dispatch:
concurrency:
group: build-wheels-cpu-win64-${{ github.ref }}

View File

@ -0,0 +1,92 @@
#!/usr/bin/env bash
#
set -ex
if [ -z $PYTHON_VERSION ]; then
echo "Please set the environment variable PYTHON_VERSION"
echo "Example: export PYTHON_VERSION=3.8"
# Valid values: 3.8, 3.9, 3.10, 3.11
exit 1
fi
if [ -z $TORCH_VERSION ]; then
echo "Please set the environment variable TORCH_VERSION"
echo "Example: export TORCH_VERSION=1.10.0"
exit 1
fi
echo "Installing ${PYTHON_VERSION}.1"
yum -y install openssl-devel bzip2-devel libffi-devel xz-devel wget redhat-lsb-core
curl -O https://www.python.org/ftp/python/${PYTHON_VERSION}.1/Python-${PYTHON_VERSION}.1.tgz
tar xf Python-${PYTHON_VERSION}.1.tgz
pushd Python-${PYTHON_VERSION}.1
PYTHON_INSTALL_DIR=$PWD/py-${PYTHON_VERSION}
if [[ $PYTHON_VERSION =~ 3.1. ]]; then
yum install -y openssl11-devel
sed -i 's/PKG_CONFIG openssl /PKG_CONFIG openssl11 /g' configure
fi
./configure --enable-shared --prefix=$PYTHON_INSTALL_DIR
make install
popd
export PATH=$PYTHON_INSTALL_DIR/bin:$PATH
export LD_LIBRARY_PATH=$PYTHON_INSTALL_DIR/lib:$LD_LIBRARY_PATH
ls -lh $PYTHON_INSTALL_DIR/lib/
python3 --version
which python3
if [[ $PYTHON_VERSION != 3.6 ]]; then
curl -O https://bootstrap.pypa.io/get-pip.py
python3 get-pip.py
fi
python3 -m pip install scikit-build
python3 -m pip install -U pip cmake
python3 -m pip install wheel twine typing_extensions
python3 -m pip install bs4 requests tqdm auditwheel
echo "Installing torch"
python3 -m pip install -qq torch==$TORCH_VERSION+cpu -f https://download.pytorch.org/whl/torch_stable.html
rm -rf ~/.cache/pip
yum clean all
cd /var/www
export CMAKE_CUDA_COMPILER_LAUNCHER=
export KALDIFEAT_CMAKE_ARGS=" -DPYTHON_EXECUTABLE=$PYTHON_INSTALL_DIR/bin/python3 "
export KALDIFEAT_MAKE_ARGS=" -j "
python3 setup.py bdist_wheel
auditwheel --verbose repair \
--exclude libc10.so \
--exclude libc10_cuda.so \
--exclude libcuda.so.1 \
--exclude libcudart.so.${CUDA_VERSION} \
--exclude libnvToolsExt.so.1 \
--exclude libnvrtc.so.${CUDA_VERSION} \
--exclude libtorch.so \
--exclude libtorch_cpu.so \
--exclude libtorch_cuda.so \
--exclude libtorch_python.so \
\
--exclude libcudnn.so.8 \
--exclude libcublas.so.11 \
--exclude libcublasLt.so.11 \
--exclude libcudart.so.11.0 \
--exclude libnvrtc.so.11.2 \
--exclude libtorch_cuda_cu.so \
--exclude libtorch_cuda_cpp.so \
--plat manylinux_2_17_x86_64 \
-w /var/www/wheelhouse \
dist/*.whl
ls -lh /var/www

View File

@ -166,6 +166,14 @@ def generate_build_matrix(enable_cuda, for_windows, for_macos, test_only_latest_
if for_windows or for_macos:
p = "cp" + "".join(p.split("."))
ans.append({"torch": torch, "python-version": p})
else:
ans.append(
{
"torch": torch,
"python-version": p,
"image": f"pytorch/manylinux-builder:cuda10.2",
}
)
print(json.dumps({"include": ans}))