Unverified Commit 285ad4dd authored by Wei Kang's avatar Wei Kang Committed by GitHub
Browse files

Add github actions (#30)

parent a801adc3
#!/bin/bash
#
# Copyright 2020 Mobvoi Inc. (authors: Fangjun Kuang)
#
# 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.
echo "cuda version: $cuda"
case "$cuda" in
10.0)
url=https://developer.nvidia.com/compute/cuda/10.0/Prod/local_installers/cuda_10.0.130_410.48_linux
;;
10.1)
# WARNING: there are bugs in
# https://developer.nvidia.com/compute/cuda/10.1/Prod/local_installers/cuda_10.1.105_418.39_linux.run
# with GCC 7. Please use the following version
url=http://developer.download.nvidia.com/compute/cuda/10.1/Prod/local_installers/cuda_10.1.243_418.87.00_linux.run
;;
10.2)
url=http://developer.download.nvidia.com/compute/cuda/10.2/Prod/local_installers/cuda_10.2.89_440.33.01_linux.run
;;
11.0)
url=http://developer.download.nvidia.com/compute/cuda/11.0.2/local_installers/cuda_11.0.2_450.51.05_linux.run
;;
11.1)
# url=https://developer.download.nvidia.com/compute/cuda/11.1.0/local_installers/cuda_11.1.0_455.23.05_linux.run
url=https://developer.download.nvidia.com/compute/cuda/11.1.1/local_installers/cuda_11.1.1_455.32.00_linux.run
;;
11.3)
# url=https://developer.download.nvidia.com/compute/cuda/11.3.0/local_installers/cuda_11.3.0_465.19.01_linux.run
url=https://developer.download.nvidia.com/compute/cuda/11.3.1/local_installers/cuda_11.3.1_465.19.01_linux.run
;;
11.5)
url=https://developer.download.nvidia.com/compute/cuda/11.5.2/local_installers/cuda_11.5.2_495.29.05_linux.run
;;
11.6)
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
;;
*)
echo "Unknown cuda version: $cuda"
exit 1
;;
esac
function retry() {
$* || (sleep 1 && $*) || (sleep 2 && $*) || (sleep 4 && $*) || (sleep 8 && $*)
}
retry curl -LSs -O $url
filename=$(basename $url)
echo "filename: $filename"
chmod +x ./$filename
sudo ./$filename --toolkit --silent
rm -fv ./$filename
export CUDA_HOME=/usr/local/cuda
export PATH=$CUDA_HOME/bin:$PATH
export LD_LIBRARY_PATH=$CUDA_HOME/lib:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=$CUDA_HOME/lib64:$LD_LIBRARY_PATH
#!/bin/bash
#
# Copyright 2020 Mobvoi Inc. (authors: Fangjun Kuang)
#
# 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.
case $cuda in
10.0)
filename=cudnn-10.0-linux-x64-v7.6.5.32.tgz
;;
10.1)
filename=cudnn-10.1-linux-x64-v8.0.2.39.tgz
;;
10.2)
filename=cudnn-10.2-linux-x64-v8.0.2.39.tgz
;;
11.0)
filename=cudnn-11.0-linux-x64-v8.0.5.39.tgz
;;
11.1)
filename=cudnn-11.1-linux-x64-v8.0.4.30.tgz
;;
11.3)
filename=cudnn-11.3-linux-x64-v8.2.0.53.tgz
;;
11.5)
filename=cudnn-11.3-linux-x64-v8.2.0.53.tgz
;;
11.6)
filename=cudnn-11.3-linux-x64-v8.2.0.53.tgz
;;
11.7)
filename=cudnn-11.3-linux-x64-v8.2.0.53.tgz
;;
*)
echo "Unsupported cuda version: $cuda"
exit 1
;;
esac
command -v git-lfs >/dev/null 2>&1 || { echo >&2 "\nPlease install 'git-lfs' first."; exit 2; }
GIT_LFS_SKIP_SMUDGE=1 git clone https://huggingface.co/csukuangfj/cudnn
cd cudnn
git lfs pull --include="$filename"
sudo tar xf ./$filename --strip-components=1 -C /usr/local/cuda
# save disk space
git lfs prune && cd .. && rm -rf cudnn
sudo sed -i '59i#define CUDNN_MAJOR 8' /usr/local/cuda/include/cudnn.h
#!/bin/bash
#
# Copyright 2020 Mobvoi Inc. (authors: Fangjun Kuang)
#
# 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.
torch=$TORCH_VERSION
cuda=$CUDA_VERSION
case ${torch} in
1.5.*)
case ${cuda} in
10.1)
package="torch==${torch}+cu101"
url=https://download.pytorch.org/whl/torch_stable.html
;;
10.2)
package="torch==${torch}"
# Leave url empty to use PyPI.
# torch_stable provides cu92 but we want cu102
url=
;;
esac
;;
1.6.0)
case ${cuda} in
10.1)
package="torch==1.6.0+cu101"
url=https://download.pytorch.org/whl/torch_stable.html
;;
10.2)
package="torch==1.6.0"
# Leave it empty to use PyPI.
# torch_stable provides cu92 but we want cu102
url=
;;
esac
;;
1.7.*)
case ${cuda} in
10.1)
package="torch==${torch}+cu101"
url=https://download.pytorch.org/whl/torch_stable.html
;;
10.2)
package="torch==${torch}"
# Leave it empty to use PyPI.
# torch_stable provides cu92 but we want cu102
url=
;;
11.0)
package="torch==${torch}+cu110"
url=https://download.pytorch.org/whl/torch_stable.html
;;
esac
;;
1.8.*)
case ${cuda} in
10.1)
package="torch==${torch}+cu101"
url=https://download.pytorch.org/whl/torch_stable.html
;;
10.2)
package="torch==${torch}"
# Leave it empty to use PyPI.
url=
;;
11.1)
package="torch==${torch}+cu111"
url=https://download.pytorch.org/whl/torch_stable.html
;;
esac
;;
1.9.*)
case ${cuda} in
10.2)
package="torch==${torch}"
# Leave it empty to use PyPI.
url=
;;
11.1)
package="torch==${torch}+cu111"
url=https://download.pytorch.org/whl/torch_stable.html
;;
esac
;;
1.10.*)
case ${cuda} in
10.2)
package="torch==${torch}"
# Leave it empty to use PyPI.
url=
;;
11.1)
package="torch==${torch}+cu111"
url=https://download.pytorch.org/whl/torch_stable.html
;;
11.3)
package="torch==${torch}+cu113"
url=https://download.pytorch.org/whl/torch_stable.html
;;
esac
;;
1.11.*)
case ${cuda} in
10.2)
package="torch==${torch}"
# Leave it empty to use PyPI.
url=
;;
11.3)
package="torch==${torch}+cu113"
url=https://download.pytorch.org/whl/torch_stable.html
;;
11.5)
package="torch==${torch}+cu115"
url=https://download.pytorch.org/whl/torch_stable.html
;;
esac
;;
1.12.*)
case ${cuda} in
10.2)
package="torch==${torch}"
# Leave it empty to use PyPI.
url=
;;
11.3)
package="torch==${torch}+cu113"
url=https://download.pytorch.org/whl/torch_stable.html
;;
11.6)
package="torch==${torch}+cu116"
url=https://download.pytorch.org/whl/torch_stable.html
;;
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
;;
*)
echo "Unsupported PyTorch version: ${torch}"
exit 1
;;
esac
function retry() {
$* || (sleep 1 && $*) || (sleep 2 && $*) || (sleep 4 && $*) || (sleep 8 && $*)
}
if [ x"${url}" == "x" ]; then
retry python3 -m pip install -q $package
else
retry python3 -m pip install -q $package -f $url
fi
rm -rfv ~/.cache/pip
# Copyright 2023 Xiaomi Corp. (Wei Kang)
# 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: run-tests-cpu
on:
push:
branches:
- master
paths:
- '.github/workflows/run_tests_cpu.yml'
- 'CMakeLists.txt'
- 'cmake/**'
- 'fast_rnnt/csrc/**'
- 'fast_rnnt/python/**'
pull_request:
branches:
- master
paths:
- '.github/workflows/run_tests_cpu.yml'
- 'CMakeLists.txt'
- 'cmake/**'
- 'fast_rnnt/csrc/**'
- 'fast_rnnt/python/**'
concurrency:
group: run-tests-cpu-${{ github.ref }}
cancel-in-progress: true
jobs:
run-tests-cpu:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
torch: ["1.13.1"]
torchaudio: ["0.13.1"]
python-version: ["3.11"]
build_type: ["Release", "Debug"]
steps:
# refer to https://github.com/actions/checkout
- uses: actions/checkout@v2
- name: Display GCC version
run: |
gcc --version
- name: Display clang version
if: startsWith(matrix.os, 'macos')
run: |
clang --version
- 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 PyTorch ${{ matrix.torch }}
if: startsWith(matrix.os, 'ubuntu')
shell: bash
run: |
python3 -m pip install -qq --upgrade pip
python3 -m pip install -qq torch==${{ matrix.torch }}+cpu -f https://download.pytorch.org/whl/torch_stable.html
python3 -m pip install -qq torchaudio==${{ matrix.torchaudio }}+cpu -f https://download.pytorch.org/whl/cpu/torch_stable.html
python3 -c "import torch; print('torch version:', torch.__version__)"
python3 -m torch.utils.collect_env
- name: Install PyTorch ${{ matrix.torch }}
if: startsWith(matrix.os, 'macos')
shell: bash
run: |
python3 -m pip install -qq --upgrade pip
python3 -m pip install -qq torch==${{ matrix.torch }}
python3 -m pip install -qq torch==${{ matrix.torchaudio }}
python3 -c "import torch; print('torch version:', torch.__version__)"
python3 -m torch.utils.collect_env
- name: Configure CMake
shell: bash
env:
torch: ${{ matrix.torch }}
run: |
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} -DFT_WITH_CUDA=OFF ..
- name: ${{ matrix.build_type }} Build
shell: bash
run: |
cd build
make -j2 VERBOSE=1
- name: Display Build Information
shell: bash
run: |
export PYTHONPATH=$PWD/fast_rnnt/python:$PWD/build/lib:$PYTHONPATH
- name: Run Tests
shell: bash
run: |
cd build
ctest --output-on-failure
# Copyright 2023 Xiaomi Corp. (Wei Kang)
# 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: run-tests-cuda
on:
push:
branches:
- master
paths:
- '.github/workflows/run_tests_cuda.yml'
- 'CMakeLists.txt'
- 'cmake/**'
- 'fast_rnnt/csrc/**'
- 'fast_rnnt/python/**'
pull_request:
branches:
- master
paths:
- '.github/workflows/run_tests_cuda.yml'
- 'CMakeLists.txt'
- 'cmake/**'
- 'fast_rnnt/csrc/**'
- 'fast_rnnt/python/**'
concurrency:
group: run-tests-${{ github.ref }}
cancel-in-progress: true
jobs:
run-tests:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest]
cuda: ["11.7"]
torch: ["1.13.1"]
torchaudio: ["1.13.0"]
python-version: ["3.11"]
build_type: ["Release", "Debug"]
steps:
# refer to https://github.com/actions/checkout
- uses: actions/checkout@v2
- name: Install CUDA Toolkit ${{ matrix.cuda }}
env:
cuda: ${{ matrix.cuda }}
run: |
source ./.github/scripts/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
shell: bash
- name: Display NVCC version
run: |
which nvcc
nvcc --version
- name: Display GCC version
run: |
gcc --version
- 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 PyTorch ${{ matrix.torch }}
env:
cuda: ${{ matrix.cuda }}
torch: ${{ matrix.torch }}
shell: bash
run: |
python3 -m pip install -qq --upgrade pip
./.github/scripts/install_torch.sh
python3 -c "import torch; print('torch version:', torch.__version__)"
- name: Install git lfs
run: |
sudo apt-get install -y git-lfs
- name: Download cudnn 8.0
env:
cuda: ${{ matrix.cuda }}
run: |
./scripts/github_actions/install_cudnn.sh
- name: Configure CMake
shell: bash
env:
torch: ${{ matrix.torch }}
run: |
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} ..
- name: ${{ matrix.build_type }} Build
shell: bash
run: |
echo "number of cores: $(nproc)"
cd build
# we cannot use -j here because of limited RAM
# of the VM provided by GitHub actions
make VERBOSE=1 -j2
- name: Display Build Information
shell: bash
run: |
export PYTHONPATH=$PWD/fast_rnnt/python:$PWD/build/lib:$PYTHONPATH
- name: Run Tests
shell: bash
run: |
cd build
ctest --output-on-failure
# Copyright 2023 Xiaomi Corp. (Fangjun Kuang
# Wei Kang)
# 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: style_check
on:
push:
branches:
- master
pull_request:
branches:
- master
concurrency:
group: style_check-${{ github.ref }}
cancel-in-progress: true
jobs:
style_check:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
python-version: [3.8]
fail-fast: false
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v1
with:
python-version: ${{ matrix.python-version }}
- name: Install Python dependencies
run: |
python3 -m pip install --upgrade pip black==22.3.0 flake8==5.0.4 click==8.1.0
# Click issue fixed in https://github.com/psf/black/pull/2966
- name: Run flake8
shell: bash
working-directory: ${{github.workspace}}
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 . --count --exit-zero --max-complexity=10 --max-line-length=127 \
--statistics --extend-ignore=E203,E266,E501,F401,E402,F403,F841,W503
- name: Run black
shell: bash
working-directory: ${{github.workspace}}
run: |
black --check --diff .
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment