Support Linux arm64 (#114)

This commit is contained in:
Fangjun Kuang 2025-03-07 14:22:18 +08:00 committed by GitHub
parent 3f79fbbd6d
commit 0ecdee6e88
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
14 changed files with 565 additions and 148 deletions

View File

@ -84,7 +84,7 @@ jobs:
ls -lh ./wheelhouse/ ls -lh ./wheelhouse/
- name: Upload Wheel - name: Upload Wheel
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v4
with: with:
name: torch-${{ matrix.torch }}-python-${{ matrix.python-version }}-macos-latest-cpu name: torch-${{ matrix.torch }}-python-${{ matrix.python-version }}-macos-latest-cpu
path: wheelhouse/*.whl path: wheelhouse/*.whl

View File

@ -107,7 +107,7 @@ jobs:
python3 -c "import kaldifeat; print(kaldifeat.__version__)" python3 -c "import kaldifeat; print(kaldifeat.__version__)"
- name: Upload Wheel - name: Upload Wheel
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v4
with: with:
name: python-${{ matrix.python-version }}-${{ matrix.os }}-cpu name: python-${{ matrix.python-version }}-${{ matrix.os }}-cpu
path: dist/*.whl path: dist/*.whl

View File

@ -159,7 +159,7 @@ jobs:
python3 -c "import kaldifeat; print(kaldifeat.__version__)" python3 -c "import kaldifeat; print(kaldifeat.__version__)"
- name: Upload Wheel - name: Upload Wheel
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v4
with: with:
name: python-${{ matrix.python-version }}-${{ matrix.os }}-cuda-${{ matrix.cuda }} name: python-${{ matrix.python-version }}-${{ matrix.os }}-cuda-${{ matrix.cuda }}
path: dist/*.whl path: dist/*.whl

View File

@ -0,0 +1,168 @@
name: build-wheels-cpu-arm64-ubuntu
on:
push:
branches:
# - wheel
- fix-cuda-12.6
tags:
- '*'
workflow_dispatch:
concurrency:
group: build-wheels-cpu-arm64-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@v4
with:
fetch-depth: 0
- name: Generating build matrix
id: set-matrix
run: |
# outputting for debugging purposes
python ./scripts/github_actions/generate_build_matrix.py --for-arm64
MATRIX=$(python ./scripts/github_actions/generate_build_matrix.py --for-arm64)
# python ./scripts/github_actions/generate_build_matrix.py --test-only-latest-torch --for-arm64
# MATRIX=$(python ./scripts/github_actions/generate_build_matrix.py --test-only-latest-torch --for-arm64)
echo "::set-output name=matrix::${MATRIX}"
build-manylinux-wheels:
needs: generate_build_matrix
name: ${{ matrix.torch }} ${{ matrix.python-version }}
runs-on: ubuntu-22.04-arm
strategy:
fail-fast: false
matrix:
${{ fromJson(needs.generate_build_matrix.outputs.matrix) }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
# 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 IS_2_28=${{ matrix.is_2_28 }} -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
ls -lh /opt/python/
echo "---"
ls -lh /opt/python/cp*
ls -lh /opt/python/*/bin
echo "---"
find /opt/python/cp* -name "libpython*"
echo "-----"
find /opt/_internal/cp* -name "libpython*"
echo "-----"
find / -name "libpython*"
echo "----"
ls -lh /usr/lib64/libpython3.so
# cp36-cp36m
# cp37-cp37m
# cp38-cp38
# cp39-cp39
# cp310-cp310
# cp311-cp311
# cp312-cp312
# cp313-cp313
# cp313-cp313t (no gil)
if [[ $PYTHON_VERSION == "3.6" ]]; then
python_dir=/opt/python/cp36-cp36m
export PYTHONPATH=/opt/python/cp36-cp36m/lib/python3.6/site-packages:$PYTHONPATH
elif [[ $PYTHON_VERSION == "3.7" ]]; then
python_dir=/opt/python/cp37-cp37m
export PYTHONPATH=/opt/python/cp37-cp37m/lib/python3.7/site-packages:$PYTHONPATH
elif [[ $PYTHON_VERSION == "3.8" ]]; then
python_dir=/opt/python/cp38-cp38
export PYTHONPATH=/opt/python/cp38-cp38/lib/python3.8/site-packages:$PYTHONPATH
elif [[ $PYTHON_VERSION == "3.9" ]]; then
python_dir=/opt/python/cp39-cp39
export PYTHONPATH=/opt/python/cp39-cp39/lib/python3.9/site-packages:$PYTHONPATH
elif [[ $PYTHON_VERSION == "3.10" ]]; then
python_dir=/opt/python/cp310-cp310
export PYTHONPATH=/opt/python/cp310-cp310/lib/python3.10/site-packages:$PYTHONPATH
elif [[ $PYTHON_VERSION == "3.11" ]]; then
python_dir=/opt/python/cp311-cp311
export PYTHONPATH=/opt/python/cp311-cp311/lib/python3.11/site-packages:$PYTHONPATH
elif [[ $PYTHON_VERSION == "3.12" ]]; then
python_dir=/opt/python/cp312-cp312
export PYTHONPATH=/opt/python/cp312-cp312/lib/python3.12/site-packages:$PYTHONPATH
elif [[ $PYTHON_VERSION == "3.13" ]]; then
python_dir=/opt/python/cp313-cp313
export PYTHONPATH=/opt/python/cp313-cp313/lib/python3.13/site-packages:$PYTHONPATH
else
echo "Unsupported Python version $PYTHON_VERSION"
exit 1
fi
export PYTHON_INSTALL_DIR=$python_dir
export PATH=$PYTHON_INSTALL_DIR/bin:$PATH
python3 --version
which python3
/var/www/scripts/github_actions/build-ubuntu-cpu-arm64.sh
- name: Display wheels
shell: bash
run: |
ls -lh ./wheelhouse/
# https://huggingface.co/docs/hub/spaces-github-actions
- name: Publish to huggingface
if: github.repository_owner == 'csukuangfj'
env:
HF_TOKEN: ${{ secrets.HF_TOKEN }}
uses: nick-fields/retry@v2
with:
max_attempts: 20
timeout_seconds: 200
shell: bash
command: |
git config --global user.email "csukuangfj@gmail.com"
git config --global user.name "Fangjun Kuang"
rm -rf huggingface
export GIT_LFS_SKIP_SMUDGE=1
git clone https://huggingface.co/csukuangfj/kaldifeat huggingface
cd huggingface
git pull
d=cpu/1.25.5.dev20250307/linux-arm64
mkdir -p $d
cp -v ../wheelhouse/*.whl ./$d
git status
git lfs track "*.whl"
git add .
git commit -m "upload ubuntu-arm64-cpu wheel for torch ${{ matrix.torch }} python ${{ matrix.python-version }}"
git push https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/kaldifeat main

View File

@ -3,7 +3,8 @@ name: build-wheels-cpu-ubuntu
on: on:
push: push:
branches: branches:
- fix-wheel-2 # - fix-cuda-12.6
- wheel
tags: tags:
- '*' - '*'
workflow_dispatch: workflow_dispatch:
@ -56,7 +57,7 @@ jobs:
uses: addnab/docker-run-action@v3 uses: addnab/docker-run-action@v3
with: with:
image: ${{ matrix.image }} image: ${{ matrix.image }}
options: -v ${{ github.workspace }}:/var/www -e PYTHON_VERSION=${{ matrix.python-version }} -e TORCH_VERSION=${{ matrix.torch }} options: -v ${{ github.workspace }}:/var/www -e IS_2_28=${{ matrix.is_2_28 }} -e PYTHON_VERSION=${{ matrix.python-version }} -e TORCH_VERSION=${{ matrix.torch }}
run: | run: |
echo "pwd: $PWD" echo "pwd: $PWD"
uname -a uname -a
@ -65,6 +66,69 @@ jobs:
gcc --version gcc --version
python3 --version python3 --version
which python3 which python3
ls -lh /opt/python/
echo "---"
ls -lh /opt/python/cp*
ls -lh /opt/python/*/bin
echo "---"
find /opt/python/cp* -name "libpython*"
echo "-----"
find /opt/_internal/cp* -name "libpython*"
echo "-----"
find / -name "libpython*"
echo "----"
ls -lh /usr/lib64/libpython3.so || true
# cp36-cp36m
# cp37-cp37m
# cp38-cp38
# cp39-cp39
# cp310-cp310
# cp311-cp311
# cp312-cp312
# cp313-cp313
# cp313-cp313t (no gil)
if [[ $PYTHON_VERSION == "3.6" ]]; then
python_dir=/opt/python/cp36-cp36m
export PYTHONPATH=/opt/python/cp36-cp36m/lib/python3.6/site-packages:$PYTHONPATH
elif [[ $PYTHON_VERSION == "3.7" ]]; then
python_dir=/opt/python/cp37-cp37m
export PYTHONPATH=/opt/python/cp37-cp37m/lib/python3.7/site-packages:$PYTHONPATH
elif [[ $PYTHON_VERSION == "3.8" ]]; then
python_dir=/opt/python/cp38-cp38
export PYTHONPATH=/opt/python/cp38-cp38/lib/python3.8/site-packages:$PYTHONPATH
elif [[ $PYTHON_VERSION == "3.9" ]]; then
python_dir=/opt/python/cp39-cp39
export PYTHONPATH=/opt/python/cp39-cp39/lib/python3.9/site-packages:$PYTHONPATH
elif [[ $PYTHON_VERSION == "3.10" ]]; then
python_dir=/opt/python/cp310-cp310
export PYTHONPATH=/opt/python/cp310-cp310/lib/python3.10/site-packages:$PYTHONPATH
elif [[ $PYTHON_VERSION == "3.11" ]]; then
python_dir=/opt/python/cp311-cp311
export PYTHONPATH=/opt/python/cp311-cp311/lib/python3.11/site-packages:$PYTHONPATH
elif [[ $PYTHON_VERSION == "3.12" ]]; then
python_dir=/opt/python/cp312-cp312
export PYTHONPATH=/opt/python/cp312-cp312/lib/python3.12/site-packages:$PYTHONPATH
elif [[ $PYTHON_VERSION == "3.13" ]]; then
python_dir=/opt/python/cp313-cp313
export PYTHONPATH=/opt/python/cp313-cp313/lib/python3.13/site-packages:$PYTHONPATH
else
echo "Unsupported Python version $PYTHON_VERSION"
exit 1
fi
export PYTHON_INSTALL_DIR=$python_dir
export PATH=$PYTHON_INSTALL_DIR/bin:$PATH
python3 --version
which python3
/var/www/scripts/github_actions/build-ubuntu-cpu.sh /var/www/scripts/github_actions/build-ubuntu-cpu.sh
- name: Display wheels - name: Display wheels
@ -72,12 +136,6 @@ jobs:
run: | run: |
ls -lh ./wheelhouse/ ls -lh ./wheelhouse/
- name: Upload Wheel
uses: actions/upload-artifact@v3
with:
name: torch-${{ matrix.torch }}-python-${{ matrix.python-version }}-ubuntu-latest-cpu
path: wheelhouse/*.whl
# https://huggingface.co/docs/hub/spaces-github-actions # https://huggingface.co/docs/hub/spaces-github-actions
- name: Publish to huggingface - name: Publish to huggingface
if: github.repository_owner == 'csukuangfj' if: github.repository_owner == 'csukuangfj'
@ -100,7 +158,7 @@ jobs:
cd huggingface cd huggingface
git pull git pull
d=cpu/1.25.5.dev20241029/linux d=cpu/1.25.5.dev20250307/linux-x64
mkdir -p $d mkdir -p $d
cp -v ../wheelhouse/*.whl ./$d cp -v ../wheelhouse/*.whl ./$d
git status git status

View File

@ -3,7 +3,7 @@ name: build-wheels-cuda-ubuntu
on: on:
push: push:
branches: branches:
- fix-wheel-2 - wheel
tags: tags:
- '*' - '*'
workflow_dispatch: workflow_dispatch:
@ -26,11 +26,11 @@ jobs:
id: set-matrix id: set-matrix
run: | run: |
# outputting for debugging purposes # outputting for debugging purposes
# python ./scripts/github_actions/generate_build_matrix.py --enable-cuda python ./scripts/github_actions/generate_build_matrix.py --enable-cuda
# MATRIX=$(python ./scripts/github_actions/generate_build_matrix.py --enable-cuda) MATRIX=$(python ./scripts/github_actions/generate_build_matrix.py --enable-cuda)
python ./scripts/github_actions/generate_build_matrix.py --enable-cuda --test-only-latest-torch # python ./scripts/github_actions/generate_build_matrix.py --enable-cuda --test-only-latest-torch
MATRIX=$(python ./scripts/github_actions/generate_build_matrix.py --enable-cuda --test-only-latest-torch) # MATRIX=$(python ./scripts/github_actions/generate_build_matrix.py --enable-cuda --test-only-latest-torch)
echo "::set-output name=matrix::${MATRIX}" echo "::set-output name=matrix::${MATRIX}"
build-manylinux-wheels: build-manylinux-wheels:
@ -65,7 +65,7 @@ jobs:
uses: addnab/docker-run-action@v3 uses: addnab/docker-run-action@v3
with: with:
image: ${{ matrix.image }} 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 }} options: -v ${{ github.workspace }}:/var/www -e IS_2_28=${{ matrix.is_2_28 }} -e PYTHON_VERSION=${{ matrix.python-version }} -e TORCH_VERSION=${{ matrix.torch }} -e CUDA_VERSION=${{ matrix.cuda }}
run: | run: |
echo "pwd: $PWD" echo "pwd: $PWD"
uname -a uname -a
@ -75,6 +75,69 @@ jobs:
python3 --version python3 --version
which python3 which python3
ls -lh /opt/python/
echo "---"
ls -lh /opt/python/cp*
ls -lh /opt/python/*/bin
echo "---"
find /opt/python/cp* -name "libpython*"
echo "-----"
find /opt/_internal/cp* -name "libpython*"
echo "-----"
find / -name "libpython*"
# cp36-cp36m
# cp37-cp37m
# cp38-cp38
# cp39-cp39
# cp310-cp310
# cp311-cp311
# cp312-cp312
# cp313-cp313
# cp313-cp313t (no gil)
if [[ $PYTHON_VERSION == "3.6" ]]; then
python_dir=/opt/python/cp36-cp36m
export PYTHONPATH=/opt/python/cp36-cp36m/lib/python3.6/site-packages:$PYTHONPATH
elif [[ $PYTHON_VERSION == "3.7" ]]; then
python_dir=/opt/python/cp37-cp37m
export PYTHONPATH=/opt/python/cp37-cp37m/lib/python3.7/site-packages:$PYTHONPATH
elif [[ $PYTHON_VERSION == "3.8" ]]; then
python_dir=/opt/python/cp38-cp38
export PYTHONPATH=/opt/python/cp38-cp38/lib/python3.8/site-packages:$PYTHONPATH
elif [[ $PYTHON_VERSION == "3.9" ]]; then
python_dir=/opt/python/cp39-cp39
export PYTHONPATH=/opt/python/cp39-cp39/lib/python3.9/site-packages:$PYTHONPATH
elif [[ $PYTHON_VERSION == "3.10" ]]; then
python_dir=/opt/python/cp310-cp310
export PYTHONPATH=/opt/python/cp310-cp310/lib/python3.10/site-packages:$PYTHONPATH
elif [[ $PYTHON_VERSION == "3.11" ]]; then
python_dir=/opt/python/cp311-cp311
export PYTHONPATH=/opt/python/cp311-cp311/lib/python3.11/site-packages:$PYTHONPATH
elif [[ $PYTHON_VERSION == "3.12" ]]; then
python_dir=/opt/python/cp312-cp312
export PYTHONPATH=/opt/python/cp312-cp312/lib/python3.12/site-packages:$PYTHONPATH
elif [[ $PYTHON_VERSION == "3.13" ]]; then
python_dir=/opt/python/cp313-cp313
export PYTHONPATH=/opt/python/cp313-cp313/lib/python3.13/site-packages:$PYTHONPATH
else
echo "Unsupported Python version $PYTHON_VERSION"
exit 1
fi
export PYTHON_INSTALL_DIR=$python_dir
export PATH=$PYTHON_INSTALL_DIR/bin:$PATH
# There are no libpython.so inside $PYTHON_INSTALL_DIR
# since they are statically linked.
python3 --version
which python3
pushd /usr/local pushd /usr/local
rm cuda rm cuda
ln -s cuda-$CUDA_VERSION cuda ln -s cuda-$CUDA_VERSION cuda
@ -93,9 +156,10 @@ jobs:
ls -lh ./wheelhouse/ ls -lh ./wheelhouse/
- name: Upload Wheel - name: Upload Wheel
uses: actions/upload-artifact@v3 if: false
uses: actions/upload-artifact@v4
with: with:
name: torch-${{ matrix.torch }}-python-${{ matrix.python-version }}-ubuntu-latest-cuda name: torch-${{ matrix.torch }}-python-${{ matrix.python-version }}-ubuntu-latest-cuda-is_2_28-${{ matrix.is_2_28 }}
path: wheelhouse/*.whl path: wheelhouse/*.whl
# https://huggingface.co/docs/hub/spaces-github-actions # https://huggingface.co/docs/hub/spaces-github-actions

View File

@ -63,7 +63,7 @@ jobs:
ls -lh ./wheelhouse/ ls -lh ./wheelhouse/
- name: Upload Wheel - name: Upload Wheel
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v4
with: with:
name: torch-${{ matrix.torch }}-python-${{ matrix.python-version }}-windows-latest-cpu name: torch-${{ matrix.torch }}-python-${{ matrix.python-version }}-windows-latest-cpu
path: wheelhouse/*.whl path: wheelhouse/*.whl

View File

@ -43,7 +43,7 @@ list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules)
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake) list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
option(BUILD_SHARED_LIBS "Whether to build shared libraries" ON) option(BUILD_SHARED_LIBS "Whether to build shared libraries" ON)
option(kaldifeat_BUILD_TESTS "Whether to build tests or not" ON) option(kaldifeat_BUILD_TESTS "Whether to build tests or not" OFF)
option(kaldifeat_BUILD_PYMODULE "Whether to build python module or not" ON) option(kaldifeat_BUILD_PYMODULE "Whether to build python module or not" ON)
message(STATUS "BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS}") message(STATUS "BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS}")

View File

@ -29,10 +29,10 @@ endif()
target_link_libraries(_kaldifeat PRIVATE kaldifeat_core) target_link_libraries(_kaldifeat PRIVATE kaldifeat_core)
if(UNIX AND NOT APPLE) if(UNIX AND NOT APPLE)
target_link_libraries(_kaldifeat PUBLIC ${TORCH_DIR}/lib/libtorch_python.so) target_link_libraries(_kaldifeat PUBLIC ${TORCH_DIR}/lib/libtorch_python.so)
target_link_libraries(_kaldifeat PUBLIC ${PYTHON_LIBRARY}) # target_link_libraries(_kaldifeat PUBLIC ${PYTHON_LIBRARY})
elseif(WIN32) elseif(WIN32)
target_link_libraries(_kaldifeat PUBLIC ${TORCH_DIR}/lib/torch_python.lib) target_link_libraries(_kaldifeat PUBLIC ${TORCH_DIR}/lib/torch_python.lib)
target_link_libraries(_kaldifeat PUBLIC ${PYTHON_LIBRARIES}) # target_link_libraries(_kaldifeat PUBLIC ${PYTHON_LIBRARIES})
endif() endif()
install(TARGETS _kaldifeat install(TARGETS _kaldifeat

View File

@ -0,0 +1,78 @@
#!/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
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
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 || \
python3 -m pip install -qq torch==$TORCH_VERSION -f https://download.pytorch.org/whl/torch_stable.html || \
python3 -m pip install -qq torch==$TORCH_VERSION -f https://download.pytorch.org/whl/torch/
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 "
nvcc --version || true
rm -rf /usr/local/cuda*
nvcc --version || true
if [[ x"$IS_2_28" == x"1" ]]; then
plat=manylinux_2_28_aarch64
else
plat=manylinux_2_17_aarch64
fi
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 $plat \
dist/*.whl
ls -lh /var/www

View File

@ -15,46 +15,13 @@ if [ -z $TORCH_VERSION ]; then
exit 1 exit 1
fi fi
yum -y install openssl-devel bzip2-devel libffi-devel xz-devel wget redhat-lsb-core
INSTALLED_PYTHON_VERSION=${PYTHON_VERSION}.2
if [[ $PYTHON_VERSION == "3.13" ]]; then
INSTALLED_PYTHON_VERSION=${PYTHON_VERSION}.0
fi
echo "Installing $INSTALLED_PYTHON_VERSION"
curl -O https://www.python.org/ftp/python/$INSTALLED_PYTHON_VERSION/Python-$INSTALLED_PYTHON_VERSION.tgz
tar xf Python-$INSTALLED_PYTHON_VERSION.tgz
pushd Python-$INSTALLED_PYTHON_VERSION
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 >/dev/null 2>&1
make install >/dev/null 2>&1
popd
export PATH=$PYTHON_INSTALL_DIR/bin:$PATH export PATH=$PYTHON_INSTALL_DIR/bin:$PATH
export LD_LIBRARY_PATH=$PYTHON_INSTALL_DIR/lib:$LD_LIBRARY_PATH export LD_LIBRARY_PATH=$PYTHON_INSTALL_DIR/lib:$LD_LIBRARY_PATH
ls -lh $PYTHON_INSTALL_DIR/lib/ ls -lh $PYTHON_INSTALL_DIR/lib/
nvcc --version || true
rm -rf /usr/local/cuda*
nvcc --version || true
python3 --version python3 --version
which python3 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 scikit-build
python3 -m pip install -U pip cmake python3 -m pip install -U pip cmake
python3 -m pip install wheel twine typing_extensions python3 -m pip install wheel twine typing_extensions
@ -73,8 +40,16 @@ export CMAKE_CUDA_COMPILER_LAUNCHER=
export KALDIFEAT_CMAKE_ARGS=" -DPYTHON_EXECUTABLE=$PYTHON_INSTALL_DIR/bin/python3 " export KALDIFEAT_CMAKE_ARGS=" -DPYTHON_EXECUTABLE=$PYTHON_INSTALL_DIR/bin/python3 "
export KALDIFEAT_MAKE_ARGS=" -j " export KALDIFEAT_MAKE_ARGS=" -j "
nvcc --version || true
rm -rf /usr/local/cuda*
nvcc --version || true
python3 setup.py bdist_wheel python3 setup.py bdist_wheel
if [[ x"$IS_2_28" == x"1" ]]; then
plat=manylinux_2_28_x86_64
else
plat=manylinux_2_17_x86_64
fi
auditwheel --verbose repair \ auditwheel --verbose repair \
--exclude libc10.so \ --exclude libc10.so \
@ -95,8 +70,7 @@ auditwheel --verbose repair \
--exclude libnvrtc.so.11.2 \ --exclude libnvrtc.so.11.2 \
--exclude libtorch_cuda_cu.so \ --exclude libtorch_cuda_cu.so \
--exclude libtorch_cuda_cpp.so \ --exclude libtorch_cuda_cpp.so \
--plat manylinux_2_17_x86_64 \ --plat $plat \
-w /var/www/wheelhouse \
dist/*.whl dist/*.whl
ls -lh /var/www ls -lh /var/www

View File

@ -27,49 +27,7 @@ if [[ $TORCH_VERSION =~ 2.2.* && $CUDA_VERSION =~ 12.* ]]; then
export TORCH_CUDA_ARCH_LIST="8.0 8.6 8.9 9.0" export TORCH_CUDA_ARCH_LIST="8.0 8.6 8.9 9.0"
fi fi
# python3 -m pip install scikit-build
yum -y install openssl-devel bzip2-devel libffi-devel xz-devel wget redhat-lsb-core
INSTALLED_PYTHON_VERSION=${PYTHON_VERSION}.2
if [[ $PYTHON_VERSION == "3.13" ]]; then
INSTALLED_PYTHON_VERSION=${PYTHON_VERSION}.0
fi
echo "Installing $INSTALLED_PYTHON_VERSION"
curl -O https://www.python.org/ftp/python/$INSTALLED_PYTHON_VERSION/Python-$INSTALLED_PYTHON_VERSION.tgz
tar xf Python-$INSTALLED_PYTHON_VERSION.tgz
pushd Python-$INSTALLED_PYTHON_VERSION
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 >/dev/null 2>&1
make install >/dev/null 2>&1
popd
echo "pwd: $PWD"
# rm -rf Python-${PYTHON_VERSION}.2
export PATH=$PYTHON_INSTALL_DIR/bin:$PATH
export LD_LIBRARY_PATH=$PYTHON_INSTALL_DIR/lib:$LD_LIBRARY_PATH
ls -lh $PYTHON_INSTALL_DIR
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 -U pip cmake
python3 -m pip install wheel twine typing_extensions python3 -m pip install wheel twine typing_extensions
python3 -m pip install bs4 requests tqdm auditwheel python3 -m pip install bs4 requests tqdm auditwheel
@ -77,6 +35,9 @@ python3 -m pip install bs4 requests tqdm auditwheel
echo "Installing torch" echo "Installing torch"
./install_torch.sh ./install_torch.sh
python3 -c "import torch; print(torch.__file__)"
# -- Autodetected CUDA architecture(s): 5.0;8.0;8.6;8.9;9.0;9.0a # -- Autodetected CUDA architecture(s): 5.0;8.0;8.6;8.9;9.0;9.0a
# CMake Error at /Python-3.8.2/py-3.8/lib/python3.8/site-packages/torch/share/cmake/Caffe2/Modules_CUDA_fix/upstream/FindCUDA/select_compute_arch.cmake:227 (message): # CMake Error at /Python-3.8.2/py-3.8/lib/python3.8/site-packages/torch/share/cmake/Caffe2/Modules_CUDA_fix/upstream/FindCUDA/select_compute_arch.cmake:227 (message):
# Unknown CUDA Architecture Name 9.0a in CUDA_SELECT_NVCC_ARCH_FLAGS # Unknown CUDA Architecture Name 9.0a in CUDA_SELECT_NVCC_ARCH_FLAGS
@ -89,6 +50,41 @@ echo "Installing torch"
# CMakeLists.txt:62 (include) # CMakeLists.txt:62 (include)
sed -i.bak /9.0a/d /Python-*/py-3.*/lib/python3.*/site-packages/torch/share/cmake/Caffe2/Modules_CUDA_fix/upstream/FindCUDA/select_compute_arch.cmake || true sed -i.bak /9.0a/d /Python-*/py-3.*/lib/python3.*/site-packages/torch/share/cmake/Caffe2/Modules_CUDA_fix/upstream/FindCUDA/select_compute_arch.cmake || true
if [[ x"$IS_2_28" != x"1" ]]; then
yum -y install openssl-devel
fi
yum -y install zlib-devel bzip2-devel libffi-devel xz-devel wget redhat-lsb-core
INSTALLED_PYTHON_VERSION=${PYTHON_VERSION}.2
if [[ $PYTHON_VERSION == "3.13" ]]; then
INSTALLED_PYTHON_VERSION=${PYTHON_VERSION}.0
fi
echo "Installing $INSTALLED_PYTHON_VERSION"
curl -O https://www.python.org/ftp/python/$INSTALLED_PYTHON_VERSION/Python-$INSTALLED_PYTHON_VERSION.tgz
tar xf Python-$INSTALLED_PYTHON_VERSION.tgz
pushd Python-$INSTALLED_PYTHON_VERSION
PYTHON_INSTALL_DIR=$PWD/py-${PYTHON_VERSION}
if [[ $PYTHON_VERSION =~ 3.1. && x"$IS_2_28" != x"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 >/dev/null
make install >/dev/null
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
rm -rf ~/.cache/pip >/dev/null 2>&1 rm -rf ~/.cache/pip >/dev/null 2>&1
yum clean all >/dev/null 2>&1 yum clean all >/dev/null 2>&1
@ -98,9 +94,20 @@ export CMAKE_CUDA_COMPILER_LAUNCHER=
export KALDIFEAT_CMAKE_ARGS=" -DPYTHON_EXECUTABLE=$PYTHON_INSTALL_DIR/bin/python3 " export KALDIFEAT_CMAKE_ARGS=" -DPYTHON_EXECUTABLE=$PYTHON_INSTALL_DIR/bin/python3 "
export KALDIFEAT_MAKE_ARGS=" -j2 " export KALDIFEAT_MAKE_ARGS=" -j2 "
echo "KALDIFEAT_CMAKE_ARGS: $KALDIFEAT_CMAKE_ARGS"
python3 setup.py bdist_wheel python3 setup.py bdist_wheel
if [[ x"$IS_2_28" == x"1" ]]; then
plat=manylinux_2_28_x86_64
else
plat=manylinux_2_17_x86_64
fi
export PATH=$PYTHON_INSTALL_DIR/bin:$PATH
python3 --version
which python3
auditwheel --verbose repair \ auditwheel --verbose repair \
--exclude libc10.so \ --exclude libc10.so \
--exclude libc10_cuda.so \ --exclude libc10_cuda.so \
@ -140,7 +147,7 @@ auditwheel --verbose repair \
--exclude libshm.so \ --exclude libshm.so \
--exclude libtorch_cuda_cpp.so \ --exclude libtorch_cuda_cpp.so \
--exclude libtorch_cuda_cu.so \ --exclude libtorch_cuda_cu.so \
--plat manylinux_2_17_x86_64 \ --plat $plat \
-w /var/www/wheelhouse \ -w /var/www/wheelhouse \
dist/*.whl dist/*.whl

View File

@ -1,6 +1,15 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
# Copyright 2022 Xiaomi Corp. (authors: Fangjun Kuang) # Copyright 2022 Xiaomi Corp. (authors: Fangjun Kuang)
"""
See also
https://github.com/pytorch/test-infra/blob/main/.github/workflows/test_build_wheels_linux_with_cuda.yml
https://github.com/pytorch/test-infra/blob/main/.github/workflows/test_build_wheels_linux_without_cuda.yml
https://github.com/pytorch/test-infra/actions/workflows/test_build_wheels_linux_with_cuda.yml
https://github.com/pytorch/test-infra/blob/main/tools/scripts/generate_binary_build_matrix.py
"""
import argparse import argparse
import json import json
@ -40,6 +49,13 @@ def get_args():
help="True for macOS", help="True for macOS",
) )
parser.add_argument(
"--for-arm64",
action="store_true",
default=False,
help="True for arm64",
)
parser.add_argument( parser.add_argument(
"--test-only-latest-torch", "--test-only-latest-torch",
action="store_true", action="store_true",
@ -50,7 +66,9 @@ def get_args():
return parser.parse_args() return parser.parse_args()
def generate_build_matrix(enable_cuda, for_windows, for_macos, test_only_latest_torch): def generate_build_matrix(
enable_cuda, for_windows, for_macos, test_only_latest_torch, for_arm64
):
matrix = { matrix = {
# 1.5.x is removed because there are compilation errors. # 1.5.x is removed because there are compilation errors.
# See # See
@ -69,46 +87,46 @@ def generate_build_matrix(enable_cuda, for_windows, for_macos, test_only_latest_
# "python-version": ["3.6", "3.7", "3.8"], # "python-version": ["3.6", "3.7", "3.8"],
# "cuda": ["10.1", "10.2"] if not for_windows else ["10.1.243", "10.2.89"], # "cuda": ["10.1", "10.2"] if not for_windows else ["10.1.243", "10.2.89"],
# }, # },
"1.7.0": { # "1.7.0": {
"python-version": ["3.6", "3.7", "3.8"], # "python-version": ["3.6", "3.7", "3.8"],
"cuda": ( # "cuda": (
["10.1", "10.2", "11.0"] # ["10.1", "10.2", "11.0"]
if not for_windows # if not for_windows
else ["10.1.243", "10.2.89", "11.0.3"] # else ["10.1.243", "10.2.89", "11.0.3"]
), # ),
}, # },
"1.7.1": { # "1.7.1": {
"python-version": ["3.6", "3.7", "3.8", "3.9"], # "python-version": ["3.6", "3.7", "3.8", "3.9"],
"cuda": ( # "cuda": (
["10.1", "10.2", "11.0"] # ["10.1", "10.2", "11.0"]
if not for_windows # if not for_windows
else ["10.1.243", "10.2.89", "11.0.3"] # else ["10.1.243", "10.2.89", "11.0.3"]
), # ),
}, # },
"1.8.0": { # "1.8.0": {
"python-version": ["3.6", "3.7", "3.8", "3.9"], # "python-version": ["3.6", "3.7", "3.8", "3.9"],
"cuda": ( # "cuda": (
["10.1", "10.2", "11.1"] # ["10.1", "10.2", "11.1"]
if not for_windows # if not for_windows
else ["10.1.243", "10.2.89", "11.1.1"] # else ["10.1.243", "10.2.89", "11.1.1"]
), # ),
}, # },
"1.8.1": { # "1.8.1": {
"python-version": ["3.6", "3.7", "3.8", "3.9"], # "python-version": ["3.6", "3.7", "3.8", "3.9"],
"cuda": ( # "cuda": (
["10.1", "10.2", "11.1"] # ["10.1", "10.2", "11.1"]
if not for_windows # if not for_windows
else ["10.1.243", "10.2.89", "11.1.1"] # else ["10.1.243", "10.2.89", "11.1.1"]
), # ),
}, # },
"1.9.0": { # "1.9.0": {
"python-version": ["3.6", "3.7", "3.8", "3.9"], # "python-version": ["3.6", "3.7", "3.8", "3.9"],
"cuda": ["10.2", "11.1"] if not for_windows else ["10.2.89", "11.1.1"], # "cuda": ["10.2", "11.1"] if not for_windows else ["10.2.89", "11.1.1"],
}, # },
"1.9.1": { # "1.9.1": {
"python-version": ["3.6", "3.7", "3.8", "3.9"], # "python-version": ["3.6", "3.7", "3.8", "3.9"],
"cuda": ["10.2", "11.1"] if not for_windows else ["10.2.89", "11.1.1"], # "cuda": ["10.2", "11.1"] if not for_windows else ["10.2.89", "11.1.1"],
}, # },
"1.10.0": { "1.10.0": {
"python-version": ["3.6", "3.7", "3.8", "3.9"], "python-version": ["3.6", "3.7", "3.8", "3.9"],
"cuda": ( "cuda": (
@ -305,9 +323,18 @@ def generate_build_matrix(enable_cuda, for_windows, for_macos, test_only_latest_
matrix["1.13.1"]["python-version"].remove("3.11") matrix["1.13.1"]["python-version"].remove("3.11")
excluded_python_versions = ["3.6"] excluded_python_versions = ["3.6"]
enabled_torch_versions = ["1.10.0"]
enabled_torch_versions += ["1.13.0", "1.13.1"]
min_torch_version = "2.0.0"
ans = [] ans = []
for torch, python_cuda in matrix.items(): for torch, python_cuda in matrix.items():
if enabled_torch_versions and torch not in enabled_torch_versions:
if not version_ge(torch, min_torch_version):
continue
python_versions = python_cuda["python-version"] python_versions = python_cuda["python-version"]
cuda_versions = python_cuda["cuda"] cuda_versions = python_cuda["cuda"]
if enable_cuda: if enable_cuda:
@ -318,12 +345,30 @@ def generate_build_matrix(enable_cuda, for_windows, for_macos, test_only_latest_
if c in ["10.1", "11.0"]: if c in ["10.1", "11.0"]:
# no docker image for cuda 10.1 and 11.0 # no docker image for cuda 10.1 and 11.0
continue continue
if version_ge(torch, "2.7.0") or (
version_ge(torch, "2.6.0") and c == "12.6"
):
# case 1: torch >= 2.7
# case 2: torch == 2.6.0 && cuda == 12.6
ans.append(
{
"torch": torch,
"python-version": p,
"cuda": c,
"image": f"pytorch/manylinux2_28-builder:cuda{c}",
"is_2_28": "1",
}
)
continue
ans.append( ans.append(
{ {
"torch": torch, "torch": torch,
"python-version": p, "python-version": p,
"cuda": c, "cuda": c,
"image": f"pytorch/manylinux-builder:cuda{c}", "image": f"pytorch/manylinux-builder:cuda{c}",
"is_2_28": "0",
} }
) )
else: else:
@ -336,13 +381,27 @@ def generate_build_matrix(enable_cuda, for_windows, for_macos, test_only_latest_
ans.append({"torch": torch, "python-version": p}) ans.append({"torch": torch, "python-version": p})
elif for_macos: elif for_macos:
ans.append({"torch": torch, "python-version": p}) ans.append({"torch": torch, "python-version": p})
elif version_ge(torch, "2.6.0"):
ans.append(
{
"torch": torch,
"python-version": p,
"image": "pytorch/manylinux2_28-builder:cpu"
if not for_arm64
else "pytorch/manylinux2_28_aarch64-builder:cpu-aarch64",
"is_2_28": "1",
}
)
elif version_ge(torch, "2.4.0"): elif version_ge(torch, "2.4.0"):
ans.append( ans.append(
{ {
"torch": torch, "torch": torch,
"python-version": p, "python-version": p,
# "image": "pytorch/manylinux-builder:cpu-2.4", # "image": "pytorch/manylinux-builder:cpu-2.4",
"image": "pytorch/manylinux-builder:cpu-27677ead7c8293c299a885ae2c474bf445e653a5", "image": "pytorch/manylinux-builder:cpu-27677ead7c8293c299a885ae2c474bf445e653a5"
if not for_arm64
else "pytorch/manylinuxaarch64-builder:cpu-aarch64-195148266541a9789074265141cb7dc19dc14c54",
"is_2_28": "0",
} }
) )
elif version_ge(torch, "2.2.0"): elif version_ge(torch, "2.2.0"):
@ -350,7 +409,10 @@ def generate_build_matrix(enable_cuda, for_windows, for_macos, test_only_latest_
{ {
"torch": torch, "torch": torch,
"python-version": p, "python-version": p,
"image": "pytorch/manylinux-builder:cpu-2.2", "image": "pytorch/manylinux-builder:cpu-2.2"
if not for_arm64
else "pytorch/manylinuxaarch64-builder:cpu-aarch64-195148266541a9789074265141cb7dc19dc14c54",
"is_2_28": "0",
} }
) )
else: else:
@ -358,7 +420,10 @@ def generate_build_matrix(enable_cuda, for_windows, for_macos, test_only_latest_
{ {
"torch": torch, "torch": torch,
"python-version": p, "python-version": p,
"image": f"pytorch/manylinux-builder:cuda10.2", "image": "pytorch/manylinux-builder:cuda10.2"
if not for_arm64
else "pytorch/manylinuxaarch64-builder:cpu-aarch64-195148266541a9789074265141cb7dc19dc14c54",
"is_2_28": "0",
} }
) )
@ -371,6 +436,7 @@ def main():
enable_cuda=args.enable_cuda, enable_cuda=args.enable_cuda,
for_windows=args.for_windows, for_windows=args.for_windows,
for_macos=args.for_macos, for_macos=args.for_macos,
for_arm64=args.for_arm64,
test_only_latest_torch=args.test_only_latest_torch, test_only_latest_torch=args.test_only_latest_torch,
) )

View File

@ -280,4 +280,6 @@ else
retry python3 -m pip install -q $package -f $url retry python3 -m pip install -q $package -f $url
fi fi
rm -rfv ~/.cache/pip python3 -m torch.utils.collect_env
rm -rf ~/.cache/pip