mirror of
https://github.com/csukuangfj/kaldifeat.git
synced 2025-08-12 19:42:17 +00:00
Compare commits
48 Commits
Author | SHA1 | Date | |
---|---|---|---|
|
9165e73a3b | ||
|
8cda08e0c5 | ||
|
6edd6a8370 | ||
|
0ecdee6e88 | ||
|
3f79fbbd6d | ||
|
c1aefb643e | ||
|
e485c5749b | ||
|
e05540cfad | ||
|
5f9602afab | ||
|
a39a011de9 | ||
|
eeefc87660 | ||
|
0355ed8ced | ||
|
f36767ed1d | ||
|
40cc0a4a2c | ||
|
843763fd05 | ||
|
5dee672556 | ||
|
2a8a993f15 | ||
|
2e042b356e | ||
|
b75abef4c0 | ||
|
4fd12b48b8 | ||
|
f834ad861d | ||
|
352aa43ce3 | ||
|
c1adbda9f0 | ||
|
2624da8275 | ||
|
20379449fc | ||
|
01aed93b1b | ||
|
7912c2f442 | ||
|
46ab855aa5 | ||
|
b30f385898 | ||
|
9fae1afa65 | ||
|
5a5895d20b | ||
|
6f5ab0ee14 | ||
|
dde905597c | ||
|
3c78253a56 | ||
|
64b6e7fcc5 | ||
|
114ea348a7 | ||
|
af6e61a5a3 | ||
|
b65c799b4e | ||
|
6c60c618e6 | ||
|
1868136b40 | ||
|
6be131252a | ||
|
17861dce6b | ||
|
9b79da9128 | ||
|
bf2047023f | ||
|
9fdc43df23 | ||
|
749eff994f | ||
|
94a567c638 | ||
|
8ee0c34d3a |
21
.github/workflows/build-doc.yml
vendored
21
.github/workflows/build-doc.yml
vendored
@ -23,6 +23,7 @@ on:
|
|||||||
branches:
|
branches:
|
||||||
- master
|
- master
|
||||||
- doc
|
- doc
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
build-doc:
|
build-doc:
|
||||||
@ -34,7 +35,7 @@ jobs:
|
|||||||
python-version: [3.8]
|
python-version: [3.8]
|
||||||
steps:
|
steps:
|
||||||
# refer to https://github.com/actions/checkout
|
# refer to https://github.com/actions/checkout
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
@ -46,12 +47,30 @@ jobs:
|
|||||||
- name: Display Python version
|
- name: Display Python version
|
||||||
run: python -c "import sys; print(sys.version)"
|
run: python -c "import sys; print(sys.version)"
|
||||||
|
|
||||||
|
- name: Update wheels
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
export KALDIFEAT_DIR=$PWD
|
||||||
|
ls -lh $KALDIFEAT_DIR
|
||||||
|
|
||||||
|
export GIT_LFS_SKIP_SMUDGE=1
|
||||||
|
export GIT_CLONE_PROTECTION_ACTIVE=false
|
||||||
|
git clone https://huggingface.co/csukuangfj/kaldifeat huggingface
|
||||||
|
cd huggingface
|
||||||
|
|
||||||
|
./run.sh
|
||||||
|
|
||||||
- name: Build doc
|
- name: Build doc
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
cd doc
|
cd doc
|
||||||
|
git status
|
||||||
python3 -m pip install -r ./requirements.txt
|
python3 -m pip install -r ./requirements.txt
|
||||||
make html
|
make html
|
||||||
|
cp source/cpu.html build/html/
|
||||||
|
cp source/cuda.html build/html/
|
||||||
|
cp source/cpu-cn.html build/html/
|
||||||
|
cp source/cuda-cn.html build/html/
|
||||||
touch build/html/.nojekyll
|
touch build/html/.nojekyll
|
||||||
|
|
||||||
- name: Deploy
|
- name: Deploy
|
||||||
|
111
.github/workflows/build_conda_macos_cpu.yml
vendored
111
.github/workflows/build_conda_macos_cpu.yml
vendored
@ -1,111 +0,0 @@
|
|||||||
# Copyright 2021 Xiaomi Corp. (author: Fangjun Kuang)
|
|
||||||
|
|
||||||
# See ../../LICENSE for clarification regarding multiple authors
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
|
|
||||||
# refer to https://github.com/actions/starter-workflows/pull/47/files
|
|
||||||
|
|
||||||
name: build_conda_macos_cpu
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
tags:
|
|
||||||
- '*'
|
|
||||||
|
|
||||||
env:
|
|
||||||
KALDIFEAT_BUILD_TYPE: Release
|
|
||||||
|
|
||||||
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_conda_macos_cpu:
|
|
||||||
needs: generate_build_matrix
|
|
||||||
runs-on: macos-10.15
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
${{ fromJson(needs.generate_build_matrix.outputs.matrix) }}
|
|
||||||
|
|
||||||
steps:
|
|
||||||
# refer to https://github.com/actions/checkout
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
|
|
||||||
- name: Display clang version
|
|
||||||
run: |
|
|
||||||
clang --version
|
|
||||||
|
|
||||||
- uses: conda-incubator/setup-miniconda@v2
|
|
||||||
with:
|
|
||||||
auto-update-conda: true
|
|
||||||
python-version: ${{ matrix.python-version }}
|
|
||||||
activate-environment: kaldifeat
|
|
||||||
|
|
||||||
- name: Display Python version
|
|
||||||
shell: bash -l {0}
|
|
||||||
run: |
|
|
||||||
python3 -c "import sys; print(sys.version)"
|
|
||||||
which python3
|
|
||||||
|
|
||||||
- name: Install conda dependencies
|
|
||||||
shell: bash -l {0}
|
|
||||||
run: |
|
|
||||||
conda install -y -q anaconda-client
|
|
||||||
conda install -y -q conda-build
|
|
||||||
conda install -y -q -c pytorch pytorch=${{ matrix.torch }} cpuonly
|
|
||||||
|
|
||||||
- name: Display conda info
|
|
||||||
shell: bash -l {0}
|
|
||||||
run: |
|
|
||||||
which conda
|
|
||||||
conda env list
|
|
||||||
conda info
|
|
||||||
|
|
||||||
- name: Build kaldifeat
|
|
||||||
shell: bash -l {0}
|
|
||||||
env:
|
|
||||||
KALDIFEAT_PYTHON_VERSION: ${{ matrix.python-version}}
|
|
||||||
KALDIFEAT_TORCH_VERSION: ${{ matrix.torch }}
|
|
||||||
KALDIFEAT_CONDA_TOKEN: ${{ secrets.KALDIFEAT_CONDA_TOKEN}}
|
|
||||||
KALDIFEAT_IS_GITHUB_ACTIONS: 1
|
|
||||||
KALDIFEAT_IS_FOR_CONDA: 1
|
|
||||||
run: |
|
|
||||||
export KALDIFEAT_BUILD_TYPE=$KALDIFEAT_BUILD_TYPE
|
|
||||||
./scripts/build_conda_cpu.sh
|
|
||||||
|
|
||||||
- name: Display generated files
|
|
||||||
run: |
|
|
||||||
ls -lh /usr/local/miniconda/envs/kaldifeat/conda-bld/osx-64
|
|
||||||
|
|
||||||
- name: Upload generated files
|
|
||||||
uses: actions/upload-artifact@v2
|
|
||||||
with:
|
|
||||||
name: cpu-torch-${{ matrix.torch }}-python-${{ matrix.python-version }}-macos-10.15
|
|
||||||
path: /usr/local/miniconda/envs/kaldifeat/conda-bld/osx-64/*.tar.bz2
|
|
108
.github/workflows/build_conda_ubuntu_cpu.yml
vendored
108
.github/workflows/build_conda_ubuntu_cpu.yml
vendored
@ -1,108 +0,0 @@
|
|||||||
# Copyright 2021 Xiaomi Corp. (author: Fangjun Kuang)
|
|
||||||
|
|
||||||
# See ../../LICENSE for clarification regarding multiple authors
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
|
|
||||||
# refer to https://github.com/actions/starter-workflows/pull/47/files
|
|
||||||
|
|
||||||
name: build_conda_ubuntu_cpu
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
tags:
|
|
||||||
- '*'
|
|
||||||
|
|
||||||
env:
|
|
||||||
KALDIFEAT_BUILD_TYPE: Release
|
|
||||||
|
|
||||||
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_conda_ubuntu_cpu:
|
|
||||||
needs: generate_build_matrix
|
|
||||||
runs-on: ubuntu-18.04
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
${{ fromJson(needs.generate_build_matrix.outputs.matrix) }}
|
|
||||||
|
|
||||||
steps:
|
|
||||||
# refer to https://github.com/actions/checkout
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
|
|
||||||
- uses: conda-incubator/setup-miniconda@v2
|
|
||||||
with:
|
|
||||||
auto-update-conda: true
|
|
||||||
python-version: ${{ matrix.python-version }}
|
|
||||||
activate-environment: kaldifeat
|
|
||||||
|
|
||||||
- name: Display Python version
|
|
||||||
shell: bash -l {0}
|
|
||||||
run: |
|
|
||||||
python3 -c "import sys; print(sys.version)"
|
|
||||||
which python3
|
|
||||||
|
|
||||||
- name: Install conda dependencies
|
|
||||||
shell: bash -l {0}
|
|
||||||
run: |
|
|
||||||
conda install -y -q anaconda-client
|
|
||||||
conda install -y -q conda-build
|
|
||||||
conda install -y -q -c pytorch pytorch=${{ matrix.torch }} cpuonly
|
|
||||||
|
|
||||||
- name: Display conda info
|
|
||||||
shell: bash -l {0}
|
|
||||||
run: |
|
|
||||||
which conda
|
|
||||||
conda env list
|
|
||||||
conda info
|
|
||||||
nproc
|
|
||||||
|
|
||||||
- name: Build kaldifeat
|
|
||||||
shell: bash -l {0}
|
|
||||||
env:
|
|
||||||
KALDIFEAT_PYTHON_VERSION: ${{ matrix.python-version}}
|
|
||||||
KALDIFEAT_TORCH_VERSION: ${{ matrix.torch }}
|
|
||||||
KALDIFEAT_CONDA_TOKEN: ${{ secrets.KALDIFEAT_CONDA_TOKEN}}
|
|
||||||
KALDIFEAT_IS_GITHUB_ACTIONS: 1
|
|
||||||
KALDIFEAT_IS_FOR_CONDA: 1
|
|
||||||
run: |
|
|
||||||
export KALDIFEAT_BUILD_TYPE=$KALDIFEAT_BUILD_TYPE
|
|
||||||
./scripts/build_conda_cpu.sh
|
|
||||||
|
|
||||||
- name: Display generated files
|
|
||||||
run: |
|
|
||||||
ls -lh /usr/share/miniconda/envs/kaldifeat/conda-bld/linux-64
|
|
||||||
|
|
||||||
- name: Upload generated files
|
|
||||||
uses: actions/upload-artifact@v2
|
|
||||||
with:
|
|
||||||
name: cpu-torch-${{ matrix.torch }}-python-${{ matrix.python-version }}-ubuntu-18.04
|
|
||||||
path: /usr/share/miniconda/envs/kaldifeat/conda-bld/linux-64/*.tar.bz2
|
|
132
.github/workflows/build_conda_ubuntu_cuda.yml
vendored
132
.github/workflows/build_conda_ubuntu_cuda.yml
vendored
@ -1,132 +0,0 @@
|
|||||||
# Copyright 2021 Xiaomi Corp. (author: Fangjun Kuang)
|
|
||||||
|
|
||||||
# See ../../LICENSE for clarification regarding multiple authors
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
|
|
||||||
# refer to https://github.com/actions/starter-workflows/pull/47/files
|
|
||||||
|
|
||||||
name: build_conda_ubuntu_cuda
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
tags:
|
|
||||||
- '*'
|
|
||||||
|
|
||||||
env:
|
|
||||||
KALDIFEAT_BUILD_TYPE: Release
|
|
||||||
|
|
||||||
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_conda_ubuntu_cuda:
|
|
||||||
needs: generate_build_matrix
|
|
||||||
runs-on: ubuntu-18.04
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
${{ fromJson(needs.generate_build_matrix.outputs.matrix) }}
|
|
||||||
|
|
||||||
steps:
|
|
||||||
# refer to https://github.com/actions/checkout
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
|
|
||||||
- name: Install CUDA Toolkit ${{ matrix.cuda }}
|
|
||||||
shell: bash -l {0}
|
|
||||||
env:
|
|
||||||
cuda: ${{ matrix.cuda }}
|
|
||||||
run: |
|
|
||||||
source ./scripts/github_actions/install_cuda.sh
|
|
||||||
echo "CUDA_HOME=${CUDA_HOME}" >> $GITHUB_ENV
|
|
||||||
echo "${CUDA_HOME}/bin" >> $GITHUB_PATH
|
|
||||||
echo "LD_LIBRARY_PATH=${CUDA_HOME}/lib:${CUDA_HOME}/lib64:${LD_LIBRARY_PATH}" >> $GITHUB_ENV
|
|
||||||
|
|
||||||
- name: Display NVCC version
|
|
||||||
shell: bash -l {0}
|
|
||||||
run: |
|
|
||||||
which nvcc
|
|
||||||
nvcc --version
|
|
||||||
|
|
||||||
- uses: conda-incubator/setup-miniconda@v2
|
|
||||||
with:
|
|
||||||
auto-update-conda: true
|
|
||||||
python-version: ${{ matrix.python-version }}
|
|
||||||
activate-environment: kaldifeat
|
|
||||||
|
|
||||||
- name: Display Python version
|
|
||||||
shell: bash -l {0}
|
|
||||||
run: |
|
|
||||||
python3 -c "import sys; print(sys.version)"
|
|
||||||
which python3
|
|
||||||
|
|
||||||
- name: Install conda dependencies
|
|
||||||
shell: bash -l {0}
|
|
||||||
run: |
|
|
||||||
conda install -y -q anaconda-client
|
|
||||||
conda install -y -q conda-build
|
|
||||||
conda install -y -q -c pytorch -c conda-forge pytorch=${{ matrix.torch }} cudatoolkit=${{ matrix.cuda }}
|
|
||||||
|
|
||||||
- name: Display conda info
|
|
||||||
shell: bash -l {0}
|
|
||||||
run: |
|
|
||||||
which conda
|
|
||||||
conda env list
|
|
||||||
conda info
|
|
||||||
nproc
|
|
||||||
|
|
||||||
- name: Download cudnn 8.0
|
|
||||||
shell: bash -l {0}
|
|
||||||
env:
|
|
||||||
cuda: ${{ matrix.cuda }}
|
|
||||||
run: |
|
|
||||||
./scripts/github_actions/install_cudnn.sh
|
|
||||||
|
|
||||||
- name: Build kaldifeat
|
|
||||||
shell: bash -l {0}
|
|
||||||
env:
|
|
||||||
KALDIFEAT_CUDA_VERSION: ${{ matrix.cuda }}
|
|
||||||
KALDIFEAT_PYTHON_VERSION: ${{ matrix.python-version}}
|
|
||||||
KALDIFEAT_TORCH_VERSION: ${{ matrix.torch }}
|
|
||||||
KALDIFEAT_CONDA_TOKEN: ${{ secrets.KALDIFEAT_CONDA_TOKEN}}
|
|
||||||
KALDIFEAT_IS_GITHUB_ACTIONS: 1
|
|
||||||
KALDIFEAT_IS_FOR_CONDA: 1
|
|
||||||
run: |
|
|
||||||
export KALDIFEAT_BUILD_TYPE=$KALDIFEAT_BUILD_TYPE
|
|
||||||
./scripts/build_conda.sh
|
|
||||||
|
|
||||||
- name: Display generated files
|
|
||||||
run: |
|
|
||||||
ls -lh /usr/share/miniconda/envs/kaldifeat/conda-bld/linux-64
|
|
||||||
|
|
||||||
- name: Upload generated files
|
|
||||||
uses: actions/upload-artifact@v2
|
|
||||||
with:
|
|
||||||
name: cuda-${{ matrix.cuda }}-torch-${{ matrix.torch }}-python-${{ matrix.python-version }}-ubuntu-18.04
|
|
||||||
path: /usr/share/miniconda/envs/kaldifeat/conda-bld/linux-64/*.tar.bz2
|
|
113
.github/workflows/build_conda_windows_cpu.yml
vendored
113
.github/workflows/build_conda_windows_cpu.yml
vendored
@ -1,113 +0,0 @@
|
|||||||
# Copyright 2021 Xiaomi Corp. (author: Fangjun Kuang)
|
|
||||||
|
|
||||||
# See ../../LICENSE for clarification regarding multiple authors
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
|
|
||||||
# refer to https://github.com/actions/starter-workflows/pull/47/files
|
|
||||||
|
|
||||||
name: build_conda_windows_cpu
|
|
||||||
|
|
||||||
on:
|
|
||||||
push:
|
|
||||||
tags:
|
|
||||||
- '*'
|
|
||||||
|
|
||||||
env:
|
|
||||||
KALDIFEAT_BUILD_TYPE: Release
|
|
||||||
|
|
||||||
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_conda_windows_cpu:
|
|
||||||
needs: generate_build_matrix
|
|
||||||
runs-on: windows-2019
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
${{ fromJson(needs.generate_build_matrix.outputs.matrix) }}
|
|
||||||
|
|
||||||
steps:
|
|
||||||
# refer to https://github.com/actions/checkout
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
|
|
||||||
- uses: conda-incubator/setup-miniconda@v2
|
|
||||||
with:
|
|
||||||
auto-update-conda: true
|
|
||||||
python-version: ${{ matrix.python-version }}
|
|
||||||
activate-environment: kaldifeat
|
|
||||||
|
|
||||||
- name: Install conda dependencies
|
|
||||||
shell: bash -l {0}
|
|
||||||
run: |
|
|
||||||
conda install -y -q anaconda-client
|
|
||||||
conda install -y -q conda-build
|
|
||||||
conda install -y -q -c pytorch pytorch=${{ matrix.torch }} cpuonly
|
|
||||||
|
|
||||||
- name: Display Python version
|
|
||||||
shell: bash -l {0}
|
|
||||||
run: |
|
|
||||||
python -c "import sys; print(sys.version)"
|
|
||||||
which python
|
|
||||||
|
|
||||||
- name: Display conda info
|
|
||||||
shell: bash -l {0}
|
|
||||||
run: |
|
|
||||||
conda env list
|
|
||||||
conda info
|
|
||||||
which conda
|
|
||||||
python --version
|
|
||||||
which python
|
|
||||||
python -m torch.utils.collect_env
|
|
||||||
|
|
||||||
- name: Build kaldifeat
|
|
||||||
shell: bash -l {0}
|
|
||||||
env:
|
|
||||||
KALDIFEAT_PYTHON_VERSION: ${{ matrix.python-version}}
|
|
||||||
KALDIFEAT_TORCH_VERSION: ${{ matrix.torch }}
|
|
||||||
KALDIFEAT_CONDA_TOKEN: ${{ secrets.KALDIFEAT_CONDA_TOKEN}}
|
|
||||||
KALDIFEAT_IS_GITHUB_ACTIONS: 1
|
|
||||||
KALDIFEAT_IS_FOR_CONDA: 1
|
|
||||||
run: |
|
|
||||||
export KALDIFEAT_BUILD_TYPE=$KALDIFEAT_BUILD_TYPE
|
|
||||||
./scripts/build_conda_cpu.sh
|
|
||||||
|
|
||||||
- name: Display generated files
|
|
||||||
shell: bash -l {0}
|
|
||||||
run: |
|
|
||||||
ls -lh /c/Miniconda/envs/kaldifeat/conda-bld
|
|
||||||
ls -lh /c/Miniconda/envs/kaldifeat/conda-bld/*/*
|
|
||||||
ls -lh /c/Miniconda/envs/kaldifeat/conda-bld/win-64/*
|
|
||||||
|
|
||||||
- name: Upload generated files
|
|
||||||
uses: actions/upload-artifact@v2
|
|
||||||
with:
|
|
||||||
name: cpu-torch-${{ matrix.torch }}-python-${{ matrix.python-version }}-windows-2019
|
|
||||||
path: c:/Miniconda/envs/kaldifeat/conda-bld/win-64/*.tar.bz2
|
|
121
.github/workflows/macos-cpu-wheels.yml
vendored
Normal file
121
.github/workflows/macos-cpu-wheels.yml
vendored
Normal file
@ -0,0 +1,121 @@
|
|||||||
|
name: build-wheels-cpu-macos
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
# - wheel
|
||||||
|
- torch-2.8.0
|
||||||
|
tags:
|
||||||
|
- '*'
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: build-wheels-cpu-macos-${{ 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-macos
|
||||||
|
# MATRIX=$(python ./scripts/github_actions/generate_build_matrix.py --for-macos)
|
||||||
|
|
||||||
|
python ./scripts/github_actions/generate_build_matrix.py --for-macos --test-only-latest-torch
|
||||||
|
MATRIX=$(python ./scripts/github_actions/generate_build_matrix.py --for-macos --test-only-latest-torch)
|
||||||
|
echo "::set-output name=matrix::${MATRIX}"
|
||||||
|
|
||||||
|
build_wheels_macos_cpu:
|
||||||
|
needs: generate_build_matrix
|
||||||
|
name: ${{ matrix.torch }} ${{ matrix.python-version }}
|
||||||
|
runs-on: macos-14
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
${{ fromJson(needs.generate_build_matrix.outputs.matrix) }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Setup Python
|
||||||
|
uses: actions/setup-python@v5
|
||||||
|
with:
|
||||||
|
python-version: ${{ matrix.python-version }}
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
pip install -q torch==${{ matrix.torch}} cmake numpy wheel>=0.40.0 twine setuptools
|
||||||
|
|
||||||
|
- name: Build wheel
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
python3 setup.py bdist_wheel
|
||||||
|
mkdir wheelhouse
|
||||||
|
cp -v dist/* wheelhouse
|
||||||
|
|
||||||
|
- name: Display wheels (before fix)
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
ls -lh ./wheelhouse/
|
||||||
|
|
||||||
|
- name: Fix wheel platform tag
|
||||||
|
run: |
|
||||||
|
# See https://github.com/glencoesoftware/zeroc-ice-py-macos-x86_64/pull/3/files
|
||||||
|
# See:
|
||||||
|
# * https://github.com/pypa/wheel/issues/406
|
||||||
|
python -m wheel tags \
|
||||||
|
--platform-tag=macosx_11_0_arm64 \
|
||||||
|
--remove wheelhouse/*.whl
|
||||||
|
|
||||||
|
- name: Display wheels (after fix)
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
ls -lh ./wheelhouse/
|
||||||
|
|
||||||
|
- name: Upload Wheel
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: torch-${{ matrix.torch }}-python-${{ matrix.python-version }}-macos-latest-cpu
|
||||||
|
path: wheelhouse/*.whl
|
||||||
|
|
||||||
|
# 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.dev20241029/macos
|
||||||
|
mkdir -p $d
|
||||||
|
cp -v ../wheelhouse/*.whl ./$d
|
||||||
|
git status
|
||||||
|
git lfs track "*.whl"
|
||||||
|
git add .
|
||||||
|
git commit -m "upload macos wheel for torch ${{ matrix.torch }} python ${{ matrix.python-version }}"
|
||||||
|
git push https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/kaldifeat main
|
116
.github/workflows/nightly-tests-macos-cpu.yml
vendored
116
.github/workflows/nightly-tests-macos-cpu.yml
vendored
@ -1,116 +0,0 @@
|
|||||||
# Copyright 2021 Xiaomi Corp. (author: Fangjun Kuang)
|
|
||||||
|
|
||||||
# See ../../LICENSE for clarification regarding multiple authors
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
#
|
|
||||||
name: Nightly tests macos cpu
|
|
||||||
|
|
||||||
on:
|
|
||||||
schedule:
|
|
||||||
# minute (0-59)
|
|
||||||
# hour (0-23)
|
|
||||||
# day of the month (1-31)
|
|
||||||
# month (1-12)
|
|
||||||
# day of the week (0-6)
|
|
||||||
# nightly build at 23:50 UTC time every day
|
|
||||||
- cron: "50 23 * * *"
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
enable_nightly_build:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
outputs:
|
|
||||||
enabled: ${{ steps.set-enabled.outputs.enabled }}
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
- name: Set enabled
|
|
||||||
id: set-enabled
|
|
||||||
run: |
|
|
||||||
enabled=$(python scripts/github_actions/run-nightly-build.py)
|
|
||||||
echo "enabled: $enabled"
|
|
||||||
echo "::set-output name=enabled::${enabled}"
|
|
||||||
|
|
||||||
generate_build_matrix:
|
|
||||||
needs: enable_nightly_build
|
|
||||||
if: needs.enable_nightly_build.outputs.enabled == 'true'
|
|
||||||
# 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}"
|
|
||||||
|
|
||||||
run_nightly_tests_macos_cpu:
|
|
||||||
needs: generate_build_matrix
|
|
||||||
runs-on: macos-10.15
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
${{ fromJson(needs.generate_build_matrix.outputs.matrix) }}
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
|
|
||||||
- name: Setup Python
|
|
||||||
uses: actions/setup-python@v2
|
|
||||||
with:
|
|
||||||
python-version: ${{ matrix.python-version }}
|
|
||||||
|
|
||||||
- name: Display Python version
|
|
||||||
run: python -c "import sys; print(sys.version)"
|
|
||||||
|
|
||||||
- name: Display clang version
|
|
||||||
run: |
|
|
||||||
clang --version
|
|
||||||
|
|
||||||
- name: Install PyTorch ${{ matrix.torch }}
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
python3 -m pip install -qq --upgrade pip
|
|
||||||
python3 -m pip install -qq wheel twine numpy typing_extensions
|
|
||||||
python3 -m pip install -qq torch==${{ matrix.torch }} numpy
|
|
||||||
python3 -m pip install -qq dataclasses soundfile
|
|
||||||
|
|
||||||
python3 -c "import torch; print('torch version:', torch.__version__)"
|
|
||||||
|
|
||||||
- name: Install from PyPI
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
export KALDIFEAT_MAKE_ARGS="-j 3"
|
|
||||||
pip install --verbose kaldifeat
|
|
||||||
|
|
||||||
- name: Run tests
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
lib_path=$(python -c "from distutils.sysconfig import get_python_lib; print(get_python_lib())")
|
|
||||||
echo "lib_path: $lib_path"
|
|
||||||
ls -lh $lib_path
|
|
||||||
# export DYLD_LIBRARY_PATH=$lib_path:$DYLD_LIBRARY_PATH
|
|
||||||
otool -L $lib_path/_kaldifeat.*.so
|
|
||||||
otool -l $lib_path/_kaldifeat.*.so
|
|
||||||
|
|
||||||
cd kaldifeat/python/tests
|
|
||||||
make test
|
|
100
.github/workflows/nightly-tests-ubuntu-conda-cpu.yml
vendored
100
.github/workflows/nightly-tests-ubuntu-conda-cpu.yml
vendored
@ -1,100 +0,0 @@
|
|||||||
# Copyright 2021 Xiaomi Corp. (author: Fangjun Kuang)
|
|
||||||
|
|
||||||
# See ../../LICENSE for clarification regarding multiple authors
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
#
|
|
||||||
name: Nightly tests ubuntu conda cpu
|
|
||||||
|
|
||||||
on:
|
|
||||||
schedule:
|
|
||||||
# minute (0-59)
|
|
||||||
# hour (0-23)
|
|
||||||
# day of the month (1-31)
|
|
||||||
# month (1-12)
|
|
||||||
# day of the week (0-6)
|
|
||||||
# nightly build at 23:50 UTC time every day
|
|
||||||
- cron: "50 23 * * *"
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
enable_nightly_build:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
outputs:
|
|
||||||
enabled: ${{ steps.set-enabled.outputs.enabled }}
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
- name: Set enabled
|
|
||||||
id: set-enabled
|
|
||||||
run: |
|
|
||||||
enabled=$(python scripts/github_actions/run-nightly-build.py)
|
|
||||||
echo "enabled: $enabled"
|
|
||||||
echo "::set-output name=enabled::${enabled}"
|
|
||||||
|
|
||||||
generate_build_matrix:
|
|
||||||
needs: enable_nightly_build
|
|
||||||
if: needs.enable_nightly_build.outputs.enabled == 'true'
|
|
||||||
# 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 --test-only-latest-torch
|
|
||||||
MATRIX=$(python scripts/github_actions/generate_build_matrix.py --test-only-latest-torch)
|
|
||||||
echo "::set-output name=matrix::${MATRIX}"
|
|
||||||
|
|
||||||
run_nightly_tests_ubuntu_conda_cpu:
|
|
||||||
needs: generate_build_matrix
|
|
||||||
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
|
|
||||||
|
|
||||||
- uses: conda-incubator/setup-miniconda@v2
|
|
||||||
with:
|
|
||||||
auto-update-conda: true
|
|
||||||
python-version: ${{ matrix.python-version }}
|
|
||||||
activate-environment: kaldifeat
|
|
||||||
|
|
||||||
- name: Display Python version
|
|
||||||
shell: bash -l {0}
|
|
||||||
run: |
|
|
||||||
python3 -c "import sys; print(sys.version)"
|
|
||||||
which python3
|
|
||||||
|
|
||||||
- name: Install kaldifeat and run tests
|
|
||||||
shell: bash -l {0}
|
|
||||||
run: |
|
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get install -y libsndfile1-dev libsndfile1 ffmpeg
|
|
||||||
|
|
||||||
conda install -y -c kaldifeat -c pytorch cpuonly pytorch=${{ matrix.torch }} kaldifeat python=${{ matrix.python-version }}
|
|
||||||
conda install -y -c conda-forge pysoundfile
|
|
||||||
|
|
||||||
|
|
||||||
cd kaldifeat/python/tests
|
|
||||||
make test
|
|
@ -1,96 +0,0 @@
|
|||||||
# Copyright 2021 Xiaomi Corp. (author: Fangjun Kuang)
|
|
||||||
|
|
||||||
# See ../../LICENSE for clarification regarding multiple authors
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
#
|
|
||||||
name: Nightly tests ubuntu conda cuda
|
|
||||||
|
|
||||||
on:
|
|
||||||
schedule:
|
|
||||||
# minute (0-59)
|
|
||||||
# hour (0-23)
|
|
||||||
# day of the month (1-31)
|
|
||||||
# month (1-12)
|
|
||||||
# day of the week (0-6)
|
|
||||||
# nightly build at 23:50 UTC time every day
|
|
||||||
- cron: "50 23 * * *"
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
enable_nightly_build:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
outputs:
|
|
||||||
enabled: ${{ steps.set-enabled.outputs.enabled }}
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
- name: Set enabled
|
|
||||||
id: set-enabled
|
|
||||||
run: |
|
|
||||||
enabled=$(python scripts/github_actions/run-nightly-build.py)
|
|
||||||
echo "enabled: $enabled"
|
|
||||||
echo "::set-output name=enabled::${enabled}"
|
|
||||||
|
|
||||||
generate_build_matrix:
|
|
||||||
needs: enable_nightly_build
|
|
||||||
if: needs.enable_nightly_build.outputs.enabled == 'true'
|
|
||||||
# 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 --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}"
|
|
||||||
|
|
||||||
run_nightly_tests_ubuntu_conda_cuda:
|
|
||||||
needs: generate_build_matrix
|
|
||||||
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
|
|
||||||
|
|
||||||
- uses: conda-incubator/setup-miniconda@v2
|
|
||||||
with:
|
|
||||||
auto-update-conda: true
|
|
||||||
python-version: ${{ matrix.python-version }}
|
|
||||||
activate-environment: kaldifeat
|
|
||||||
|
|
||||||
- name: Display Python version
|
|
||||||
shell: bash -l {0}
|
|
||||||
run: |
|
|
||||||
python3 -c "import sys; print(sys.version)"
|
|
||||||
which python3
|
|
||||||
|
|
||||||
- name: Install kaldifeat and run tests
|
|
||||||
shell: bash -l {0}
|
|
||||||
run: |
|
|
||||||
conda install -y -c kaldifeat -c pytorch -c conda-forge pytorch=${{ matrix.torch }} cudatoolkit=${{ matrix.cuda }} kaldifeat python=${{ matrix.python-version }}
|
|
||||||
conda install -y -c conda-forge pysoundfile
|
|
||||||
|
|
||||||
cd kaldifeat/python/tests
|
|
||||||
make test
|
|
118
.github/workflows/nightly-tests-ubuntu-pip-cpu.yml
vendored
118
.github/workflows/nightly-tests-ubuntu-pip-cpu.yml
vendored
@ -1,118 +0,0 @@
|
|||||||
# Copyright 2021 Xiaomi Corp. (author: Fangjun Kuang)
|
|
||||||
|
|
||||||
# See ../../LICENSE for clarification regarding multiple authors
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
#
|
|
||||||
name: Nightly tests ubuntu pip cpu
|
|
||||||
|
|
||||||
on:
|
|
||||||
schedule:
|
|
||||||
# minute (0-59)
|
|
||||||
# hour (0-23)
|
|
||||||
# day of the month (1-31)
|
|
||||||
# month (1-12)
|
|
||||||
# day of the week (0-6)
|
|
||||||
# nightly build at 23:50 UTC time every day
|
|
||||||
- cron: "50 23 * * *"
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
enable_nightly_build:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
outputs:
|
|
||||||
enabled: ${{ steps.set-enabled.outputs.enabled }}
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
- name: Set enabled
|
|
||||||
id: set-enabled
|
|
||||||
run: |
|
|
||||||
enabled=$(python scripts/github_actions/run-nightly-build.py)
|
|
||||||
echo "enabled: $enabled"
|
|
||||||
echo "::set-output name=enabled::${enabled}"
|
|
||||||
|
|
||||||
generate_build_matrix:
|
|
||||||
needs: enable_nightly_build
|
|
||||||
if: needs.enable_nightly_build.outputs.enabled == 'true'
|
|
||||||
# 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}"
|
|
||||||
|
|
||||||
run_nightly_tests_ubuntu_pip_cpu:
|
|
||||||
needs: generate_build_matrix
|
|
||||||
runs-on: ubuntu-18.04
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
${{ fromJson(needs.generate_build_matrix.outputs.matrix) }}
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
|
|
||||||
- name: Setup Python
|
|
||||||
uses: actions/setup-python@v2
|
|
||||||
with:
|
|
||||||
python-version: ${{ matrix.python-version }}
|
|
||||||
|
|
||||||
- name: Display Python version
|
|
||||||
run: python -c "import sys; print(sys.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: Display GCC version
|
|
||||||
run: |
|
|
||||||
gcc --version
|
|
||||||
|
|
||||||
- name: Install PyTorch ${{ matrix.torch }}
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get install -y libsndfile1-dev libsndfile1 ffmpeg
|
|
||||||
|
|
||||||
python3 -m pip install -qq --upgrade pip
|
|
||||||
python3 -m pip install -qq wheel twine typing_extensions numpy soundfile
|
|
||||||
python3 -m pip install -qq torch==${{ matrix.torch }}+cpu -f https://download.pytorch.org/whl/torch_stable.html
|
|
||||||
python3 -m pip install -qq dataclasses
|
|
||||||
|
|
||||||
python3 -c "import torch; print('torch version:', torch.__version__)"
|
|
||||||
|
|
||||||
- name: Install from PyPI
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
export KALDIFEAT_MAKE_ARGS="-j 3"
|
|
||||||
pip install --verbose kaldifeat
|
|
||||||
|
|
||||||
- name: Run tests
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
cd kaldifeat/python/tests
|
|
||||||
make test
|
|
134
.github/workflows/nightly-tests-ubuntu-pip-cuda.yml
vendored
134
.github/workflows/nightly-tests-ubuntu-pip-cuda.yml
vendored
@ -1,134 +0,0 @@
|
|||||||
# Copyright 2021 Xiaomi Corp. (author: Fangjun Kuang)
|
|
||||||
|
|
||||||
# See ../../LICENSE for clarification regarding multiple authors
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
#
|
|
||||||
name: Nightly tests ubuntu pip cuda
|
|
||||||
|
|
||||||
on:
|
|
||||||
schedule:
|
|
||||||
# minute (0-59)
|
|
||||||
# hour (0-23)
|
|
||||||
# day of the month (1-31)
|
|
||||||
# month (1-12)
|
|
||||||
# day of the week (0-6)
|
|
||||||
# nightly build at 23:50 UTC time every day
|
|
||||||
- cron: "50 23 * * *"
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
enable_nightly_build:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
outputs:
|
|
||||||
enabled: ${{ steps.set-enabled.outputs.enabled }}
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
- name: Set enabled
|
|
||||||
id: set-enabled
|
|
||||||
run: |
|
|
||||||
enabled=$(python scripts/github_actions/run-nightly-build.py)
|
|
||||||
echo "enabled: $enabled"
|
|
||||||
echo "::set-output name=enabled::${enabled}"
|
|
||||||
|
|
||||||
generate_build_matrix:
|
|
||||||
needs: enable_nightly_build
|
|
||||||
if: needs.enable_nightly_build.outputs.enabled == 'true'
|
|
||||||
# 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}"
|
|
||||||
|
|
||||||
run_nightly_tests_ubuntu_pip_cuda:
|
|
||||||
needs: generate_build_matrix
|
|
||||||
runs-on: ubuntu-18.04
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
${{ fromJson(needs.generate_build_matrix.outputs.matrix) }}
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
|
|
||||||
- name: Setup Python
|
|
||||||
uses: actions/setup-python@v2
|
|
||||||
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 CUDA Toolkit ${{ matrix.cuda }}
|
|
||||||
shell: bash
|
|
||||||
env:
|
|
||||||
cuda: ${{ matrix.cuda }}
|
|
||||||
run: |
|
|
||||||
source ./scripts/github_actions/install_cuda.sh
|
|
||||||
echo "CUDA_HOME=${CUDA_HOME}" >> $GITHUB_ENV
|
|
||||||
echo "${CUDA_HOME}/bin" >> $GITHUB_PATH
|
|
||||||
echo "LD_LIBRARY_PATH=${CUDA_HOME}/lib:${CUDA_HOME}/lib64:${LD_LIBRARY_PATH}" >> $GITHUB_ENV
|
|
||||||
|
|
||||||
- name: Display NVCC version
|
|
||||||
run: |
|
|
||||||
which nvcc
|
|
||||||
nvcc --version
|
|
||||||
|
|
||||||
- name: Install PyTorch ${{ matrix.torch }}
|
|
||||||
env:
|
|
||||||
cuda: ${{ matrix.cuda }}
|
|
||||||
torch: ${{ matrix.torch }}
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
sudo apt-get update
|
|
||||||
sudo apt-get install -y libsndfile1-dev libsndfile1 ffmpeg
|
|
||||||
python3 -m pip install --upgrade pip
|
|
||||||
python3 -m pip install wheel twine typing_extensions soundfile
|
|
||||||
python3 -m pip install bs4 requests tqdm numpy
|
|
||||||
|
|
||||||
./scripts/github_actions/install_torch.sh
|
|
||||||
python3 -c "import torch; print('torch version:', torch.__version__)"
|
|
||||||
|
|
||||||
- name: Download cudnn 8.0
|
|
||||||
env:
|
|
||||||
cuda: ${{ matrix.cuda }}
|
|
||||||
run: |
|
|
||||||
./scripts/github_actions/install_cudnn.sh
|
|
||||||
|
|
||||||
- name: Install from PyPI
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
export KALDIFEAT_MAKE_ARGS="-j 3"
|
|
||||||
pip install --verbose kaldifeat
|
|
||||||
|
|
||||||
- name: Run tests
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
cd kaldifeat/python/tests
|
|
||||||
make test
|
|
119
.github/workflows/nightly-tests-windows-pip-cpu.yml
vendored
119
.github/workflows/nightly-tests-windows-pip-cpu.yml
vendored
@ -1,119 +0,0 @@
|
|||||||
# Copyright 2021 Xiaomi Corp. (author: Fangjun Kuang)
|
|
||||||
|
|
||||||
# See ../../LICENSE for clarification regarding multiple authors
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
#
|
|
||||||
name: Nightly tests windows pip cpu
|
|
||||||
|
|
||||||
on:
|
|
||||||
schedule:
|
|
||||||
# minute (0-59)
|
|
||||||
# hour (0-23)
|
|
||||||
# day of the month (1-31)
|
|
||||||
# month (1-12)
|
|
||||||
# day of the week (0-6)
|
|
||||||
# nightly build at 23:50 UTC time every day
|
|
||||||
- cron: "50 23 * * *"
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
enable_nightly_build:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
outputs:
|
|
||||||
enabled: ${{ steps.set-enabled.outputs.enabled }}
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
- name: Set enabled
|
|
||||||
id: set-enabled
|
|
||||||
run: |
|
|
||||||
enabled=$(python scripts/github_actions/run-nightly-build.py)
|
|
||||||
echo "enabled: $enabled"
|
|
||||||
echo "::set-output name=enabled::${enabled}"
|
|
||||||
|
|
||||||
generate_build_matrix:
|
|
||||||
needs: enable_nightly_build
|
|
||||||
if: needs.enable_nightly_build.outputs.enabled == 'true'
|
|
||||||
# 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}"
|
|
||||||
|
|
||||||
run_nightly_tests_windows_pip_cpu:
|
|
||||||
needs: generate_build_matrix
|
|
||||||
runs-on: windows-2019
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
${{ fromJson(needs.generate_build_matrix.outputs.matrix) }}
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
|
|
||||||
# see https://github.com/microsoft/setup-msbuild
|
|
||||||
- name: Add msbuild to PATH
|
|
||||||
uses: microsoft/setup-msbuild@v1.0.2
|
|
||||||
|
|
||||||
- name: Setup Python
|
|
||||||
uses: actions/setup-python@v2
|
|
||||||
with:
|
|
||||||
python-version: ${{ matrix.python-version }}
|
|
||||||
|
|
||||||
- name: Display Python version
|
|
||||||
run: python -c "import sys; print(sys.version)"
|
|
||||||
|
|
||||||
- name: Install PyTorch ${{ matrix.torch }}
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
python3 -m pip install -qq --upgrade pip
|
|
||||||
python3 -m pip install -qq wheel twine numpy typing_extensions
|
|
||||||
python3 -m pip install -qq dataclasses soundfile numpy
|
|
||||||
python3 -m pip install -qq torch==${{ matrix.torch }}+cpu -f https://download.pytorch.org/whl/torch_stable.html
|
|
||||||
|
|
||||||
python3 -c "import torch; print('torch version:', torch.__version__)"
|
|
||||||
|
|
||||||
- name: Install from PyPI
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
export KALDIFEAT_MAKE_ARGS="-j 3"
|
|
||||||
pip install --verbose kaldifeat
|
|
||||||
|
|
||||||
- name: Run tests
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
cd kaldifeat/python/tests
|
|
||||||
|
|
||||||
python3 ./test_fbank.py
|
|
||||||
python3 ./test_fbank_options.py
|
|
||||||
python3 ./test_frame_extraction_options.py
|
|
||||||
python3 ./test_mel_bank_options.py
|
|
||||||
python3 ./test_mfcc.py
|
|
||||||
python3 ./test_mfcc_options.py
|
|
||||||
python3 ./test_plp.py
|
|
||||||
python3 ./test_plp_options.py
|
|
||||||
python3 ./test_spectrogram.py
|
|
||||||
python3 ./test_spectrogram_options.py
|
|
160
.github/workflows/nightly-tests-windows-pip-cuda.yml
vendored
160
.github/workflows/nightly-tests-windows-pip-cuda.yml
vendored
@ -1,160 +0,0 @@
|
|||||||
# Copyright 2021 Xiaomi Corp. (author: Fangjun Kuang)
|
|
||||||
|
|
||||||
# See ../../LICENSE for clarification regarding multiple authors
|
|
||||||
#
|
|
||||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
# you may not use this file except in compliance with the License.
|
|
||||||
# You may obtain a copy of the License at
|
|
||||||
#
|
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
#
|
|
||||||
# Unless required by applicable law or agreed to in writing, software
|
|
||||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
# See the License for the specific language governing permissions and
|
|
||||||
# limitations under the License.
|
|
||||||
#
|
|
||||||
name: Nightly tests windows pip cuda
|
|
||||||
|
|
||||||
on:
|
|
||||||
schedule:
|
|
||||||
# minute (0-59)
|
|
||||||
# hour (0-23)
|
|
||||||
# day of the month (1-31)
|
|
||||||
# month (1-12)
|
|
||||||
# day of the week (0-6)
|
|
||||||
# nightly build at 23:50 UTC time every day
|
|
||||||
- cron: "50 23 * * *"
|
|
||||||
|
|
||||||
jobs:
|
|
||||||
enable_nightly_build:
|
|
||||||
runs-on: ubuntu-latest
|
|
||||||
outputs:
|
|
||||||
enabled: ${{ steps.set-enabled.outputs.enabled }}
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
- name: Set enabled
|
|
||||||
id: set-enabled
|
|
||||||
run: |
|
|
||||||
enabled=$(python scripts/github_actions/run-nightly-build.py)
|
|
||||||
echo "enabled: $enabled"
|
|
||||||
echo "::set-output name=enabled::${enabled}"
|
|
||||||
|
|
||||||
generate_build_matrix:
|
|
||||||
needs: enable_nightly_build
|
|
||||||
if: needs.enable_nightly_build.outputs.enabled == 'true'
|
|
||||||
# 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 --for-windows
|
|
||||||
MATRIX=$(python scripts/github_actions/generate_build_matrix.py --enable-cuda --for-windows)
|
|
||||||
echo "::set-output name=matrix::${MATRIX}"
|
|
||||||
|
|
||||||
run_nightly_tests_windows_pip_cuda:
|
|
||||||
needs: generate_build_matrix
|
|
||||||
runs-on: windows-2019
|
|
||||||
strategy:
|
|
||||||
fail-fast: false
|
|
||||||
matrix:
|
|
||||||
${{ fromJson(needs.generate_build_matrix.outputs.matrix) }}
|
|
||||||
|
|
||||||
steps:
|
|
||||||
- uses: actions/checkout@v2
|
|
||||||
with:
|
|
||||||
fetch-depth: 0
|
|
||||||
|
|
||||||
# see https://github.com/microsoft/setup-msbuild
|
|
||||||
- name: Add msbuild to PATH
|
|
||||||
uses: microsoft/setup-msbuild@v1.0.2
|
|
||||||
|
|
||||||
- name: Setup Python
|
|
||||||
uses: actions/setup-python@v2
|
|
||||||
with:
|
|
||||||
python-version: ${{ matrix.python-version }}
|
|
||||||
|
|
||||||
- name: Display Python version
|
|
||||||
run: python -c "import sys; print(sys.version)"
|
|
||||||
|
|
||||||
# See https://github.com/Jimver/cuda-toolkit/blob/master/src/links/windows-links.ts
|
|
||||||
# for available CUDA versions
|
|
||||||
- uses: Jimver/cuda-toolkit@v0.2.7
|
|
||||||
id: cuda-toolkit
|
|
||||||
with:
|
|
||||||
cuda: ${{ matrix.cuda }}
|
|
||||||
|
|
||||||
- name: Display CUDA version
|
|
||||||
run: |
|
|
||||||
echo "Installed cuda version is: ${{ steps.cuda-toolkit.outputs.cuda }}"
|
|
||||||
echo "Cuda install location: ${{steps.cuda-toolkit.outputs.CUDA_PATH}}"
|
|
||||||
nvcc --version
|
|
||||||
|
|
||||||
- name: Remove CUDA installation package
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
rm "C:/hostedtoolcache/windows/cuda_installer-windows/${{ matrix.cuda }}/x64/cuda_installer_${{ matrix.cuda }}.exe"
|
|
||||||
|
|
||||||
- name: Download cuDNN
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
GIT_LFS_SKIP_SMUDGE=1 git clone https://huggingface.co/csukuangfj/cudnn-for-windows
|
|
||||||
cd cudnn-for-windows
|
|
||||||
git lfs pull --include="cudnn-windows-x86_64-8.4.1.50_cuda11.6-archive.zip"
|
|
||||||
unzip cudnn-windows-x86_64-8.4.1.50_cuda11.6-archive.zip
|
|
||||||
rm cudnn-windows-x86_64-8.4.1.50_cuda11.6-archive.zip
|
|
||||||
ls -lh *
|
|
||||||
ls -lh */*
|
|
||||||
|
|
||||||
echo "PWD: $PWD"
|
|
||||||
|
|
||||||
- name: Install PyTorch ${{ matrix.torch }}
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
version=${{ matrix.cuda }}
|
|
||||||
major=${version:0:2}
|
|
||||||
minor=${version:3:1}
|
|
||||||
v=${major}${minor}
|
|
||||||
if [ ${v} -eq 102 ]; then v=""; else v="+cu${v}"; fi
|
|
||||||
|
|
||||||
python3 -m pip install -qq --upgrade pip
|
|
||||||
python3 -m pip install -qq wheel twine numpy typing_extensions
|
|
||||||
python3 -m pip install -qq dataclasses soundfile numpy
|
|
||||||
python3 -m pip install -qq torch==${{ matrix.torch }}${v} -f https://download.pytorch.org/whl/torch_stable.html numpy
|
|
||||||
|
|
||||||
python3 -c "import torch; print('torch version:', torch.__version__)"
|
|
||||||
|
|
||||||
python3 -m torch.utils.collect_env
|
|
||||||
|
|
||||||
- name: Install from PyPI
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
echo "PWD: $PWD"
|
|
||||||
export KALDIFEAT_CMAKE_ARGS="-DCMAKE_BUILD_TYPE=$BUILD_TYPE -DCUDNN_INCLUDE_PATH=d:/a/kaldifeat/kaldifeat/cudnn-for-windows/cudnn-windows-x86_64-8.4.1.50_cuda11.6-archive/include -DCUDNN_LIBRARY_PATH=d:/a/kaldifeat/kaldifeat/cudnn-for-windows/cudnn-windows-x86_64-8.4.1.50_cuda11.6-archive/lib/cudnn.lib"
|
|
||||||
export KALDIFEAT_MAKE_ARGS="-j 3"
|
|
||||||
pip install --verbose kaldifeat
|
|
||||||
|
|
||||||
- name: Run tests
|
|
||||||
shell: bash
|
|
||||||
run: |
|
|
||||||
cd kaldifeat/python/tests
|
|
||||||
|
|
||||||
python3 ./test_fbank.py
|
|
||||||
python3 ./test_fbank_options.py
|
|
||||||
python3 ./test_frame_extraction_options.py
|
|
||||||
python3 ./test_mel_bank_options.py
|
|
||||||
python3 ./test_mfcc.py
|
|
||||||
python3 ./test_mfcc_options.py
|
|
||||||
python3 ./test_plp.py
|
|
||||||
python3 ./test_plp_options.py
|
|
||||||
python3 ./test_spectrogram.py
|
|
||||||
python3 ./test_spectrogram_options.py
|
|
6
.github/workflows/publish_to_pypi.yml
vendored
6
.github/workflows/publish_to_pypi.yml
vendored
@ -20,25 +20,27 @@ on:
|
|||||||
push:
|
push:
|
||||||
tags:
|
tags:
|
||||||
- '*'
|
- '*'
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
pypi:
|
pypi:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
- name: Setup Python
|
- name: Setup Python
|
||||||
uses: actions/setup-python@v2
|
uses: actions/setup-python@v2
|
||||||
with:
|
with:
|
||||||
python-version: 3.6
|
python-version: 3.8
|
||||||
|
|
||||||
- name: Install Python dependencies
|
- name: Install Python dependencies
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
python3 -m pip install --upgrade pip
|
python3 -m pip install --upgrade pip
|
||||||
python3 -m pip install wheel twine setuptools
|
python3 -m pip install wheel twine setuptools
|
||||||
|
python3 -m pip install torch==1.10.0+cpu -f https://download.pytorch.org/whl/torch_stable.html
|
||||||
|
|
||||||
- name: Build
|
- name: Build
|
||||||
shell: bash
|
shell: bash
|
||||||
|
10
.github/workflows/run-tests-macos-cpu.yml
vendored
10
.github/workflows/run-tests-macos-cpu.yml
vendored
@ -32,7 +32,7 @@ jobs:
|
|||||||
outputs:
|
outputs:
|
||||||
matrix: ${{ steps.set-matrix.outputs.matrix }}
|
matrix: ${{ steps.set-matrix.outputs.matrix }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
- name: Generating build matrix
|
- name: Generating build matrix
|
||||||
@ -45,14 +45,14 @@ jobs:
|
|||||||
|
|
||||||
run_tests_macos_cpu:
|
run_tests_macos_cpu:
|
||||||
needs: generate_build_matrix
|
needs: generate_build_matrix
|
||||||
runs-on: macos-10.15
|
runs-on: macos-latest
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
${{ fromJson(needs.generate_build_matrix.outputs.matrix) }}
|
${{ fromJson(needs.generate_build_matrix.outputs.matrix) }}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
@ -66,7 +66,7 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
python3 -m pip install -qq --upgrade pip
|
python3 -m pip install -qq --upgrade pip
|
||||||
python3 -m pip install -qq wheel twine typing_extensions soundfile numpy
|
python3 -m pip install -qq wheel twine typing_extensions soundfile numpy
|
||||||
python3 -m pip install -qq torch==${{ matrix.torch }} -f https://download.pytorch.org/whl/torch_stable.html
|
python3 -m pip install -qq torch==${{ matrix.torch }} -f https://download.pytorch.org/whl/torch_stable.html || python3 -m pip install -qq torch==${{ matrix.torch }} -f https://download.pytorch.org/whl/torch/
|
||||||
|
|
||||||
python3 -c "import torch; print('torch version:', torch.__version__)"
|
python3 -c "import torch; print('torch version:', torch.__version__)"
|
||||||
|
|
||||||
@ -75,7 +75,7 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
mkdir build_release
|
mkdir build_release
|
||||||
cd build_release
|
cd build_release
|
||||||
cmake ..
|
cmake -DCMAKE_CXX_STANDARD=17 ..
|
||||||
make VERBOSE=1 -j3
|
make VERBOSE=1 -j3
|
||||||
|
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
|
14
.github/workflows/run-tests-ubuntu-cpu.yml
vendored
14
.github/workflows/run-tests-ubuntu-cpu.yml
vendored
@ -32,7 +32,7 @@ jobs:
|
|||||||
outputs:
|
outputs:
|
||||||
matrix: ${{ steps.set-matrix.outputs.matrix }}
|
matrix: ${{ steps.set-matrix.outputs.matrix }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
- name: Generating build matrix
|
- name: Generating build matrix
|
||||||
@ -52,7 +52,7 @@ jobs:
|
|||||||
${{ fromJson(needs.generate_build_matrix.outputs.matrix) }}
|
${{ fromJson(needs.generate_build_matrix.outputs.matrix) }}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
@ -61,12 +61,6 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
python-version: ${{ matrix.python-version }}
|
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 }}
|
- name: Install PyTorch ${{ matrix.torch }}
|
||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
@ -75,7 +69,7 @@ jobs:
|
|||||||
python3 -m pip install --upgrade pip
|
python3 -m pip install --upgrade pip
|
||||||
python3 -m pip install wheel twine typing_extensions soundfile
|
python3 -m pip install wheel twine typing_extensions soundfile
|
||||||
python3 -m pip install bs4 requests tqdm numpy
|
python3 -m pip install bs4 requests tqdm numpy
|
||||||
python3 -m pip install -qq torch==${{ matrix.torch }}+cpu -f https://download.pytorch.org/whl/torch_stable.html
|
python3 -m pip install -qq torch==${{ matrix.torch }}+cpu -f https://download.pytorch.org/whl/torch_stable.html || python3 -m pip install -qq torch==${{ matrix.torch }}+cpu -f https://download.pytorch.org/whl/torch/
|
||||||
|
|
||||||
python3 -c "import torch; print('torch version:', torch.__version__)"
|
python3 -c "import torch; print('torch version:', torch.__version__)"
|
||||||
|
|
||||||
@ -84,7 +78,7 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
mkdir build_release
|
mkdir build_release
|
||||||
cd build_release
|
cd build_release
|
||||||
cmake ..
|
cmake -DCMAKE_CXX_STANDARD=17 ..
|
||||||
make VERBOSE=1 -j3
|
make VERBOSE=1 -j3
|
||||||
|
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
|
16
.github/workflows/run-tests-ubuntu-cuda.yml
vendored
16
.github/workflows/run-tests-ubuntu-cuda.yml
vendored
@ -32,7 +32,7 @@ jobs:
|
|||||||
outputs:
|
outputs:
|
||||||
matrix: ${{ steps.set-matrix.outputs.matrix }}
|
matrix: ${{ steps.set-matrix.outputs.matrix }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
- name: Generating build matrix
|
- name: Generating build matrix
|
||||||
@ -45,14 +45,14 @@ jobs:
|
|||||||
|
|
||||||
run_tests_ubuntu_cuda:
|
run_tests_ubuntu_cuda:
|
||||||
needs: generate_build_matrix
|
needs: generate_build_matrix
|
||||||
runs-on: ubuntu-18.04
|
runs-on: ubuntu-latest
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
${{ fromJson(needs.generate_build_matrix.outputs.matrix) }}
|
${{ fromJson(needs.generate_build_matrix.outputs.matrix) }}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
@ -61,14 +61,6 @@ jobs:
|
|||||||
with:
|
with:
|
||||||
python-version: ${{ matrix.python-version }}
|
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 }}
|
- name: Install CUDA Toolkit ${{ matrix.cuda }}
|
||||||
shell: bash
|
shell: bash
|
||||||
env:
|
env:
|
||||||
@ -110,7 +102,7 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
mkdir build_release
|
mkdir build_release
|
||||||
cd build_release
|
cd build_release
|
||||||
cmake ..
|
cmake -DCMAKE_CXX_STANDARD=17 ..
|
||||||
make VERBOSE=1 -j3
|
make VERBOSE=1 -j3
|
||||||
|
|
||||||
- name: Run tests
|
- name: Run tests
|
||||||
|
14
.github/workflows/run-tests-windows-cpu.yml
vendored
14
.github/workflows/run-tests-windows-cpu.yml
vendored
@ -32,7 +32,7 @@ jobs:
|
|||||||
outputs:
|
outputs:
|
||||||
matrix: ${{ steps.set-matrix.outputs.matrix }}
|
matrix: ${{ steps.set-matrix.outputs.matrix }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
- name: Generating build matrix
|
- name: Generating build matrix
|
||||||
@ -46,14 +46,14 @@ jobs:
|
|||||||
run_tests_windows_cpu:
|
run_tests_windows_cpu:
|
||||||
# see https://github.com/actions/virtual-environments/blob/win19/20210525.0/images/win/Windows2019-Readme.md
|
# see https://github.com/actions/virtual-environments/blob/win19/20210525.0/images/win/Windows2019-Readme.md
|
||||||
needs: generate_build_matrix
|
needs: generate_build_matrix
|
||||||
runs-on: windows-2019
|
runs-on: windows-latest
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
${{ fromJson(needs.generate_build_matrix.outputs.matrix) }}
|
${{ fromJson(needs.generate_build_matrix.outputs.matrix) }}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
@ -71,7 +71,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Install PyTorch ${{ matrix.torch }}
|
- name: Install PyTorch ${{ matrix.torch }}
|
||||||
run: |
|
run: |
|
||||||
pip3 install -qq torch==${{ matrix.torch }}+cpu -f https://download.pytorch.org/whl/torch_stable.html
|
pip3 install -qq torch==${{ matrix.torch }}+cpu -f https://download.pytorch.org/whl/torch_stable.html || pip3 install -qq torch==${{ matrix.torch }}+cpu -f https://download.pytorch.org/whl/torch/
|
||||||
pip3 install -qq wheel twine dataclasses numpy typing_extensions soundfile
|
pip3 install -qq wheel twine dataclasses numpy typing_extensions soundfile
|
||||||
|
|
||||||
- name: Display CMake version
|
- name: Display CMake version
|
||||||
@ -90,7 +90,7 @@ jobs:
|
|||||||
- name: Build kaldifeat
|
- name: Build kaldifeat
|
||||||
run: |
|
run: |
|
||||||
cd build_release
|
cd build_release
|
||||||
cmake --build . --target _kaldifeat --config Release
|
cmake --build -DCMAKE_CXX_STANDARD=17 . --target _kaldifeat --config Release
|
||||||
|
|
||||||
- name: Display generated files
|
- name: Display generated files
|
||||||
shell: bash
|
shell: bash
|
||||||
@ -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@v2
|
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
|
||||||
@ -116,6 +116,6 @@ jobs:
|
|||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
cd build_release
|
cd build_release
|
||||||
cmake --build . --target ALL_BUILD --config Release
|
cmake -DCMAKE_CXX_STANDARD=17 --build . --target ALL_BUILD --config Release
|
||||||
ls -lh bin/*/*
|
ls -lh bin/*/*
|
||||||
ctest -C Release --verbose --output-on-failure
|
ctest -C Release --verbose --output-on-failure
|
||||||
|
12
.github/workflows/run-tests-windows-cuda.yml
vendored
12
.github/workflows/run-tests-windows-cuda.yml
vendored
@ -33,7 +33,7 @@ jobs:
|
|||||||
outputs:
|
outputs:
|
||||||
matrix: ${{ steps.set-matrix.outputs.matrix }}
|
matrix: ${{ steps.set-matrix.outputs.matrix }}
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
- name: Generating build matrix
|
- name: Generating build matrix
|
||||||
@ -46,14 +46,14 @@ jobs:
|
|||||||
|
|
||||||
run_tests_windows_cuda:
|
run_tests_windows_cuda:
|
||||||
needs: generate_build_matrix
|
needs: generate_build_matrix
|
||||||
runs-on: windows-2019
|
runs-on: windows-latest
|
||||||
strategy:
|
strategy:
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
matrix:
|
matrix:
|
||||||
${{ fromJson(needs.generate_build_matrix.outputs.matrix) }}
|
${{ fromJson(needs.generate_build_matrix.outputs.matrix) }}
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
@ -113,7 +113,7 @@ jobs:
|
|||||||
python3 -m pip install -qq --upgrade pip
|
python3 -m pip install -qq --upgrade pip
|
||||||
python3 -m pip install -qq wheel twine numpy typing_extensions
|
python3 -m pip install -qq wheel twine numpy typing_extensions
|
||||||
python3 -m pip install -qq dataclasses soundfile numpy
|
python3 -m pip install -qq dataclasses soundfile numpy
|
||||||
python3 -m pip install -qq torch==${{ matrix.torch }}${v} -f https://download.pytorch.org/whl/torch_stable.html numpy
|
python3 -m pip install -qq torch==${{ matrix.torch }}${v} -f https://download.pytorch.org/whl/torch_stable.html numpy || python3 -m pip install -qq torch==${{ matrix.torch }}${v} -f https://download.pytorch.org/whl/torch/ numpy
|
||||||
|
|
||||||
python3 -c "import torch; print('torch version:', torch.__version__)"
|
python3 -c "import torch; print('torch version:', torch.__version__)"
|
||||||
|
|
||||||
@ -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@v2
|
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
|
||||||
@ -168,6 +168,6 @@ jobs:
|
|||||||
shell: bash
|
shell: bash
|
||||||
run: |
|
run: |
|
||||||
cd build_release
|
cd build_release
|
||||||
cmake --build . --target ALL_BUILD --config Release
|
cmake -DCMAKE_CXX_STANDARD=17 --build . --target ALL_BUILD --config Release
|
||||||
ls -lh bin/*/*
|
ls -lh bin/*/*
|
||||||
ctest -C Release --verbose --output-on-failure
|
ctest -C Release --verbose --output-on-failure
|
||||||
|
6
.github/workflows/style_check.yml
vendored
6
.github/workflows/style_check.yml
vendored
@ -29,12 +29,12 @@ jobs:
|
|||||||
runs-on: ${{ matrix.os }}
|
runs-on: ${{ matrix.os }}
|
||||||
strategy:
|
strategy:
|
||||||
matrix:
|
matrix:
|
||||||
os: [ubuntu-18.04, macos-10.15]
|
os: [ubuntu-latest, macos-latest]
|
||||||
python-version: [3.7, 3.8, 3.9]
|
python-version: ["3.8"]
|
||||||
fail-fast: false
|
fail-fast: false
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v2
|
- uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
|
|
||||||
|
67
.github/workflows/test-wheels.yml
vendored
Normal file
67
.github/workflows/test-wheels.yml
vendored
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
name: Test pre-compiled wheels
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
torch_version:
|
||||||
|
description: "torch version, e.g., 2.0.1"
|
||||||
|
required: true
|
||||||
|
kaldifeat_version:
|
||||||
|
description: "kaldifeat version, e.g., 1.25.0.dev20230726"
|
||||||
|
required: true
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
Test_pre_compiled_wheels:
|
||||||
|
name: ${{ matrix.os }} ${{ github.event.inputs.torch_version }} ${{ github.event.inputs.kaldifeat_version }} ${{ matrix.python-version }}
|
||||||
|
runs-on: ${{ matrix.os }}
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
os: [ubuntu-latest, windows-latest, macos-latest]
|
||||||
|
python-version: ["3.8", "3.9", "3.10"]
|
||||||
|
steps:
|
||||||
|
# refer to https://github.com/actions/checkout
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Setup Python ${{ matrix.python-version }}
|
||||||
|
uses: actions/setup-python@v2
|
||||||
|
with:
|
||||||
|
python-version: ${{ matrix.python-version }}
|
||||||
|
|
||||||
|
- name: Display Python version
|
||||||
|
run: python -c "import sys; print(sys.version)"
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
pip install numpy
|
||||||
|
|
||||||
|
- name: Install torch
|
||||||
|
if: startsWith(matrix.os, 'macos')
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
pip install torch==${{ github.event.inputs.torch_version }}
|
||||||
|
|
||||||
|
- name: Install torch
|
||||||
|
if: startsWith(matrix.os, 'ubuntu') || startsWith(matrix.os, 'windows')
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
pip install torch==${{ github.event.inputs.torch_version }}+cpu -f https://download.pytorch.org/whl/torch_stable.html || pip install torch==${{ github.event.inputs.torch_version }}+cpu -f https://download.pytorch.org/whl/torch/
|
||||||
|
|
||||||
|
- name: Install kaldifeat
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
pip install kaldifeat==${{ github.event.inputs.kaldifeat_version }}+cpu.torch${{ github.event.inputs.torch_version }} -f https://csukuangfj.github.io/kaldifeat/cpu.html
|
||||||
|
|
||||||
|
- name: Run tests
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
cd kaldifeat/python/tests
|
||||||
|
|
||||||
|
python3 -c "import kaldifeat; print(kaldifeat.__file__)"
|
||||||
|
python3 -c "import kaldifeat; print(kaldifeat.__version__)"
|
||||||
|
|
||||||
|
python3 ./test_fbank_options.py
|
||||||
|
|
||||||
|
python3 ./test_mfcc_options.py
|
168
.github/workflows/ubuntu-arm64-cpu-wheels.yml
vendored
Normal file
168
.github/workflows/ubuntu-arm64-cpu-wheels.yml
vendored
Normal file
@ -0,0 +1,168 @@
|
|||||||
|
name: build-wheels-cpu-arm64-ubuntu
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
# - wheel
|
||||||
|
- torch-2.8.0
|
||||||
|
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
|
168
.github/workflows/ubuntu-cpu-wheels.yml
vendored
Normal file
168
.github/workflows/ubuntu-cpu-wheels.yml
vendored
Normal file
@ -0,0 +1,168 @@
|
|||||||
|
name: build-wheels-cpu-ubuntu
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
# - wheel
|
||||||
|
- torch-2.8.0
|
||||||
|
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@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
|
||||||
|
# MATRIX=$(python ./scripts/github_actions/generate_build_matrix.py)
|
||||||
|
|
||||||
|
python ./scripts/github_actions/generate_build_matrix.py --test-only-latest-torch
|
||||||
|
MATRIX=$(python ./scripts/github_actions/generate_build_matrix.py --test-only-latest-torch)
|
||||||
|
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@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 || 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
|
||||||
|
|
||||||
|
- 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-x64
|
||||||
|
mkdir -p $d
|
||||||
|
cp -v ../wheelhouse/*.whl ./$d
|
||||||
|
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
|
194
.github/workflows/ubuntu-cuda-wheels.yml
vendored
Normal file
194
.github/workflows/ubuntu-cuda-wheels.yml
vendored
Normal file
@ -0,0 +1,194 @@
|
|||||||
|
name: build-wheels-cuda-ubuntu
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- wheel
|
||||||
|
# - torch-2.7.1
|
||||||
|
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@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 --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
|
||||||
|
MATRIX=$(python ./scripts/github_actions/generate_build_matrix.py --enable-cuda --test-only-latest-torch)
|
||||||
|
echo "::set-output name=matrix::${MATRIX}"
|
||||||
|
|
||||||
|
build-manylinux-wheels:
|
||||||
|
needs: generate_build_matrix
|
||||||
|
name: ${{ matrix.torch }} ${{ matrix.python-version }} cuda${{ matrix.cuda }}
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
${{ fromJson(needs.generate_build_matrix.outputs.matrix) }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Free space
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
df -h
|
||||||
|
rm -rf /opt/hostedtoolcache
|
||||||
|
df -h
|
||||||
|
echo "pwd: $PWD"
|
||||||
|
echo "github.workspace ${{ github.workspace }}"
|
||||||
|
|
||||||
|
# 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 }} -e CUDA_VERSION=${{ matrix.cuda }}
|
||||||
|
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*"
|
||||||
|
|
||||||
|
# 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
|
||||||
|
rm cuda
|
||||||
|
ln -s cuda-$CUDA_VERSION cuda
|
||||||
|
popd
|
||||||
|
which nvcc
|
||||||
|
nvcc --version
|
||||||
|
|
||||||
|
cp /var/www/scripts/github_actions/install_torch.sh .
|
||||||
|
chmod +x install_torch.sh
|
||||||
|
|
||||||
|
/var/www/scripts/github_actions/build-ubuntu-cuda.sh
|
||||||
|
|
||||||
|
- name: Display wheels
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
ls -lh ./wheelhouse/
|
||||||
|
|
||||||
|
- name: Upload Wheel
|
||||||
|
if: false
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: torch-${{ matrix.torch }}-python-${{ matrix.python-version }}-ubuntu-latest-cuda-is_2_28-${{ matrix.is_2_28 }}
|
||||||
|
path: wheelhouse/*.whl
|
||||||
|
|
||||||
|
# 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=cuda/1.25.5.dev20241029/linux
|
||||||
|
mkdir -p $d
|
||||||
|
cp -v ../wheelhouse/*.whl ./$d
|
||||||
|
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
|
108
.github/workflows/windows-x64-cpu-wheels.yml
vendored
Normal file
108
.github/workflows/windows-x64-cpu-wheels.yml
vendored
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
name: build-wheels-cpu-win64
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
# - wheel
|
||||||
|
- torch-2.8.0
|
||||||
|
tags:
|
||||||
|
- '*'
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
concurrency:
|
||||||
|
group: build-wheels-cpu-win64-${{ 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-windows
|
||||||
|
# MATRIX=$(python ./scripts/github_actions/generate_build_matrix.py --for-windows)
|
||||||
|
|
||||||
|
python ./scripts/github_actions/generate_build_matrix.py --for-windows --test-only-latest-torch
|
||||||
|
MATRIX=$(python ./scripts/github_actions/generate_build_matrix.py --for-windows --test-only-latest-torch)
|
||||||
|
echo "::set-output name=matrix::${MATRIX}"
|
||||||
|
|
||||||
|
build_wheels_win64_cpu:
|
||||||
|
needs: generate_build_matrix
|
||||||
|
name: ${{ matrix.torch }} ${{ matrix.python-version }}
|
||||||
|
runs-on: windows-latest
|
||||||
|
strategy:
|
||||||
|
fail-fast: false
|
||||||
|
matrix:
|
||||||
|
${{ fromJson(needs.generate_build_matrix.outputs.matrix) }}
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v4
|
||||||
|
with:
|
||||||
|
fetch-depth: 0
|
||||||
|
|
||||||
|
- name: Setup Python
|
||||||
|
uses: actions/setup-python@v5
|
||||||
|
with:
|
||||||
|
python-version: ${{ matrix.python-version }}
|
||||||
|
|
||||||
|
- name: Install dependencies
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
pip install -q torch==${{ matrix.torch}} cmake numpy wheel>=0.40.0 twine setuptools
|
||||||
|
pip install torch==${{ matrix.torch}}+cpu -f https://download.pytorch.org/whl/torch_stable.html cmake numpy || pip install torch==${{ matrix.torch}}+cpu -f https://download.pytorch.org/whl/torch/ cmake numpy
|
||||||
|
|
||||||
|
- name: Build wheel
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
python3 setup.py bdist_wheel
|
||||||
|
mkdir wheelhouse
|
||||||
|
cp -v dist/* wheelhouse
|
||||||
|
|
||||||
|
- name: Display wheels
|
||||||
|
shell: bash
|
||||||
|
run: |
|
||||||
|
ls -lh ./wheelhouse/
|
||||||
|
|
||||||
|
- name: Upload Wheel
|
||||||
|
uses: actions/upload-artifact@v4
|
||||||
|
with:
|
||||||
|
name: torch-${{ matrix.torch }}-python-${{ matrix.python-version }}-windows-latest-cpu
|
||||||
|
path: wheelhouse/*.whl
|
||||||
|
|
||||||
|
# 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.dev20241029/windows
|
||||||
|
mkdir -p $d
|
||||||
|
cp -v ../wheelhouse/*.whl ./$d
|
||||||
|
git status
|
||||||
|
git lfs track "*.whl"
|
||||||
|
git add .
|
||||||
|
git commit -m "upload windows-cpu wheel for torch ${{ matrix.torch }} python ${{ matrix.python-version }}"
|
||||||
|
git push https://csukuangfj:$HF_TOKEN@huggingface.co/csukuangfj/kaldifeat main
|
2
.gitignore
vendored
2
.gitignore
vendored
@ -6,3 +6,5 @@ __pycache__/
|
|||||||
test-1hour.wav
|
test-1hour.wav
|
||||||
path.sh
|
path.sh
|
||||||
torch_version.py
|
torch_version.py
|
||||||
|
cpu*.html
|
||||||
|
cuda*.html
|
||||||
|
@ -1,4 +1,7 @@
|
|||||||
# Copyright (c) 2021 Xiaomi Corporation (author: Fangjun Kuang)
|
# Copyright (c) 2021 Xiaomi Corporation (author: Fangjun Kuang)
|
||||||
|
if (CMAKE_VERSION VERSION_GREATER_EQUAL "4.0.0")
|
||||||
|
set(CMAKE_POLICY_VERSION_MINIMUM 3.5)
|
||||||
|
endif()
|
||||||
|
|
||||||
cmake_minimum_required(VERSION 3.8 FATAL_ERROR)
|
cmake_minimum_required(VERSION 3.8 FATAL_ERROR)
|
||||||
|
|
||||||
@ -7,7 +10,7 @@ project(kaldifeat)
|
|||||||
# remember to change the version in
|
# remember to change the version in
|
||||||
# scripts/conda/kaldifeat/meta.yaml
|
# scripts/conda/kaldifeat/meta.yaml
|
||||||
# scripts/conda-cpu/kaldifeat/meta.yaml
|
# scripts/conda-cpu/kaldifeat/meta.yaml
|
||||||
set(kaldifeat_VERSION "1.21")
|
set(kaldifeat_VERSION "1.25.5")
|
||||||
|
|
||||||
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
|
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
|
||||||
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
|
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/lib")
|
||||||
@ -17,6 +20,7 @@ set(CMAKE_SKIP_BUILD_RPATH FALSE)
|
|||||||
set(BUILD_RPATH_USE_ORIGIN TRUE)
|
set(BUILD_RPATH_USE_ORIGIN TRUE)
|
||||||
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
|
set(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
|
||||||
|
|
||||||
|
|
||||||
if(NOT APPLE)
|
if(NOT APPLE)
|
||||||
set(kaldifeat_rpath_origin "$ORIGIN")
|
set(kaldifeat_rpath_origin "$ORIGIN")
|
||||||
else()
|
else()
|
||||||
@ -26,33 +30,38 @@ endif()
|
|||||||
set(CMAKE_INSTALL_RPATH ${kaldifeat_rpath_origin})
|
set(CMAKE_INSTALL_RPATH ${kaldifeat_rpath_origin})
|
||||||
set(CMAKE_BUILD_RPATH ${kaldifeat_rpath_origin})
|
set(CMAKE_BUILD_RPATH ${kaldifeat_rpath_origin})
|
||||||
|
|
||||||
set(BUILD_SHARED_LIBS ON)
|
|
||||||
if(WIN32)
|
|
||||||
message(STATUS "Set BUILD_SHARED_LIBS to OFF for Windows")
|
|
||||||
set(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE)
|
|
||||||
endif()
|
|
||||||
|
|
||||||
if(NOT CMAKE_BUILD_TYPE)
|
if(NOT CMAKE_BUILD_TYPE)
|
||||||
message(STATUS "No CMAKE_BUILD_TYPE given, default to Release")
|
message(STATUS "No CMAKE_BUILD_TYPE given, default to Release")
|
||||||
set(CMAKE_BUILD_TYPE Release)
|
set(CMAKE_BUILD_TYPE Release)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(CMAKE_CXX_STANDARD 14 CACHE STRING "The C++ version to be used.")
|
if (NOT CMAKE_CXX_STANDARD)
|
||||||
set(CMAKE_CXX_EXTENSIONS OFF)
|
set(CMAKE_CXX_STANDARD 17 CACHE STRING "The C++ version to be used.")
|
||||||
|
endif()
|
||||||
message(STATUS "C++ Standard version: ${CMAKE_CXX_STANDARD}")
|
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/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(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}")
|
||||||
|
|
||||||
|
if(BUILD_SHARED_LIBS AND MSVC)
|
||||||
|
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
|
||||||
|
endif()
|
||||||
|
|
||||||
if(kaldifeat_BUILD_PYMODULE)
|
if(kaldifeat_BUILD_PYMODULE)
|
||||||
include(pybind11)
|
include(pybind11)
|
||||||
endif()
|
endif()
|
||||||
|
# to prevent cmake from trying to link with system installed mkl since we not directly use it
|
||||||
|
# mkl libraries should be linked with pytorch already
|
||||||
|
# ref: https://github.com/pytorch/pytorch/blob/master/cmake/public/mkl.cmake
|
||||||
|
set(CMAKE_DISABLE_FIND_PACKAGE_MKL TRUE)
|
||||||
include(torch)
|
include(torch)
|
||||||
|
|
||||||
if(kaldifeat_BUILD_TESTS)
|
if(kaldifeat_BUILD_TESTS)
|
||||||
|
51
README.md
51
README.md
@ -11,6 +11,23 @@
|
|||||||
|
|
||||||
**Documentation**: <https://csukuangfj.github.io/kaldifeat>
|
**Documentation**: <https://csukuangfj.github.io/kaldifeat>
|
||||||
|
|
||||||
|
**Note**: If you are looking for a version that does not depend on PyTorch,
|
||||||
|
please see <https://github.com/csukuangfj/kaldi-native-fbank>
|
||||||
|
|
||||||
|
# Installation
|
||||||
|
|
||||||
|
Refer to
|
||||||
|
<https://csukuangfj.github.io/kaldifeat/installation/from_wheels.html>
|
||||||
|
for installation.
|
||||||
|
|
||||||
|
> Never use `pip install kaldifeat`
|
||||||
|
|
||||||
|
> Never use `pip install kaldifeat`
|
||||||
|
|
||||||
|
> Never use `pip install kaldifeat`
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
<sub>
|
<sub>
|
||||||
<table>
|
<table>
|
||||||
<tr>
|
<tr>
|
||||||
@ -20,6 +37,36 @@
|
|||||||
<th>Usage</th>
|
<th>Usage</th>
|
||||||
</tr>
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td>Fbank for <a href="https://github.com/openai/whisper">Whisper</a></td>
|
||||||
|
<td><code>kaldifeat.WhisperFbankOptions</code></td>
|
||||||
|
<td><code>kaldifeat.WhisperFbank</code></td>
|
||||||
|
<td>
|
||||||
|
<pre lang="python">
|
||||||
|
opts = kaldifeat.WhisperFbankOptions()
|
||||||
|
opts.device = torch.device('cuda', 0)
|
||||||
|
fbank = kaldifeat.WhisperFbank(opts)
|
||||||
|
features = fbank(wave)
|
||||||
|
</pre>
|
||||||
|
See <a href="https://github.com/csukuangfj/kaldifeat/pull/82">#82</a>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
|
<tr>
|
||||||
|
<td>Fbank for <a href="https://github.com/openai/whisper">Whisper-V3</a></td>
|
||||||
|
<td><code>kaldifeat.WhisperFbankOptions</code></td>
|
||||||
|
<td><code>kaldifeat.WhisperFbank</code></td>
|
||||||
|
<td>
|
||||||
|
<pre lang="python">
|
||||||
|
opts = kaldifeat.WhisperFbankOptions()
|
||||||
|
opts.num_mels = 128
|
||||||
|
opts.device = torch.device('cuda', 0)
|
||||||
|
fbank = kaldifeat.WhisperFbank(opts)
|
||||||
|
features = fbank(wave)
|
||||||
|
</pre>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
|
||||||
<tr>
|
<tr>
|
||||||
<td>FBANK</td>
|
<td>FBANK</td>
|
||||||
<td><code>kaldifeat.FbankOptions</code></td>
|
<td><code>kaldifeat.FbankOptions</code></td>
|
||||||
@ -279,8 +326,4 @@ extraction.
|
|||||||
|
|
||||||
See <https://github.com/k2-fsa/sherpa/blob/master/sherpa/bin/pruned_stateless_emformer_rnnt2/decode.py>
|
See <https://github.com/k2-fsa/sherpa/blob/master/sherpa/bin/pruned_stateless_emformer_rnnt2/decode.py>
|
||||||
|
|
||||||
# Installation
|
|
||||||
|
|
||||||
Refer to
|
|
||||||
<https://csukuangfj.github.io/kaldifeat>
|
|
||||||
for installation.
|
|
||||||
|
@ -8,9 +8,15 @@ import sys
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
import setuptools
|
import setuptools
|
||||||
|
import torch
|
||||||
from setuptools.command.build_ext import build_ext
|
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():
|
def is_for_pypi():
|
||||||
ans = os.environ.get("KALDIFEAT_IS_FOR_PYPI", None)
|
ans = os.environ.get("KALDIFEAT_IS_FOR_PYPI", None)
|
||||||
return ans is not None
|
return ans is not None
|
||||||
@ -39,7 +45,6 @@ try:
|
|||||||
# -linux_x86_64.whl
|
# -linux_x86_64.whl
|
||||||
self.root_is_pure = False
|
self.root_is_pure = False
|
||||||
|
|
||||||
|
|
||||||
except ImportError:
|
except ImportError:
|
||||||
bdist_wheel = None
|
bdist_wheel = None
|
||||||
|
|
||||||
@ -70,6 +75,13 @@ class BuildExtension(build_ext):
|
|||||||
extra_cmake_args = " -Dkaldifeat_BUILD_TESTS=OFF "
|
extra_cmake_args = " -Dkaldifeat_BUILD_TESTS=OFF "
|
||||||
extra_cmake_args += f" -DCMAKE_INSTALL_PREFIX={Path(self.build_lib).resolve()}/kaldifeat " # noqa
|
extra_cmake_args += f" -DCMAKE_INSTALL_PREFIX={Path(self.build_lib).resolve()}/kaldifeat " # noqa
|
||||||
|
|
||||||
|
major, minor = get_pytorch_version().split(".")[:2]
|
||||||
|
print("major, minor", major, minor)
|
||||||
|
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:
|
if "PYTHON_EXECUTABLE" not in cmake_args:
|
||||||
print(f"Setting PYTHON_EXECUTABLE to {sys.executable}")
|
print(f"Setting PYTHON_EXECUTABLE to {sys.executable}")
|
||||||
cmake_args += f" -DPYTHON_EXECUTABLE={sys.executable}"
|
cmake_args += f" -DPYTHON_EXECUTABLE={sys.executable}"
|
||||||
@ -103,9 +115,7 @@ class BuildExtension(build_ext):
|
|||||||
else:
|
else:
|
||||||
if make_args == "" and system_make_args == "":
|
if make_args == "" and system_make_args == "":
|
||||||
print("For fast compilation, run:")
|
print("For fast compilation, run:")
|
||||||
print(
|
print('export KALDIFEAT_MAKE_ARGS="-j"; python setup.py install')
|
||||||
'export KALDIFEAT_MAKE_ARGS="-j"; python setup.py install'
|
|
||||||
)
|
|
||||||
make_args = " -j4 "
|
make_args = " -j4 "
|
||||||
print("Setting make_args to '-j4'")
|
print("Setting make_args to '-j4'")
|
||||||
|
|
||||||
|
@ -24,8 +24,28 @@ function(download_googltest)
|
|||||||
|
|
||||||
include(FetchContent)
|
include(FetchContent)
|
||||||
|
|
||||||
set(googletest_URL "https://github.com/google/googletest/archive/release-1.10.0.tar.gz")
|
set(googletest_URL "https://github.com/google/googletest/archive/refs/tags/v1.13.0.tar.gz")
|
||||||
set(googletest_HASH "SHA256=9dc9157a9a1551ec7a7e43daea9a694a0bb5fb8bec81235d8a1e6ef64c716dcb")
|
set(googletest_URL2 "https://huggingface.co/csukuangfj/k2-cmake-deps/resolve/main/googletest-1.13.0.tar.gz")
|
||||||
|
set(googletest_HASH "SHA256=ad7fdba11ea011c1d925b3289cf4af2c66a352e18d4c7264392fead75e919363")
|
||||||
|
|
||||||
|
# If you don't have access to the Internet,
|
||||||
|
# please pre-download googletest
|
||||||
|
set(possible_file_locations
|
||||||
|
$ENV{HOME}/Downloads/googletest-1.13.0.tar.gz
|
||||||
|
${PROJECT_SOURCE_DIR}/googletest-1.13.0.tar.gz
|
||||||
|
${PROJECT_BINARY_DIR}/googletest-1.13.0.tar.gz
|
||||||
|
/tmp/googletest-1.13.0.tar.gz
|
||||||
|
/star-fj/fangjun/download/github/googletest-1.13.0.tar.gz
|
||||||
|
)
|
||||||
|
|
||||||
|
foreach(f IN LISTS possible_file_locations)
|
||||||
|
if(EXISTS ${f})
|
||||||
|
set(googletest_URL "${f}")
|
||||||
|
file(TO_CMAKE_PATH "${googletest_URL}" googletest_URL)
|
||||||
|
set(googletest_URL2)
|
||||||
|
break()
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
|
||||||
set(BUILD_GMOCK ON CACHE BOOL "" FORCE)
|
set(BUILD_GMOCK ON CACHE BOOL "" FORCE)
|
||||||
set(INSTALL_GTEST OFF CACHE BOOL "" FORCE)
|
set(INSTALL_GTEST OFF CACHE BOOL "" FORCE)
|
||||||
@ -33,13 +53,15 @@ function(download_googltest)
|
|||||||
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
|
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
|
||||||
|
|
||||||
FetchContent_Declare(googletest
|
FetchContent_Declare(googletest
|
||||||
URL ${googletest_URL}
|
URL
|
||||||
|
${googletest_URL}
|
||||||
|
${googletest_URL2}
|
||||||
URL_HASH ${googletest_HASH}
|
URL_HASH ${googletest_HASH}
|
||||||
)
|
)
|
||||||
|
|
||||||
FetchContent_GetProperties(googletest)
|
FetchContent_GetProperties(googletest)
|
||||||
if(NOT googletest_POPULATED)
|
if(NOT googletest_POPULATED)
|
||||||
message(STATUS "Downloading googletest")
|
message(STATUS "Downloading googletest from ${googletest_URL}")
|
||||||
FetchContent_Populate(googletest)
|
FetchContent_Populate(googletest)
|
||||||
endif()
|
endif()
|
||||||
message(STATUS "googletest is downloaded to ${googletest_SOURCE_DIR}")
|
message(STATUS "googletest is downloaded to ${googletest_SOURCE_DIR}")
|
||||||
|
@ -8,17 +8,39 @@ function(download_pybind11)
|
|||||||
|
|
||||||
include(FetchContent)
|
include(FetchContent)
|
||||||
|
|
||||||
set(pybind11_URL "https://github.com/pybind/pybind11/archive/v2.9.2.tar.gz")
|
set(pybind11_URL "https://github.com/pybind/pybind11/archive/refs/tags/v2.12.0.tar.gz")
|
||||||
set(pybind11_HASH "SHA256=6bd528c4dbe2276635dc787b6b1f2e5316cf6b49ee3e150264e455a0d68d19c1")
|
set(pybind11_URL2 "https://hf-mirror.com/csukuangfj/sherpa-onnx-cmake-deps/resolve/main/pybind11-2.12.0.tar.gz")
|
||||||
|
set(pybind11_HASH "SHA256=bf8f242abd1abcd375d516a7067490fb71abd79519a282d22b6e4d19282185a7")
|
||||||
|
|
||||||
|
# If you don't have access to the Internet,
|
||||||
|
# please pre-download pybind11
|
||||||
|
set(possible_file_locations
|
||||||
|
$ENV{HOME}/Downloads/pybind11-2.12.0.tar.gz
|
||||||
|
${CMAKE_SOURCE_DIR}/pybind11-2.12.0.tar.gz
|
||||||
|
${CMAKE_BINARY_DIR}/pybind11-2.12.0.tar.gz
|
||||||
|
/tmp/pybind11-2.12.0.tar.gz
|
||||||
|
/star-fj/fangjun/download/github/pybind11-2.12.0.tar.gz
|
||||||
|
)
|
||||||
|
|
||||||
|
foreach(f IN LISTS possible_file_locations)
|
||||||
|
if(EXISTS ${f})
|
||||||
|
set(pybind11_URL "${f}")
|
||||||
|
file(TO_CMAKE_PATH "${pybind11_URL}" pybind11_URL)
|
||||||
|
set(pybind11_URL2)
|
||||||
|
break()
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
|
||||||
FetchContent_Declare(pybind11
|
FetchContent_Declare(pybind11
|
||||||
URL ${pybind11_URL}
|
URL
|
||||||
|
${pybind11_URL}
|
||||||
|
${pybind11_URL2}
|
||||||
URL_HASH ${pybind11_HASH}
|
URL_HASH ${pybind11_HASH}
|
||||||
)
|
)
|
||||||
|
|
||||||
FetchContent_GetProperties(pybind11)
|
FetchContent_GetProperties(pybind11)
|
||||||
if(NOT pybind11_POPULATED)
|
if(NOT pybind11_POPULATED)
|
||||||
message(STATUS "Downloading pybind11")
|
message(STATUS "Downloading pybind11 from ${pybind11_URL}")
|
||||||
FetchContent_Populate(pybind11)
|
FetchContent_Populate(pybind11)
|
||||||
endif()
|
endif()
|
||||||
message(STATUS "pybind11 is downloaded to ${pybind11_SOURCE_DIR}")
|
message(STATUS "pybind11 is downloaded to ${pybind11_SOURCE_DIR}")
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
dataclasses
|
dataclasses
|
||||||
recommonmark
|
recommonmark
|
||||||
sphinx
|
sphinx<7.0
|
||||||
sphinx-autodoc-typehints
|
sphinx-autodoc-typehints
|
||||||
sphinx_rtd_theme
|
sphinx_rtd_theme
|
||||||
sphinxcontrib-bibtex
|
sphinxcontrib-bibtex
|
||||||
|
@ -12,5 +12,5 @@ kaldifeat
|
|||||||
:caption: Contents
|
:caption: Contents
|
||||||
|
|
||||||
intro
|
intro
|
||||||
installation
|
installation/index
|
||||||
usage/index
|
usage/index
|
||||||
|
@ -1,167 +0,0 @@
|
|||||||
Installation
|
|
||||||
============
|
|
||||||
|
|
||||||
- |os_types|
|
|
||||||
- |python_versions|
|
|
||||||
- |pytorch_versions|
|
|
||||||
- |cuda_versions|
|
|
||||||
|
|
||||||
.. caution::
|
|
||||||
|
|
||||||
`kaldifeat`_ depends on `PyTorch`_. `PyTorch`_ >= 1.5.0 is known to work.
|
|
||||||
|
|
||||||
Please first install `PyTorch`_ before you install `kaldifeat`_.
|
|
||||||
|
|
||||||
.. hint::
|
|
||||||
|
|
||||||
To install a CPU version of `kaldifeat`_, please install a CPU version
|
|
||||||
of `PyTorch`_.
|
|
||||||
|
|
||||||
To install a CUDA version of `kaldifeat`_, please install a CUDA version
|
|
||||||
of `PyTorch`_. CUDA >= 10.1 is known to work.
|
|
||||||
|
|
||||||
.. _from source:
|
|
||||||
|
|
||||||
Install kaldifeat from source
|
|
||||||
-----------------------------
|
|
||||||
|
|
||||||
You have to install ``cmake`` and `PyTorch`_ first.
|
|
||||||
|
|
||||||
- ``cmake`` 3.11 is known to work. Other CMake versions may also work.
|
|
||||||
- `PyTorch`_ >= 1.5.0 is known to work. Other PyTorch versions may also work.
|
|
||||||
- Python >= 3.6
|
|
||||||
|
|
||||||
|
|
||||||
The commands to install `kaldifeat`_ from source are:
|
|
||||||
|
|
||||||
.. code-block:: bash
|
|
||||||
|
|
||||||
git clone https://github.com/csukuangfj/kaldifeat
|
|
||||||
cd kaldifeat
|
|
||||||
python3 setup.py install
|
|
||||||
|
|
||||||
To test that you have installed `kaldifeat`_ successfully, please run:
|
|
||||||
|
|
||||||
.. code-block:: bash
|
|
||||||
|
|
||||||
python3 -c "import kaldifeat; print(kaldifeat.__version__)"
|
|
||||||
|
|
||||||
It should print the version, e.g., ``1.0``.
|
|
||||||
|
|
||||||
.. _from PyPI:
|
|
||||||
|
|
||||||
Install kaldifeat from PyPI
|
|
||||||
---------------------------
|
|
||||||
|
|
||||||
The command to install `kaldifeat`_ from PyPI is:
|
|
||||||
|
|
||||||
.. code-block:: bash
|
|
||||||
|
|
||||||
pip install --verbose kaldifeat
|
|
||||||
|
|
||||||
To test that you have installed `kaldifeat`_ successfully, please run:
|
|
||||||
|
|
||||||
.. code-block:: bash
|
|
||||||
|
|
||||||
python3 -c "import kaldifeat; print(kaldifeat.__version__)"
|
|
||||||
|
|
||||||
It should print the version, e.g., ``1.0``.
|
|
||||||
|
|
||||||
Install kaldifeat from conda (Only for Linux)
|
|
||||||
---------------------------------------------
|
|
||||||
|
|
||||||
.. hint::
|
|
||||||
|
|
||||||
Installation using ``conda`` supports only Linux. For macOS and Windows,
|
|
||||||
please use either :ref:`from source` or :ref:`from PyPI`.
|
|
||||||
|
|
||||||
The command to install `kaldifeat` using ``conda`` is
|
|
||||||
|
|
||||||
.. code-block:: bash
|
|
||||||
|
|
||||||
conda install -c kaldifeat -c pytorch -c conda-forge kaldifeat python=3.8 cudatoolkit=11.1 pytorch=1.8.1
|
|
||||||
|
|
||||||
You can select the supported Python version, CUDA toolkit version and `PyTorch`_ version as you wish.
|
|
||||||
|
|
||||||
To install a CPU version of `kaldifeat`, use:
|
|
||||||
|
|
||||||
.. code-block:: bash
|
|
||||||
|
|
||||||
conda install -c kaldifeat -c pytorch cpuonly kaldifeat python=3.8 pytorch=1.8.1
|
|
||||||
|
|
||||||
.. caution::
|
|
||||||
|
|
||||||
If you encounter issues about missing GLIBC after installing `kaldifeat`_
|
|
||||||
with ``conda``, please consider :ref:`from source` or :ref:`from PyPI`.
|
|
||||||
The reason is that the package was built using Ubuntu 18.04 and your system's
|
|
||||||
GLIBC is older.
|
|
||||||
|
|
||||||
|
|
||||||
.. |os_types| image:: ./images/os-green.svg
|
|
||||||
:alt: Supported operating systems
|
|
||||||
|
|
||||||
.. |python_versions| image:: ./images/python_ge_3.6-blue.svg
|
|
||||||
:alt: Supported python versions
|
|
||||||
|
|
||||||
.. |cuda_versions| image:: ./images/cuda_ge_10.1-orange.svg
|
|
||||||
:alt: Supported cuda versions
|
|
||||||
|
|
||||||
.. |pytorch_versions| image:: ./images/pytorch_ge_1.5.0-green.svg
|
|
||||||
:alt: Supported pytorch versions
|
|
||||||
|
|
||||||
To test that you have installed `kaldifeat`_ successfully, please run:
|
|
||||||
|
|
||||||
.. code-block:: bash
|
|
||||||
|
|
||||||
python3 -c "import kaldifeat; print(kaldifeat.__version__)"
|
|
||||||
|
|
||||||
It should print the version, e.g., ``1.0``.
|
|
||||||
|
|
||||||
FAQs
|
|
||||||
----
|
|
||||||
|
|
||||||
How to install a CUDA version of kaldifeat
|
|
||||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
You need to first install a CUDA version of `PyTorch`_ and then install `kaldifeat`_.
|
|
||||||
|
|
||||||
.. note::
|
|
||||||
|
|
||||||
You can use a CUDA version of `kaldifeat`_ on machines with no GPUs.
|
|
||||||
|
|
||||||
How to install a CPU version of kaldifeat
|
|
||||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
You need to first install a CPU version of `PyTorch`_ and then install `kaldifeat`_.
|
|
||||||
|
|
||||||
How to fix `Caffe2: Cannot find cuDNN library`
|
|
||||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
|
||||||
|
|
||||||
.. code-block::
|
|
||||||
|
|
||||||
Your installed Caffe2 version uses cuDNN but I cannot find the cuDNN
|
|
||||||
libraries. Please set the proper cuDNN prefixes and / or install cuDNN.
|
|
||||||
|
|
||||||
You will have such an error when you want to install a CUDA version of `kaldifeat`_
|
|
||||||
by ``pip install kaldifeat`` or from source.
|
|
||||||
|
|
||||||
You need to first install cuDNN. Assume you have installed cuDNN to the
|
|
||||||
path ``/path/to/cudnn``. You can fix the error by using ``one`` of the following
|
|
||||||
commands.
|
|
||||||
|
|
||||||
(1) Fix for installation using ``pip install``
|
|
||||||
|
|
||||||
.. code-block:: bash
|
|
||||||
|
|
||||||
export KALDIFEAT_CMAKE_ARGS="-DCMAKE_BUILD_TYPE=Release -DCUDNN_LIBRARY_PATH=/path/to/cudnn/lib/libcudnn.so -DCUDNN_INCLUDE_PATH=/path/to/cudnn/include"
|
|
||||||
pip install --verbose kaldifeat
|
|
||||||
|
|
||||||
(2) Fix for installation from source
|
|
||||||
|
|
||||||
.. code-block:: bash
|
|
||||||
|
|
||||||
mkdir /some/path
|
|
||||||
git clone https://github.com/csukuangfj/kaldifeat.git
|
|
||||||
cd kaldifeat
|
|
||||||
export KALDIFEAT_CMAKE_ARGS="-DCMAKE_BUILD_TYPE=Release -DCUDNN_LIBRARY_PATH=/path/to/cudnn/lib/libcudnn.so -DCUDNN_INCLUDE_PATH=/path/to/cudnn/include"
|
|
||||||
python setup.py install
|
|
48
doc/source/installation/faq.rst
Normal file
48
doc/source/installation/faq.rst
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
FAQs
|
||||||
|
====
|
||||||
|
|
||||||
|
How to install a CUDA version of kaldifeat from source
|
||||||
|
------------------------------------------------------
|
||||||
|
|
||||||
|
You need to first install a CUDA version of `PyTorch`_ and then install `kaldifeat`_.
|
||||||
|
|
||||||
|
.. note::
|
||||||
|
|
||||||
|
You can use a CUDA version of `kaldifeat`_ on machines with no GPUs.
|
||||||
|
|
||||||
|
How to install a CPU version of kaldifeat from source
|
||||||
|
-----------------------------------------------------
|
||||||
|
|
||||||
|
You need to first install a CPU version of `PyTorch`_ and then install `kaldifeat`_.
|
||||||
|
|
||||||
|
How to fix `Caffe2: Cannot find cuDNN library`
|
||||||
|
----------------------------------------------
|
||||||
|
|
||||||
|
.. code-block::
|
||||||
|
|
||||||
|
Your installed Caffe2 version uses cuDNN but I cannot find the cuDNN
|
||||||
|
libraries. Please set the proper cuDNN prefixes and / or install cuDNN.
|
||||||
|
|
||||||
|
You will have such an error when you want to install a CUDA version of `kaldifeat`_
|
||||||
|
by ``pip install kaldifeat`` or from source.
|
||||||
|
|
||||||
|
You need to first install cuDNN. Assume you have installed cuDNN to the
|
||||||
|
path ``/path/to/cudnn``. You can fix the error by using ``one`` of the following
|
||||||
|
commands.
|
||||||
|
|
||||||
|
(1) Fix for installation using ``pip install``
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
export KALDIFEAT_CMAKE_ARGS="-DCMAKE_BUILD_TYPE=Release -DCUDNN_LIBRARY_PATH=/path/to/cudnn/lib/libcudnn.so -DCUDNN_INCLUDE_PATH=/path/to/cudnn/include"
|
||||||
|
pip install --verbose kaldifeat
|
||||||
|
|
||||||
|
(2) Fix for installation from source
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
mkdir /some/path
|
||||||
|
git clone https://github.com/csukuangfj/kaldifeat.git
|
||||||
|
cd kaldifeat
|
||||||
|
export KALDIFEAT_CMAKE_ARGS="-DCMAKE_BUILD_TYPE=Release -DCUDNN_LIBRARY_PATH=/path/to/cudnn/lib/libcudnn.so -DCUDNN_INCLUDE_PATH=/path/to/cudnn/include"
|
||||||
|
python setup.py install
|
47
doc/source/installation/from_source.rst
Normal file
47
doc/source/installation/from_source.rst
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
.. _from source:
|
||||||
|
|
||||||
|
Install kaldifeat from source
|
||||||
|
=============================
|
||||||
|
|
||||||
|
You have to install ``cmake`` and `PyTorch`_ first.
|
||||||
|
|
||||||
|
- ``cmake`` 3.11 is known to work. Other CMake versions may also work.
|
||||||
|
- `PyTorch`_ >= 1.5.0 is known to work. Other PyTorch versions may also work.
|
||||||
|
- Python >= 3.6
|
||||||
|
- A compiler that supports C++ 14
|
||||||
|
|
||||||
|
|
||||||
|
The commands to install `kaldifeat`_ from source are:
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
git clone https://github.com/csukuangfj/kaldifeat
|
||||||
|
cd kaldifeat
|
||||||
|
python3 setup.py install
|
||||||
|
|
||||||
|
To test that you have installed `kaldifeat`_ successfully, please run:
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
python3 -c "import kaldifeat; print(kaldifeat.__version__)"
|
||||||
|
|
||||||
|
It should print the version, e.g., ``1.0``.
|
||||||
|
|
||||||
|
.. _from PyPI:
|
||||||
|
|
||||||
|
Install kaldifeat from PyPI
|
||||||
|
---------------------------
|
||||||
|
|
||||||
|
The command to install `kaldifeat`_ from PyPI is:
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
pip install --verbose kaldifeat
|
||||||
|
|
||||||
|
To test that you have installed `kaldifeat`_ successfully, please run:
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
python3 -c "import kaldifeat; print(kaldifeat.__version__)"
|
||||||
|
|
||||||
|
It should print the version, e.g., ``1.0``.
|
139
doc/source/installation/from_wheels.rst
Normal file
139
doc/source/installation/from_wheels.rst
Normal file
@ -0,0 +1,139 @@
|
|||||||
|
From pre-compiled wheels (Recommended)
|
||||||
|
=======================================
|
||||||
|
|
||||||
|
You can find pre-compiled wheels at
|
||||||
|
|
||||||
|
- CPU wheels: `<https://csukuangfj.github.io/kaldifeat/cpu.html>`_
|
||||||
|
- CUDA wheels: `<https://csukuangfj.github.io/kaldifeat/cuda.html>`_
|
||||||
|
|
||||||
|
We give a few examples below to show you how to install `kaldifeat`_ from
|
||||||
|
pre-compiled wheels.
|
||||||
|
|
||||||
|
.. hint::
|
||||||
|
|
||||||
|
The following lists only some examples. We suggest that you always select the
|
||||||
|
latest version of ``kaldifeat``.
|
||||||
|
|
||||||
|
Linux (CPU)
|
||||||
|
-----------
|
||||||
|
|
||||||
|
Suppose you want to install the following wheel:
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
https://huggingface.co/csukuangfj/kaldifeat/resolve/main/ubuntu-cpu/kaldifeat-1.25.4.dev20240725+cpu.torch2.4.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
|
||||||
|
|
||||||
|
you can use one of the following methods:
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
# method 1
|
||||||
|
pip install torch==2.4.0+cpu -f https://download.pytorch.org/whl/torch/
|
||||||
|
pip install kaldifeat==1.25.4.dev20240725+cpu.torch2.4.0 -f https://csukuangfj.github.io/kaldifeat/cpu.html
|
||||||
|
|
||||||
|
# For users from China
|
||||||
|
# 中国国内用户,如果访问不了 huggingface, 请使用
|
||||||
|
# pip install kaldifeat==1.25.4.dev20240725+cpu.torch2.4.0 -f https://csukuangfj.github.io/kaldifeat/cpu-cn.html
|
||||||
|
|
||||||
|
# method 2
|
||||||
|
pip install torch==2.4.0+cpu -f https://download.pytorch.org/whl/torch/
|
||||||
|
wget https://huggingface.co/csukuangfj/kaldifeat/resolve/main/ubuntu-cpu/kaldifeat-1.25.4.dev20240725+cpu.torch2.4.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
|
||||||
|
|
||||||
|
# For users from China
|
||||||
|
# 中国国内用户,如果访问不了 huggingface, 请使用
|
||||||
|
# wget https://hf-mirror.com/csukuangfj/kaldifeat/resolve/main/ubuntu-cpu/kaldifeat-1.25.4.dev20240725+cpu.torch2.4.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
|
||||||
|
|
||||||
|
pip install ./kaldifeat-1.25.4.dev20240725+cpu.torch2.4.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
|
||||||
|
|
||||||
|
Windows (CPU)
|
||||||
|
--------------
|
||||||
|
|
||||||
|
Suppose you want to install the following wheel:
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
https://huggingface.co/csukuangfj/kaldifeat/resolve/main/windows-cpu/kaldifeat-1.25.4.dev20240725+cpu.torch2.4.0-cp312-cp312-win_amd64.whl
|
||||||
|
|
||||||
|
you can use one of the following methods:
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
# method 1
|
||||||
|
pip install torch==2.4.0+cpu -f https://download.pytorch.org/whl/torch/
|
||||||
|
pip install kaldifeat==1.25.4.dev20240725+cpu.torch2.4.0 -f https://csukuangfj.github.io/kaldifeat/cpu.html
|
||||||
|
|
||||||
|
# For users from China
|
||||||
|
# 中国国内用户,如果访问不了 huggingface, 请使用
|
||||||
|
# pip install kaldifeat==1.25.4.dev20240725+cpu.torch2.4.0 -f https://csukuangfj.github.io/kaldifeat/cpu-cn.html
|
||||||
|
|
||||||
|
# method 2
|
||||||
|
pip install torch==2.4.0+cpu -f https://download.pytorch.org/whl/torch/
|
||||||
|
wget https://huggingface.co/csukuangfj/kaldifeat/resolve/main/windows-cpu/kaldifeat-1.25.4.dev20240725+cpu.torch2.4.0-cp312-cp312-win_amd64.whl
|
||||||
|
|
||||||
|
# For users from China
|
||||||
|
# 中国国内用户,如果访问不了 huggingface, 请使用
|
||||||
|
# wget https://hf-mirror.com/csukuangfj/kaldifeat/resolve/main/windows-cpu/kaldifeat-1.25.4.dev20240725+cpu.torch2.4.0-cp312-cp312-win_amd64.whl
|
||||||
|
|
||||||
|
pip install ./kaldifeat-1.25.4.dev20240725+cpu.torch2.4.0-cp312-cp312-win_amd64.whl
|
||||||
|
|
||||||
|
macOS (CPU)
|
||||||
|
-----------
|
||||||
|
|
||||||
|
Suppose you want to install the following wheel:
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
https://huggingface.co/csukuangfj/kaldifeat/resolve/main/macos/kaldifeat-1.25.4.dev20240725+cpu.torch2.4.0-cp311-cp311-macosx_11_0_arm64.whl
|
||||||
|
|
||||||
|
you can use one of the following methods:
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
# method 1
|
||||||
|
pip install torch==2.4.0
|
||||||
|
pip install kaldifeat==1.25.4.dev20240725+cpu.torch2.4.0 -f https://csukuangfj.github.io/kaldifeat/cpu.html
|
||||||
|
|
||||||
|
# For users from China
|
||||||
|
# 中国国内用户,如果访问不了 huggingface, 请使用
|
||||||
|
# pip install kaldifeat==1.25.4.dev20240725+cpu.torch2.4.0 -f https://csukuangfj.github.io/kaldifeat/cpu-cn.html
|
||||||
|
|
||||||
|
# method 2
|
||||||
|
pip install torch==2.4.0 -f https://download.pytorch.org/whl/torch/
|
||||||
|
wget https://huggingface.co/csukuangfj/kaldifeat/resolve/main/macos/kaldifeat-1.25.4.dev20240725+cpu.torch2.4.0-cp311-cp311-macosx_11_0_arm64.whl
|
||||||
|
|
||||||
|
# For users from China
|
||||||
|
# 中国国内用户,如果访问不了 huggingface, 请使用
|
||||||
|
# wget https://hf-mirror.com/csukuangfj/kaldifeat/resolve/main/macos/kaldifeat-1.25.4.dev20240725+cpu.torch2.4.0-cp311-cp311-macosx_11_0_arm64.whl
|
||||||
|
|
||||||
|
pip install ./kaldifeat-1.25.4.dev20240725+cpu.torch2.4.0-cp311-cp311-macosx_11_0_arm64.whl
|
||||||
|
|
||||||
|
Linux (CUDA)
|
||||||
|
------------
|
||||||
|
|
||||||
|
Suppose you want to install the following wheel:
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
https://huggingface.co/csukuangfj/kaldifeat/resolve/main/ubuntu-cuda/kaldifeat-1.25.4.dev20240725+cuda12.4.torch2.4.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
|
||||||
|
|
||||||
|
you can use one of the following methods:
|
||||||
|
|
||||||
|
.. code-block:: bash
|
||||||
|
|
||||||
|
# method 1
|
||||||
|
pip install torch==2.4.0+cu124 -f https://download.pytorch.org/whl/torch/
|
||||||
|
pip install kaldifeat==1.25.4.dev20240725+cuda12.4.torch2.4.0 -f https://csukuangfj.github.io/kaldifeat/cuda.html
|
||||||
|
|
||||||
|
# For users from China
|
||||||
|
# 中国国内用户,如果访问不了 huggingface, 请使用
|
||||||
|
# pip install kaldifeat==1.25.4.dev20240725+cuda12.4.torch2.4.0 -f https://csukuangfj.github.io/kaldifeat/cuda-cn.html
|
||||||
|
|
||||||
|
# method 2
|
||||||
|
pip install torch==2.4.0+cu124 -f https://download.pytorch.org/whl/torch/
|
||||||
|
wget https://huggingface.co/csukuangfj/kaldifeat/resolve/main/ubuntu-cuda/kaldifeat-1.25.4.dev20240725+cuda12.4.torch2.4.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
|
||||||
|
|
||||||
|
# For users from China
|
||||||
|
# 中国国内用户,如果访问不了 huggingface, 请使用
|
||||||
|
# wget https://hf-mirror.com/csukuangfj/kaldifeat/resolve/main/ubuntu-cuda/kaldifeat-1.25.4.dev20240725+cuda12.4.torch2.4.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
|
||||||
|
|
||||||
|
pip install ./kaldifeat-1.25.4.dev20240725+cuda12.4.torch2.4.0-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
|
11
doc/source/installation/index.rst
Normal file
11
doc/source/installation/index.rst
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
Installation
|
||||||
|
============
|
||||||
|
|
||||||
|
.. toctree::
|
||||||
|
:maxdepth: 3
|
||||||
|
|
||||||
|
./from_wheels.rst
|
||||||
|
./from_source.rst
|
||||||
|
./faq.rst
|
||||||
|
|
||||||
|
|
@ -10,7 +10,6 @@ The following code shows how to construct an instance of `kaldifeat.FbankOptions
|
|||||||
.. literalinclude:: ./code/fbank_options-1.txt
|
.. literalinclude:: ./code/fbank_options-1.txt
|
||||||
:caption: Usage of `kaldifeat.FbankOptions`_
|
:caption: Usage of `kaldifeat.FbankOptions`_
|
||||||
:emphasize-lines: 6,8,22,37
|
:emphasize-lines: 6,8,22,37
|
||||||
:language: python
|
|
||||||
|
|
||||||
Note that we reuse the same option name with `compute-fbank-feats`_ from `Kaldi`_:
|
Note that we reuse the same option name with `compute-fbank-feats`_ from `Kaldi`_:
|
||||||
|
|
||||||
|
106
get_version.py
Executable file
106
get_version.py
Executable file
@ -0,0 +1,106 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
import datetime
|
||||||
|
import os
|
||||||
|
import platform
|
||||||
|
import re
|
||||||
|
import shutil
|
||||||
|
|
||||||
|
import torch
|
||||||
|
|
||||||
|
|
||||||
|
def is_macos():
|
||||||
|
return platform.system() == "Darwin"
|
||||||
|
|
||||||
|
|
||||||
|
def is_windows():
|
||||||
|
return platform.system() == "Windows"
|
||||||
|
|
||||||
|
|
||||||
|
def with_cuda():
|
||||||
|
if shutil.which("nvcc") is None:
|
||||||
|
return False
|
||||||
|
|
||||||
|
if is_macos():
|
||||||
|
return False
|
||||||
|
|
||||||
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
def get_pytorch_version():
|
||||||
|
# if it is 1.7.1+cuda101, then strip +cuda101
|
||||||
|
return torch.__version__.split("+")[0]
|
||||||
|
|
||||||
|
|
||||||
|
def get_cuda_version():
|
||||||
|
from torch.utils import collect_env
|
||||||
|
|
||||||
|
running_cuda_version = collect_env.get_running_cuda_version(collect_env.run)
|
||||||
|
cuda_version = torch.version.cuda
|
||||||
|
if running_cuda_version is not None and cuda_version is not None:
|
||||||
|
assert cuda_version in running_cuda_version, (
|
||||||
|
f"PyTorch is built with CUDA version: {cuda_version}.\n"
|
||||||
|
f"The current running CUDA version is: {running_cuda_version}"
|
||||||
|
)
|
||||||
|
return cuda_version
|
||||||
|
|
||||||
|
|
||||||
|
def is_for_pypi():
|
||||||
|
ans = os.environ.get("KALDIFEAT_IS_FOR_PYPI", None)
|
||||||
|
return ans is not None
|
||||||
|
|
||||||
|
|
||||||
|
def is_stable():
|
||||||
|
ans = os.environ.get("KALDIFEAT_IS_STABLE", None)
|
||||||
|
return ans is not None
|
||||||
|
|
||||||
|
|
||||||
|
def is_for_conda():
|
||||||
|
ans = os.environ.get("KALDIFEAT_IS_FOR_CONDA", None)
|
||||||
|
return ans is not None
|
||||||
|
|
||||||
|
|
||||||
|
def get_package_version():
|
||||||
|
# Set a default CUDA version here so that `pip install kaldifeat`
|
||||||
|
# uses the default CUDA version.
|
||||||
|
#
|
||||||
|
default_cuda_version = "10.1" # CUDA 10.1
|
||||||
|
|
||||||
|
if with_cuda():
|
||||||
|
cuda_version = get_cuda_version()
|
||||||
|
if is_for_pypi() and default_cuda_version == cuda_version:
|
||||||
|
cuda_version = ""
|
||||||
|
pytorch_version = ""
|
||||||
|
local_version = ""
|
||||||
|
else:
|
||||||
|
cuda_version = f"+cuda{cuda_version}"
|
||||||
|
pytorch_version = get_pytorch_version()
|
||||||
|
local_version = f"{cuda_version}.torch{pytorch_version}"
|
||||||
|
else:
|
||||||
|
pytorch_version = get_pytorch_version()
|
||||||
|
local_version = f"+cpu.torch{pytorch_version}"
|
||||||
|
|
||||||
|
if is_for_conda():
|
||||||
|
local_version = ""
|
||||||
|
|
||||||
|
if is_for_pypi() and is_macos():
|
||||||
|
local_version = ""
|
||||||
|
|
||||||
|
with open("CMakeLists.txt") as f:
|
||||||
|
content = f.read()
|
||||||
|
|
||||||
|
latest_version = re.search(r"set\(kaldifeat_VERSION (.*)\)", content).group(
|
||||||
|
1
|
||||||
|
)
|
||||||
|
latest_version = latest_version.strip('"')
|
||||||
|
|
||||||
|
if not is_stable():
|
||||||
|
dt = datetime.datetime.utcnow()
|
||||||
|
package_version = f"{latest_version}.dev{dt.year}{dt.month:02d}{dt.day:02d}{local_version}"
|
||||||
|
else:
|
||||||
|
package_version = f"{latest_version}"
|
||||||
|
return package_version
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
print(get_package_version())
|
@ -10,6 +10,7 @@ set(kaldifeat_srcs
|
|||||||
matrix-functions.cc
|
matrix-functions.cc
|
||||||
mel-computations.cc
|
mel-computations.cc
|
||||||
online-feature.cc
|
online-feature.cc
|
||||||
|
whisper-fbank.cc
|
||||||
)
|
)
|
||||||
|
|
||||||
add_library(kaldifeat_core ${kaldifeat_srcs})
|
add_library(kaldifeat_core ${kaldifeat_srcs})
|
||||||
@ -78,10 +79,15 @@ file(COPY
|
|||||||
DESTINATION
|
DESTINATION
|
||||||
${PROJECT_BINARY_DIR}/include/kaldifeat/csrc
|
${PROJECT_BINARY_DIR}/include/kaldifeat/csrc
|
||||||
)
|
)
|
||||||
|
if(BUILD_SHARED_LIBS AND WIN32)
|
||||||
|
install(TARGETS kaldifeat_core
|
||||||
|
DESTINATION ../
|
||||||
|
)
|
||||||
|
endif()
|
||||||
install(TARGETS kaldifeat_core
|
install(TARGETS kaldifeat_core
|
||||||
DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
DESTINATION ${CMAKE_INSTALL_LIBDIR}
|
||||||
)
|
)
|
||||||
|
|
||||||
install(FILES ${all_headers}
|
install(FILES ${all_headers}
|
||||||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/kaldifeat/csrc
|
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/kaldifeat/csrc
|
||||||
)
|
)
|
||||||
|
1
kaldifeat/csrc/CPPLINT.cfg
Normal file
1
kaldifeat/csrc/CPPLINT.cfg
Normal file
@ -0,0 +1 @@
|
|||||||
|
exclude_files=whisper-mel-bank.h,whisper-v3-mel-bank.h
|
@ -65,7 +65,7 @@ torch::Tensor FbankComputer::Compute(torch::Tensor signal_raw_log_energy,
|
|||||||
// note spectrum is in magnitude, not power, because of `abs()`
|
// note spectrum is in magnitude, not power, because of `abs()`
|
||||||
#if defined(KALDIFEAT_HAS_FFT_NAMESPACE)
|
#if defined(KALDIFEAT_HAS_FFT_NAMESPACE)
|
||||||
// signal_frame shape: [x, 512]
|
// signal_frame shape: [x, 512]
|
||||||
// spectrum shape [x, 257
|
// spectrum shape [x, 257]
|
||||||
torch::Tensor spectrum = torch::fft::rfft(signal_frame).abs();
|
torch::Tensor spectrum = torch::fft::rfft(signal_frame).abs();
|
||||||
#else
|
#else
|
||||||
// signal_frame shape [x, 512]
|
// signal_frame shape [x, 512]
|
||||||
|
@ -44,20 +44,18 @@ struct FbankOptions {
|
|||||||
|
|
||||||
std::string ToString() const {
|
std::string ToString() const {
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
os << "frame_opts: \n";
|
os << "FbankOptions(";
|
||||||
os << frame_opts << "\n";
|
|
||||||
os << "\n";
|
|
||||||
|
|
||||||
os << "mel_opts: \n";
|
os << "frame_opts=" << frame_opts.ToString() << ", ";
|
||||||
os << mel_opts << "\n";
|
os << "mel_opts=" << mel_opts.ToString() << ", ";
|
||||||
|
|
||||||
os << "use_energy: " << use_energy << "\n";
|
os << "use_energy=" << (use_energy ? "True" : "False") << ", ";
|
||||||
os << "energy_floor: " << energy_floor << "\n";
|
os << "energy_floor=" << energy_floor << ", ";
|
||||||
os << "raw_energy: " << raw_energy << "\n";
|
os << "raw_energy=" << (raw_energy ? "True" : "False") << ", ";
|
||||||
os << "htk_compat: " << htk_compat << "\n";
|
os << "htk_compat=" << (htk_compat ? "True" : "False") << ", ";
|
||||||
os << "use_log_fbank: " << use_log_fbank << "\n";
|
os << "use_log_fbank=" << (use_log_fbank ? "True" : "False") << ", ";
|
||||||
os << "use_power: " << use_power << "\n";
|
os << "use_power=" << (use_power ? "True" : "False") << ", ";
|
||||||
os << "device: " << device << "\n";
|
os << "device=\"" << device << "\")";
|
||||||
return os.str();
|
return os.str();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -53,20 +53,18 @@ struct MfccOptions {
|
|||||||
|
|
||||||
std::string ToString() const {
|
std::string ToString() const {
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
os << "frame_opts: \n";
|
os << "MfccOptions(";
|
||||||
os << frame_opts << "\n";
|
os << "frame_opts=" << frame_opts.ToString() << ", ";
|
||||||
os << "\n";
|
os << "mel_opts=" << mel_opts.ToString() << ", ";
|
||||||
|
|
||||||
os << "mel_opts: \n";
|
os << "num_ceps=" << num_ceps << ", ";
|
||||||
os << mel_opts << "\n";
|
os << "use_energy=" << (use_energy ? "True" : "False") << ", ";
|
||||||
|
os << "energy_floor=" << energy_floor << ", ";
|
||||||
|
os << "raw_energy=" << (raw_energy ? "True" : "False") << ", ";
|
||||||
|
os << "cepstral_lifter=" << cepstral_lifter << ", ";
|
||||||
|
os << "htk_compat=" << (htk_compat ? "True" : "False") << ", ";
|
||||||
|
os << "device=\"" << device << "\")";
|
||||||
|
|
||||||
os << "num_ceps: " << num_ceps << "\n";
|
|
||||||
os << "use_energy: " << use_energy << "\n";
|
|
||||||
os << "energy_floor: " << energy_floor << "\n";
|
|
||||||
os << "raw_energy: " << raw_energy << "\n";
|
|
||||||
os << "cepstral_lifter: " << cepstral_lifter << "\n";
|
|
||||||
os << "htk_compat: " << htk_compat << "\n";
|
|
||||||
os << "device: " << device << "\n";
|
|
||||||
return os.str();
|
return os.str();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -61,23 +61,21 @@ struct PlpOptions {
|
|||||||
|
|
||||||
std::string ToString() const {
|
std::string ToString() const {
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
os << "frame_opts: \n";
|
os << "PlpOptions(";
|
||||||
os << frame_opts << "\n";
|
|
||||||
os << "\n";
|
|
||||||
|
|
||||||
os << "mel_opts: \n";
|
os << "frame_opts=" << frame_opts.ToString() << ", ";
|
||||||
os << mel_opts << "\n";
|
os << "mel_opts=" << mel_opts.ToString() << ", ";
|
||||||
|
|
||||||
os << "lpc_order: " << lpc_order << "\n";
|
os << "lpc_order=" << lpc_order << ", ";
|
||||||
os << "num_ceps: " << num_ceps << "\n";
|
os << "num_ceps=" << num_ceps << ", ";
|
||||||
os << "use_energy: " << use_energy << "\n";
|
os << "use_energy=" << (use_energy ? "True" : "False") << ", ";
|
||||||
os << "energy_floor: " << energy_floor << "\n";
|
os << "energy_floor=" << energy_floor << ", ";
|
||||||
os << "raw_energy: " << raw_energy << "\n";
|
os << "raw_energy=" << (raw_energy ? "True" : "False") << ", ";
|
||||||
os << "compress_factor: " << compress_factor << "\n";
|
os << "compress_factor=" << compress_factor << ", ";
|
||||||
os << "cepstral_lifter: " << cepstral_lifter << "\n";
|
os << "cepstral_lifter=" << cepstral_lifter << ", ";
|
||||||
os << "cepstral_scale: " << cepstral_scale << "\n";
|
os << "cepstral_scale=" << cepstral_scale << ", ";
|
||||||
os << "htk_compat: " << htk_compat << "\n";
|
os << "htk_compat=" << (htk_compat ? "True" : "False") << ", ";
|
||||||
os << "device: " << device << "\n";
|
os << "device=\"" << device << "\")";
|
||||||
return os.str();
|
return os.str();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -36,13 +36,12 @@ struct SpectrogramOptions {
|
|||||||
|
|
||||||
std::string ToString() const {
|
std::string ToString() const {
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
os << "frame_opts: \n";
|
os << "SpectrogramOptions(";
|
||||||
os << frame_opts << "\n";
|
os << "frame_opts=" << frame_opts.ToString() << ", ";
|
||||||
|
os << "energy_floor=" << energy_floor << ", ";
|
||||||
os << "energy_floor: " << energy_floor << "\n";
|
os << "raw_energy=" << (raw_energy ? "True" : "False") << ", ";
|
||||||
os << "raw_energy: " << raw_energy << "\n";
|
os << "return_raw_fft=" << (return_raw_fft ? "True" : "False") << ", ";
|
||||||
// os << "return_raw_fft: " << return_raw_fft << "\n";
|
os << "device=\"" << device << "\")";
|
||||||
os << "device: " << device << "\n";
|
|
||||||
return os.str();
|
return os.str();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -29,6 +29,13 @@ FeatureWindowFunction::FeatureWindowFunction(const FrameExtractionOptions &opts,
|
|||||||
float *window_data = window.data_ptr<float>();
|
float *window_data = window.data_ptr<float>();
|
||||||
|
|
||||||
double a = M_2PI / (frame_length - 1);
|
double a = M_2PI / (frame_length - 1);
|
||||||
|
|
||||||
|
if (opts.window_type == "hann") {
|
||||||
|
// see https://pytorch.org/docs/stable/generated/torch.hann_window.html
|
||||||
|
// We assume periodic is true
|
||||||
|
a = M_2PI / frame_length;
|
||||||
|
}
|
||||||
|
|
||||||
for (int32_t i = 0; i < frame_length; i++) {
|
for (int32_t i = 0; i < frame_length; i++) {
|
||||||
double i_fl = static_cast<double>(i);
|
double i_fl = static_cast<double>(i);
|
||||||
if (opts.window_type == "hanning") {
|
if (opts.window_type == "hanning") {
|
||||||
@ -39,6 +46,8 @@ FeatureWindowFunction::FeatureWindowFunction(const FrameExtractionOptions &opts,
|
|||||||
window_data[i] = sin(0.5 * a * i_fl);
|
window_data[i] = sin(0.5 * a * i_fl);
|
||||||
} else if (opts.window_type == "hamming") {
|
} else if (opts.window_type == "hamming") {
|
||||||
window_data[i] = 0.54 - 0.46 * cos(a * i_fl);
|
window_data[i] = 0.54 - 0.46 * cos(a * i_fl);
|
||||||
|
} else if (opts.window_type == "hann") {
|
||||||
|
window_data[i] = 0.50 - 0.50 * cos(a * i_fl);
|
||||||
} else if (opts.window_type ==
|
} else if (opts.window_type ==
|
||||||
"povey") { // like hamming but goes to zero at edges.
|
"povey") { // like hamming but goes to zero at edges.
|
||||||
window_data[i] = pow(0.5 - 0.5 * cos(a * i_fl), 0.85);
|
window_data[i] = pow(0.5 - 0.5 * cos(a * i_fl), 0.85);
|
||||||
|
@ -62,21 +62,20 @@ struct FrameExtractionOptions {
|
|||||||
}
|
}
|
||||||
std::string ToString() const {
|
std::string ToString() const {
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
#define KALDIFEAT_PRINT(x) os << #x << ": " << x << "\n"
|
os << "FrameExtractionOptions(";
|
||||||
KALDIFEAT_PRINT(samp_freq);
|
os << "samp_freq=" << samp_freq << ", ";
|
||||||
KALDIFEAT_PRINT(frame_shift_ms);
|
os << "frame_shift_ms=" << frame_shift_ms << ", ";
|
||||||
KALDIFEAT_PRINT(frame_length_ms);
|
os << "frame_length_ms=" << frame_length_ms << ", ";
|
||||||
KALDIFEAT_PRINT(dither);
|
os << "dither=" << dither << ", ";
|
||||||
KALDIFEAT_PRINT(preemph_coeff);
|
os << "preemph_coeff=" << preemph_coeff << ", ";
|
||||||
KALDIFEAT_PRINT(remove_dc_offset);
|
os << "remove_dc_offset=" << (remove_dc_offset ? "True" : "False") << ", ";
|
||||||
KALDIFEAT_PRINT(window_type);
|
os << "window_type=" << '"' << window_type << '"' << ", ";
|
||||||
KALDIFEAT_PRINT(round_to_power_of_two);
|
os << "round_to_power_of_two=" << (round_to_power_of_two ? "True" : "False")
|
||||||
KALDIFEAT_PRINT(blackman_coeff);
|
<< ", ";
|
||||||
KALDIFEAT_PRINT(snip_edges);
|
os << "blackman_coeff=" << blackman_coeff << ", ";
|
||||||
// KALDIFEAT_PRINT(allow_downsample);
|
os << "snip_edges=" << (snip_edges ? "True" : "False") << ", ";
|
||||||
// KALDIFEAT_PRINT(allow_upsample);
|
os << "max_feature_vectors=" << max_feature_vectors << ")";
|
||||||
KALDIFEAT_PRINT(max_feature_vectors);
|
|
||||||
#undef KALDIFEAT_PRINT
|
|
||||||
return os.str();
|
return os.str();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
39
kaldifeat/csrc/generate-whisper-melbank-v3.py
Executable file
39
kaldifeat/csrc/generate-whisper-melbank-v3.py
Executable file
@ -0,0 +1,39 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
# Copyright (c) 2023 Xiaomi Corporation (authors: Fangjun Kuang)
|
||||||
|
|
||||||
|
import librosa
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
m = librosa.filters.mel(sr=16000, n_fft=400, n_mels=128)
|
||||||
|
assert m.shape == (128, 201)
|
||||||
|
s = "// Auto-generated. Do NOT edit!\n\n"
|
||||||
|
s += "// Copyright (c) 2023 Xiaomi Corporation (authors: Fangjun Kuang)\n\n"
|
||||||
|
s += "\n"
|
||||||
|
s += "#ifndef KALDIFEAT_CSRC_WHISPER_V3_MEL_BANK_H_\n"
|
||||||
|
s += "#define KALDIFEAT_CSRC_WHISPER_V3_MEL_BANK_H_\n"
|
||||||
|
s += "namespace kaldifeat {\n\n"
|
||||||
|
s += f"constexpr int32_t kWhisperV3MelRows = {m.shape[0]};\n"
|
||||||
|
s += f"constexpr int32_t kWhisperV3MelCols = {m.shape[1]};\n"
|
||||||
|
s += "\n"
|
||||||
|
s += "constexpr float kWhisperV3MelArray[] = {\n"
|
||||||
|
sep = ""
|
||||||
|
for i, f in enumerate(m.reshape(-1).tolist()):
|
||||||
|
s += f"{sep}{f:.8f}"
|
||||||
|
sep = ", "
|
||||||
|
if i and i % 7 == 0:
|
||||||
|
s += ",\n"
|
||||||
|
sep = ""
|
||||||
|
|
||||||
|
s += "};\n\n"
|
||||||
|
s += "} // namespace kaldifeat\n\n"
|
||||||
|
s += "#endif // KALDIFEAT_CSRC_WHISPER_V3_MEL_BANK_H_\n"
|
||||||
|
|
||||||
|
with open("whisper-v3-mel-bank.h", "w") as f:
|
||||||
|
f.write(s)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
39
kaldifeat/csrc/generate-whisper-melbank.py
Executable file
39
kaldifeat/csrc/generate-whisper-melbank.py
Executable file
@ -0,0 +1,39 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
|
||||||
|
# Copyright (c) 2023 Xiaomi Corporation (authors: Fangjun Kuang)
|
||||||
|
|
||||||
|
import librosa
|
||||||
|
import numpy as np
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
m = librosa.filters.mel(sr=16000, n_fft=400, n_mels=80)
|
||||||
|
assert m.shape == (80, 201)
|
||||||
|
s = "// Auto-generated. Do NOT edit!\n\n"
|
||||||
|
s += "// Copyright (c) 2023 Xiaomi Corporation (authors: Fangjun Kuang)\n\n"
|
||||||
|
s += "\n"
|
||||||
|
s += "#ifndef KALDIFEAT_CSRC_WHISPER_MEL_BANK_H_\n"
|
||||||
|
s += "#define KALDIFEAT_CSRC_WHISPER_MEL_BANK_H_\n"
|
||||||
|
s += "namespace kaldifeat {\n\n"
|
||||||
|
s += f"constexpr int32_t kWhisperMelRows = {m.shape[0]};\n"
|
||||||
|
s += f"constexpr int32_t kWhisperMelCols = {m.shape[1]};\n"
|
||||||
|
s += "\n"
|
||||||
|
s += "constexpr float kWhisperMelArray[] = {\n"
|
||||||
|
sep = ""
|
||||||
|
for i, f in enumerate(m.reshape(-1).tolist()):
|
||||||
|
s += f"{sep}{f:.8f}"
|
||||||
|
sep = ", "
|
||||||
|
if i and i % 7 == 0:
|
||||||
|
s += ",\n"
|
||||||
|
sep = ""
|
||||||
|
|
||||||
|
s += "};\n\n"
|
||||||
|
s += "} // namespace kaldifeat\n\n"
|
||||||
|
s += "#endif // KALDIFEAT_CSRC_WHISPER_MEL_BANK_H_\n"
|
||||||
|
|
||||||
|
with open("whisper-mel-bank.h", "w") as f:
|
||||||
|
f.write(s)
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
@ -5,6 +5,7 @@
|
|||||||
#ifndef KALDIFEAT_CSRC_LOG_H_
|
#ifndef KALDIFEAT_CSRC_LOG_H_
|
||||||
#define KALDIFEAT_CSRC_LOG_H_
|
#define KALDIFEAT_CSRC_LOG_H_
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
#include <cstdlib>
|
#include <cstdlib>
|
||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
@ -138,7 +138,7 @@ MelBanks::MelBanks(const MelBanksOptions &opts,
|
|||||||
<< " and vtln-high " << vtln_high << ", versus "
|
<< " and vtln-high " << vtln_high << ", versus "
|
||||||
<< "low-freq " << low_freq << " and high-freq " << high_freq;
|
<< "low-freq " << low_freq << " and high-freq " << high_freq;
|
||||||
|
|
||||||
// we will transpose bins_mat_ at the end of this funciton
|
// we will transpose bins_mat_ at the end of this function
|
||||||
bins_mat_ = torch::zeros({num_bins, num_fft_bins}, torch::kFloat);
|
bins_mat_ = torch::zeros({num_bins, num_fft_bins}, torch::kFloat);
|
||||||
|
|
||||||
int32_t stride = bins_mat_.strides()[0];
|
int32_t stride = bins_mat_.strides()[0];
|
||||||
@ -179,12 +179,14 @@ MelBanks::MelBanks(const MelBanksOptions &opts,
|
|||||||
last_index = i;
|
last_index = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
KALDIFEAT_ASSERT(first_index != -1 && last_index >= first_index &&
|
|
||||||
"You may have set num_mel_bins too large.");
|
// Note: It is possible that first_index == last_index == -1 at this line.
|
||||||
|
|
||||||
// Replicate a bug in HTK, for testing purposes.
|
// Replicate a bug in HTK, for testing purposes.
|
||||||
if (opts.htk_mode && bin == 0 && mel_low_freq != 0.0f)
|
if (opts.htk_mode && bin == 0 && mel_low_freq != 0.0f &&
|
||||||
|
first_index != -1) {
|
||||||
this_bin[first_index] = 0.0f;
|
this_bin[first_index] = 0.0f;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (debug_) KALDIFEAT_LOG << bins_mat_;
|
if (debug_) KALDIFEAT_LOG << bins_mat_;
|
||||||
@ -196,6 +198,15 @@ MelBanks::MelBanks(const MelBanksOptions &opts,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MelBanks::MelBanks(const float *weights, int32_t num_rows, int32_t num_cols,
|
||||||
|
torch::Device device)
|
||||||
|
: debug_(false), htk_mode_(false) {
|
||||||
|
bins_mat_ = torch::from_blob(const_cast<float *>(weights),
|
||||||
|
{num_rows, num_cols}, torch::kFloat)
|
||||||
|
.t()
|
||||||
|
.to(device);
|
||||||
|
}
|
||||||
|
|
||||||
torch::Tensor MelBanks::Compute(const torch::Tensor &spectrum) const {
|
torch::Tensor MelBanks::Compute(const torch::Tensor &spectrum) const {
|
||||||
return torch::mm(spectrum, bins_mat_);
|
return torch::mm(spectrum, bins_mat_);
|
||||||
}
|
}
|
||||||
|
@ -36,13 +36,14 @@ struct MelBanksOptions {
|
|||||||
|
|
||||||
std::string ToString() const {
|
std::string ToString() const {
|
||||||
std::ostringstream os;
|
std::ostringstream os;
|
||||||
os << "num_bins: " << num_bins << "\n";
|
os << "MelBanksOptions(";
|
||||||
os << "low_freq: " << low_freq << "\n";
|
os << "num_bins=" << num_bins << ", ";
|
||||||
os << "high_freq: " << high_freq << "\n";
|
os << "low_freq=" << low_freq << ", ";
|
||||||
os << "vtln_low: " << vtln_low << "\n";
|
os << "high_freq=" << high_freq << ", ";
|
||||||
os << "vtln_high: " << vtln_high << "\n";
|
os << "vtln_low=" << vtln_low << ", ";
|
||||||
os << "debug_mel: " << debug_mel << "\n";
|
os << "vtln_high=" << vtln_high << ", ";
|
||||||
os << "htk_mode: " << htk_mode << "\n";
|
os << "debug_mel=" << (debug_mel ? "True" : "False") << ", ";
|
||||||
|
os << "htk_mode=" << (htk_mode ? "True" : "False") << ")";
|
||||||
return os.str();
|
return os.str();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -75,6 +76,17 @@ class MelBanks {
|
|||||||
const FrameExtractionOptions &frame_opts, float vtln_warp_factor,
|
const FrameExtractionOptions &frame_opts, float vtln_warp_factor,
|
||||||
torch::Device device);
|
torch::Device device);
|
||||||
|
|
||||||
|
// Initialize with a 2-d weights matrix
|
||||||
|
//
|
||||||
|
// Note: This constructor is for Whisper. It does not initialize
|
||||||
|
// center_freqs_.
|
||||||
|
//
|
||||||
|
// @param weights Pointer to the start address of the matrix
|
||||||
|
// @param num_rows It equals to number of mel bins
|
||||||
|
// @param num_cols It equals to (number of fft bins)/2+1
|
||||||
|
MelBanks(const float *weights, int32_t num_rows, int32_t num_cols,
|
||||||
|
torch::Device device);
|
||||||
|
|
||||||
// CAUTION: we save a transposed version of bins_mat_, so return size(1) here
|
// CAUTION: we save a transposed version of bins_mat_, so return size(1) here
|
||||||
int32_t NumBins() const { return static_cast<int32_t>(bins_mat_.size(1)); }
|
int32_t NumBins() const { return static_cast<int32_t>(bins_mat_.size(1)); }
|
||||||
|
|
||||||
@ -88,7 +100,8 @@ class MelBanks {
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
// A 2-D matrix. Its shape is NOT [num_bins, num_fft_bins]
|
// A 2-D matrix. Its shape is NOT [num_bins, num_fft_bins]
|
||||||
// Its shape is [num_fft_bins, num_bins].
|
// Its shape is [num_fft_bins, num_bins] for non-whisper.
|
||||||
|
// For whisper, its shape is [num_fft_bins/2+1, num_bins]
|
||||||
torch::Tensor bins_mat_;
|
torch::Tensor bins_mat_;
|
||||||
|
|
||||||
// center frequencies of bins, numbered from 0 ... num_bins-1.
|
// center frequencies of bins, numbered from 0 ... num_bins-1.
|
||||||
|
88
kaldifeat/csrc/whisper-fbank.cc
Normal file
88
kaldifeat/csrc/whisper-fbank.cc
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2023 Xiaomi Corporation (authors: Fangjun Kuang)
|
||||||
|
*
|
||||||
|
* See LICENSE for clarification regarding multiple authors
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "kaldifeat/csrc/whisper-fbank.h"
|
||||||
|
|
||||||
|
#include <cmath>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include "kaldifeat/csrc/mel-computations.h"
|
||||||
|
#include "kaldifeat/csrc/whisper-mel-bank.h"
|
||||||
|
#include "kaldifeat/csrc/whisper-v3-mel-bank.h"
|
||||||
|
|
||||||
|
#ifndef M_2PI
|
||||||
|
#define M_2PI 6.283185307179586476925286766559005
|
||||||
|
#endif
|
||||||
|
|
||||||
|
namespace kaldifeat {
|
||||||
|
|
||||||
|
WhisperFbankComputer::WhisperFbankComputer(const WhisperFbankOptions &opts)
|
||||||
|
: opts_(opts) {
|
||||||
|
if (opts.num_mels == 80) {
|
||||||
|
mel_banks_ = std::make_unique<MelBanks>(kWhisperMelArray, kWhisperMelRows,
|
||||||
|
kWhisperMelCols, opts.device);
|
||||||
|
} else if (opts.num_mels == 128) {
|
||||||
|
mel_banks_ = std::make_unique<MelBanks>(
|
||||||
|
kWhisperV3MelArray, kWhisperV3MelRows, kWhisperV3MelCols, opts.device);
|
||||||
|
} else {
|
||||||
|
KALDIFEAT_ERR << "Unsupported num_mels: " << opts.num_mels
|
||||||
|
<< ". Support only 80 and 128";
|
||||||
|
}
|
||||||
|
|
||||||
|
opts_.frame_opts.samp_freq = 16000;
|
||||||
|
opts_.frame_opts.frame_shift_ms = 10;
|
||||||
|
opts_.frame_opts.frame_length_ms = 25;
|
||||||
|
opts_.frame_opts.dither = 0;
|
||||||
|
opts_.frame_opts.preemph_coeff = 0;
|
||||||
|
opts_.frame_opts.remove_dc_offset = false;
|
||||||
|
opts_.frame_opts.window_type = "hann";
|
||||||
|
opts_.frame_opts.round_to_power_of_two = false;
|
||||||
|
opts_.frame_opts.snip_edges = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
torch::Tensor WhisperFbankComputer::Compute(
|
||||||
|
torch::Tensor /*signal_raw_log_energy*/, float /*vtln_warp*/,
|
||||||
|
const torch::Tensor &signal_frame) {
|
||||||
|
KALDIFEAT_ASSERT(signal_frame.dim() == 2);
|
||||||
|
KALDIFEAT_ASSERT(signal_frame.size(1) == opts_.frame_opts.PaddedWindowSize());
|
||||||
|
|
||||||
|
// note spectrum is in magnitude, not power, because of `abs()`
|
||||||
|
#if defined(KALDIFEAT_HAS_FFT_NAMESPACE)
|
||||||
|
// signal_frame shape: [x, 512]
|
||||||
|
// power shape [x, 257]
|
||||||
|
torch::Tensor power = torch::fft::rfft(signal_frame).abs().pow(2);
|
||||||
|
#else
|
||||||
|
// signal_frame shape [x, 512]
|
||||||
|
// real_imag shape [x, 257, 2],
|
||||||
|
// where [..., 0] is the real part
|
||||||
|
// [..., 1] is the imaginary part
|
||||||
|
torch::Tensor real_imag = torch::rfft(signal_frame, 1);
|
||||||
|
torch::Tensor real = real_imag.index({"...", 0});
|
||||||
|
torch::Tensor imag = real_imag.index({"...", 1});
|
||||||
|
torch::Tensor power = (real.square() + imag.square());
|
||||||
|
#endif
|
||||||
|
|
||||||
|
torch::Tensor mel_energies = mel_banks_->Compute(power);
|
||||||
|
torch::Tensor log_spec = torch::clamp_min(mel_energies, 1e-10).log10();
|
||||||
|
log_spec = torch::maximum(log_spec, log_spec.max() - 8.0);
|
||||||
|
torch::Tensor mel = (log_spec + 4.0) / 4.0;
|
||||||
|
|
||||||
|
return mel;
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace kaldifeat
|
78
kaldifeat/csrc/whisper-fbank.h
Normal file
78
kaldifeat/csrc/whisper-fbank.h
Normal file
@ -0,0 +1,78 @@
|
|||||||
|
/**
|
||||||
|
* Copyright (c) 2023 Xiaomi Corporation (authors: Fangjun Kuang)
|
||||||
|
*
|
||||||
|
* See LICENSE for clarification regarding multiple authors
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef KALDIFEAT_CSRC_WHISPER_FBANK_H_
|
||||||
|
#define KALDIFEAT_CSRC_WHISPER_FBANK_H_
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#include "kaldifeat/csrc/feature-common.h"
|
||||||
|
#include "kaldifeat/csrc/feature-window.h"
|
||||||
|
#include "kaldifeat/csrc/mel-computations.h"
|
||||||
|
|
||||||
|
namespace kaldifeat {
|
||||||
|
|
||||||
|
struct WhisperFbankOptions {
|
||||||
|
FrameExtractionOptions frame_opts;
|
||||||
|
// for large v3, please use 128
|
||||||
|
int32_t num_mels = 80;
|
||||||
|
|
||||||
|
torch::Device device{"cpu"};
|
||||||
|
std::string ToString() const {
|
||||||
|
std::ostringstream os;
|
||||||
|
os << "WhisperFbankOptions(";
|
||||||
|
os << "frame_opts=" << frame_opts.ToString() << ", ";
|
||||||
|
os << "num_mels=" << num_mels << ", ";
|
||||||
|
os << "device=\"" << device << "\")";
|
||||||
|
return os.str();
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
class WhisperFbankComputer {
|
||||||
|
public:
|
||||||
|
// note: Only frame_opts.device is used. All other fields from frame_opts
|
||||||
|
// are ignored
|
||||||
|
explicit WhisperFbankComputer(const WhisperFbankOptions &opts = {});
|
||||||
|
|
||||||
|
int32_t Dim() const { return opts_.num_mels; }
|
||||||
|
|
||||||
|
const FrameExtractionOptions &GetFrameOptions() const {
|
||||||
|
return opts_.frame_opts;
|
||||||
|
}
|
||||||
|
|
||||||
|
const WhisperFbankOptions &GetOptions() const { return opts_; }
|
||||||
|
|
||||||
|
torch::Tensor Compute(torch::Tensor /*signal_raw_log_energy*/,
|
||||||
|
float /*vtln_warp*/, const torch::Tensor &signal_frame);
|
||||||
|
|
||||||
|
// if true, compute log_energy_pre_window but after dithering and dc removal
|
||||||
|
bool NeedRawLogEnergy() const { return false; }
|
||||||
|
using Options = WhisperFbankOptions;
|
||||||
|
|
||||||
|
private:
|
||||||
|
WhisperFbankOptions opts_;
|
||||||
|
std::unique_ptr<MelBanks> mel_banks_;
|
||||||
|
};
|
||||||
|
|
||||||
|
using WhisperFbank = OfflineFeatureTpl<WhisperFbankComputer>;
|
||||||
|
|
||||||
|
} // namespace kaldifeat
|
||||||
|
|
||||||
|
#endif // KALDIFEAT_CSRC_WHISPER_FBANK_H_
|
2315
kaldifeat/csrc/whisper-mel-bank.h
Normal file
2315
kaldifeat/csrc/whisper-mel-bank.h
Normal file
File diff suppressed because it is too large
Load Diff
3693
kaldifeat/csrc/whisper-v3-mel-bank.h
Normal file
3693
kaldifeat/csrc/whisper-v3-mel-bank.h
Normal file
File diff suppressed because it is too large
Load Diff
@ -9,6 +9,7 @@ pybind11_add_module(_kaldifeat
|
|||||||
mel-computations.cc
|
mel-computations.cc
|
||||||
online-feature.cc
|
online-feature.cc
|
||||||
utils.cc
|
utils.cc
|
||||||
|
whisper-fbank.cc
|
||||||
)
|
)
|
||||||
|
|
||||||
if(APPLE)
|
if(APPLE)
|
||||||
@ -28,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
|
||||||
|
@ -16,6 +16,35 @@ static void PybindFbankOptions(py::module &m) {
|
|||||||
using PyClass = FbankOptions;
|
using PyClass = FbankOptions;
|
||||||
py::class_<PyClass>(m, "FbankOptions")
|
py::class_<PyClass>(m, "FbankOptions")
|
||||||
.def(py::init<>())
|
.def(py::init<>())
|
||||||
|
.def(py::init([](const MelBanksOptions &mel_opts,
|
||||||
|
const FrameExtractionOptions &frame_opts =
|
||||||
|
FrameExtractionOptions(),
|
||||||
|
bool use_energy = false, float energy_floor = 0.0f,
|
||||||
|
bool raw_energy = true, bool htk_compat = false,
|
||||||
|
bool use_log_fbank = true, bool use_power = true,
|
||||||
|
py::object device =
|
||||||
|
py::str("cpu")) -> std::unique_ptr<FbankOptions> {
|
||||||
|
auto opts = std::make_unique<FbankOptions>();
|
||||||
|
opts->frame_opts = frame_opts;
|
||||||
|
opts->mel_opts = mel_opts;
|
||||||
|
opts->use_energy = use_energy;
|
||||||
|
opts->energy_floor = energy_floor;
|
||||||
|
opts->raw_energy = raw_energy;
|
||||||
|
opts->htk_compat = htk_compat;
|
||||||
|
opts->use_log_fbank = use_log_fbank;
|
||||||
|
opts->use_power = use_power;
|
||||||
|
|
||||||
|
std::string s = static_cast<py::str>(device);
|
||||||
|
opts->device = torch::Device(s);
|
||||||
|
|
||||||
|
return opts;
|
||||||
|
}),
|
||||||
|
py::arg("mel_opts"),
|
||||||
|
py::arg("frame_opts") = FrameExtractionOptions(),
|
||||||
|
py::arg("use_energy") = false, py::arg("energy_floor") = 0.0f,
|
||||||
|
py::arg("raw_energy") = true, py::arg("htk_compat") = false,
|
||||||
|
py::arg("use_log_fbank") = true, py::arg("use_power") = true,
|
||||||
|
py::arg("device") = py::str("cpu"))
|
||||||
.def_readwrite("frame_opts", &PyClass::frame_opts)
|
.def_readwrite("frame_opts", &PyClass::frame_opts)
|
||||||
.def_readwrite("mel_opts", &PyClass::mel_opts)
|
.def_readwrite("mel_opts", &PyClass::mel_opts)
|
||||||
.def_readwrite("use_energy", &PyClass::use_energy)
|
.def_readwrite("use_energy", &PyClass::use_energy)
|
||||||
|
@ -16,6 +16,35 @@ void PybindMfccOptions(py::module &m) {
|
|||||||
using PyClass = MfccOptions;
|
using PyClass = MfccOptions;
|
||||||
py::class_<PyClass>(m, "MfccOptions")
|
py::class_<PyClass>(m, "MfccOptions")
|
||||||
.def(py::init<>())
|
.def(py::init<>())
|
||||||
|
.def(py::init([](const MelBanksOptions &mel_opts,
|
||||||
|
const FrameExtractionOptions &frame_opts =
|
||||||
|
FrameExtractionOptions(),
|
||||||
|
int32_t num_ceps = 13, bool use_energy = true,
|
||||||
|
float energy_floor = 0.0, bool raw_energy = true,
|
||||||
|
float cepstral_lifter = 22.0, bool htk_compat = false,
|
||||||
|
py::object device =
|
||||||
|
py::str("cpu")) -> std::unique_ptr<MfccOptions> {
|
||||||
|
auto opts = std::make_unique<MfccOptions>();
|
||||||
|
opts->frame_opts = frame_opts;
|
||||||
|
opts->mel_opts = mel_opts;
|
||||||
|
opts->num_ceps = num_ceps;
|
||||||
|
opts->use_energy = use_energy;
|
||||||
|
opts->energy_floor = energy_floor;
|
||||||
|
opts->raw_energy = raw_energy;
|
||||||
|
opts->cepstral_lifter = cepstral_lifter;
|
||||||
|
opts->htk_compat = htk_compat;
|
||||||
|
|
||||||
|
std::string s = static_cast<py::str>(device);
|
||||||
|
opts->device = torch::Device(s);
|
||||||
|
|
||||||
|
return opts;
|
||||||
|
}),
|
||||||
|
py::arg("mel_opts"),
|
||||||
|
py::arg("frame_opts") = FrameExtractionOptions(),
|
||||||
|
py::arg("num_ceps") = 13, py::arg("use_energy") = true,
|
||||||
|
py::arg("energy_floor") = 0.0f, py::arg("raw_energy") = true,
|
||||||
|
py::arg("cepstral_lifter") = 22.0, py::arg("htk_compat") = false,
|
||||||
|
py::arg("device") = py::str("cpu"))
|
||||||
.def_readwrite("frame_opts", &PyClass::frame_opts)
|
.def_readwrite("frame_opts", &PyClass::frame_opts)
|
||||||
.def_readwrite("mel_opts", &PyClass::mel_opts)
|
.def_readwrite("mel_opts", &PyClass::mel_opts)
|
||||||
.def_readwrite("num_ceps", &PyClass::num_ceps)
|
.def_readwrite("num_ceps", &PyClass::num_ceps)
|
||||||
|
@ -16,6 +16,41 @@ void PybindPlpOptions(py::module &m) {
|
|||||||
using PyClass = PlpOptions;
|
using PyClass = PlpOptions;
|
||||||
py::class_<PyClass>(m, "PlpOptions")
|
py::class_<PyClass>(m, "PlpOptions")
|
||||||
.def(py::init<>())
|
.def(py::init<>())
|
||||||
|
.def(py::init([](const MelBanksOptions &mel_opts,
|
||||||
|
const FrameExtractionOptions &frame_opts =
|
||||||
|
FrameExtractionOptions(),
|
||||||
|
int32_t lpc_order = 12, int32_t num_ceps = 13,
|
||||||
|
bool use_energy = true, float energy_floor = 0.0,
|
||||||
|
bool raw_energy = true, float compress_factor = 0.33333,
|
||||||
|
int32_t cepstral_lifter = 22, float cepstral_scale = 1.0,
|
||||||
|
bool htk_compat = false,
|
||||||
|
py::object device =
|
||||||
|
py::str("cpu")) -> std::unique_ptr<PlpOptions> {
|
||||||
|
auto opts = std::make_unique<PlpOptions>();
|
||||||
|
opts->frame_opts = frame_opts;
|
||||||
|
opts->mel_opts = mel_opts;
|
||||||
|
opts->lpc_order = lpc_order;
|
||||||
|
opts->num_ceps = num_ceps;
|
||||||
|
opts->use_energy = use_energy;
|
||||||
|
opts->energy_floor = energy_floor;
|
||||||
|
opts->raw_energy = raw_energy;
|
||||||
|
opts->compress_factor = compress_factor;
|
||||||
|
opts->cepstral_lifter = cepstral_lifter;
|
||||||
|
opts->cepstral_scale = cepstral_scale;
|
||||||
|
opts->htk_compat = htk_compat;
|
||||||
|
|
||||||
|
std::string s = static_cast<py::str>(device);
|
||||||
|
opts->device = torch::Device(s);
|
||||||
|
|
||||||
|
return opts;
|
||||||
|
}),
|
||||||
|
py::arg("mel_opts"),
|
||||||
|
py::arg("frame_opts") = FrameExtractionOptions(),
|
||||||
|
py::arg("lpc_order") = 12, py::arg("num_ceps") = 13,
|
||||||
|
py::arg("use_energy") = true, py::arg("energy_floor") = 0.0,
|
||||||
|
py::arg("raw_energy") = true, py::arg("compress_factor") = 0.33333,
|
||||||
|
py::arg("cepstral_lifter") = 22, py::arg("cepstral_scale") = 1.0,
|
||||||
|
py::arg("htk_compat") = false, py::arg("device") = py::str("cpu"))
|
||||||
.def_readwrite("frame_opts", &PyClass::frame_opts)
|
.def_readwrite("frame_opts", &PyClass::frame_opts)
|
||||||
.def_readwrite("mel_opts", &PyClass::mel_opts)
|
.def_readwrite("mel_opts", &PyClass::mel_opts)
|
||||||
.def_readwrite("lpc_order", &PyClass::lpc_order)
|
.def_readwrite("lpc_order", &PyClass::lpc_order)
|
||||||
|
@ -15,7 +15,27 @@ namespace kaldifeat {
|
|||||||
static void PybindSpectrogramOptions(py::module &m) {
|
static void PybindSpectrogramOptions(py::module &m) {
|
||||||
using PyClass = SpectrogramOptions;
|
using PyClass = SpectrogramOptions;
|
||||||
py::class_<PyClass>(m, "SpectrogramOptions")
|
py::class_<PyClass>(m, "SpectrogramOptions")
|
||||||
.def(py::init<>())
|
.def(py::init([](const FrameExtractionOptions &frame_opts =
|
||||||
|
FrameExtractionOptions(),
|
||||||
|
float energy_floor = 0.0, bool raw_energy = true,
|
||||||
|
bool return_raw_fft = false,
|
||||||
|
py::object device = py::str(
|
||||||
|
"cpu")) -> std::unique_ptr<SpectrogramOptions> {
|
||||||
|
auto opts = std::make_unique<SpectrogramOptions>();
|
||||||
|
opts->frame_opts = frame_opts;
|
||||||
|
opts->energy_floor = energy_floor;
|
||||||
|
opts->raw_energy = raw_energy;
|
||||||
|
opts->return_raw_fft = return_raw_fft;
|
||||||
|
|
||||||
|
std::string s = static_cast<py::str>(device);
|
||||||
|
opts->device = torch::Device(s);
|
||||||
|
|
||||||
|
return opts;
|
||||||
|
}),
|
||||||
|
py::arg("frame_opts") = FrameExtractionOptions(),
|
||||||
|
py::arg("energy_floor") = 0.0, py::arg("raw_energy") = true,
|
||||||
|
py::arg("return_raw_fft") = false,
|
||||||
|
py::arg("device") = py::str("cpu"))
|
||||||
.def_readwrite("frame_opts", &PyClass::frame_opts)
|
.def_readwrite("frame_opts", &PyClass::frame_opts)
|
||||||
.def_readwrite("energy_floor", &PyClass::energy_floor)
|
.def_readwrite("energy_floor", &PyClass::energy_floor)
|
||||||
.def_readwrite("raw_energy", &PyClass::raw_energy)
|
.def_readwrite("raw_energy", &PyClass::raw_energy)
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
#include "kaldifeat/python/csrc/feature-window.h"
|
#include "kaldifeat/python/csrc/feature-window.h"
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "kaldifeat/csrc/feature-window.h"
|
#include "kaldifeat/csrc/feature-window.h"
|
||||||
@ -14,7 +15,38 @@ namespace kaldifeat {
|
|||||||
static void PybindFrameExtractionOptions(py::module &m) {
|
static void PybindFrameExtractionOptions(py::module &m) {
|
||||||
using PyClass = FrameExtractionOptions;
|
using PyClass = FrameExtractionOptions;
|
||||||
py::class_<PyClass>(m, "FrameExtractionOptions")
|
py::class_<PyClass>(m, "FrameExtractionOptions")
|
||||||
.def(py::init<>())
|
.def(
|
||||||
|
py::init([](float samp_freq = 16000, float frame_shift_ms = 10.0f,
|
||||||
|
float frame_length_ms = 25.0f, float dither = 1.0f,
|
||||||
|
float preemph_coeff = 0.97f, bool remove_dc_offset = true,
|
||||||
|
const std::string &window_type = "povey",
|
||||||
|
bool round_to_power_of_two = true,
|
||||||
|
float blackman_coeff = 0.42f, bool snip_edges = true,
|
||||||
|
int32_t max_feature_vectors =
|
||||||
|
-1) -> std::unique_ptr<FrameExtractionOptions> {
|
||||||
|
auto opts = std::make_unique<FrameExtractionOptions>();
|
||||||
|
|
||||||
|
opts->samp_freq = samp_freq;
|
||||||
|
opts->frame_shift_ms = frame_shift_ms;
|
||||||
|
opts->frame_length_ms = frame_length_ms;
|
||||||
|
opts->dither = dither;
|
||||||
|
opts->preemph_coeff = preemph_coeff;
|
||||||
|
opts->remove_dc_offset = remove_dc_offset;
|
||||||
|
opts->window_type = window_type;
|
||||||
|
opts->round_to_power_of_two = round_to_power_of_two;
|
||||||
|
opts->blackman_coeff = blackman_coeff;
|
||||||
|
opts->snip_edges = snip_edges;
|
||||||
|
opts->max_feature_vectors = max_feature_vectors;
|
||||||
|
|
||||||
|
return opts;
|
||||||
|
}),
|
||||||
|
py::arg("samp_freq") = 16000, py::arg("frame_shift_ms") = 10.0f,
|
||||||
|
py::arg("frame_length_ms") = 25.0f, py::arg("dither") = 1.0f,
|
||||||
|
py::arg("preemph_coeff") = 0.97f, py::arg("remove_dc_offset") = true,
|
||||||
|
py::arg("window_type") = "povey",
|
||||||
|
py::arg("round_to_power_of_two") = true,
|
||||||
|
py::arg("blackman_coeff") = 0.42f, py::arg("snip_edges") = true,
|
||||||
|
py::arg("max_feature_vectors") = -1)
|
||||||
.def_readwrite("samp_freq", &PyClass::samp_freq)
|
.def_readwrite("samp_freq", &PyClass::samp_freq)
|
||||||
.def_readwrite("frame_shift_ms", &PyClass::frame_shift_ms)
|
.def_readwrite("frame_shift_ms", &PyClass::frame_shift_ms)
|
||||||
.def_readwrite("frame_length_ms", &PyClass::frame_length_ms)
|
.def_readwrite("frame_length_ms", &PyClass::frame_length_ms)
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
#include "kaldifeat/python/csrc/feature-window.h"
|
#include "kaldifeat/python/csrc/feature-window.h"
|
||||||
#include "kaldifeat/python/csrc/mel-computations.h"
|
#include "kaldifeat/python/csrc/mel-computations.h"
|
||||||
#include "kaldifeat/python/csrc/online-feature.h"
|
#include "kaldifeat/python/csrc/online-feature.h"
|
||||||
|
#include "kaldifeat/python/csrc/whisper-fbank.h"
|
||||||
#include "torch/torch.h"
|
#include "torch/torch.h"
|
||||||
|
|
||||||
namespace kaldifeat {
|
namespace kaldifeat {
|
||||||
@ -22,6 +23,7 @@ PYBIND11_MODULE(_kaldifeat, m) {
|
|||||||
PybindFeatureWindow(m);
|
PybindFeatureWindow(m);
|
||||||
PybindMelComputations(m);
|
PybindMelComputations(m);
|
||||||
PybindFeatureFbank(m);
|
PybindFeatureFbank(m);
|
||||||
|
PybindWhisperFbank(&m);
|
||||||
PybindFeatureMfcc(m);
|
PybindFeatureMfcc(m);
|
||||||
PybindFeaturePlp(m);
|
PybindFeaturePlp(m);
|
||||||
PybindFeatureSpectrogram(m);
|
PybindFeatureSpectrogram(m);
|
||||||
|
@ -4,6 +4,7 @@
|
|||||||
|
|
||||||
#include "kaldifeat/python/csrc/mel-computations.h"
|
#include "kaldifeat/python/csrc/mel-computations.h"
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
|
||||||
#include "kaldifeat/csrc/mel-computations.h"
|
#include "kaldifeat/csrc/mel-computations.h"
|
||||||
@ -14,7 +15,24 @@ namespace kaldifeat {
|
|||||||
static void PybindMelBanksOptions(py::module &m) {
|
static void PybindMelBanksOptions(py::module &m) {
|
||||||
using PyClass = MelBanksOptions;
|
using PyClass = MelBanksOptions;
|
||||||
py::class_<PyClass>(m, "MelBanksOptions")
|
py::class_<PyClass>(m, "MelBanksOptions")
|
||||||
.def(py::init<>())
|
.def(py::init(
|
||||||
|
[](int32_t num_bins = 25, float low_freq = 20,
|
||||||
|
float high_freq = 0, float vtln_low = 100,
|
||||||
|
float vtln_high = -500,
|
||||||
|
bool debug_mel = false) -> std::unique_ptr<MelBanksOptions> {
|
||||||
|
auto opts = std::make_unique<MelBanksOptions>();
|
||||||
|
|
||||||
|
opts->num_bins = num_bins;
|
||||||
|
opts->low_freq = low_freq;
|
||||||
|
opts->high_freq = high_freq;
|
||||||
|
opts->vtln_low = vtln_low;
|
||||||
|
opts->vtln_high = vtln_high;
|
||||||
|
|
||||||
|
return opts;
|
||||||
|
}),
|
||||||
|
py::arg("num_bins") = 25, py::arg("low_freq") = 20,
|
||||||
|
py::arg("high_freq") = 0, py::arg("vtln_low") = 100,
|
||||||
|
py::arg("vtln_high") = -500, py::arg("debug_mel") = false)
|
||||||
.def_readwrite("num_bins", &PyClass::num_bins)
|
.def_readwrite("num_bins", &PyClass::num_bins)
|
||||||
.def_readwrite("low_freq", &PyClass::low_freq)
|
.def_readwrite("low_freq", &PyClass::low_freq)
|
||||||
.def_readwrite("high_freq", &PyClass::high_freq)
|
.def_readwrite("high_freq", &PyClass::high_freq)
|
||||||
|
@ -123,6 +123,35 @@ py::dict AsDict(const FbankOptions &opts) {
|
|||||||
return dict;
|
return dict;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WhisperFbankOptions WhisperFbankOptionsFromDict(py::dict dict) {
|
||||||
|
WhisperFbankOptions opts;
|
||||||
|
|
||||||
|
if (dict.contains("frame_opts")) {
|
||||||
|
opts.frame_opts = FrameExtractionOptionsFromDict(dict["frame_opts"]);
|
||||||
|
}
|
||||||
|
|
||||||
|
FROM_DICT(int_, num_mels);
|
||||||
|
|
||||||
|
if (dict.contains("device")) {
|
||||||
|
opts.device = torch::Device(std::string(py::str(dict["device"])));
|
||||||
|
}
|
||||||
|
|
||||||
|
return opts;
|
||||||
|
}
|
||||||
|
|
||||||
|
py::dict AsDict(const WhisperFbankOptions &opts) {
|
||||||
|
py::dict dict;
|
||||||
|
|
||||||
|
dict["frame_opts"] = AsDict(opts.frame_opts);
|
||||||
|
|
||||||
|
AS_DICT(num_mels);
|
||||||
|
|
||||||
|
auto torch_device = py::module_::import("torch").attr("device");
|
||||||
|
dict["device"] = torch_device(opts.device.str());
|
||||||
|
|
||||||
|
return dict;
|
||||||
|
}
|
||||||
|
|
||||||
MfccOptions MfccOptionsFromDict(py::dict dict) {
|
MfccOptions MfccOptionsFromDict(py::dict dict) {
|
||||||
MfccOptions opts;
|
MfccOptions opts;
|
||||||
|
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#include "kaldifeat/csrc/feature-spectrogram.h"
|
#include "kaldifeat/csrc/feature-spectrogram.h"
|
||||||
#include "kaldifeat/csrc/feature-window.h"
|
#include "kaldifeat/csrc/feature-window.h"
|
||||||
#include "kaldifeat/csrc/mel-computations.h"
|
#include "kaldifeat/csrc/mel-computations.h"
|
||||||
|
#include "kaldifeat/csrc/whisper-fbank.h"
|
||||||
#include "kaldifeat/python/csrc/kaldifeat.h"
|
#include "kaldifeat/python/csrc/kaldifeat.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -36,6 +37,9 @@ py::dict AsDict(const MelBanksOptions &opts);
|
|||||||
FbankOptions FbankOptionsFromDict(py::dict dict);
|
FbankOptions FbankOptionsFromDict(py::dict dict);
|
||||||
py::dict AsDict(const FbankOptions &opts);
|
py::dict AsDict(const FbankOptions &opts);
|
||||||
|
|
||||||
|
WhisperFbankOptions WhisperFbankOptionsFromDict(py::dict dict);
|
||||||
|
py::dict AsDict(const WhisperFbankOptions &opts);
|
||||||
|
|
||||||
MfccOptions MfccOptionsFromDict(py::dict dict);
|
MfccOptions MfccOptionsFromDict(py::dict dict);
|
||||||
py::dict AsDict(const MfccOptions &opts);
|
py::dict AsDict(const MfccOptions &opts);
|
||||||
|
|
||||||
|
84
kaldifeat/python/csrc/whisper-fbank.cc
Normal file
84
kaldifeat/python/csrc/whisper-fbank.cc
Normal file
@ -0,0 +1,84 @@
|
|||||||
|
// kaldifeat/python/csrc/whisper-fbank.cc
|
||||||
|
//
|
||||||
|
// Copyright (c) 2023 Xiaomi Corporation (authors: Fangjun Kuang)
|
||||||
|
|
||||||
|
#include "kaldifeat/python/csrc/whisper-fbank.h"
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
#include "kaldifeat/csrc/whisper-fbank.h"
|
||||||
|
#include "kaldifeat/python/csrc/utils.h"
|
||||||
|
|
||||||
|
namespace kaldifeat {
|
||||||
|
|
||||||
|
static void PybindWhisperFbankOptions(py::module *m) {
|
||||||
|
using PyClass = WhisperFbankOptions;
|
||||||
|
py::class_<PyClass>(*m, "WhisperFbankOptions")
|
||||||
|
.def(py::init<>())
|
||||||
|
.def(py::init([](const FrameExtractionOptions &frame_opts =
|
||||||
|
FrameExtractionOptions(),
|
||||||
|
int32_t num_mels = 80,
|
||||||
|
py::object device = py::str(
|
||||||
|
"cpu")) -> std::unique_ptr<WhisperFbankOptions> {
|
||||||
|
auto opts = std::make_unique<WhisperFbankOptions>();
|
||||||
|
opts->frame_opts = frame_opts;
|
||||||
|
opts->num_mels = num_mels;
|
||||||
|
|
||||||
|
std::string s = static_cast<py::str>(device);
|
||||||
|
opts->device = torch::Device(s);
|
||||||
|
|
||||||
|
return opts;
|
||||||
|
}),
|
||||||
|
py::arg("frame_opts") = FrameExtractionOptions(),
|
||||||
|
py::arg("num_mels") = 80, py::arg("device") = py::str("cpu"))
|
||||||
|
.def_readwrite("frame_opts", &PyClass::frame_opts)
|
||||||
|
.def_readwrite("num_mels", &PyClass::num_mels)
|
||||||
|
.def_property(
|
||||||
|
"device",
|
||||||
|
[](const PyClass &self) -> py::object {
|
||||||
|
py::object ans = py::module_::import("torch").attr("device");
|
||||||
|
return ans(self.device.str());
|
||||||
|
},
|
||||||
|
[](PyClass &self, py::object obj) -> void {
|
||||||
|
std::string s = static_cast<py::str>(obj);
|
||||||
|
self.device = torch::Device(s);
|
||||||
|
})
|
||||||
|
.def("__str__",
|
||||||
|
[](const PyClass &self) -> std::string { return self.ToString(); })
|
||||||
|
.def("as_dict",
|
||||||
|
[](const PyClass &self) -> py::dict { return AsDict(self); })
|
||||||
|
.def_static("from_dict",
|
||||||
|
[](py::dict dict) -> PyClass {
|
||||||
|
return WhisperFbankOptionsFromDict(dict);
|
||||||
|
})
|
||||||
|
.def(py::pickle(
|
||||||
|
[](const PyClass &self) -> py::dict { return AsDict(self); },
|
||||||
|
[](py::dict dict) -> PyClass {
|
||||||
|
return WhisperFbankOptionsFromDict(dict);
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
static void PybindWhisperFbankImpl(py::module *m) {
|
||||||
|
using PyClass = WhisperFbank;
|
||||||
|
py::class_<PyClass>(*m, "WhisperFbank")
|
||||||
|
.def(py::init<const WhisperFbankOptions &>(), py::arg("opts"))
|
||||||
|
.def("dim", &PyClass::Dim)
|
||||||
|
.def_property_readonly("options", &PyClass::GetOptions)
|
||||||
|
.def("compute_features", &PyClass::ComputeFeatures, py::arg("wave"),
|
||||||
|
py::arg("vtln_warp"), py::call_guard<py::gil_scoped_release>())
|
||||||
|
.def(py::pickle(
|
||||||
|
[](const PyClass &self) -> py::dict {
|
||||||
|
return AsDict(self.GetOptions());
|
||||||
|
},
|
||||||
|
[](py::dict dict) -> std::unique_ptr<PyClass> {
|
||||||
|
return std::make_unique<PyClass>(WhisperFbankOptionsFromDict(dict));
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
void PybindWhisperFbank(py::module *m) {
|
||||||
|
PybindWhisperFbankOptions(m);
|
||||||
|
PybindWhisperFbankImpl(m);
|
||||||
|
}
|
||||||
|
|
||||||
|
} // namespace kaldifeat
|
16
kaldifeat/python/csrc/whisper-fbank.h
Normal file
16
kaldifeat/python/csrc/whisper-fbank.h
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
// kaldifeat/python/csrc/whisper-fbank.h
|
||||||
|
//
|
||||||
|
// Copyright (c) 2023 Xiaomi Corporation (authors: Fangjun Kuang)
|
||||||
|
|
||||||
|
#ifndef KALDIFEAT_PYTHON_CSRC_WHISPER_FBANK_H_
|
||||||
|
#define KALDIFEAT_PYTHON_CSRC_WHISPER_FBANK_H_
|
||||||
|
|
||||||
|
#include "kaldifeat/python/csrc/kaldifeat.h"
|
||||||
|
|
||||||
|
namespace kaldifeat {
|
||||||
|
|
||||||
|
void PybindWhisperFbank(py::module *m);
|
||||||
|
|
||||||
|
} // namespace kaldifeat
|
||||||
|
|
||||||
|
#endif // KALDIFEAT_PYTHON_CSRC_WHISPER_FBANK_H_
|
@ -8,6 +8,8 @@ if torch.__version__.split("+")[0] != kaldifeat_torch_version.split("+")[0]:
|
|||||||
f"But you are using PyTorch {torch.__version__} to run it"
|
f"But you are using PyTorch {torch.__version__} to run it"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
from pathlib import Path as _Path
|
||||||
|
|
||||||
from _kaldifeat import (
|
from _kaldifeat import (
|
||||||
FbankOptions,
|
FbankOptions,
|
||||||
FrameExtractionOptions,
|
FrameExtractionOptions,
|
||||||
@ -15,6 +17,8 @@ from _kaldifeat import (
|
|||||||
MfccOptions,
|
MfccOptions,
|
||||||
PlpOptions,
|
PlpOptions,
|
||||||
SpectrogramOptions,
|
SpectrogramOptions,
|
||||||
|
WhisperFbankOptions,
|
||||||
|
num_frames,
|
||||||
)
|
)
|
||||||
|
|
||||||
from .fbank import Fbank, OnlineFbank
|
from .fbank import Fbank, OnlineFbank
|
||||||
@ -23,8 +27,7 @@ from .offline_feature import OfflineFeature
|
|||||||
from .online_feature import OnlineFeature
|
from .online_feature import OnlineFeature
|
||||||
from .plp import OnlinePlp, Plp
|
from .plp import OnlinePlp, Plp
|
||||||
from .spectrogram import Spectrogram
|
from .spectrogram import Spectrogram
|
||||||
|
from .whisper_fbank import WhisperFbank
|
||||||
from pathlib import Path as _Path
|
|
||||||
|
|
||||||
cmake_prefix_path = _Path(__file__).parent / "share" / "cmake"
|
cmake_prefix_path = _Path(__file__).parent / "share" / "cmake"
|
||||||
del _Path
|
del _Path
|
||||||
|
12
kaldifeat/python/kaldifeat/whisper_fbank.py
Normal file
12
kaldifeat/python/kaldifeat/whisper_fbank.py
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
# Copyright (c) 2021 Xiaomi Corporation (authors: Fangjun Kuang)
|
||||||
|
|
||||||
|
|
||||||
|
import _kaldifeat
|
||||||
|
|
||||||
|
from .offline_feature import OfflineFeature
|
||||||
|
|
||||||
|
|
||||||
|
class WhisperFbank(OfflineFeature):
|
||||||
|
def __init__(self, opts: _kaldifeat.WhisperFbankOptions):
|
||||||
|
super().__init__(opts)
|
||||||
|
self.computer = _kaldifeat.WhisperFbank(opts)
|
@ -12,6 +12,7 @@ import kaldifeat
|
|||||||
|
|
||||||
def test_default():
|
def test_default():
|
||||||
opts = kaldifeat.FbankOptions()
|
opts = kaldifeat.FbankOptions()
|
||||||
|
print(opts)
|
||||||
assert opts.frame_opts.samp_freq == 16000
|
assert opts.frame_opts.samp_freq == 16000
|
||||||
assert opts.frame_opts.frame_shift_ms == 10.0
|
assert opts.frame_opts.frame_shift_ms == 10.0
|
||||||
assert opts.frame_opts.frame_length_ms == 25.0
|
assert opts.frame_opts.frame_length_ms == 25.0
|
||||||
|
@ -9,6 +9,7 @@ import kaldifeat
|
|||||||
|
|
||||||
def test_default():
|
def test_default():
|
||||||
opts = kaldifeat.FrameExtractionOptions()
|
opts = kaldifeat.FrameExtractionOptions()
|
||||||
|
print(opts)
|
||||||
assert opts.samp_freq == 16000
|
assert opts.samp_freq == 16000
|
||||||
assert opts.frame_shift_ms == 10.0
|
assert opts.frame_shift_ms == 10.0
|
||||||
assert opts.frame_length_ms == 25.0
|
assert opts.frame_length_ms == 25.0
|
||||||
@ -22,7 +23,9 @@ def test_default():
|
|||||||
|
|
||||||
|
|
||||||
def test_set_get():
|
def test_set_get():
|
||||||
opts = kaldifeat.FrameExtractionOptions()
|
opts = kaldifeat.FrameExtractionOptions(samp_freq=22150)
|
||||||
|
assert opts.samp_freq == 22150
|
||||||
|
|
||||||
opts.samp_freq = 44100
|
opts.samp_freq = 44100
|
||||||
assert opts.samp_freq == 44100
|
assert opts.samp_freq == 44100
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@ import kaldifeat
|
|||||||
|
|
||||||
def test_default():
|
def test_default():
|
||||||
opts = kaldifeat.MelBanksOptions()
|
opts = kaldifeat.MelBanksOptions()
|
||||||
|
print(opts)
|
||||||
assert opts.num_bins == 25
|
assert opts.num_bins == 25
|
||||||
assert opts.low_freq == 20
|
assert opts.low_freq == 20
|
||||||
assert opts.high_freq == 0
|
assert opts.high_freq == 0
|
||||||
@ -19,10 +20,12 @@ def test_default():
|
|||||||
|
|
||||||
|
|
||||||
def test_set_get():
|
def test_set_get():
|
||||||
opts = kaldifeat.MelBanksOptions()
|
opts = kaldifeat.MelBanksOptions(num_bins=100)
|
||||||
opts.num_bins = 100
|
|
||||||
assert opts.num_bins == 100
|
assert opts.num_bins == 100
|
||||||
|
|
||||||
|
opts.num_bins = 200
|
||||||
|
assert opts.num_bins == 200
|
||||||
|
|
||||||
opts.low_freq = 22
|
opts.low_freq = 22
|
||||||
assert opts.low_freq == 22
|
assert opts.low_freq == 22
|
||||||
|
|
||||||
|
@ -12,6 +12,7 @@ import kaldifeat
|
|||||||
|
|
||||||
def test_default():
|
def test_default():
|
||||||
opts = kaldifeat.MfccOptions()
|
opts = kaldifeat.MfccOptions()
|
||||||
|
print(opts)
|
||||||
|
|
||||||
assert opts.frame_opts.samp_freq == 16000
|
assert opts.frame_opts.samp_freq == 16000
|
||||||
assert opts.frame_opts.frame_shift_ms == 10.0
|
assert opts.frame_opts.frame_shift_ms == 10.0
|
||||||
|
@ -12,6 +12,7 @@ import kaldifeat
|
|||||||
|
|
||||||
def test_default():
|
def test_default():
|
||||||
opts = kaldifeat.PlpOptions()
|
opts = kaldifeat.PlpOptions()
|
||||||
|
print(opts)
|
||||||
assert opts.frame_opts.samp_freq == 16000
|
assert opts.frame_opts.samp_freq == 16000
|
||||||
assert opts.frame_opts.frame_shift_ms == 10.0
|
assert opts.frame_opts.frame_shift_ms == 10.0
|
||||||
assert opts.frame_opts.frame_length_ms == 25.0
|
assert opts.frame_opts.frame_length_ms == 25.0
|
||||||
|
@ -12,6 +12,7 @@ import kaldifeat
|
|||||||
|
|
||||||
def test_default():
|
def test_default():
|
||||||
opts = kaldifeat.SpectrogramOptions()
|
opts = kaldifeat.SpectrogramOptions()
|
||||||
|
print(opts)
|
||||||
|
|
||||||
assert opts.frame_opts.samp_freq == 16000
|
assert opts.frame_opts.samp_freq == 16000
|
||||||
assert opts.frame_opts.frame_shift_ms == 10.0
|
assert opts.frame_opts.frame_shift_ms == 10.0
|
||||||
@ -30,7 +31,8 @@ def test_default():
|
|||||||
|
|
||||||
|
|
||||||
def test_set_get():
|
def test_set_get():
|
||||||
opts = kaldifeat.SpectrogramOptions()
|
opts = kaldifeat.SpectrogramOptions(energy_floor=10)
|
||||||
|
assert opts.energy_floor == 10
|
||||||
|
|
||||||
opts.energy_floor = 1
|
opts.energy_floor = 1
|
||||||
assert opts.energy_floor == 1
|
assert opts.energy_floor == 1
|
||||||
@ -138,6 +140,30 @@ def test_pickle():
|
|||||||
assert str(opts) == str(opts2)
|
assert str(opts) == str(opts2)
|
||||||
|
|
||||||
|
|
||||||
|
def test_device():
|
||||||
|
opts = kaldifeat.SpectrogramOptions(device="cpu")
|
||||||
|
assert opts.device == torch.device("cpu")
|
||||||
|
|
||||||
|
opts = kaldifeat.SpectrogramOptions(device="cuda")
|
||||||
|
assert opts.device == torch.device("cuda")
|
||||||
|
|
||||||
|
opts = kaldifeat.SpectrogramOptions(device="cuda:1")
|
||||||
|
assert opts.device == torch.device("cuda:1")
|
||||||
|
print(opts)
|
||||||
|
|
||||||
|
opts = kaldifeat.SpectrogramOptions(device=torch.device("cpu"))
|
||||||
|
assert opts.device == torch.device("cpu")
|
||||||
|
|
||||||
|
opts = kaldifeat.SpectrogramOptions(device=torch.device("cuda"))
|
||||||
|
assert opts.device == torch.device("cuda")
|
||||||
|
|
||||||
|
opts = kaldifeat.SpectrogramOptions(device=torch.device("cuda:3"))
|
||||||
|
assert opts.device == torch.device("cuda:3")
|
||||||
|
|
||||||
|
opts = kaldifeat.SpectrogramOptions(device=torch.device("cuda", 2))
|
||||||
|
assert opts.device == torch.device("cuda", 2)
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
test_default()
|
test_default()
|
||||||
test_set_get()
|
test_set_get()
|
||||||
@ -146,6 +172,7 @@ def main():
|
|||||||
test_from_dict_partial()
|
test_from_dict_partial()
|
||||||
test_from_dict_full_and_as_dict()
|
test_from_dict_full_and_as_dict()
|
||||||
test_pickle()
|
test_pickle()
|
||||||
|
test_device()
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
|
48
kaldifeat/python/tests/test_whisper_fbank.py
Normal file
48
kaldifeat/python/tests/test_whisper_fbank.py
Normal file
@ -0,0 +1,48 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
# Copyright 2023 Xiaomi Corporation (authors: Fangjun Kuang)
|
||||||
|
|
||||||
|
import librosa
|
||||||
|
import torch
|
||||||
|
import kaldifeat
|
||||||
|
|
||||||
|
|
||||||
|
def get_ground_truth(x):
|
||||||
|
N_FFT = 400
|
||||||
|
HOP_LENGTH = 160
|
||||||
|
|
||||||
|
m = librosa.filters.mel(sr=16000, n_fft=400, n_mels=80)
|
||||||
|
m = torch.from_numpy(m)
|
||||||
|
# print(m.shape) # [80, 201]
|
||||||
|
window = torch.hann_window(N_FFT)
|
||||||
|
stft = torch.stft(x, N_FFT, HOP_LENGTH, window=window, return_complex=True)
|
||||||
|
# print(stft.shape) # [201, 301]
|
||||||
|
magnitudes = stft[..., :-1].abs() ** 2
|
||||||
|
# print(magnitudes.shape) # [201, 300]
|
||||||
|
|
||||||
|
mel_spec = m @ magnitudes
|
||||||
|
# print(mel_spec.shape) # [80, 300]
|
||||||
|
|
||||||
|
log_spec = torch.clamp(mel_spec, min=1e-10).log10()
|
||||||
|
log_spec = torch.maximum(log_spec, log_spec.max() - 8.0)
|
||||||
|
log_spec = (log_spec + 4.0) / 4.0
|
||||||
|
return log_spec.t()
|
||||||
|
|
||||||
|
|
||||||
|
def test_whisper_fbank():
|
||||||
|
x = torch.rand(16000 * 3)
|
||||||
|
|
||||||
|
gt = get_ground_truth(x)
|
||||||
|
print(gt.shape) # [300, 80]
|
||||||
|
|
||||||
|
opts = kaldifeat.WhisperFbankOptions(device="cpu")
|
||||||
|
whisper_fbank = kaldifeat.WhisperFbank(opts)
|
||||||
|
y = whisper_fbank(x) # [298, 80]
|
||||||
|
print(y.shape) # [298, 80]
|
||||||
|
|
||||||
|
# print(gt[:5, :5])
|
||||||
|
# print(y[:5, :5])
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
torch.manual_seed(20231108)
|
||||||
|
test_whisper_fbank()
|
49
kaldifeat/python/tests/test_whisper_v3_fbank.py
Normal file
49
kaldifeat/python/tests/test_whisper_v3_fbank.py
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
# Copyright 2023 Xiaomi Corporation (authors: Fangjun Kuang)
|
||||||
|
|
||||||
|
import librosa
|
||||||
|
import torch
|
||||||
|
import kaldifeat
|
||||||
|
|
||||||
|
|
||||||
|
def get_ground_truth(x):
|
||||||
|
N_FFT = 400
|
||||||
|
HOP_LENGTH = 160
|
||||||
|
|
||||||
|
m = librosa.filters.mel(sr=16000, n_fft=400, n_mels=128)
|
||||||
|
m = torch.from_numpy(m)
|
||||||
|
# print(m.shape) # [128, 201]
|
||||||
|
window = torch.hann_window(N_FFT)
|
||||||
|
stft = torch.stft(x, N_FFT, HOP_LENGTH, window=window, return_complex=True)
|
||||||
|
# print(stft.shape) # [201, 301]
|
||||||
|
magnitudes = stft[..., :-1].abs() ** 2
|
||||||
|
# print(magnitudes.shape) # [201, 300]
|
||||||
|
|
||||||
|
mel_spec = m @ magnitudes
|
||||||
|
# print(mel_spec.shape) # [128, 300]
|
||||||
|
|
||||||
|
log_spec = torch.clamp(mel_spec, min=1e-10).log10()
|
||||||
|
log_spec = torch.maximum(log_spec, log_spec.max() - 8.0)
|
||||||
|
log_spec = (log_spec + 4.0) / 4.0
|
||||||
|
return log_spec.t()
|
||||||
|
|
||||||
|
|
||||||
|
def test_whisper_v3_fbank():
|
||||||
|
x = torch.rand(16000 * 3)
|
||||||
|
|
||||||
|
gt = get_ground_truth(x)
|
||||||
|
print(gt.shape) # [300, 128]
|
||||||
|
|
||||||
|
opts = kaldifeat.WhisperFbankOptions(num_mels=128, device="cpu")
|
||||||
|
print(opts)
|
||||||
|
whisper_fbank = kaldifeat.WhisperFbank(opts)
|
||||||
|
y = whisper_fbank(x) # [298, 128]
|
||||||
|
print(y.shape) # [298, 128]
|
||||||
|
|
||||||
|
print(gt[:5, :5])
|
||||||
|
print(y[:5, :5])
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
torch.manual_seed(20231109)
|
||||||
|
test_whisper_v3_fbank()
|
@ -1,11 +0,0 @@
|
|||||||
[tool.isort]
|
|
||||||
profile = "black"
|
|
||||||
|
|
||||||
[tool.black]
|
|
||||||
line-length = 80
|
|
||||||
exclude = '''
|
|
||||||
/(
|
|
||||||
\.git
|
|
||||||
| \.github
|
|
||||||
)/
|
|
||||||
'''
|
|
@ -1,6 +1,6 @@
|
|||||||
package:
|
package:
|
||||||
name: kaldifeat
|
name: kaldifeat
|
||||||
version: "1.21"
|
version: "1.25.5"
|
||||||
|
|
||||||
source:
|
source:
|
||||||
path: "{{ environ.get('KALDIFEAT_ROOT_DIR') }}"
|
path: "{{ environ.get('KALDIFEAT_ROOT_DIR') }}"
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package:
|
package:
|
||||||
name: kaldifeat
|
name: kaldifeat
|
||||||
version: "1.21"
|
version: "1.25.5"
|
||||||
|
|
||||||
source:
|
source:
|
||||||
path: "{{ environ.get('KALDIFEAT_ROOT_DIR') }}"
|
path: "{{ environ.get('KALDIFEAT_ROOT_DIR') }}"
|
||||||
|
78
scripts/github_actions/build-ubuntu-cpu-arm64.sh
Executable file
78
scripts/github_actions/build-ubuntu-cpu-arm64.sh
Executable 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
|
76
scripts/github_actions/build-ubuntu-cpu.sh
Executable file
76
scripts/github_actions/build-ubuntu-cpu.sh
Executable file
@ -0,0 +1,76 @@
|
|||||||
|
#!/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+cpu -f https://download.pytorch.org/whl/torch_stable.html || \
|
||||||
|
python3 -m pip install -qq torch==$TORCH_VERSION+cpu -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
|
||||||
|
|
||||||
|
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 \
|
||||||
|
--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
|
154
scripts/github_actions/build-ubuntu-cuda.sh
Executable file
154
scripts/github_actions/build-ubuntu-cuda.sh
Executable file
@ -0,0 +1,154 @@
|
|||||||
|
#!/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, 12.1
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
if [[ $TORCH_VERSION =~ 2.2.* && $CUDA_VERSION =~ 12.* ]]; then
|
||||||
|
# see https://github.com/pytorch/pytorch/issues/113948
|
||||||
|
export TORCH_CUDA_ARCH_LIST="8.0 8.6 8.9 9.0"
|
||||||
|
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
|
||||||
|
|
||||||
|
python3 -c "import torch; print(torch.__file__)"
|
||||||
|
|
||||||
|
|
||||||
|
# -- 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):
|
||||||
|
# Unknown CUDA Architecture Name 9.0a in CUDA_SELECT_NVCC_ARCH_FLAGS
|
||||||
|
# Call Stack (most recent call first):
|
||||||
|
# /Python-3.8.2/py-3.8/lib/python3.8/site-packages/torch/share/cmake/Caffe2/public/utils.cmake:401 (cuda_select_nvcc_arch_flags)
|
||||||
|
# /Python-3.8.2/py-3.8/lib/python3.8/site-packages/torch/share/cmake/Caffe2/public/cuda.cmake:342 (torch_cuda_get_nvcc_gencode_flag)
|
||||||
|
# /Python-3.8.2/py-3.8/lib/python3.8/site-packages/torch/share/cmake/Caffe2/Caffe2Config.cmake:87 (include)
|
||||||
|
# /Python-3.8.2/py-3.8/lib/python3.8/site-packages/torch/share/cmake/Torch/TorchConfig.cmake:68 (find_package)
|
||||||
|
# cmake/torch.cmake:14 (find_package)
|
||||||
|
# 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
|
||||||
|
|
||||||
|
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
|
||||||
|
yum clean all >/dev/null 2>&1
|
||||||
|
|
||||||
|
cd /var/www
|
||||||
|
|
||||||
|
export CMAKE_CUDA_COMPILER_LAUNCHER=
|
||||||
|
export KALDIFEAT_CMAKE_ARGS=" -DPYTHON_EXECUTABLE=$PYTHON_INSTALL_DIR/bin/python3 "
|
||||||
|
export KALDIFEAT_MAKE_ARGS=" -j2 "
|
||||||
|
|
||||||
|
echo "KALDIFEAT_CMAKE_ARGS: $KALDIFEAT_CMAKE_ARGS"
|
||||||
|
|
||||||
|
|
||||||
|
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 \
|
||||||
|
--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 libcublas.so \
|
||||||
|
--exclude libcublas.so.11 \
|
||||||
|
--exclude libcublas.so.12 \
|
||||||
|
--exclude libcublasLt.so \
|
||||||
|
--exclude libcublasLt.so.11 \
|
||||||
|
--exclude libcublasLt.so.12 \
|
||||||
|
--exclude libcudart.so.11.0 \
|
||||||
|
--exclude libcudart.so.12 \
|
||||||
|
--exclude libcudnn.so.8 \
|
||||||
|
--exclude libcufft.so \
|
||||||
|
--exclude libcufft.so.11 \
|
||||||
|
--exclude libcupti.so \
|
||||||
|
--exclude libcupti.so.12 \
|
||||||
|
--exclude libcurand.so \
|
||||||
|
--exclude libcurand.so.10 \
|
||||||
|
--exclude libcusparse.so \
|
||||||
|
--exclude libcusparse.so.12 \
|
||||||
|
--exclude libnccl.so \
|
||||||
|
--exclude libnccl.so.2 \
|
||||||
|
--exclude libnvJitLink.so \
|
||||||
|
--exclude libnvJitLink.so.12 \
|
||||||
|
--exclude libnvrtc.so \
|
||||||
|
--exclude libnvrtc.so.11.2 \
|
||||||
|
--exclude libnvrtc.so.12 \
|
||||||
|
--exclude libshm.so \
|
||||||
|
--exclude libtorch_cuda_cpp.so \
|
||||||
|
--exclude libtorch_cuda_cu.so \
|
||||||
|
--plat $plat \
|
||||||
|
-w /var/www/wheelhouse \
|
||||||
|
dist/*.whl
|
||||||
|
|
||||||
|
ls -lh /var/www
|
@ -1,10 +1,31 @@
|
|||||||
#!/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
|
||||||
|
|
||||||
|
|
||||||
|
def version_ge(a, b):
|
||||||
|
a_major, a_minor = list(map(int, a.split(".")))[:2]
|
||||||
|
b_major, b_minor = list(map(int, b.split(".")))[:2]
|
||||||
|
if a_major > b_major:
|
||||||
|
return True
|
||||||
|
|
||||||
|
if a_major == b_major and a_minor >= b_minor:
|
||||||
|
return True
|
||||||
|
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
def get_args():
|
def get_args():
|
||||||
parser = argparse.ArgumentParser()
|
parser = argparse.ArgumentParser()
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
@ -21,6 +42,20 @@ def get_args():
|
|||||||
help="True for windows",
|
help="True for windows",
|
||||||
)
|
)
|
||||||
|
|
||||||
|
parser.add_argument(
|
||||||
|
"--for-macos",
|
||||||
|
action="store_true",
|
||||||
|
default=False,
|
||||||
|
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",
|
||||||
@ -31,7 +66,9 @@ def get_args():
|
|||||||
return parser.parse_args()
|
return parser.parse_args()
|
||||||
|
|
||||||
|
|
||||||
def generate_build_matrix(enable_cuda, for_windows, 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
|
||||||
@ -46,100 +83,372 @@ def generate_build_matrix(enable_cuda, for_windows, test_only_latest_torch):
|
|||||||
# "python-version": ["3.6", "3.7", "3.8"],
|
# "python-version": ["3.6", "3.7", "3.8"],
|
||||||
# "cuda": ["10.1", "10.2"],
|
# "cuda": ["10.1", "10.2"],
|
||||||
# },
|
# },
|
||||||
"1.6.0": {
|
# "1.6.0": {
|
||||||
"python-version": ["3.6", "3.7", "3.8"],
|
# "python-version": ["3.6", "3.7", "3.8"],
|
||||||
"cuda": ["10.1", "10.2"]
|
# "cuda": ["10.1", "10.2"] if not for_windows else ["10.1.243", "10.2.89"],
|
||||||
if not for_windows
|
# },
|
||||||
else ["10.1.243", "10.2.89"],
|
# "1.7.0": {
|
||||||
},
|
# "python-version": ["3.6", "3.7", "3.8"],
|
||||||
"1.7.0": {
|
# "cuda": (
|
||||||
"python-version": ["3.6", "3.7", "3.8"],
|
# ["10.1", "10.2", "11.0"]
|
||||||
"cuda": ["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": ["10.1", "10.2", "11.0"]
|
# "cuda": (
|
||||||
if not for_windows
|
# ["10.1", "10.2", "11.0"]
|
||||||
else ["10.1.243", "10.2.89", "11.0.3"],
|
# if not for_windows
|
||||||
},
|
# else ["10.1.243", "10.2.89", "11.0.3"]
|
||||||
"1.8.0": {
|
# ),
|
||||||
"python-version": ["3.6", "3.7", "3.8", "3.9"],
|
# },
|
||||||
"cuda": ["10.1", "10.2", "11.1"]
|
# "1.8.0": {
|
||||||
if not for_windows
|
# "python-version": ["3.6", "3.7", "3.8", "3.9"],
|
||||||
else ["10.1.243", "10.2.89", "11.1.1"],
|
# "cuda": (
|
||||||
},
|
# ["10.1", "10.2", "11.1"]
|
||||||
"1.8.1": {
|
# if not for_windows
|
||||||
"python-version": ["3.6", "3.7", "3.8", "3.9"],
|
# else ["10.1.243", "10.2.89", "11.1.1"]
|
||||||
"cuda": ["10.1", "10.2", "11.1"]
|
# ),
|
||||||
if not for_windows
|
# },
|
||||||
else ["10.1.243", "10.2.89", "11.1.1"],
|
# "1.8.1": {
|
||||||
},
|
# "python-version": ["3.6", "3.7", "3.8", "3.9"],
|
||||||
"1.9.0": {
|
# "cuda": (
|
||||||
"python-version": ["3.6", "3.7", "3.8", "3.9"],
|
# ["10.1", "10.2", "11.1"]
|
||||||
"cuda": ["10.2", "11.1"]
|
# if not for_windows
|
||||||
if not for_windows
|
# else ["10.1.243", "10.2.89", "11.1.1"]
|
||||||
else ["10.2.89", "11.1.1"],
|
# ),
|
||||||
},
|
# },
|
||||||
"1.9.1": {
|
# "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"]
|
# "cuda": ["10.2", "11.1"] if not for_windows else ["10.2.89", "11.1.1"],
|
||||||
if not for_windows
|
# },
|
||||||
else ["10.2.89", "11.1.1"],
|
# "1.9.1": {
|
||||||
},
|
# "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"],
|
||||||
|
# },
|
||||||
"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": ["10.2", "11.1", "11.3"]
|
"cuda": (
|
||||||
if not for_windows
|
["10.2", "11.1", "11.3"]
|
||||||
else ["10.2.89", "11.1.1", "11.3.1"],
|
if not for_windows
|
||||||
|
else ["10.2.89", "11.1.1", "11.3.1"]
|
||||||
|
),
|
||||||
},
|
},
|
||||||
"1.10.1": {
|
"1.10.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", "11.3"]
|
"cuda": (
|
||||||
if not for_windows
|
["10.2", "11.1", "11.3"]
|
||||||
else ["10.2.89", "11.1.1", "11.3.1"],
|
if not for_windows
|
||||||
|
else ["10.2.89", "11.1.1", "11.3.1"]
|
||||||
|
),
|
||||||
},
|
},
|
||||||
"1.10.2": {
|
"1.10.2": {
|
||||||
"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", "11.3"]
|
"cuda": (
|
||||||
if not for_windows
|
["10.2", "11.1", "11.3"]
|
||||||
else ["10.2.89", "11.1.1", "11.3.1"],
|
if not for_windows
|
||||||
|
else ["10.2.89", "11.1.1", "11.3.1"]
|
||||||
|
),
|
||||||
},
|
},
|
||||||
"1.11.0": {
|
"1.11.0": {
|
||||||
"python-version": ["3.7", "3.8", "3.9", "3.10"],
|
"python-version": ["3.7", "3.8", "3.9", "3.10"],
|
||||||
"cuda": ["10.2", "11.3", "11.5"]
|
"cuda": (
|
||||||
if not for_windows
|
["10.2", "11.3", "11.5"] if not for_windows else ["11.3.1", "11.5.2"]
|
||||||
else ["11.3.1", "11.5.2"],
|
),
|
||||||
},
|
},
|
||||||
"1.12.0": {
|
"1.12.0": {
|
||||||
"python-version": ["3.7", "3.8", "3.9", "3.10"],
|
"python-version": ["3.7", "3.8", "3.9", "3.10"],
|
||||||
"cuda": ["10.2", "11.3", "11.6"]
|
"cuda": (
|
||||||
if not for_windows
|
["10.2", "11.3", "11.6"] if not for_windows else ["11.3.1", "11.6.2"]
|
||||||
else ["11.3.1", "11.6.2"],
|
),
|
||||||
},
|
},
|
||||||
"1.12.1": {
|
"1.12.1": {
|
||||||
"python-version": ["3.7", "3.8", "3.9", "3.10"],
|
"python-version": ["3.7", "3.8", "3.9", "3.10"],
|
||||||
"cuda": ["10.2", "11.3", "11.6"]
|
"cuda": (
|
||||||
if not for_windows
|
["10.2", "11.3", "11.6"] if not for_windows else ["11.3.1", "11.6.2"]
|
||||||
else ["11.3.1", "11.6.2"],
|
),
|
||||||
},
|
},
|
||||||
|
"1.13.0": {
|
||||||
|
"python-version": ["3.7", "3.8", "3.9", "3.10", "3.11"],
|
||||||
|
"cuda": ["11.6", "11.7"], # default 11.7
|
||||||
|
},
|
||||||
|
"1.13.1": {
|
||||||
|
"python-version": ["3.7", "3.8", "3.9", "3.10", "3.11"],
|
||||||
|
"cuda": (
|
||||||
|
["11.6", "11.7"] # default 11.7
|
||||||
|
if not for_windows
|
||||||
|
else ["11.6.2", "11.7.1"]
|
||||||
|
),
|
||||||
|
},
|
||||||
|
"2.0.0": {
|
||||||
|
"python-version": ["3.8", "3.9", "3.10", "3.11"],
|
||||||
|
"cuda": (
|
||||||
|
["11.7", "11.8"] # default 11.7
|
||||||
|
if not for_windows
|
||||||
|
else ["11.7.1", "11.8.0"]
|
||||||
|
),
|
||||||
|
},
|
||||||
|
"2.0.1": {
|
||||||
|
"python-version": ["3.8", "3.9", "3.10", "3.11"],
|
||||||
|
"cuda": (
|
||||||
|
["11.7", "11.8"] # default 11.7
|
||||||
|
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"]
|
||||||
|
),
|
||||||
|
},
|
||||||
|
"2.1.1": {
|
||||||
|
"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"]
|
||||||
|
),
|
||||||
|
},
|
||||||
|
"2.1.2": {
|
||||||
|
"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"]
|
||||||
|
),
|
||||||
|
},
|
||||||
|
"2.2.0": {
|
||||||
|
"python-version": ["3.8", "3.9", "3.10", "3.11", "3.12"],
|
||||||
|
"cuda": (
|
||||||
|
["11.8", "12.1"] # default 12.1
|
||||||
|
if not for_windows
|
||||||
|
else ["11.8.0", "12.1.0"]
|
||||||
|
),
|
||||||
|
},
|
||||||
|
"2.2.1": {
|
||||||
|
"python-version": ["3.8", "3.9", "3.10", "3.11", "3.12"],
|
||||||
|
"cuda": (
|
||||||
|
["11.8", "12.1"] # default 12.1
|
||||||
|
if not for_windows
|
||||||
|
else ["11.8.0", "12.1.0"]
|
||||||
|
),
|
||||||
|
},
|
||||||
|
"2.2.2": {
|
||||||
|
"python-version": ["3.8", "3.9", "3.10", "3.11", "3.12"],
|
||||||
|
"cuda": (
|
||||||
|
["11.8", "12.1"] # default 12.1
|
||||||
|
if not for_windows
|
||||||
|
else ["11.8.0", "12.1.0"]
|
||||||
|
),
|
||||||
|
},
|
||||||
|
"2.3.0": {
|
||||||
|
"python-version": ["3.8", "3.9", "3.10", "3.11", "3.12"],
|
||||||
|
"cuda": (
|
||||||
|
["11.8", "12.1"] # default 12.1
|
||||||
|
if not for_windows
|
||||||
|
else ["11.8.0", "12.1.0"]
|
||||||
|
),
|
||||||
|
},
|
||||||
|
"2.3.1": {
|
||||||
|
"python-version": ["3.8", "3.9", "3.10", "3.11", "3.12"],
|
||||||
|
"cuda": (
|
||||||
|
["11.8", "12.1"] # default 12.1
|
||||||
|
if not for_windows
|
||||||
|
else ["11.8.0", "12.1.0"]
|
||||||
|
),
|
||||||
|
},
|
||||||
|
"2.4.0": {
|
||||||
|
"python-version": ["3.8", "3.9", "3.10", "3.11", "3.12"],
|
||||||
|
"cuda": (
|
||||||
|
["11.8", "12.1", "12.4"] # default 12.1
|
||||||
|
if not for_windows
|
||||||
|
else ["11.8.0", "12.1.0", "12.4.0"]
|
||||||
|
),
|
||||||
|
},
|
||||||
|
"2.4.1": {
|
||||||
|
"python-version": ["3.8", "3.9", "3.10", "3.11", "3.12"],
|
||||||
|
"cuda": (
|
||||||
|
["11.8", "12.1", "12.4"] # default 12.1
|
||||||
|
if not for_windows
|
||||||
|
else ["11.8.0", "12.1.0", "12.4.0"]
|
||||||
|
),
|
||||||
|
},
|
||||||
|
"2.5.0": {
|
||||||
|
# Only Linux supports python 3.13
|
||||||
|
"python-version": ["3.9", "3.10", "3.11", "3.12", "3.13"],
|
||||||
|
"cuda": (
|
||||||
|
["11.8", "12.1", "12.4"] # default 12.4
|
||||||
|
if not for_windows
|
||||||
|
else ["11.8.0", "12.1.0", "12.4.0"]
|
||||||
|
),
|
||||||
|
},
|
||||||
|
"2.5.1": {
|
||||||
|
# Only Linux supports python 3.13
|
||||||
|
"python-version": ["3.9", "3.10", "3.11", "3.12", "3.13"],
|
||||||
|
"cuda": (
|
||||||
|
["11.8", "12.1", "12.4"] # default 12.4
|
||||||
|
if not for_windows
|
||||||
|
else ["11.8.0", "12.1.0", "12.4.0"]
|
||||||
|
),
|
||||||
|
},
|
||||||
|
"2.6.0": {
|
||||||
|
"python-version": ["3.9", "3.10", "3.11", "3.12", "3.13"],
|
||||||
|
"cuda": (
|
||||||
|
["11.8", "12.4", "12.6"] # default 12.4
|
||||||
|
if not for_windows
|
||||||
|
else ["11.8.0", "12.4.0", "12.6.0"]
|
||||||
|
),
|
||||||
|
},
|
||||||
|
"2.7.0": {
|
||||||
|
"python-version": ["3.9", "3.10", "3.11", "3.12", "3.13"],
|
||||||
|
"cuda": (
|
||||||
|
["11.8", "12.6", "12.8"]
|
||||||
|
if not for_windows
|
||||||
|
else ["11.8.0", "12.6.2", "12.8.1"]
|
||||||
|
),
|
||||||
|
},
|
||||||
|
"2.7.1": {
|
||||||
|
"python-version": ["3.9", "3.10", "3.11", "3.12", "3.13"],
|
||||||
|
"cuda": (
|
||||||
|
["11.8", "12.6", "12.8"] # default 12.6
|
||||||
|
if not for_windows
|
||||||
|
else ["11.8.0", "12.6.2", "12.8.1"]
|
||||||
|
),
|
||||||
|
},
|
||||||
|
"2.8.0": {
|
||||||
|
"python-version": ["3.9", "3.10", "3.11", "3.12", "3.13"],
|
||||||
|
"cuda": (
|
||||||
|
["12.6", "12.8", "12.9"] # default 12.8
|
||||||
|
if not for_windows
|
||||||
|
else ["12.6.2", "12.8.1", "12.9.1"]
|
||||||
|
),
|
||||||
|
},
|
||||||
|
# https://github.com/Jimver/cuda-toolkit/blob/master/src/links/windows-links.ts
|
||||||
}
|
}
|
||||||
if test_only_latest_torch:
|
if test_only_latest_torch:
|
||||||
latest = "1.12.1"
|
latest = "2.8.0"
|
||||||
matrix = {latest: matrix[latest]}
|
matrix = {latest: matrix[latest]}
|
||||||
|
|
||||||
|
if for_windows or for_macos:
|
||||||
|
if "2.5.1" in matrix:
|
||||||
|
matrix["2.5.1"]["python-version"].remove("3.13")
|
||||||
|
|
||||||
|
if "2.5.0" in matrix:
|
||||||
|
matrix["2.5.0"]["python-version"].remove("3.13")
|
||||||
|
|
||||||
|
if "1.13.0" in matrix:
|
||||||
|
matrix["1.13.0"]["python-version"].remove("3.11")
|
||||||
|
|
||||||
|
if "1.13.1" in matrix:
|
||||||
|
matrix["1.13.1"]["python-version"].remove("3.11")
|
||||||
|
|
||||||
|
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:
|
||||||
for p in python_versions:
|
for p in python_versions:
|
||||||
|
if p in excluded_python_versions:
|
||||||
|
continue
|
||||||
for c in cuda_versions:
|
for c in cuda_versions:
|
||||||
ans.append({"torch": torch, "python-version": p, "cuda": c})
|
if c in ["10.1", "11.0"]:
|
||||||
|
# no docker image for cuda 10.1 and 11.0
|
||||||
|
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(
|
||||||
|
{
|
||||||
|
"torch": torch,
|
||||||
|
"python-version": p,
|
||||||
|
"cuda": c,
|
||||||
|
"image": f"pytorch/manylinux-builder:cuda{c}",
|
||||||
|
"is_2_28": "0",
|
||||||
|
}
|
||||||
|
)
|
||||||
else:
|
else:
|
||||||
for p in python_versions:
|
for p in python_versions:
|
||||||
ans.append({"torch": torch, "python-version": p})
|
if p in excluded_python_versions:
|
||||||
|
continue
|
||||||
|
|
||||||
|
if for_windows:
|
||||||
|
ans.append({"torch": torch, "python-version": p})
|
||||||
|
elif for_macos:
|
||||||
|
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"):
|
||||||
|
ans.append(
|
||||||
|
{
|
||||||
|
"torch": torch,
|
||||||
|
"python-version": p,
|
||||||
|
# "image": "pytorch/manylinux-builder:cpu-2.4",
|
||||||
|
"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"):
|
||||||
|
ans.append(
|
||||||
|
{
|
||||||
|
"torch": torch,
|
||||||
|
"python-version": p,
|
||||||
|
"image": "pytorch/manylinux-builder:cpu-2.2"
|
||||||
|
if not for_arm64
|
||||||
|
else "pytorch/manylinuxaarch64-builder:cpu-aarch64-195148266541a9789074265141cb7dc19dc14c54",
|
||||||
|
"is_2_28": "0",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
else:
|
||||||
|
ans.append(
|
||||||
|
{
|
||||||
|
"torch": torch,
|
||||||
|
"python-version": p,
|
||||||
|
"image": "pytorch/manylinux-builder:cuda10.2"
|
||||||
|
if not for_arm64
|
||||||
|
else "pytorch/manylinuxaarch64-builder:cpu-aarch64-195148266541a9789074265141cb7dc19dc14c54",
|
||||||
|
"is_2_28": "0",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
print(json.dumps({"include": ans}))
|
print(json.dumps({"include": ans}))
|
||||||
|
|
||||||
@ -149,6 +458,8 @@ def main():
|
|||||||
generate_build_matrix(
|
generate_build_matrix(
|
||||||
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_arm64=args.for_arm64,
|
||||||
test_only_latest_torch=args.test_only_latest_torch,
|
test_only_latest_torch=args.test_only_latest_torch,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -46,6 +46,18 @@ case "$cuda" in
|
|||||||
11.6)
|
11.6)
|
||||||
url=https://developer.download.nvidia.com/compute/cuda/11.6.2/local_installers/cuda_11.6.2_510.47.03_linux.run
|
url=https://developer.download.nvidia.com/compute/cuda/11.6.2/local_installers/cuda_11.6.2_510.47.03_linux.run
|
||||||
;;
|
;;
|
||||||
|
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
|
||||||
|
;;
|
||||||
|
12.4)
|
||||||
|
url=https://developer.download.nvidia.com/compute/cuda/12.4.0/local_installers/cuda_12.4.0_550.54.14_linux.run
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Unknown cuda version: $cuda"
|
echo "Unknown cuda version: $cuda"
|
||||||
exit 1
|
exit 1
|
||||||
@ -60,10 +72,21 @@ retry curl -LSs -O $url
|
|||||||
filename=$(basename $url)
|
filename=$(basename $url)
|
||||||
echo "filename: $filename"
|
echo "filename: $filename"
|
||||||
chmod +x ./$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
|
rm -fv ./$filename
|
||||||
|
|
||||||
export CUDA_HOME=/usr/local/cuda
|
export CUDA_HOME=/usr/local/cuda
|
||||||
export PATH=$CUDA_HOME/bin:$PATH
|
export PATH=$CUDA_HOME/bin:$PATH
|
||||||
export LD_LIBRARY_PATH=$CUDA_HOME/lib:$LD_LIBRARY_PATH
|
export LD_LIBRARY_PATH=$CUDA_HOME/lib:$LD_LIBRARY_PATH
|
||||||
export LD_LIBRARY_PATH=$CUDA_HOME/lib64:$LD_LIBRARY_PATH
|
export LD_LIBRARY_PATH=$CUDA_HOME/lib64:$LD_LIBRARY_PATH
|
||||||
|
ls -lh $CUDA_HOME
|
||||||
|
@ -39,6 +39,18 @@ case $cuda in
|
|||||||
11.6)
|
11.6)
|
||||||
filename=cudnn-11.3-linux-x64-v8.2.0.53.tgz
|
filename=cudnn-11.3-linux-x64-v8.2.0.53.tgz
|
||||||
;;
|
;;
|
||||||
|
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
|
||||||
|
;;
|
||||||
|
12.4)
|
||||||
|
filename=cudnn-linux-x86_64-8.9.7.29_cuda12-archive.tar.xz
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Unsupported cuda version: $cuda"
|
echo "Unsupported cuda version: $cuda"
|
||||||
exit 1
|
exit 1
|
||||||
|
@ -14,6 +14,13 @@
|
|||||||
# See the License for the specific language governing permissions and
|
# See the License for the specific language governing permissions and
|
||||||
# limitations under the License.
|
# limitations under the License.
|
||||||
|
|
||||||
|
set -x
|
||||||
|
|
||||||
|
if [ x"$TORCH_VERSION" != x"" ] && [ x"$CUDA_VERSION" != x"" ]; then
|
||||||
|
torch=$TORCH_VERSION
|
||||||
|
cuda=$CUDA_VERSION
|
||||||
|
fi
|
||||||
|
|
||||||
case ${torch} in
|
case ${torch} in
|
||||||
1.5.*)
|
1.5.*)
|
||||||
case ${cuda} in
|
case ${cuda} in
|
||||||
@ -142,6 +149,155 @@ case ${torch} in
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
;;
|
;;
|
||||||
|
1.13.*)
|
||||||
|
case ${cuda} in
|
||||||
|
11.6)
|
||||||
|
package="torch==${torch}+cu116"
|
||||||
|
url=https://download.pytorch.org/whl/torch_stable.html
|
||||||
|
;;
|
||||||
|
11.7)
|
||||||
|
package="torch==${torch}"
|
||||||
|
# Leave it empty to use PyPI.
|
||||||
|
url=
|
||||||
|
;;
|
||||||
|
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
|
||||||
|
;;
|
||||||
|
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
|
||||||
|
;;
|
||||||
|
2.2.*)
|
||||||
|
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
|
||||||
|
;;
|
||||||
|
2.3.*)
|
||||||
|
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
|
||||||
|
;;
|
||||||
|
2.4.*)
|
||||||
|
case ${cuda} in
|
||||||
|
11.8)
|
||||||
|
package="torch==${torch}+cu118"
|
||||||
|
# https://download.pytorch.org/whl/nightly/torch/
|
||||||
|
url=https://download.pytorch.org/whl/torch/
|
||||||
|
;;
|
||||||
|
12.1)
|
||||||
|
package="torch==${torch}+cu121"
|
||||||
|
url=https://download.pytorch.org/whl/torch/
|
||||||
|
;;
|
||||||
|
12.4)
|
||||||
|
package="torch==${torch}+cu124"
|
||||||
|
url=https://download.pytorch.org/whl/torch/
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
2.5.*)
|
||||||
|
case ${cuda} in
|
||||||
|
11.8)
|
||||||
|
package="torch==${torch}+cu118"
|
||||||
|
# https://download.pytorch.org/whl/nightly/torch/
|
||||||
|
url=https://download.pytorch.org/whl/torch/
|
||||||
|
;;
|
||||||
|
12.1)
|
||||||
|
package="torch==${torch}+cu121"
|
||||||
|
url=https://download.pytorch.org/whl/torch/
|
||||||
|
;;
|
||||||
|
12.4)
|
||||||
|
package="torch==${torch}+cu124"
|
||||||
|
url=https://download.pytorch.org/whl/torch/
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
2.6.*)
|
||||||
|
case ${cuda} in
|
||||||
|
11.8)
|
||||||
|
package="torch==${torch}+cu118"
|
||||||
|
# https://download.pytorch.org/whl/nightly/torch/
|
||||||
|
url=https://download.pytorch.org/whl/torch/
|
||||||
|
;;
|
||||||
|
12.4)
|
||||||
|
package="torch==${torch}+cu124"
|
||||||
|
url=https://download.pytorch.org/whl/torch/
|
||||||
|
;;
|
||||||
|
12.6)
|
||||||
|
package="torch==${torch}+cu126"
|
||||||
|
url=https://download.pytorch.org/whl/torch/
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
2.7.*)
|
||||||
|
case ${cuda} in
|
||||||
|
11.8)
|
||||||
|
package="torch==${torch}+cu118"
|
||||||
|
# https://download.pytorch.org/whl/nightly/torch/
|
||||||
|
url=https://download.pytorch.org/whl/torch/
|
||||||
|
;;
|
||||||
|
12.6)
|
||||||
|
package="torch==${torch}+cu126"
|
||||||
|
url=https://download.pytorch.org/whl/torch/
|
||||||
|
;;
|
||||||
|
12.8)
|
||||||
|
package="torch==${torch}+cu128"
|
||||||
|
url=https://download.pytorch.org/whl/torch/
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
|
2.8.*)
|
||||||
|
case ${cuda} in
|
||||||
|
12.6)
|
||||||
|
package="torch==${torch}+cu126"
|
||||||
|
# https://download.pytorch.org/whl/nightly/torch/
|
||||||
|
url=https://download.pytorch.org/whl/torch/
|
||||||
|
;;
|
||||||
|
12.8)
|
||||||
|
package="torch==${torch}+cu128"
|
||||||
|
url=https://download.pytorch.org/whl/torch/
|
||||||
|
;;
|
||||||
|
12.9)
|
||||||
|
package="torch==${torch}+cu129"
|
||||||
|
url=https://download.pytorch.org/whl/torch/
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
echo "Unsupported PyTorch version: ${torch}"
|
echo "Unsupported PyTorch version: ${torch}"
|
||||||
exit 1
|
exit 1
|
||||||
@ -157,3 +313,7 @@ if [ x"${url}" == "x" ]; then
|
|||||||
else
|
else
|
||||||
retry python3 -m pip install -q $package -f $url
|
retry python3 -m pip install -q $package -f $url
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
python3 -m torch.utils.collect_env
|
||||||
|
|
||||||
|
rm -rf ~/.cache/pip
|
||||||
|
13
setup.py
13
setup.py
@ -7,6 +7,10 @@ import re
|
|||||||
import setuptools
|
import setuptools
|
||||||
|
|
||||||
from cmake.cmake_extension import BuildExtension, bdist_wheel, cmake_extension
|
from cmake.cmake_extension import BuildExtension, bdist_wheel, cmake_extension
|
||||||
|
import get_version
|
||||||
|
|
||||||
|
|
||||||
|
get_package_version = get_version.get_package_version
|
||||||
|
|
||||||
|
|
||||||
def read_long_description():
|
def read_long_description():
|
||||||
@ -15,15 +19,6 @@ def read_long_description():
|
|||||||
return readme
|
return readme
|
||||||
|
|
||||||
|
|
||||||
def get_package_version():
|
|
||||||
with open("CMakeLists.txt") as f:
|
|
||||||
content = f.read()
|
|
||||||
|
|
||||||
match = re.search(r"set\(kaldifeat_VERSION (.*)\)", content)
|
|
||||||
latest_version = match.group(1).strip('"')
|
|
||||||
return latest_version
|
|
||||||
|
|
||||||
|
|
||||||
package_name = "kaldifeat"
|
package_name = "kaldifeat"
|
||||||
|
|
||||||
with open("kaldifeat/python/kaldifeat/__init__.py", "a") as f:
|
with open("kaldifeat/python/kaldifeat/__init__.py", "a") as f:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user