diff --git a/deepspeech/exps/deepspeech2/bin/train.py b/deepspeech/exps/deepspeech2/bin/train.py index 69ff043a08d28171711543afcbd51bcd571e69d2..6740f288fd667d2f84bca96277c46da9ce894c42 100644 --- a/deepspeech/exps/deepspeech2/bin/train.py +++ b/deepspeech/exps/deepspeech2/bin/train.py @@ -27,7 +27,7 @@ def main_sp(config, args): def main(config, args): - if args.device == "gpu" and args.nprocs > 1: + if args.nprocs > 0: dist.spawn(main_sp, args=(config, args), nprocs=args.nprocs) else: main_sp(config, args) diff --git a/deepspeech/exps/deepspeech2/model.py b/deepspeech/exps/deepspeech2/model.py index 7bf029300ff16e56a08aee8d73c22ae9c0468479..8af2b02ab0856947d35650a9f6ae42d0b532885d 100644 --- a/deepspeech/exps/deepspeech2/model.py +++ b/deepspeech/exps/deepspeech2/model.py @@ -403,7 +403,7 @@ class DeepSpeech2Tester(DeepSpeech2Trainer): def setup(self): """Setup the experiment. """ - paddle.set_device(self.args.device) + paddle.set_device('gpu' self.args.nprocs > 0 else 'cpu') self.setup_output_dir() self.setup_checkpointer() @@ -635,7 +635,7 @@ class DeepSpeech2ExportTester(DeepSpeech2Tester): def setup(self): """Setup the experiment. """ - paddle.set_device(self.args.device) + paddle.set_device('gpu' self.args.nprocs > 0 else 'cpu') self.setup_output_dir() diff --git a/deepspeech/exps/u2/bin/train.py b/deepspeech/exps/u2/bin/train.py index b664401a2f21e7c12931868cd10bdefbb536c9f3..17fb08a6c41202da97fec48911ba714942cf29c7 100644 --- a/deepspeech/exps/u2/bin/train.py +++ b/deepspeech/exps/u2/bin/train.py @@ -32,7 +32,7 @@ def main_sp(config, args): def main(config, args): - if args.device == "gpu" and args.nprocs > 1: + if args.nprocs > 0: dist.spawn(main_sp, args=(config, args), nprocs=args.nprocs) else: main_sp(config, args) diff --git a/deepspeech/exps/u2/model.py b/deepspeech/exps/u2/model.py index 6bf0190050cbe6ec16ba6d7983146e8b62893713..bc46a104b6b6b73689378b473a05698718e8d3b2 100644 --- a/deepspeech/exps/u2/model.py +++ b/deepspeech/exps/u2/model.py @@ -653,7 +653,7 @@ class U2Tester(U2Trainer): def setup(self): """Setup the experiment. """ - paddle.set_device(self.args.device) + paddle.set_device('gpu' self.args.nprocs > 0 else 'cpu') self.setup_output_dir() self.setup_checkpointer() diff --git a/deepspeech/exps/u2_kaldi/bin/train.py b/deepspeech/exps/u2_kaldi/bin/train.py index 1dcd154d35bcd941db66260fe54e60873694dc28..d909727f3a5a637f977b2f5569d553db5ff382d1 100644 --- a/deepspeech/exps/u2_kaldi/bin/train.py +++ b/deepspeech/exps/u2_kaldi/bin/train.py @@ -36,7 +36,7 @@ def main_sp(config, args): def main(config, args): - if args.device == "gpu" and args.nprocs > 1: + if args.nprocs > 0: dist.spawn(main_sp, args=(config, args), nprocs=args.nprocs) else: main_sp(config, args) diff --git a/deepspeech/exps/u2_kaldi/model.py b/deepspeech/exps/u2_kaldi/model.py index bc7cd4fd3671012cae3eb3d5913188214dcba8e0..be89c3d694255e68a8893e6de77b352d925cdc0a 100644 --- a/deepspeech/exps/u2_kaldi/model.py +++ b/deepspeech/exps/u2_kaldi/model.py @@ -637,7 +637,7 @@ class U2Tester(U2Trainer): def setup(self): """Setup the experiment. """ - paddle.set_device(self.args.device) + paddle.set_device('gpu' self.args.nprocs > 0 else 'cpu') self.setup_output_dir() self.setup_checkpointer() diff --git a/deepspeech/exps/u2_st/bin/train.py b/deepspeech/exps/u2_st/bin/train.py index 86a0f000051c720276fccdadcf5d8cd0e27a9c9c..1e6a746b848ed7e387aec91217c96640e628a39e 100644 --- a/deepspeech/exps/u2_st/bin/train.py +++ b/deepspeech/exps/u2_st/bin/train.py @@ -30,7 +30,7 @@ def main_sp(config, args): def main(config, args): - if args.device == "gpu" and args.nprocs > 1: + if args.nprocs > 0: dist.spawn(main_sp, args=(config, args), nprocs=args.nprocs) else: main_sp(config, args) diff --git a/deepspeech/exps/u2_st/model.py b/deepspeech/exps/u2_st/model.py index 4f95bc42b35491329f183c3e4cd3065ba29212de..55dadee8229015b27a674411a71adb8809c2f507 100644 --- a/deepspeech/exps/u2_st/model.py +++ b/deepspeech/exps/u2_st/model.py @@ -661,7 +661,7 @@ class U2STTester(U2STTrainer): def setup(self): """Setup the experiment. """ - paddle.set_device(self.args.device) + paddle.set_device('gpu' self.args.nprocs > 0 else 'cpu') self.setup_output_dir() self.setup_checkpointer() diff --git a/deepspeech/training/cli.py b/deepspeech/training/cli.py index 07c213dbca1e0ecb5ba0bf37b71df0859f35ceb6..aa263a0666a611c315803c1782bb45fe4ae5d70a 100644 --- a/deepspeech/training/cli.py +++ b/deepspeech/training/cli.py @@ -30,7 +30,7 @@ def default_argument_parser(): The ``--checkpoint_path`` specifies the checkpoint to load from. - The ``--device`` and ``--nprocs`` specifies how to run the training. + The ``--nprocs`` specifies how to run the training. See Also @@ -51,12 +51,6 @@ def default_argument_parser(): default=None, help="seed to use for paddle, np and random. None or 0 for random, else set seed." ) - train_group.add_argument( - "--device", - type=str, - default='gpu', - choices=["cpu", "gpu"], - help="device cpu and gpu are supported.") train_group.add_argument( "--nprocs", type=int, diff --git a/deepspeech/training/trainer.py b/deepspeech/training/trainer.py index 8b1adcd037cb39eae47ad115d59c50e41fc357f0..b180f4890feb60d083291febc57e1456792802b9 100644 --- a/deepspeech/training/trainer.py +++ b/deepspeech/training/trainer.py @@ -86,7 +86,7 @@ class Trainer(): >>> config.merge_from_list(args.opts) >>> config.freeze() >>> - >>> if args.nprocs > 1 and args.device == "gpu": + >>> if args.nprocs > 0: >>> dist.spawn(main_sp, args=(config, args), nprocs=args.nprocs) >>> else: >>> main_sp(config, args) @@ -119,7 +119,7 @@ class Trainer(): def setup(self): """Setup the experiment. """ - paddle.set_device(self.args.device) + paddle.set_device('gpu' self.args.nprocs > 0 else 'cpu') if self.parallel: self.init_parallel() @@ -139,7 +139,7 @@ class Trainer(): """A flag indicating whether the experiment should run with multiprocessing. """ - return self.args.device == "gpu" and self.args.nprocs > 1 + return elf.args.nprocs > 0 def init_parallel(self): """Init environment for multiprocess training. diff --git a/examples/aishell/s0/local/export.sh b/examples/aishell/s0/local/export.sh index 2e09e5f5e76a7f7cdf9cca8fbb91d66bb48aea0c..a5e62c28d2fa23a5ef9b9e2a0281b025aa943a30 100755 --- a/examples/aishell/s0/local/export.sh +++ b/examples/aishell/s0/local/export.sh @@ -13,13 +13,7 @@ ckpt_path_prefix=$2 jit_model_export_path=$3 model_type=$4 -device=gpu -if [ ${ngpu} == 0 ];then - device=cpu -fi - python3 -u ${BIN_DIR}/export.py \ ---device ${device} \ --nproc ${ngpu} \ --config ${config_path} \ --checkpoint_path ${ckpt_path_prefix} \ diff --git a/examples/aishell/s0/local/test.sh b/examples/aishell/s0/local/test.sh index 9fd0bc8d5bcdded1d33990a8ae20101d0a538441..2ae0740b3e8d44ab03e45f4c1b5dbb945657705e 100755 --- a/examples/aishell/s0/local/test.sh +++ b/examples/aishell/s0/local/test.sh @@ -8,10 +8,6 @@ fi ngpu=$(echo $CUDA_VISIBLE_DEVICES | awk -F "," '{print NF}') echo "using $ngpu gpus..." -device=gpu -if [ ${ngpu} == 0 ];then - device=cpu -fi config_path=$1 ckpt_prefix=$2 model_type=$3 @@ -23,8 +19,7 @@ if [ $? -ne 0 ]; then fi python3 -u ${BIN_DIR}/test.py \ ---device ${device} \ ---nproc 1 \ +--nproc ${ngpu} \ --config ${config_path} \ --result_file ${ckpt_prefix}.rsl \ --checkpoint_path ${ckpt_prefix} \ diff --git a/examples/aishell/s0/local/test_export.sh b/examples/aishell/s0/local/test_export.sh index b6d580979c9797d7de59b7555c7304e00658b591..a9a6b122df8055f872f9f0a68717b57241d99359 100755 --- a/examples/aishell/s0/local/test_export.sh +++ b/examples/aishell/s0/local/test_export.sh @@ -8,10 +8,6 @@ fi ngpu=$(echo $CUDA_VISIBLE_DEVICES | awk -F "," '{print NF}') echo "using $ngpu gpus..." -device=gpu -if [ ${ngpu} == 0 ];then - device=cpu -fi config_path=$1 jit_model_export_path=$2 model_type=$3 @@ -23,8 +19,7 @@ if [ $? -ne 0 ]; then fi python3 -u ${BIN_DIR}/test_export.py \ ---device ${device} \ ---nproc 1 \ +--nproc ${ngpu} \ --config ${config_path} \ --result_file ${jit_model_export_path}.rsl \ --export_path ${jit_model_export_path} \ diff --git a/examples/aishell/s0/local/train.sh b/examples/aishell/s0/local/train.sh index 668ad0ead41bc9933e2fd63802b95ec5263999d2..edbf3383070ed0c8a71a125c0e77371d0a4412b6 100755 --- a/examples/aishell/s0/local/train.sh +++ b/examples/aishell/s0/local/train.sh @@ -12,11 +12,6 @@ config_path=$1 ckpt_name=$2 model_type=$3 -device=gpu -if [ ${ngpu} == 0 ];then - device=cpu -fi - mkdir -p exp # seed may break model convergence @@ -26,7 +21,6 @@ if [ ${seed} != 0 ]; then fi python3 -u ${BIN_DIR}/train.py \ ---device ${device} \ --nproc ${ngpu} \ --config ${config_path} \ --output exp/${ckpt_name} \ diff --git a/examples/aishell/s1/local/align.sh b/examples/aishell/s1/local/align.sh index ad6c84bc8cf398cddecfadbbb47b7ef9c60e9158..279461aafe19967ac054df815b08e60e351fcc7f 100755 --- a/examples/aishell/s1/local/align.sh +++ b/examples/aishell/s1/local/align.sh @@ -8,10 +8,6 @@ fi ngpu=$(echo $CUDA_VISIBLE_DEVICES | awk -F "," '{print NF}') echo "using $ngpu gpus..." -device=gpu -if [ ${ngpu} == 0 ];then - device=cpu -fi config_path=$1 ckpt_prefix=$2 @@ -22,8 +18,7 @@ mkdir -p ${output_dir} # align dump in `result_file` # .tier, .TextGrid dump in `dir of result_file` python3 -u ${BIN_DIR}/alignment.py \ ---device ${device} \ ---nproc 1 \ +--nproc ${ngpu} \ --config ${config_path} \ --result_file ${output_dir}/${type}.align \ --checkpoint_path ${ckpt_prefix} \ diff --git a/examples/aishell/s1/local/export.sh b/examples/aishell/s1/local/export.sh index f99a15bade1c89f968e84a6c10d500466f884d5b..b562218e7a76c91d3b906d2c099218bf492627a8 100755 --- a/examples/aishell/s1/local/export.sh +++ b/examples/aishell/s1/local/export.sh @@ -12,13 +12,7 @@ config_path=$1 ckpt_path_prefix=$2 jit_model_export_path=$3 -device=gpu -if [ ${ngpu} == 0 ];then - device=cpu -fi - python3 -u ${BIN_DIR}/export.py \ ---device ${device} \ --nproc ${ngpu} \ --config ${config_path} \ --checkpoint_path ${ckpt_path_prefix} \ diff --git a/examples/aishell/s1/local/test.sh b/examples/aishell/s1/local/test.sh index f7e99ad7f668d804a108e295faf9ac2e58760595..c87412c9b67533f1ff3275097099f628f964a608 100755 --- a/examples/aishell/s1/local/test.sh +++ b/examples/aishell/s1/local/test.sh @@ -8,11 +8,6 @@ fi ngpu=$(echo $CUDA_VISIBLE_DEVICES | awk -F "," '{print NF}') echo "using $ngpu gpus..." -device=gpu -if [ ${ngpu} == 0 ];then - device=cpu -fi - config_path=$1 ckpt_prefix=$2 @@ -39,8 +34,7 @@ for type in attention ctc_greedy_search; do output_dir=${ckpt_prefix} mkdir -p ${output_dir} python3 -u ${BIN_DIR}/test.py \ - --device ${device} \ - --nproc 1 \ + --nproc ${ngpu} \ --config ${config_path} \ --result_file ${output_dir}/${type}.rsl \ --checkpoint_path ${ckpt_prefix} \ @@ -58,8 +52,7 @@ for type in ctc_prefix_beam_search attention_rescoring; do output_dir=${ckpt_prefix} mkdir -p ${output_dir} python3 -u ${BIN_DIR}/test.py \ - --device ${device} \ - --nproc 1 \ + --nproc ${ngpu} \ --config ${config_path} \ --result_file ${output_dir}/${type}.rsl \ --checkpoint_path ${ckpt_prefix} \ diff --git a/examples/aishell/s1/local/train.sh b/examples/aishell/s1/local/train.sh index 5097d4d030cab74fe5c3d52b223eddd1c27ea68d..71af3a006deec9032fcefd561fc46cea274d1e10 100755 --- a/examples/aishell/s1/local/train.sh +++ b/examples/aishell/s1/local/train.sh @@ -12,11 +12,6 @@ source ${MAIN_ROOT}/utils/parse_options.sh || exit 1; ngpu=$(echo $CUDA_VISIBLE_DEVICES | awk -F "," '{print NF}') echo "using $ngpu gpus..." -device=gpu -if [ ${ngpu} == 0 ];then - device=cpu -fi - if [ ${seed} != 0 ]; then export FLAGS_cudnn_deterministic=True echo "using seed $seed & FLAGS_cudnn_deterministic=True ..." @@ -34,7 +29,6 @@ mkdir -p exp python3 -u ${BIN_DIR}/train.py \ --seed ${seed} \ ---device ${device} \ --nproc ${ngpu} \ --config ${config_path} \ --output exp/${ckpt_name} \ diff --git a/examples/callcenter/s1/local/align.sh b/examples/callcenter/s1/local/align.sh index f2c878c20c6d5bb9a89b437c6c0d5b11b1b80c4f..b679e2ea7fcb1d5ebd5a50dc88cb90e59e3e4789 100755 --- a/examples/callcenter/s1/local/align.sh +++ b/examples/callcenter/s1/local/align.sh @@ -8,10 +8,6 @@ fi ngpu=$(echo $CUDA_VISIBLE_DEVICES | awk -F "," '{print NF}') echo "using $ngpu gpus..." -device=gpu -if [ ${ngpu} == 0 ];then - device=cpu -fi config_path=$1 ckpt_prefix=$2 @@ -20,7 +16,6 @@ ckpt_name=$(basename ${ckpt_prefxi}) mkdir -p exp - batch_size=1 output_dir=${ckpt_prefix} mkdir -p ${output_dir} @@ -28,8 +23,7 @@ mkdir -p ${output_dir} # align dump in `result_file` # .tier, .TextGrid dump in `dir of result_file` python3 -u ${BIN_DIR}/alignment.py \ ---device ${device} \ ---nproc 1 \ +--nproc ${ngpu} \ --config ${config_path} \ --result_file ${output_dir}/${type}.align \ --checkpoint_path ${ckpt_prefix} \ diff --git a/examples/callcenter/s1/local/export.sh b/examples/callcenter/s1/local/export.sh index d171899cdbf4220436bb71ad07e3a1a5e9ea8bc2..d5f912e9033b1d71423d87ef0a9cf4b1991d3563 100755 --- a/examples/callcenter/s1/local/export.sh +++ b/examples/callcenter/s1/local/export.sh @@ -12,13 +12,7 @@ config_path=$1 ckpt_path_prefix=$2 jit_model_export_path=$3 -device=gpu -if [ ${ngpu} == 0 ];then - device=cpu -fi - python3 -u ${BIN_DIR}/export.py \ ---device ${device} \ --nproc ${ngpu} \ --config ${config_path} \ --checkpoint_path ${ckpt_path_prefix} \ diff --git a/examples/callcenter/s1/local/test.sh b/examples/callcenter/s1/local/test.sh index 7a5b1cdb1c6f62fe25e6349226198ea6d8868a5e..dca3137dd0cf1faadd6b3c383dcb178881bb9080 100755 --- a/examples/callcenter/s1/local/test.sh +++ b/examples/callcenter/s1/local/test.sh @@ -8,10 +8,6 @@ fi ngpu=$(echo $CUDA_VISIBLE_DEVICES | awk -F "," '{print NF}') echo "using $ngpu gpus..." -device=gpu -if [ ${ngpu} == 0 ];then - device=cpu -fi config_path=$1 ckpt_prefix=$2 @@ -32,8 +28,7 @@ for type in attention ctc_greedy_search; do output_dir=${ckpt_prefix} mkdir -p ${output_dir} python3 -u ${BIN_DIR}/test.py \ - --device ${device} \ - --nproc 1 \ + --nproc ${ngpu} \ --config ${config_path} \ --result_file ${output_dir}/${type}.rsl \ --checkpoint_path ${ckpt_prefix} \ @@ -51,8 +46,7 @@ for type in ctc_prefix_beam_search attention_rescoring; do output_dir=${ckpt_prefix} mkdir -p ${output_dir} python3 -u ${BIN_DIR}/test.py \ - --device ${device} \ - --nproc 1 \ + --nproc ${ngpu} \ --config ${config_path} \ --result_file ${output_dir}/${type}.rsl \ --checkpoint_path ${ckpt_prefix} \ diff --git a/examples/callcenter/s1/local/train.sh b/examples/callcenter/s1/local/train.sh index d5dc15b03a32c2c01ba8850b38dbb2c4816cc80c..eb8f86626f8988890c89dc29accb5ae1f172e1d6 100755 --- a/examples/callcenter/s1/local/train.sh +++ b/examples/callcenter/s1/local/train.sh @@ -11,10 +11,6 @@ echo "using $ngpu gpus..." config_path=$1 ckpt_name=$2 -device=gpu -if [ ${ngpu} == 0 ];then - device=cpu -fi echo "using ${device}..." mkdir -p exp @@ -26,7 +22,6 @@ if [ ${seed} != 0 ]; then fi python3 -u ${BIN_DIR}/train.py \ ---device ${device} \ --nproc ${ngpu} \ --config ${config_path} \ --output exp/${ckpt_name} \ diff --git a/examples/librispeech/s0/local/export.sh b/examples/librispeech/s0/local/export.sh index 2e09e5f5e76a7f7cdf9cca8fbb91d66bb48aea0c..a5e62c28d2fa23a5ef9b9e2a0281b025aa943a30 100755 --- a/examples/librispeech/s0/local/export.sh +++ b/examples/librispeech/s0/local/export.sh @@ -13,13 +13,7 @@ ckpt_path_prefix=$2 jit_model_export_path=$3 model_type=$4 -device=gpu -if [ ${ngpu} == 0 ];then - device=cpu -fi - python3 -u ${BIN_DIR}/export.py \ ---device ${device} \ --nproc ${ngpu} \ --config ${config_path} \ --checkpoint_path ${ckpt_path_prefix} \ diff --git a/examples/librispeech/s0/local/test.sh b/examples/librispeech/s0/local/test.sh index b5b68c599c45ab50aa12ee35c120e02fb68740b4..4d00f30b852da5a370f5d4934f3caadd2b833c00 100755 --- a/examples/librispeech/s0/local/test.sh +++ b/examples/librispeech/s0/local/test.sh @@ -8,10 +8,6 @@ fi ngpu=$(echo $CUDA_VISIBLE_DEVICES | awk -F "," '{print NF}') echo "using $ngpu gpus..." -device=gpu -if [ ${ngpu} == 0 ];then - device=cpu -fi config_path=$1 ckpt_prefix=$2 model_type=$3 @@ -23,8 +19,7 @@ if [ $? -ne 0 ]; then fi python3 -u ${BIN_DIR}/test.py \ ---device ${device} \ ---nproc 1 \ +--nproc ${ngpu} \ --config ${config_path} \ --result_file ${ckpt_prefix}.rsl \ --checkpoint_path ${ckpt_prefix} \ diff --git a/examples/librispeech/s0/local/train.sh b/examples/librispeech/s0/local/train.sh index 6aee372a423aa7c037eb8def8c60086606d9a614..519df7fe9387a215f6d8835d90869ec0d4d7f5e5 100755 --- a/examples/librispeech/s0/local/train.sh +++ b/examples/librispeech/s0/local/train.sh @@ -12,12 +12,6 @@ config_path=$1 ckpt_name=$2 model_type=$3 -device=gpu -if [ ${ngpu} == 0 ];then - device=cpu -fi -echo "using ${device}..." - mkdir -p exp # seed may break model convergence @@ -27,7 +21,6 @@ if [ ${seed} != 0 ]; then fi python3 -u ${BIN_DIR}/train.py \ ---device ${device} \ --nproc ${ngpu} \ --config ${config_path} \ --output exp/${ckpt_name} \ diff --git a/examples/librispeech/s1/local/align.sh b/examples/librispeech/s1/local/align.sh index ad6c84bc8cf398cddecfadbbb47b7ef9c60e9158..279461aafe19967ac054df815b08e60e351fcc7f 100755 --- a/examples/librispeech/s1/local/align.sh +++ b/examples/librispeech/s1/local/align.sh @@ -8,10 +8,6 @@ fi ngpu=$(echo $CUDA_VISIBLE_DEVICES | awk -F "," '{print NF}') echo "using $ngpu gpus..." -device=gpu -if [ ${ngpu} == 0 ];then - device=cpu -fi config_path=$1 ckpt_prefix=$2 @@ -22,8 +18,7 @@ mkdir -p ${output_dir} # align dump in `result_file` # .tier, .TextGrid dump in `dir of result_file` python3 -u ${BIN_DIR}/alignment.py \ ---device ${device} \ ---nproc 1 \ +--nproc ${ngpu} \ --config ${config_path} \ --result_file ${output_dir}/${type}.align \ --checkpoint_path ${ckpt_prefix} \ diff --git a/examples/librispeech/s1/local/export.sh b/examples/librispeech/s1/local/export.sh index f99a15bade1c89f968e84a6c10d500466f884d5b..b562218e7a76c91d3b906d2c099218bf492627a8 100755 --- a/examples/librispeech/s1/local/export.sh +++ b/examples/librispeech/s1/local/export.sh @@ -12,13 +12,7 @@ config_path=$1 ckpt_path_prefix=$2 jit_model_export_path=$3 -device=gpu -if [ ${ngpu} == 0 ];then - device=cpu -fi - python3 -u ${BIN_DIR}/export.py \ ---device ${device} \ --nproc ${ngpu} \ --config ${config_path} \ --checkpoint_path ${ckpt_path_prefix} \ diff --git a/examples/librispeech/s1/local/test.sh b/examples/librispeech/s1/local/test.sh index 3bd3f0bba7668b4b52be17b64bbf415d6dc627a3..f7ec34ab57642b456247279984a1c761263d773a 100755 --- a/examples/librispeech/s1/local/test.sh +++ b/examples/librispeech/s1/local/test.sh @@ -8,11 +8,6 @@ fi ngpu=$(echo $CUDA_VISIBLE_DEVICES | awk -F "," '{print NF}') echo "using $ngpu gpus..." -device=gpu -if [ ${ngpu} == 0 ];then - device=cpu -fi - config_path=$1 ckpt_prefix=$2 @@ -38,8 +33,7 @@ for type in attention ctc_greedy_search; do batch_size=64 fi python3 -u ${BIN_DIR}/test.py \ - --device ${device} \ - --nproc 1 \ + --nproc ${ngpu} \ --config ${config_path} \ --result_file ${ckpt_prefix}.${type}.rsl \ --checkpoint_path ${ckpt_prefix} \ @@ -55,8 +49,7 @@ for type in ctc_prefix_beam_search attention_rescoring; do echo "decoding ${type}" batch_size=1 python3 -u ${BIN_DIR}/test.py \ - --device ${device} \ - --nproc 1 \ + --nproc ${ngpu} \ --config ${config_path} \ --result_file ${ckpt_prefix}.${type}.rsl \ --checkpoint_path ${ckpt_prefix} \ diff --git a/examples/librispeech/s1/local/train.sh b/examples/librispeech/s1/local/train.sh index f905b766ef52eb1ffcd98b9f31109ace916a5889..8f92c64694662b99a681bbf709f8da60d4e0eb0d 100755 --- a/examples/librispeech/s1/local/train.sh +++ b/examples/librispeech/s1/local/train.sh @@ -11,12 +11,6 @@ echo "using $ngpu gpus..." config_path=$1 ckpt_name=$2 -device=gpu -if [ ${ngpu} == 0 ];then - device=cpu -fi -echo "using ${device}..." - mkdir -p exp # seed may break model convergence @@ -25,8 +19,10 @@ if [ ${seed} != 0 ]; then export FLAGS_cudnn_deterministic=True fi +# export FLAGS_cudnn_exhaustive_search=true +# export FLAGS_conv_workspace_size_limit=4000 + python3 -u ${BIN_DIR}/train.py \ ---device ${device} \ --nproc ${ngpu} \ --config ${config_path} \ --output exp/${ckpt_name} \ diff --git a/examples/librispeech/s2/local/align.sh b/examples/librispeech/s2/local/align.sh index b3d8fa5f5519a00cf22b1940ab2eec110ebfb21e..b45f4a0f5c270740189b3a917b335eca7efdd164 100755 --- a/examples/librispeech/s2/local/align.sh +++ b/examples/librispeech/s2/local/align.sh @@ -8,10 +8,6 @@ fi ngpu=$(echo $CUDA_VISIBLE_DEVICES | awk -F "," '{print NF}') echo "using $ngpu gpus..." -device=gpu -if [ ${ngpu} == 0 ];then - device=cpu -fi config_path=$1 dict_path=$2 ckpt_prefix=$3 @@ -26,8 +22,7 @@ python3 -u ${BIN_DIR}/test.py \ --model-name 'u2_kaldi' \ --run-mode 'align' \ --dict-path ${dict_path} \ ---device ${device} \ ---nproc 1 \ +--nproc ${ngpu} \ --config ${config_path} \ --result-file ${output_dir}/${type}.align \ --checkpoint_path ${ckpt_prefix} \ diff --git a/examples/librispeech/s2/local/export.sh b/examples/librispeech/s2/local/export.sh index efa70a2b961b0a7b8e05b3008c82fea5ec94872d..9c66dc62aa603aee0df2d48e90c8c7fe955063c9 100755 --- a/examples/librispeech/s2/local/export.sh +++ b/examples/librispeech/s2/local/export.sh @@ -12,15 +12,9 @@ config_path=$1 ckpt_path_prefix=$2 jit_model_export_path=$3 -device=gpu -if [ ${ngpu} == 0 ];then - device=cpu -fi - python3 -u ${BIN_DIR}/test.py \ --model-name 'u2_kaldi' \ --run-mode 'export' \ ---device ${device} \ --nproc ${ngpu} \ --config ${config_path} \ --checkpoint_path ${ckpt_path_prefix} \ diff --git a/examples/librispeech/s2/local/train.sh b/examples/librispeech/s2/local/train.sh index 66754201f7bfbf6f0b99cdd13ca20617b4b1d8bd..33b46c20f1f752c158fb304ce8470e88d6d4a761 100755 --- a/examples/librispeech/s2/local/train.sh +++ b/examples/librispeech/s2/local/train.sh @@ -11,12 +11,6 @@ echo "using $ngpu gpus..." config_path=$1 ckpt_name=$2 -device=gpu -if [ ${ngpu} == 0 ];then - device=cpu -fi -echo "using ${device}..." - mkdir -p exp # seed may break model convergence @@ -27,7 +21,6 @@ fi python3 -u ${BIN_DIR}/train.py \ --model-name u2_kaldi \ ---device ${device} \ --nproc ${ngpu} \ --config ${config_path} \ --output exp/${ckpt_name} \ diff --git a/examples/ted_en_zh/t0/local/test.sh b/examples/ted_en_zh/t0/local/test.sh index 642328e88b221e6bb2b322a0696884bd478d27ff..34475085538b2b7994d9955003aed2704fbb31ca 100755 --- a/examples/ted_en_zh/t0/local/test.sh +++ b/examples/ted_en_zh/t0/local/test.sh @@ -8,10 +8,6 @@ fi ngpu=$(echo $CUDA_VISIBLE_DEVICES | awk -F "," '{print NF}') echo "using $ngpu gpus..." -device=gpu -if [ ${ngpu} == 0 ];then - device=cpu -fi config_path=$1 ckpt_prefix=$2 @@ -19,8 +15,7 @@ for type in fullsentence; do echo "decoding ${type}" batch_size=32 python3 -u ${BIN_DIR}/test.py \ - --device ${device} \ - --nproc 1 \ + --nproc ${ngpu} \ --config ${config_path} \ --result_file ${ckpt_prefix}.${type}.rsl \ --checkpoint_path ${ckpt_prefix} \ diff --git a/examples/ted_en_zh/t0/local/train.sh b/examples/ted_en_zh/t0/local/train.sh index f905b766ef52eb1ffcd98b9f31109ace916a5889..e5fd19ddb8d523acc328f13e3a05c126ae56db29 100755 --- a/examples/ted_en_zh/t0/local/train.sh +++ b/examples/ted_en_zh/t0/local/train.sh @@ -11,12 +11,6 @@ echo "using $ngpu gpus..." config_path=$1 ckpt_name=$2 -device=gpu -if [ ${ngpu} == 0 ];then - device=cpu -fi -echo "using ${device}..." - mkdir -p exp # seed may break model convergence @@ -26,7 +20,6 @@ if [ ${seed} != 0 ]; then fi python3 -u ${BIN_DIR}/train.py \ ---device ${device} \ --nproc ${ngpu} \ --config ${config_path} \ --output exp/${ckpt_name} \ diff --git a/examples/timit/s1/local/align.sh b/examples/timit/s1/local/align.sh index ad6c84bc8cf398cddecfadbbb47b7ef9c60e9158..279461aafe19967ac054df815b08e60e351fcc7f 100755 --- a/examples/timit/s1/local/align.sh +++ b/examples/timit/s1/local/align.sh @@ -8,10 +8,6 @@ fi ngpu=$(echo $CUDA_VISIBLE_DEVICES | awk -F "," '{print NF}') echo "using $ngpu gpus..." -device=gpu -if [ ${ngpu} == 0 ];then - device=cpu -fi config_path=$1 ckpt_prefix=$2 @@ -22,8 +18,7 @@ mkdir -p ${output_dir} # align dump in `result_file` # .tier, .TextGrid dump in `dir of result_file` python3 -u ${BIN_DIR}/alignment.py \ ---device ${device} \ ---nproc 1 \ +--nproc ${ngpu} \ --config ${config_path} \ --result_file ${output_dir}/${type}.align \ --checkpoint_path ${ckpt_prefix} \ diff --git a/examples/timit/s1/local/export.sh b/examples/timit/s1/local/export.sh index f99a15bade1c89f968e84a6c10d500466f884d5b..b562218e7a76c91d3b906d2c099218bf492627a8 100755 --- a/examples/timit/s1/local/export.sh +++ b/examples/timit/s1/local/export.sh @@ -12,13 +12,7 @@ config_path=$1 ckpt_path_prefix=$2 jit_model_export_path=$3 -device=gpu -if [ ${ngpu} == 0 ];then - device=cpu -fi - python3 -u ${BIN_DIR}/export.py \ ---device ${device} \ --nproc ${ngpu} \ --config ${config_path} \ --checkpoint_path ${ckpt_path_prefix} \ diff --git a/examples/timit/s1/local/test.sh b/examples/timit/s1/local/test.sh index a137924e22ac10328fb79e08536f65a9f2379418..868c8fda8073a8bb5bca49bf57930cb9274c5a1b 100755 --- a/examples/timit/s1/local/test.sh +++ b/examples/timit/s1/local/test.sh @@ -8,11 +8,6 @@ fi ngpu=$(echo $CUDA_VISIBLE_DEVICES | awk -F "," '{print NF}') echo "using $ngpu gpus..." -device=gpu -if [ ${ngpu} == 0 ];then - device=cpu -fi - config_path=$1 ckpt_prefix=$2 @@ -37,8 +32,7 @@ for type in attention ctc_greedy_search; do batch_size=64 fi python3 -u ${BIN_DIR}/test.py \ - --device ${device} \ - --nproc 1 \ + --nproc ${ngpu} \ --config ${config_path} \ --result_file ${ckpt_prefix}.${type}.rsl \ --checkpoint_path ${ckpt_prefix} \ @@ -54,8 +48,7 @@ for type in ctc_prefix_beam_search attention_rescoring; do echo "decoding ${type}" batch_size=1 python3 -u ${BIN_DIR}/test.py \ - --device ${device} \ - --nproc 1 \ + --nproc ${ngpu} \ --config ${config_path} \ --result_file ${ckpt_prefix}.${type}.rsl \ --checkpoint_path ${ckpt_prefix} \ diff --git a/examples/timit/s1/local/train.sh b/examples/timit/s1/local/train.sh index 180d8b5a7e4e38981fb3c087c6c754ebdfe14b71..89a64327c1befc875f50fed37f93b4abd021ac8e 100755 --- a/examples/timit/s1/local/train.sh +++ b/examples/timit/s1/local/train.sh @@ -11,12 +11,6 @@ echo "using $ngpu gpus..." config_path=$1 ckpt_name=$2 -device=gpu -if [ ${ngpu} == 0 ];then - device=cpu -fi -echo "using ${device}..." - mkdir -p exp # seed may break model convergence @@ -26,7 +20,6 @@ if [ ${seed} != 0 ]; then fi python3 -u ${BIN_DIR}/train.py \ ---device ${device} \ --nproc ${ngpu} \ --config ${config_path} \ --output exp/${ckpt_name} \ diff --git a/examples/tiny/s0/local/export.sh b/examples/tiny/s0/local/export.sh index 2e09e5f5e76a7f7cdf9cca8fbb91d66bb48aea0c..a5e62c28d2fa23a5ef9b9e2a0281b025aa943a30 100755 --- a/examples/tiny/s0/local/export.sh +++ b/examples/tiny/s0/local/export.sh @@ -13,13 +13,7 @@ ckpt_path_prefix=$2 jit_model_export_path=$3 model_type=$4 -device=gpu -if [ ${ngpu} == 0 ];then - device=cpu -fi - python3 -u ${BIN_DIR}/export.py \ ---device ${device} \ --nproc ${ngpu} \ --config ${config_path} \ --checkpoint_path ${ckpt_path_prefix} \ diff --git a/examples/tiny/s0/local/test.sh b/examples/tiny/s0/local/test.sh index b5b68c599c45ab50aa12ee35c120e02fb68740b4..4d00f30b852da5a370f5d4934f3caadd2b833c00 100755 --- a/examples/tiny/s0/local/test.sh +++ b/examples/tiny/s0/local/test.sh @@ -8,10 +8,6 @@ fi ngpu=$(echo $CUDA_VISIBLE_DEVICES | awk -F "," '{print NF}') echo "using $ngpu gpus..." -device=gpu -if [ ${ngpu} == 0 ];then - device=cpu -fi config_path=$1 ckpt_prefix=$2 model_type=$3 @@ -23,8 +19,7 @@ if [ $? -ne 0 ]; then fi python3 -u ${BIN_DIR}/test.py \ ---device ${device} \ ---nproc 1 \ +--nproc ${ngpu} \ --config ${config_path} \ --result_file ${ckpt_prefix}.rsl \ --checkpoint_path ${ckpt_prefix} \ diff --git a/examples/tiny/s0/local/train.sh b/examples/tiny/s0/local/train.sh index 9a76c7ade3b8d33d4c9828c29f941bdfc580814a..5b87780aebb1022e7914d6bd702faf7da7d21c14 100755 --- a/examples/tiny/s0/local/train.sh +++ b/examples/tiny/s0/local/train.sh @@ -10,17 +10,11 @@ source ${MAIN_ROOT}/utils/parse_options.sh || exit 1; ngpu=$(echo $CUDA_VISIBLE_DEVICES | awk -F "," '{print NF}') echo "using $ngpu gpus..." -device=gpu -if [ ${ngpu} == 0 ];then - device=cpu -fi - if [ ${seed} != 0 ]; then export FLAGS_cudnn_deterministic=True echo "using seed $seed & FLAGS_cudnn_deterministic=True ..." fi - if [ $# != 3 ];then echo "usage: CUDA_VISIBLE_DEVICES=0 ${0} config_path ckpt_name model_type" exit -1 @@ -33,7 +27,6 @@ model_type=$3 mkdir -p exp python3 -u ${BIN_DIR}/train.py \ ---device ${device} \ --nproc ${ngpu} \ --config ${config_path} \ --output exp/${ckpt_name} \ diff --git a/examples/tiny/s1/local/align.sh b/examples/tiny/s1/local/align.sh index ad6c84bc8cf398cddecfadbbb47b7ef9c60e9158..279461aafe19967ac054df815b08e60e351fcc7f 100755 --- a/examples/tiny/s1/local/align.sh +++ b/examples/tiny/s1/local/align.sh @@ -8,10 +8,6 @@ fi ngpu=$(echo $CUDA_VISIBLE_DEVICES | awk -F "," '{print NF}') echo "using $ngpu gpus..." -device=gpu -if [ ${ngpu} == 0 ];then - device=cpu -fi config_path=$1 ckpt_prefix=$2 @@ -22,8 +18,7 @@ mkdir -p ${output_dir} # align dump in `result_file` # .tier, .TextGrid dump in `dir of result_file` python3 -u ${BIN_DIR}/alignment.py \ ---device ${device} \ ---nproc 1 \ +--nproc ${ngpu} \ --config ${config_path} \ --result_file ${output_dir}/${type}.align \ --checkpoint_path ${ckpt_prefix} \ diff --git a/examples/tiny/s1/local/export.sh b/examples/tiny/s1/local/export.sh index f99a15bade1c89f968e84a6c10d500466f884d5b..b562218e7a76c91d3b906d2c099218bf492627a8 100755 --- a/examples/tiny/s1/local/export.sh +++ b/examples/tiny/s1/local/export.sh @@ -12,13 +12,7 @@ config_path=$1 ckpt_path_prefix=$2 jit_model_export_path=$3 -device=gpu -if [ ${ngpu} == 0 ];then - device=cpu -fi - python3 -u ${BIN_DIR}/export.py \ ---device ${device} \ --nproc ${ngpu} \ --config ${config_path} \ --checkpoint_path ${ckpt_path_prefix} \ diff --git a/examples/tiny/s1/local/test.sh b/examples/tiny/s1/local/test.sh index 4d3ed081a77e8bd93efa153818685537a66c6f11..19872bb36d4bfd0b6bcb20694a9f99715a591477 100755 --- a/examples/tiny/s1/local/test.sh +++ b/examples/tiny/s1/local/test.sh @@ -8,10 +8,6 @@ fi ngpu=$(echo $CUDA_VISIBLE_DEVICES | awk -F "," '{print NF}') echo "using $ngpu gpus..." -device=gpu -if [ ${ngpu} == 0 ];then - device=cpu -fi config_path=$1 ckpt_prefix=$2 @@ -35,8 +31,7 @@ for type in attention ctc_greedy_search; do batch_size=64 fi python3 -u ${BIN_DIR}/test.py \ - --device ${device} \ - --nproc 1 \ + --nproc ${ngpu} \ --config ${config_path} \ --result_file ${ckpt_prefix}.${type}.rsl \ --checkpoint_path ${ckpt_prefix} \ @@ -52,8 +47,7 @@ for type in ctc_prefix_beam_search attention_rescoring; do echo "decoding ${type}" batch_size=1 python3 -u ${BIN_DIR}/test.py \ - --device ${device} \ - --nproc 1 \ + --nproc ${ngpu} \ --config ${config_path} \ --result_file ${ckpt_prefix}.${type}.rsl \ --checkpoint_path ${ckpt_prefix} \ diff --git a/examples/tiny/s1/local/train.sh b/examples/tiny/s1/local/train.sh index 5097d4d030cab74fe5c3d52b223eddd1c27ea68d..71af3a006deec9032fcefd561fc46cea274d1e10 100755 --- a/examples/tiny/s1/local/train.sh +++ b/examples/tiny/s1/local/train.sh @@ -12,11 +12,6 @@ source ${MAIN_ROOT}/utils/parse_options.sh || exit 1; ngpu=$(echo $CUDA_VISIBLE_DEVICES | awk -F "," '{print NF}') echo "using $ngpu gpus..." -device=gpu -if [ ${ngpu} == 0 ];then - device=cpu -fi - if [ ${seed} != 0 ]; then export FLAGS_cudnn_deterministic=True echo "using seed $seed & FLAGS_cudnn_deterministic=True ..." @@ -34,7 +29,6 @@ mkdir -p exp python3 -u ${BIN_DIR}/train.py \ --seed ${seed} \ ---device ${device} \ --nproc ${ngpu} \ --config ${config_path} \ --output exp/${ckpt_name} \ diff --git a/examples/v18_to_v2x/deepspeech2x/model.py b/examples/v18_to_v2x/deepspeech2x/model.py index 1fe1e2d682644580f2e61ca66db64282923989cf..cbbc502d2e8e29479b091afb7a3a02fe9c2c85b1 100644 --- a/examples/v18_to_v2x/deepspeech2x/model.py +++ b/examples/v18_to_v2x/deepspeech2x/model.py @@ -401,7 +401,7 @@ class DeepSpeech2Tester(DeepSpeech2Trainer): def setup(self): """Setup the experiment. """ - paddle.set_device(self.args.device) + paddle.set_device('gpu' if self.args.nprocs > 0 else 'cpu') self.setup_output_dir() self.setup_checkpointer() diff --git a/examples/v18_to_v2x/exp_aishell/local/test.sh b/examples/v18_to_v2x/exp_aishell/local/test.sh index 9fd0bc8d5bcdded1d33990a8ae20101d0a538441..2ae0740b3e8d44ab03e45f4c1b5dbb945657705e 100755 --- a/examples/v18_to_v2x/exp_aishell/local/test.sh +++ b/examples/v18_to_v2x/exp_aishell/local/test.sh @@ -8,10 +8,6 @@ fi ngpu=$(echo $CUDA_VISIBLE_DEVICES | awk -F "," '{print NF}') echo "using $ngpu gpus..." -device=gpu -if [ ${ngpu} == 0 ];then - device=cpu -fi config_path=$1 ckpt_prefix=$2 model_type=$3 @@ -23,8 +19,7 @@ if [ $? -ne 0 ]; then fi python3 -u ${BIN_DIR}/test.py \ ---device ${device} \ ---nproc 1 \ +--nproc ${ngpu} \ --config ${config_path} \ --result_file ${ckpt_prefix}.rsl \ --checkpoint_path ${ckpt_prefix} \ diff --git a/examples/v18_to_v2x/exp_baidu_en8k/local/test.sh b/examples/v18_to_v2x/exp_baidu_en8k/local/test.sh index b5b68c599c45ab50aa12ee35c120e02fb68740b4..4d00f30b852da5a370f5d4934f3caadd2b833c00 100755 --- a/examples/v18_to_v2x/exp_baidu_en8k/local/test.sh +++ b/examples/v18_to_v2x/exp_baidu_en8k/local/test.sh @@ -8,10 +8,6 @@ fi ngpu=$(echo $CUDA_VISIBLE_DEVICES | awk -F "," '{print NF}') echo "using $ngpu gpus..." -device=gpu -if [ ${ngpu} == 0 ];then - device=cpu -fi config_path=$1 ckpt_prefix=$2 model_type=$3 @@ -23,8 +19,7 @@ if [ $? -ne 0 ]; then fi python3 -u ${BIN_DIR}/test.py \ ---device ${device} \ ---nproc 1 \ +--nproc ${ngpu} \ --config ${config_path} \ --result_file ${ckpt_prefix}.rsl \ --checkpoint_path ${ckpt_prefix} \ diff --git a/examples/v18_to_v2x/exp_librispeech/local/test.sh b/examples/v18_to_v2x/exp_librispeech/local/test.sh index b5b68c599c45ab50aa12ee35c120e02fb68740b4..4d00f30b852da5a370f5d4934f3caadd2b833c00 100755 --- a/examples/v18_to_v2x/exp_librispeech/local/test.sh +++ b/examples/v18_to_v2x/exp_librispeech/local/test.sh @@ -8,10 +8,6 @@ fi ngpu=$(echo $CUDA_VISIBLE_DEVICES | awk -F "," '{print NF}') echo "using $ngpu gpus..." -device=gpu -if [ ${ngpu} == 0 ];then - device=cpu -fi config_path=$1 ckpt_prefix=$2 model_type=$3 @@ -23,8 +19,7 @@ if [ $? -ne 0 ]; then fi python3 -u ${BIN_DIR}/test.py \ ---device ${device} \ ---nproc 1 \ +--nproc ${ngpu} \ --config ${config_path} \ --result_file ${ckpt_prefix}.rsl \ --checkpoint_path ${ckpt_prefix} \ diff --git a/tests/chains/ds2_params_lite_train_infer.txt b/tests/chains/ds2_params_lite_train_infer.txt index 82a9da9a98361ac868fc573e9230c0c7c1e01ca6..47f7db95b15f3a741b7b0ed56ca8ceb016258983 100644 --- a/tests/chains/ds2_params_lite_train_infer.txt +++ b/tests/chains/ds2_params_lite_train_infer.txt @@ -13,7 +13,7 @@ null:null null:null ## trainer:norm_train -norm_train: ../../../deepspeech/exps/deepspeech2/bin/train.py --nproc 1 --config conf/deepspeech2.yaml --model_type offline --device gpu +norm_train: ../../../deepspeech/exps/deepspeech2/bin/train.py --nproc 1 --config conf/deepspeech2.yaml --model_type offline pact_train:null fpgm_train:null distill_train:null @@ -21,7 +21,7 @@ null:null null:null ## ===========================eval_params=========================== -eval: ../../../deepspeech/exps/deepspeech2/bin/test.py --nproc 1 --config conf/deepspeech2.yaml --result_file tests/9.rsl --model_type offline --device gpu +eval: ../../../deepspeech/exps/deepspeech2/bin/test.py --nproc 1 --config conf/deepspeech2.yaml --result_file tests/9.rsl --model_type offline null:null ## ===========================infer_params===========================