mirror of
https://github.com/csukuangfj/kaldifeat.git
synced 2025-08-19 14:56:17 +00:00
ubuntu cuda
This commit is contained in:
parent
3e90b086e0
commit
7e79458dfe
2
.github/workflows/ubuntu-cpu-wheels.yml
vendored
2
.github/workflows/ubuntu-cpu-wheels.yml
vendored
@ -2,8 +2,6 @@ name: build-wheels-cpu-ubuntu
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- wheels
|
||||
tags:
|
||||
- '*'
|
||||
workflow_dispatch:
|
||||
|
138
.github/workflows/ubuntu-cuda-wheels.yml
vendored
Normal file
138
.github/workflows/ubuntu-cuda-wheels.yml
vendored
Normal file
@ -0,0 +1,138 @@
|
||||
name: build-wheels-cuda-ubuntu
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- wheels
|
||||
tags:
|
||||
- '*'
|
||||
workflow_dispatch:
|
||||
|
||||
concurrency:
|
||||
group: build-wheels-cuda-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 --enable-cuda
|
||||
MATRIX=$(python ./scripts/github_actions/generate_build_matrix.py --enable-cuda)
|
||||
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 }} -e CUDA_VERSION=${{ matrix.cuda }}
|
||||
run: |
|
||||
echo "pwd: $PWD"
|
||||
uname -a
|
||||
id
|
||||
cat /etc/*release
|
||||
gcc --version
|
||||
python3 --version
|
||||
which python3
|
||||
|
||||
pushd /usr/local
|
||||
rm cuda
|
||||
ln -s cuda-$CUDA_VERSION cuda
|
||||
popd
|
||||
which nvcc
|
||||
nvcc --version
|
||||
|
||||
/var/www/scripts/github_actions/build-ubuntu-cuda.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-cuda
|
||||
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-cuda
|
||||
cp -v ../wheelhouse/*.whl ./ubuntu-cuda
|
||||
git status
|
||||
git lfs track "*.whl"
|
||||
git add .
|
||||
git commit -m "upload ubuntu-cuda 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
|
101
scripts/github_actions/build-ubuntu-cuda.sh
Executable file
101
scripts/github_actions/build-ubuntu-cuda.sh
Executable file
@ -0,0 +1,101 @@
|
||||
#!/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.6, 3.7, 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
|
||||
|
||||
if [ -z $CUDA_VERSION ]; then
|
||||
echo "Please set the environment variable CUDA_VERSION"
|
||||
echo "Example: export CUDA_VERSION=10.2"
|
||||
# valid values: 10.2, 11.1, 11.3, 11.6, 11.7, 11.8
|
||||
exit 1
|
||||
fi
|
||||
|
||||
|
||||
yum -y install openssl-devel bzip2-devel libffi-devel xz-devel wget redhat-lsb-core
|
||||
|
||||
|
||||
echo "Installing ${PYTHON_VERSION}.3"
|
||||
curl -O https://www.python.org/ftp/python/${PYTHON_VERSION}.3/Python-${PYTHON_VERSION}.3.tgz
|
||||
tar xf Python-${PYTHON_VERSION}.3.tgz
|
||||
pushd Python-${PYTHON_VERSION}.3
|
||||
|
||||
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"
|
||||
./install_torch.sh
|
||||
|
||||
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=" -j2 "
|
||||
|
||||
|
||||
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
|
@ -160,11 +160,19 @@ def generate_build_matrix(enable_cuda, for_windows, for_macos, test_only_latest_
|
||||
if enable_cuda:
|
||||
for p in python_versions:
|
||||
for c in cuda_versions:
|
||||
ans.append({"torch": torch, "python-version": p, "cuda": c})
|
||||
if c == "10.1":
|
||||
# no docker image for cuda 10.1
|
||||
continue
|
||||
ans.append(
|
||||
{
|
||||
"torch": torch,
|
||||
"python-version": p,
|
||||
"cuda": c,
|
||||
"image": f"pytorch/manylinux-builder:cuda{c}",
|
||||
}
|
||||
)
|
||||
else:
|
||||
for p in python_versions:
|
||||
if p != "3.6":
|
||||
continue
|
||||
if for_windows or for_macos:
|
||||
p = "cp" + "".join(p.split("."))
|
||||
ans.append({"torch": torch, "python-version": p})
|
||||
|
@ -14,6 +14,8 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
torch=$TORCH_VERSION
|
||||
cuda=$CUDA_VERSION
|
||||
case ${torch} in
|
||||
1.5.*)
|
||||
case ${cuda} in
|
||||
@ -155,6 +157,18 @@ case ${torch} in
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
2.0.*)
|
||||
case ${cuda} in
|
||||
11.7)
|
||||
package="torch==${torch}+cu117"
|
||||
url=https://download.pytorch.org/whl/torch_stable.html
|
||||
;;
|
||||
11.8)
|
||||
package="torch==${torch}+cu118"
|
||||
url=https://download.pytorch.org/whl/torch_stable.html
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
*)
|
||||
echo "Unsupported PyTorch version: ${torch}"
|
||||
exit 1
|
||||
@ -170,3 +184,5 @@ if [ x"${url}" == "x" ]; then
|
||||
else
|
||||
retry python3 -m pip install -q $package -f $url
|
||||
fi
|
||||
|
||||
rm -rfv ~/.cache/pip
|
||||
|
Loading…
x
Reference in New Issue
Block a user