Skip to content

Commit

Permalink
Use the CPU docker in CI to simplify the test code (#1427)
Browse files Browse the repository at this point in the history
  • Loading branch information
csukuangfj authored Dec 24, 2023
1 parent 79a4214 commit e5bb1ae
Show file tree
Hide file tree
Showing 4 changed files with 72 additions and 104 deletions.
21 changes: 11 additions & 10 deletions .github/scripts/docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ RUN apt-get update -y && \
ffmpeg \
git \
git-lfs \
graphviz \
less \
vim \
&& \
Expand All @@ -32,23 +33,23 @@ RUN pip install --no-cache-dir \
k2==${_K2_VERSION} -f https://k2-fsa.github.io/k2/cpu.html \
git+https://github.com/lhotse-speech/lhotse \
kaldifeat==${_KALDIFEAT_VERSION} -f https://csukuangfj.github.io/kaldifeat/cpu.html \
dill \
graphviz \
kaldi_native_io \
kaldialign \
kaldifst \
kaldilm \
sentencepiece>=0.1.96 \
tensorboard \
typeguard \
dill \
onnx \
onnxruntime \
onnxmltools \
six \
matplotlib \
multi_quantization \
typeguard \
numpy \
onnx \
onnxmltools \
onnxruntime \
pytest \
graphviz
sentencepiece>=0.1.96 \
six \
tensorboard \
typeguard

# RUN git clone https://github.com/k2-fsa/icefall /workspace/icefall && \
# cd /workspace/icefall && \
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/build-cpu-docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ jobs:
matrix:
os: [ubuntu-latest]
python-version: ["3.8", "3.9", "3.10"]
torch-version: ["1.13.0", "2.0.0", "2.0.1", "2.1.0", "2.1.1", "2.1.2"]
torch-version: ["1.13.0", "1.13.1", "2.0.0", "2.0.1", "2.1.0", "2.1.1", "2.1.2"]
k2-version: ["1.24.4.dev20231220"]
kaldifeat-version: ["1.25.3.dev20231221"]
version: ["1.0"]
version: ["1.1"]

steps:
# refer to https://github.com/actions/checkout
Expand All @@ -45,8 +45,12 @@ jobs:
run: |
cd .github/scripts/docker
torch_version=${{ matrix.torch-version }}
# see https://pytorch.org/audio/stable/installation.html#compatibility-matrix
if [[ $torch_version == 1.13.0 ]]; then
torchaudio_version=0.13.0
elif [[ $torch_version == 1.13.1 ]]; then
torchaudio_version=0.13.1
elif [[ $torch_version == 2.0.0 ]]; then
torchaudio_version=2.0.1
elif [[ $torch_version == 2.0.1 ]]; then
Expand Down
139 changes: 52 additions & 87 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,129 +1,94 @@
# Copyright 2021 Fangjun Kuang ([email protected])

# 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: test

on:
push:
branches:
- master

pull_request:
branches:
- master

workflow_dispatch:

concurrency:
group: test-${{ github.ref }}
cancel-in-progress: true

jobs:
test:
name: py${{ matrix.python-version }} torch${{ matrix.torch-version }} v${{ matrix.version }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
python-version: ["3.8"]
torch: ["1.13.0"]
torchaudio: ["0.13.0"]
k2-version: ["1.24.3.dev20230719"]

fail-fast: false
python-version: ["3.8", "3.9", "3.10"]
torch-version: ["1.13.0", "1.13.1", "2.0.0", "2.0.1", "2.1.0", "2.1.1", "2.1.2"]
version: ["1.1"]

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}

- name: Install libnsdfile and libsox
if: startsWith(matrix.os, 'ubuntu')
run: |
sudo apt update
sudo apt install -q -y libsndfile1-dev libsndfile1 ffmpeg
sudo apt install -q -y --fix-missing libsox-dev libsox-fmt-all
- name: Install Python dependencies
run: |
python3 -m pip install --upgrade pip pytest
# numpy 1.20.x does not support python 3.6
pip install numpy==1.19
pip install torch==${{ matrix.torch }}+cpu -f https://download.pytorch.org/whl/cpu/torch_stable.html
pip install torchaudio==${{ matrix.torchaudio }}+cpu -f https://download.pytorch.org/whl/cpu/torch_stable.html
pip install k2==${{ matrix.k2-version }}+cpu.torch${{ matrix.torch }} -f https://k2-fsa.github.io/k2/cpu.html
pip install git+https://github.com/lhotse-speech/lhotse
# icefall requirements
pip uninstall -y protobuf
pip install --no-binary protobuf protobuf==3.20.*
pip install kaldifst
pip install onnxruntime matplotlib
pip install -r requirements.txt
- name: Install graphviz
if: startsWith(matrix.os, 'ubuntu')
- name: Free space
shell: bash
run: |
python3 -m pip install -qq graphviz
sudo apt-get -qq install graphviz
df -h
rm -rf /opt/hostedtoolcache
df -h
echo "pwd: $PWD"
echo "github.workspace ${{ github.workspace }}"
- name: Run tests
if: startsWith(matrix.os, 'ubuntu')
run: |
ls -lh
export PYTHONPATH=$PWD:$PWD/lhotse:$PYTHONPATH
echo $PYTHONPATH
pytest -v -s ./test
# runt tests for conformer ctc
cd egs/librispeech/ASR/conformer_ctc
pytest -v -s
uses: addnab/docker-run-action@v3
with:
image: ghcr.io/k2-fsa/icefall:cpu-py${{ matrix.python-version }}-torch${{ matrix.torch-version }}-v${{ matrix.version }}
options: |
--volume ${{ github.workspace }}/:/icefall
shell: bash
run: |
export PYTHONPATH=/icefall:$PYTHONPATH
cd /icefall
git config --global --add safe.directory /icefall
pytest -v -s ./test
# runt tests for conformer ctc
cd egs/librispeech/ASR/conformer_ctc
pytest -v -s
cd ../pruned_transducer_stateless
pytest -v -s
cd ../pruned_transducer_stateless
pytest -v -s
cd ../pruned_transducer_stateless2
pytest -v -s
cd ../pruned_transducer_stateless2
pytest -v -s
cd ../pruned_transducer_stateless3
pytest -v -s
cd ../pruned_transducer_stateless3
pytest -v -s
cd ../pruned_transducer_stateless4
pytest -v -s
cd ../pruned_transducer_stateless4
pytest -v -s
echo $PYTHONPATH
cd ../pruned_transducer_stateless7
pytest -v -s
echo $PYTHONPATH
cd ../pruned_transducer_stateless7
pytest -v -s
cd ../transducer_stateless
pytest -v -s
cd ../transducer_stateless
pytest -v -s
# cd ../transducer
# pytest -v -s
# cd ../transducer
# pytest -v -s
cd ../transducer_stateless2
pytest -v -s
cd ../transducer_stateless2
pytest -v -s
cd ../transducer_lstm
pytest -v -s
cd ../transducer_lstm
pytest -v -s
cd ../zipformer
pytest -v -s
cd ../zipformer
pytest -v -s
- uses: actions/upload-artifact@v2
with:
Expand Down
8 changes: 3 additions & 5 deletions .github/workflows/train-librispeech.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,8 @@ jobs:
matrix:
os: [ubuntu-latest]
python-version: ["3.8", "3.9", "3.10"]
torch-version: ["1.13.0", "2.0.0", "2.0.1", "2.1.0", "2.1.1", "2.1.2"]
k2-version: ["1.24.4.dev20231220"]
kaldifeat-version: ["1.25.3.dev20231221"]
version: ["1.0"]
torch-version: ["1.13.0", "1.13.1", "2.0.0", "2.0.1", "2.1.0", "2.1.1", "2.1.2"]
version: ["1.1"]

steps:
# refer to https://github.com/actions/checkout
Expand All @@ -43,7 +41,7 @@ jobs:
echo "pwd: $PWD"
echo "github.workspace ${{ github.workspace }}"
- name: Run the build process with Docker
- name: Test zipformer/train.py with LibriSpeech
uses: addnab/docker-run-action@v3
with:
image: ghcr.io/k2-fsa/icefall:cpu-py${{ matrix.python-version }}-torch${{ matrix.torch-version }}-v${{ matrix.version }}
Expand Down

0 comments on commit e5bb1ae

Please sign in to comment.