mirror of
https://github.com/csukuangfj/kaldifeat.git
synced 2025-08-09 18:12:17 +00:00
Fix building wheels for torch 2.1.x (#81)
This commit is contained in:
parent
46ab855aa5
commit
7912c2f442
2
.github/workflows/build-doc.yml
vendored
2
.github/workflows/build-doc.yml
vendored
@ -35,7 +35,7 @@ jobs:
|
||||
python-version: [3.8]
|
||||
steps:
|
||||
# refer to https://github.com/actions/checkout
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
|
6
.github/workflows/macos-cpu-wheels.yml
vendored
6
.github/workflows/macos-cpu-wheels.yml
vendored
@ -2,6 +2,8 @@ name: build-wheels-cpu-macos
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- fix-wheel
|
||||
tags:
|
||||
- '*'
|
||||
workflow_dispatch:
|
||||
@ -17,7 +19,7 @@ jobs:
|
||||
outputs:
|
||||
matrix: ${{ steps.set-matrix.outputs.matrix }}
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Generating build matrix
|
||||
@ -38,7 +40,7 @@ jobs:
|
||||
${{ fromJson(needs.generate_build_matrix.outputs.matrix) }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
|
2
.github/workflows/publish_to_pypi.yml
vendored
2
.github/workflows/publish_to_pypi.yml
vendored
@ -26,7 +26,7 @@ jobs:
|
||||
pypi:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
|
6
.github/workflows/run-tests-macos-cpu.yml
vendored
6
.github/workflows/run-tests-macos-cpu.yml
vendored
@ -32,7 +32,7 @@ jobs:
|
||||
outputs:
|
||||
matrix: ${{ steps.set-matrix.outputs.matrix }}
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Generating build matrix
|
||||
@ -45,14 +45,14 @@ jobs:
|
||||
|
||||
run_tests_macos_cpu:
|
||||
needs: generate_build_matrix
|
||||
runs-on: macos-10.15
|
||||
runs-on: macos-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
${{ fromJson(needs.generate_build_matrix.outputs.matrix) }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
|
10
.github/workflows/run-tests-ubuntu-cpu.yml
vendored
10
.github/workflows/run-tests-ubuntu-cpu.yml
vendored
@ -32,7 +32,7 @@ jobs:
|
||||
outputs:
|
||||
matrix: ${{ steps.set-matrix.outputs.matrix }}
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Generating build matrix
|
||||
@ -52,7 +52,7 @@ jobs:
|
||||
${{ fromJson(needs.generate_build_matrix.outputs.matrix) }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
@ -61,12 +61,6 @@ jobs:
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
|
||||
- name: Install GCC 7
|
||||
run: |
|
||||
sudo apt-get install -y gcc-7 g++-7
|
||||
echo "CC=/usr/bin/gcc-7" >> $GITHUB_ENV
|
||||
echo "CXX=/usr/bin/g++-7" >> $GITHUB_ENV
|
||||
|
||||
- name: Install PyTorch ${{ matrix.torch }}
|
||||
shell: bash
|
||||
run: |
|
||||
|
14
.github/workflows/run-tests-ubuntu-cuda.yml
vendored
14
.github/workflows/run-tests-ubuntu-cuda.yml
vendored
@ -32,7 +32,7 @@ jobs:
|
||||
outputs:
|
||||
matrix: ${{ steps.set-matrix.outputs.matrix }}
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Generating build matrix
|
||||
@ -45,14 +45,14 @@ jobs:
|
||||
|
||||
run_tests_ubuntu_cuda:
|
||||
needs: generate_build_matrix
|
||||
runs-on: ubuntu-18.04
|
||||
runs-on: ubuntu-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
${{ fromJson(needs.generate_build_matrix.outputs.matrix) }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
@ -61,14 +61,6 @@ jobs:
|
||||
with:
|
||||
python-version: ${{ matrix.python-version }}
|
||||
|
||||
- name: Install GCC 7
|
||||
if: startsWith(matrix.os, 'ubuntu')
|
||||
run: |
|
||||
sudo apt-get install -y gcc-7 g++-7
|
||||
echo "CC=/usr/bin/gcc-7" >> $GITHUB_ENV
|
||||
echo "CXX=/usr/bin/g++-7" >> $GITHUB_ENV
|
||||
|
||||
|
||||
- name: Install CUDA Toolkit ${{ matrix.cuda }}
|
||||
shell: bash
|
||||
env:
|
||||
|
6
.github/workflows/run-tests-windows-cpu.yml
vendored
6
.github/workflows/run-tests-windows-cpu.yml
vendored
@ -32,7 +32,7 @@ jobs:
|
||||
outputs:
|
||||
matrix: ${{ steps.set-matrix.outputs.matrix }}
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Generating build matrix
|
||||
@ -46,14 +46,14 @@ jobs:
|
||||
run_tests_windows_cpu:
|
||||
# see https://github.com/actions/virtual-environments/blob/win19/20210525.0/images/win/Windows2019-Readme.md
|
||||
needs: generate_build_matrix
|
||||
runs-on: windows-2019
|
||||
runs-on: windows-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
${{ fromJson(needs.generate_build_matrix.outputs.matrix) }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
|
6
.github/workflows/run-tests-windows-cuda.yml
vendored
6
.github/workflows/run-tests-windows-cuda.yml
vendored
@ -33,7 +33,7 @@ jobs:
|
||||
outputs:
|
||||
matrix: ${{ steps.set-matrix.outputs.matrix }}
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Generating build matrix
|
||||
@ -46,14 +46,14 @@ jobs:
|
||||
|
||||
run_tests_windows_cuda:
|
||||
needs: generate_build_matrix
|
||||
runs-on: windows-2019
|
||||
runs-on: windows-latest
|
||||
strategy:
|
||||
fail-fast: false
|
||||
matrix:
|
||||
${{ fromJson(needs.generate_build_matrix.outputs.matrix) }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
|
6
.github/workflows/style_check.yml
vendored
6
.github/workflows/style_check.yml
vendored
@ -29,12 +29,12 @@ jobs:
|
||||
runs-on: ${{ matrix.os }}
|
||||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-18.04, macos-10.15]
|
||||
python-version: [3.7, 3.8, 3.9]
|
||||
os: [ubuntu-latest, macos-latest]
|
||||
python-version: ["3.8"]
|
||||
fail-fast: false
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
|
2
.github/workflows/test-wheels.yml
vendored
2
.github/workflows/test-wheels.yml
vendored
@ -20,7 +20,7 @@ jobs:
|
||||
python-version: ["3.8", "3.9", "3.10"]
|
||||
steps:
|
||||
# refer to https://github.com/actions/checkout
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
|
6
.github/workflows/ubuntu-cpu-wheels.yml
vendored
6
.github/workflows/ubuntu-cpu-wheels.yml
vendored
@ -2,6 +2,8 @@ name: build-wheels-cpu-ubuntu
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- fix-wheel
|
||||
tags:
|
||||
- '*'
|
||||
workflow_dispatch:
|
||||
@ -17,7 +19,7 @@ jobs:
|
||||
outputs:
|
||||
matrix: ${{ steps.set-matrix.outputs.matrix }}
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Generating build matrix
|
||||
@ -38,7 +40,7 @@ jobs:
|
||||
${{ fromJson(needs.generate_build_matrix.outputs.matrix) }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
|
8
.github/workflows/ubuntu-cuda-wheels.yml
vendored
8
.github/workflows/ubuntu-cuda-wheels.yml
vendored
@ -2,6 +2,8 @@ name: build-wheels-cuda-ubuntu
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- fix-wheel
|
||||
tags:
|
||||
- '*'
|
||||
workflow_dispatch:
|
||||
@ -17,7 +19,7 @@ jobs:
|
||||
outputs:
|
||||
matrix: ${{ steps.set-matrix.outputs.matrix }}
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Generating build matrix
|
||||
@ -38,7 +40,7 @@ jobs:
|
||||
${{ fromJson(needs.generate_build_matrix.outputs.matrix) }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
@ -79,7 +81,7 @@ jobs:
|
||||
ls -lh ./wheelhouse/
|
||||
|
||||
- name: Upload Wheel
|
||||
uses: actions/upload-artifact@v2
|
||||
uses: actions/upload-artifact@v3
|
||||
with:
|
||||
name: torch-${{ matrix.torch }}-python-${{ matrix.python-version }}-ubuntu-latest-cuda
|
||||
path: wheelhouse/*.whl
|
||||
|
6
.github/workflows/windows-x64-cpu-wheels.yml
vendored
6
.github/workflows/windows-x64-cpu-wheels.yml
vendored
@ -2,6 +2,8 @@ name: build-wheels-cpu-win64
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- fix-wheel
|
||||
tags:
|
||||
- '*'
|
||||
workflow_dispatch:
|
||||
@ -17,7 +19,7 @@ jobs:
|
||||
outputs:
|
||||
matrix: ${{ steps.set-matrix.outputs.matrix }}
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
- name: Generating build matrix
|
||||
@ -38,7 +40,7 @@ jobs:
|
||||
${{ fromJson(needs.generate_build_matrix.outputs.matrix) }}
|
||||
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
- uses: actions/checkout@v4
|
||||
with:
|
||||
fetch-depth: 0
|
||||
|
||||
|
@ -32,10 +32,11 @@ if(NOT CMAKE_BUILD_TYPE)
|
||||
set(CMAKE_BUILD_TYPE Release)
|
||||
endif()
|
||||
|
||||
set(CMAKE_CXX_STANDARD 14 CACHE STRING "The C++ version to be used.")
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
|
||||
if (NOT CMAKE_CXX_STANDARD)
|
||||
set(CMAKE_CXX_STANDARD 14 CACHE STRING "The C++ version to be used.")
|
||||
endif()
|
||||
message(STATUS "C++ Standard version: ${CMAKE_CXX_STANDARD}")
|
||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
||||
|
||||
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake/Modules)
|
||||
list(APPEND CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)
|
||||
@ -44,6 +45,7 @@ option(BUILD_SHARED_LIBS "Whether to build shared libraries" ON)
|
||||
option(kaldifeat_BUILD_TESTS "Whether to build tests or not" ON)
|
||||
option(kaldifeat_BUILD_PYMODULE "Whether to build python module or not" ON)
|
||||
|
||||
|
||||
message(STATUS "BUILD_SHARED_LIBS ${BUILD_SHARED_LIBS}")
|
||||
|
||||
if(BUILD_SHARED_LIBS AND MSVC)
|
||||
|
@ -8,9 +8,15 @@ import sys
|
||||
from pathlib import Path
|
||||
|
||||
import setuptools
|
||||
import torch
|
||||
from setuptools.command.build_ext import build_ext
|
||||
|
||||
|
||||
def get_pytorch_version():
|
||||
# if it is 1.7.1+cuda101, then strip +cuda101
|
||||
return torch.__version__.split("+")[0]
|
||||
|
||||
|
||||
def is_for_pypi():
|
||||
ans = os.environ.get("KALDIFEAT_IS_FOR_PYPI", None)
|
||||
return ans is not None
|
||||
@ -39,7 +45,6 @@ try:
|
||||
# -linux_x86_64.whl
|
||||
self.root_is_pure = False
|
||||
|
||||
|
||||
except ImportError:
|
||||
bdist_wheel = None
|
||||
|
||||
@ -70,6 +75,12 @@ class BuildExtension(build_ext):
|
||||
extra_cmake_args = " -Dkaldifeat_BUILD_TESTS=OFF "
|
||||
extra_cmake_args += f" -DCMAKE_INSTALL_PREFIX={Path(self.build_lib).resolve()}/kaldifeat " # noqa
|
||||
|
||||
major, minor = get_pytorch_version().split(".")[:2]
|
||||
major = int(major)
|
||||
minor = int(minor)
|
||||
if major > 2 or (major == 2 and minor >= 1):
|
||||
extra_cmake_args += f" -DCMAKE_CXX_STANDARD=17 "
|
||||
|
||||
if "PYTHON_EXECUTABLE" not in cmake_args:
|
||||
print(f"Setting PYTHON_EXECUTABLE to {sys.executable}")
|
||||
cmake_args += f" -DPYTHON_EXECUTABLE={sys.executable}"
|
||||
@ -103,9 +114,7 @@ class BuildExtension(build_ext):
|
||||
else:
|
||||
if make_args == "" and system_make_args == "":
|
||||
print("For fast compilation, run:")
|
||||
print(
|
||||
'export KALDIFEAT_MAKE_ARGS="-j"; python setup.py install'
|
||||
)
|
||||
print('export KALDIFEAT_MAKE_ARGS="-j"; python setup.py install')
|
||||
make_args = " -j4 "
|
||||
print("Setting make_args to '-j4'")
|
||||
|
||||
|
@ -18,7 +18,7 @@ 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
|
||||
# valid values: 10.2, 11.1, 11.3, 11.6, 11.7, 11.8, 12.1
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@ -43,8 +43,12 @@ make install >/dev/null 2>&1
|
||||
|
||||
popd
|
||||
|
||||
echo "pwd: $PWD"
|
||||
# rm -rf Python-${PYTHON_VERSION}.3
|
||||
|
||||
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
|
||||
@ -63,8 +67,8 @@ python3 -m pip install bs4 requests tqdm auditwheel
|
||||
echo "Installing torch"
|
||||
./install_torch.sh
|
||||
|
||||
rm -rf ~/.cache/pip
|
||||
yum clean all
|
||||
rm -rf ~/.cache/pip >/dev/null 2>&1
|
||||
yum clean all >/dev/null 2>&1
|
||||
|
||||
cd /var/www
|
||||
|
||||
|
@ -147,9 +147,16 @@ def generate_build_matrix(enable_cuda, for_windows, for_macos, test_only_latest_
|
||||
if not for_windows
|
||||
else ["11.7.1", "11.8.0"],
|
||||
},
|
||||
"2.1.0": {
|
||||
"python-version": ["3.8", "3.9", "3.10", "3.11"],
|
||||
"cuda": ["11.8", "12.1"] # default 12.1
|
||||
if not for_windows
|
||||
else ["11.8.0", "12.1.0"],
|
||||
},
|
||||
# https://github.com/Jimver/cuda-toolkit/blob/master/src/links/windows-links.ts
|
||||
}
|
||||
if test_only_latest_torch:
|
||||
latest = "2.0.1"
|
||||
latest = "2.1.0"
|
||||
matrix = {latest: matrix[latest]}
|
||||
|
||||
if for_windows or for_macos:
|
||||
|
@ -49,6 +49,12 @@ case "$cuda" in
|
||||
11.7)
|
||||
url=https://developer.download.nvidia.com/compute/cuda/11.7.1/local_installers/cuda_11.7.1_515.65.01_linux.run
|
||||
;;
|
||||
11.8)
|
||||
url=https://developer.download.nvidia.com/compute/cuda/11.8.0/local_installers/cuda_11.8.0_520.61.05_linux.run
|
||||
;;
|
||||
12.1)
|
||||
url=https://developer.download.nvidia.com/compute/cuda/12.1.0/local_installers/cuda_12.1.0_530.30.02_linux.run
|
||||
;;
|
||||
*)
|
||||
echo "Unknown cuda version: $cuda"
|
||||
exit 1
|
||||
@ -63,10 +69,21 @@ retry curl -LSs -O $url
|
||||
filename=$(basename $url)
|
||||
echo "filename: $filename"
|
||||
chmod +x ./$filename
|
||||
sudo ./$filename --toolkit --silent
|
||||
|
||||
ls -lh
|
||||
ls -lh /usr/local
|
||||
|
||||
sudo ./$filename \
|
||||
--silent \
|
||||
--toolkit \
|
||||
--no-opengl-libs \
|
||||
--no-drm \
|
||||
--no-man-page
|
||||
|
||||
rm -fv ./$filename
|
||||
|
||||
export CUDA_HOME=/usr/local/cuda
|
||||
export PATH=$CUDA_HOME/bin:$PATH
|
||||
export LD_LIBRARY_PATH=$CUDA_HOME/lib:$LD_LIBRARY_PATH
|
||||
export LD_LIBRARY_PATH=$CUDA_HOME/lib64:$LD_LIBRARY_PATH
|
||||
ls -lh $CUDA_HOME
|
||||
|
@ -42,6 +42,12 @@ case $cuda in
|
||||
11.7)
|
||||
filename=cudnn-11.3-linux-x64-v8.2.0.53.tgz
|
||||
;;
|
||||
11.8)
|
||||
filename=cudnn-11.3-linux-x64-v8.2.0.53.tgz
|
||||
;;
|
||||
12.1)
|
||||
filename=cudnn-linux-x86_64-8.9.5.29_cuda12-archive.tar.xz
|
||||
;;
|
||||
*)
|
||||
echo "Unsupported cuda version: $cuda"
|
||||
exit 1
|
||||
|
@ -14,8 +14,11 @@
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
torch=$TORCH_VERSION
|
||||
cuda=$CUDA_VERSION
|
||||
if [ x"$TORCH_VERSION" != x"" ] && [ x"$CUDA_VERSION" != x"" ]; then
|
||||
torch=$TORCH_VERSION
|
||||
cuda=$CUDA_VERSION
|
||||
fi
|
||||
|
||||
case ${torch} in
|
||||
1.5.*)
|
||||
case ${cuda} in
|
||||
@ -169,6 +172,19 @@ case ${torch} in
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
2.1.*)
|
||||
case ${cuda} in
|
||||
11.8)
|
||||
package="torch==${torch}+cu118"
|
||||
url=https://download.pytorch.org/whl/torch_stable.html
|
||||
;;
|
||||
12.1)
|
||||
package="torch==${torch}"
|
||||
# Leave it empty to use PyPI.
|
||||
url=
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
*)
|
||||
echo "Unsupported PyTorch version: ${torch}"
|
||||
exit 1
|
||||
|
Loading…
x
Reference in New Issue
Block a user