Skip to content

Commit

Permalink
Merge branch 'espnet:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
roshansh-cmu authored Feb 13, 2022
2 parents eafa483 + 2ad5b51 commit 4aefb6e
Show file tree
Hide file tree
Showing 48 changed files with 322 additions and 816 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ egs*/*/*/wav*
egs*/*/*/nltk*
egs*/*/*/.cache*
egs*/*/*/pretrained_models*
egs*/fisher_callhome_spanish/*/local/mapping*

# tools related
tools/chainer
Expand Down
12 changes: 12 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,18 @@ to its differences.
- If a recipe for a new corpus is proposed, you should add its name and information to:
https://github.com/espnet/espnet/blob/master/egs/README.md if it's a ESPnet1 recipe,
or https://github.com/espnet/espnet/blob/master/egs2/README.md + `db.sh` if it's a ESPnet2 recipe.

#### 1.3.4 Checklist before you submit the recipe-based PR

- [ ] be careful about the name for the recipe. It is recommended to follow naming conventions of the other recipes
- [ ] common/shared files are linked with **soft link** (see Section 1.3.3)
- [ ] modified or new python scripts should be passed through **latest** black formating (by using python package black). The command to be executed could be `black espnet espnet2 test utils setup.py egs*/*/*/local egs2/TEMPLATE/asr1/pyscripts`
- [ ] cluster settings should be set as **default** (e.g., cmd.sh conf/slurm.conf conf/queue.conf conf/pbs.conf)
- [ ] update `egs/README.md` or `egs2/README.md` with corresponding recipes
- [ ] add corresponding entry in `egs2/TEMPLATE/db.sh` for a new corpus
- [ ] try to **simplify** the model configurations. We recommend to have only the best configuration for the start of a recipe. Please also follow the default rule defined in Section 1.3.3
- [ ] large meta-information for a corpus should be maintained elsewhere other than in the recipe itself
- [ ] recommend to also include results and pre-trained model with the recipe

## 2 Pull Request
If your proposed feature or bugfix is ready, please open a Pull Request (PR) at https://github.com/espnet/espnet
Expand Down
69 changes: 38 additions & 31 deletions docker/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@
# 2019, Nelson Yalta
# 2019, Ludwig Kürzinger, Technische Universität München

log() {
local fname=${BASH_SOURCE[1]##*/}
echo -e "$(date '+%Y-%m-%dT%H:%M:%S') (${fname}:${BASH_LINENO[0]}:${FUNCNAME[1]}) $*"
}

SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"

Expand All @@ -11,10 +15,7 @@ ubuntu_ver=20.04
cuda_ver=11.1
build_ver=cpu
build_cores=24
th_ver=1.8.0

docker_ver=$(docker version -f '{{.Server.Version}}')
echo "Using Docker Ver.${docker_ver}"
th_ver=1.10.1


cmd_usage() {
Expand Down Expand Up @@ -63,16 +64,16 @@ cmd_usage() {


build(){
echo "Build Latest docker containers"
log "Build Latest docker containers"
# build runtime and gpu based containers
this_tag=espnet/espnet:runtime-latest
docker_image=$( docker images -q ${this_tag} )
if ! [[ -n ${docker_image} ]]; then
echo "Now building Runtime container"
log "Now building Runtime container"
docker build --build-arg DOCKER_VER=${docker_ver} \
--build-arg FROM_TAG=${default_ubuntu_ver} \
--build-arg NUM_BUILD_CORES=${build_cores} \
-f prebuilt/runtime/Dockerfile -t ${this_tag} . | tee -a build_runtime.log > /dev/null
-f prebuilt/runtime.dockerfile -t ${this_tag} . | tee -a build_runtime.log > /dev/null

docker_image=$( docker images -q ${this_tag} )
[ -z "${docker_image}" ] && exit 1
Expand All @@ -81,9 +82,9 @@ build(){
this_tag=espnet/espnet:cuda-latest
docker_image=$( docker images -q ${this_tag} )
if ! [[ -n ${docker_image} ]]; then
echo "Now building CUDA container"
log "Now building CUDA container"
docker build --build-arg FROM_TAG=runtime-latest \
-f prebuilt/devel/gpu/${default_cuda_ver}/Dockerfile -t ${this_tag} . | tee -a build_cuda.log > /dev/null
-f prebuilt/gpu.dockerfile -t ${this_tag} . | tee -a build_cuda.log > /dev/null
docker_image=$( docker images -q ${this_tag} )
[ -z "${docker_image}" ] && exit 1
fi
Expand All @@ -93,8 +94,11 @@ build(){
this_tag=espnet/espnet:cpu-latest
docker_image=$( docker images -q ${this_tag} )
if ! [[ -n ${docker_image} ]]; then
echo "Now building cpu-latest with ubuntu:${default_ubuntu_ver}"
docker build --build-arg FROM_TAG=runtime-latest -f prebuilt/devel/Dockerfile -t ${this_tag} . | tee -a build_cpu.log > /dev/null
log "Now building cpu-latest with ubuntu:${default_ubuntu_ver}"
docker build --build-arg FROM_TAG=runtime-latest \
-f prebuilt/devel.dockerfile \
--target devel \
-t ${this_tag} . | tee -a build_cpu.log > /dev/null

docker_image=$( docker images -q ${this_tag} )
[ -z "${docker_image}" ] && exit 1
Expand All @@ -106,29 +110,31 @@ build(){
this_tag=espnet/espnet:gpu-latest
docker_image=$( docker images -q ${this_tag} )
if ! [[ -n ${docker_image} ]]; then
echo "Now building gpu-latest with ubuntu:${default_ubuntu_ver} and cuda:${default_cuda_ver}"
docker build ${build_args} -f prebuilt/devel/Dockerfile -t ${this_tag} . | tee -a build_gpu.log > /dev/null
log "Now building gpu-latest with ubuntu:${default_ubuntu_ver} and cuda:${default_cuda_ver}"
docker build ${build_args} -f prebuilt/devel.dockerfile \
--target devel \
-t ${this_tag} . | tee -a build_gpu.log > /dev/null
docker_image=$( docker images -q ${this_tag} )
[ -z "${docker_image}" ] && exit 1
fi
}


build_local(){
echo "Building docker container: base image, and image for ${build_ver}"
log "Building docker container: base image, and image for ${build_ver}"
sleep 1

# prepare espnet-repo, assuming that this script is in folder espnet/docker
cd ${SCRIPTPATH}/..
ESPNET_ARCHIVE="./espnet-local.tar"
echo "Reconstructing the local repository from the last commit"
log "Reconstructing the local repository from the last commit"
git archive -o docker/${ESPNET_ARCHIVE} HEAD || exit 1
cd ${SCRIPTPATH}
test -r ${ESPNET_ARCHIVE} || exit 1;
sleep 1

if [ "${build_base_image}" = true ]; then
echo "building ESPnet base image with ubuntu:${ubuntu_ver}"
log "building ESPnet base image with ubuntu:${ubuntu_ver}"
docker build --build-arg DOCKER_VER=${docker_ver} \
--build-arg FROM_TAG=${ubuntu_ver} \
--build-arg NUM_BUILD_CORES=${build_cores} \
Expand All @@ -137,11 +143,11 @@ build_local(){
fi

if [[ ${build_ver} == "cpu" ]]; then
echo "building ESPnet CPU Image with ubuntu:${ubuntu_ver}"
log "building ESPnet CPU Image with ubuntu:${ubuntu_ver}"
docker build --build-arg FROM_TAG=runtime-local --build-arg ESPNET_ARCHIVE=${ESPNET_ARCHIVE} \
-f prebuilt/local/Dockerfile -t espnet/espnet:cpu-local . || exit 1
elif [[ ${build_ver} == "gpu" ]]; then
echo "building ESPnet GPU Image with ubuntu:${ubuntu_ver} and cuda:${cuda_ver}"
log "building ESPnet GPU Image with ubuntu:${ubuntu_ver} and cuda:${cuda_ver}"
if [ "${build_base_image}" = true ] ; then
docker build -f prebuilt/devel/gpu/${ver}/Dockerfile -t espnet/espnet:cuda${ver}-cudnn7 . || exit 1
else
Expand All @@ -154,15 +160,15 @@ build_local(){
build_args="${build_args} --build-arg ESPNET_ARCHIVE=${ESPNET_ARCHIVE}"
docker build ${build_args} -f prebuilt/local/Dockerfile -t espnet/espnet:gpu-cuda${ver}-cudnn7-u18-local . || exit 1
else
echo "Parameter invalid: " ${ver}
log "ERROR: Parameter invalid: " ${ver}
fi

echo "cleanup."
log "cleanup."
test -r ${ESPNET_ARCHIVE} && rm ${ESPNET_ARCHIVE}
}

run_recipe1(){
./run.sh --docker-egs an4/asr1 \
./run.sh --docker-egs mini_an4/asr1 \
--docker-cmd run.sh \
--docker-gpu ${1} \
--verbose 1 \
Expand All @@ -173,10 +179,10 @@ run_recipe1(){
}

run_recipe2(){
./run.sh --docker-egs an4/asr1 \
./run.sh --docker-egs mini_an4/asr1 \
--docker-cmd run.sh \
--docker-gpu ${1} \
--docker-env "NLTK_DATA=/espnet/egs2/an4/asr1/nltk_data,HOME=/espnet/egs2/an4/asr1" \
--docker-env "NLTK_DATA=/espnet/egs2/mini_an4/asr1/nltk_data,HOME=/espnet/egs2/mini_an4/asr1" \
--is-egs2 \
--ngpu ${2} \
--stage ${3} \
Expand All @@ -185,11 +191,11 @@ run_recipe2(){
}

testing(){
echo "Testing docker containers"
log "Testing docker containers"
# Test Docker Containers with cpu setup
run_stage=-1
for backend in chainer pytorch; do
if [ -f ../egs/an4/asr1/dump/train_nodev/deltafalse/data.json ]; then
if [ -f ../egs/mini_an4/asr1/dump/train_nodev/deltafalse/data.json ]; then
run_stage=3
fi
if [ ! -f .test_cpu_${backend}.done ]; then
Expand All @@ -199,7 +205,7 @@ testing(){
done

for backend in chainer pytorch; do
if [ -f ../egs/an4/asr1/dump/train_nodev/deltafalse/data.json ]; then
if [ -f ../egs/mini_an4/asr1/dump/train_nodev/deltafalse/data.json ]; then
run_stage=3
fi
if [ ! -f .test_gpu_${backend}.done ]; then
Expand All @@ -208,7 +214,7 @@ testing(){
fi
done

echo "ESPnet egs Done. Press <enter> to continue with ESPnet2 egs"
log "ESPnet egs Done. Press <enter> to continue with ESPnet2 egs"
read enter
# Test for espnet2
run_stage=-1
Expand All @@ -227,7 +233,7 @@ testing(){

push(){
for tag in runtime-latest cuda-latest cpu-latest gpu-latest;do
echo "docker push espnet/espnet:${tag}"
log "docker push espnet/espnet:${tag}"
( docker push espnet/espnet:${tag} )|| exit 1
done
}
Expand Down Expand Up @@ -273,14 +279,15 @@ check=true
[ "${default_ubuntu_ver}" != "${ubuntu_ver}" ] || [ "${default_cuda_ver}" != "${cuda_ver}" ] && check=false

if [ ${check} = false ] && [ "${mode}" != "fully_local" ]; then
echo "Error: Use of custom versions of Ubuntu (!=${default_ubuntu_ver}) and CUDA (!=${default_cuda_ver})
log "Error: Use of custom versions of Ubuntu (!=${default_ubuntu_ver}) and CUDA (!=${default_cuda_ver})
is only available for <mode> == fully_local.
Exiting... "
exit 0;
fi

docker_ver=$(docker version -f '{{.Server.Version}}')
log "Using Docker Ver.${docker_ver}"

echo "Using Docker Ver.${docker_ver}"
## Application menu
if [[ "${mode}" == "build" ]]; then
build
Expand All @@ -302,4 +309,4 @@ else
cmd_usage
fi

echo "$(basename "$0") done."
log "$(basename "$0") done."
4 changes: 1 addition & 3 deletions docker/prebuilt/Dockerfile → docker/espnet.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,7 @@ ARG EXTRA_LIBS

RUN if [ ${EXTRA_LIBS} = true ]; then \
cd /espnet/tools; \
. ./activate_python.sh; \
pip install parallel_wavegan; \
pip install git+https://github.com/cybertronai/pytorch-lamb; \
make extra; \
fi

# Add user to container
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
ARG FROM_TAG
FROM espnet/espnet:${FROM_TAG}
FROM espnet/espnet:${FROM_TAG} as devel
LABEL maintainer "Nelson Yalta <nyalta21@gmail.com>"

ARG CUDA_VER
Expand Down Expand Up @@ -48,11 +48,36 @@ RUN if [ -z "${CUDA_VER}" ]; then \
. ./activate_python.sh && \
./installers/install_warp-ctc.sh && \
./installers/install_kenlm.sh && \
# ./installers/install_chainer_ctc.sh && \
./installers/install_chainer.sh cpu && \
conda clean --all && \
rm -f *.tar.* && \
pip cache purge

RUN rm -rf ../espnet

WORKDIR /


#### For local docker
FROM devel as espnet_local
LABEL maintainer "Nelson Yalta <nyalta21@gmail.com>"

ARG CUDA_VER
WORKDIR /

# IF using a local ESPNet repository, a temporary file containing the ESPnet git repo is copied over
ARG ESPNET_ARCHIVE=./espnet-local.tar
COPY ${ESPNET_ARCHIVE} /espnet-local.tar


# Download ESPnet
RUN echo "Getting ESPnet sources from local repository, in temporary file: " ${ESPNET_ARCHIVE}
RUN mkdir /espnet
RUN tar xf espnet-local.tar -C /espnet/
RUN rm espnet-local.tar

RUN cd espnet && \
rm -rf docker egs test utils

# Install espnet
WORKDIR /espnet/tools
74 changes: 0 additions & 74 deletions docker/prebuilt/devel/gpu/10.0/Dockerfile

This file was deleted.

Loading

0 comments on commit 4aefb6e

Please sign in to comment.