From 331acdb7f8d42850a4e5c5886c9135611e4e6621 Mon Sep 17 00:00:00 2001 From: Mirco Ravanelli Date: Mon, 14 Aug 2023 20:06:43 +0000 Subject: [PATCH 1/4] add notes on tests with non-default gpu --- tests/recipes/README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/recipes/README.md b/tests/recipes/README.md index e255c79394..e39df8e2ca 100644 --- a/tests/recipes/README.md +++ b/tests/recipes/README.md @@ -16,6 +16,18 @@ If you like to test for all recipes belonging to one dataset: python -c 'from tests.utils.recipe_tests import run_recipe_tests; print("TEST FAILED!") if not(run_recipe_tests(filters_fields=["Dataset"], filters=[["CommonLanguage", "LibriSpeech"]], do_checks=False, run_opts="--device=cuda")) else print("TEST PASSED")' ``` +You can run the recipe on the CPU just by setting the run_opts properly: +``` +python -c 'from tests.utils.recipe_tests import run_recipe_tests; print("TEST FAILED!") if not(run_recipe_tests(filters_fields=["Dataset"], filters=[["CommonLanguage", "LibriSpeech"]], do_checks=False, run_opts="--device=cpu")) else print("TEST PASSED")' +``` + +In some cases, you might want to test the recipe on a non-default GPU (e.g, cuda:1). Thia helps detecting issues in recipes where the device was hard-coded. You can do that simply with: + +``` +python -c 'from tests.utils.recipe_tests import run_recipe_tests; print("TEST FAILED!") if not(run_recipe_tests(filters_fields=["Dataset"], filters=[["CommonLanguage", "LibriSpeech"]], do_checks=False, run_opts="--device=cuda:0")) else print("TEST PASSED")' +``` + + To target a specific recipe (here by its hparam yaml): ``` python -c 'from tests.utils.recipe_tests import run_recipe_tests; print("TEST FAILED!") if not(run_recipe_tests(filters_fields=["Hparam_file"], filters=[["recipes/TIMIT/ASR/transducer/hparams/train_wav2vec.yaml"]], do_checks=False, run_opts="--device=cuda")) else print("TEST PASSED")' From 091b3ce8c96583881b0dd40d1b823be4da2a18d0 Mon Sep 17 00:00:00 2001 From: Mirco Ravanelli Date: Mon, 14 Aug 2023 20:07:00 +0000 Subject: [PATCH 2/4] fixed hard-coded device --- recipes/SLURP/direct/hparams/train.yaml | 4 +--- recipes/SLURP/direct/train.py | 8 ++++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/recipes/SLURP/direct/hparams/train.yaml b/recipes/SLURP/direct/hparams/train.yaml index 004e2fde28..90ea7e8322 100644 --- a/recipes/SLURP/direct/hparams/train.yaml +++ b/recipes/SLURP/direct/hparams/train.yaml @@ -60,9 +60,7 @@ epoch_counter: !new:speechbrain.utils.epoch_loop.EpochCounter limit: !ref # Models -asr_model: !apply:speechbrain.pretrained.EncoderDecoderASR.from_hparams - source: speechbrain/asr-crdnn-rnnlm-librispeech - run_opts: {"device":"cuda:0"} +asr_model_source: speechbrain/asr-crdnn-rnnlm-librispeech slu_enc: !new:speechbrain.nnet.containers.Sequential input_shape: [null, null, !ref ] diff --git a/recipes/SLURP/direct/train.py b/recipes/SLURP/direct/train.py index ad73bc1fef..a4ccbfcd3a 100644 --- a/recipes/SLURP/direct/train.py +++ b/recipes/SLURP/direct/train.py @@ -340,6 +340,14 @@ def text_pipeline(semantics): run_on_main(hparams["pretrainer"].collect_files) hparams["pretrainer"].load_collected(device=run_opts["device"]) + # Download pretrained ASR model + from speechbrain.pretrained import EncoderDecoderASR + + hparams["asr_model"] = EncoderDecoderASR.from_hparams( + source=hparams["asr_model_source"], + run_opts={"device": run_opts["device"]}, + ) + # Brain class initialization slu_brain = SLU( modules=hparams["modules"], From cc72c9eb1a35f6b9836f7e814e9a33cfe3e301b8 Mon Sep 17 00:00:00 2001 From: Mirco Ravanelli Date: Mon, 14 Aug 2023 20:07:46 +0000 Subject: [PATCH 3/4] fixed hard-coded device --- recipes/fluent-speech-commands/direct/hparams/train.yaml | 4 +--- recipes/fluent-speech-commands/direct/train.py | 8 ++++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/recipes/fluent-speech-commands/direct/hparams/train.yaml b/recipes/fluent-speech-commands/direct/hparams/train.yaml index 61e57782a1..838d955e67 100644 --- a/recipes/fluent-speech-commands/direct/hparams/train.yaml +++ b/recipes/fluent-speech-commands/direct/hparams/train.yaml @@ -56,9 +56,7 @@ epoch_counter: !new:speechbrain.utils.epoch_loop.EpochCounter limit: !ref # Models -asr_model: !apply:speechbrain.pretrained.EncoderDecoderASR.from_hparams - source: speechbrain/asr-crdnn-rnnlm-librispeech - run_opts: {"device":"cuda:0"} +asr_model_source: speechbrain/asr-crdnn-rnnlm-librispeech slu_enc: !new:speechbrain.nnet.containers.Sequential input_shape: [null, null, !ref ] diff --git a/recipes/fluent-speech-commands/direct/train.py b/recipes/fluent-speech-commands/direct/train.py index 61271635fd..f4a0d9553c 100644 --- a/recipes/fluent-speech-commands/direct/train.py +++ b/recipes/fluent-speech-commands/direct/train.py @@ -322,6 +322,14 @@ def text_pipeline(semantics): run_on_main(hparams["pretrainer"].collect_files) hparams["pretrainer"].load_collected(device=run_opts["device"]) + # Download pretrained ASR model + from speechbrain.pretrained import EncoderDecoderASR + + hparams["asr_model"] = EncoderDecoderASR.from_hparams( + source=hparams["asr_model_source"], + run_opts={"device": run_opts["device"]}, + ) + # Brain class initialization slu_brain = SLU( modules=hparams["modules"], From c60e606c4aab205e9cd85c034df21b41698f07ff Mon Sep 17 00:00:00 2001 From: Mirco Ravanelli Date: Mon, 14 Aug 2023 20:07:53 +0000 Subject: [PATCH 4/4] fixed hard-coded device --- recipes/timers-and-such/direct/hparams/train.yaml | 4 +--- recipes/timers-and-such/direct/train.py | 8 ++++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/recipes/timers-and-such/direct/hparams/train.yaml b/recipes/timers-and-such/direct/hparams/train.yaml index f9edc3d789..102afec5b5 100644 --- a/recipes/timers-and-such/direct/hparams/train.yaml +++ b/recipes/timers-and-such/direct/hparams/train.yaml @@ -66,9 +66,7 @@ epoch_counter: !new:speechbrain.utils.epoch_loop.EpochCounter limit: !ref # Models -asr_model: !apply:speechbrain.pretrained.EncoderDecoderASR.from_hparams - source: speechbrain/asr-crdnn-rnnlm-librispeech - run_opts: {"device":"cuda:0"} +asr_model_source: speechbrain/asr-crdnn-rnnlm-librispeech slu_enc: !new:speechbrain.nnet.containers.Sequential input_shape: [null, null, !ref ] diff --git a/recipes/timers-and-such/direct/train.py b/recipes/timers-and-such/direct/train.py index d7dd5edd2e..894423713c 100644 --- a/recipes/timers-and-such/direct/train.py +++ b/recipes/timers-and-such/direct/train.py @@ -344,6 +344,14 @@ def text_pipeline(semantics): run_on_main(hparams["pretrainer"].collect_files) hparams["pretrainer"].load_collected(device=run_opts["device"]) + # Download pretrained ASR model + from speechbrain.pretrained import EncoderDecoderASR + + hparams["asr_model"] = EncoderDecoderASR.from_hparams( + source=hparams["asr_model_source"], + run_opts={"device": run_opts["device"]}, + ) + # Brain class initialization slu_brain = SLU( modules=hparams["modules"],