Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Fix GPU flag handling in tts.sh script#6226

Merged
sw005320 merged 3 commits intoespnet:masterfrom
ZhuoyanTao:terry/fix-versa-use-gpu-flag
Aug 29, 2025
Merged

Fix GPU flag handling in tts.sh script#6226
sw005320 merged 3 commits intoespnet:masterfrom
ZhuoyanTao:terry/fix-versa-use-gpu-flag

Conversation

@ZhuoyanTao
Copy link
Contributor

What did you change?


Fix the bug that makes versa always use gpu even when gpu_inference is False

Why did you make this change?


Previously, the code used --use_gpu False to tell Versa Scorer not to use a GPU. However, versa reads the existence of this option as True, leading to exception when the node doesn't have gpu.

Is your PR small enough?


Additional Context

@dosubot dosubot bot added size:S This PR changes 10-29 lines, ignoring generated files. Bug bug should be fixed labels Aug 28, 2025
@mergify mergify bot added the ESPnet2 label Aug 28, 2025
Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request correctly fixes an issue where the --use_gpu flag was being passed incorrectly to the versa.bin.scorer script, causing it to always attempt to use a GPU. The change ensures the flag is only present when gpu_inference is true. Additionally, a redundant --gt argument is removed, which is also a good fix. I have one suggestion to refactor the new logic to avoid code duplication and improve maintainability.

Comment on lines +1163 to +1167
if ${gpu_inference}; then
use_gpu_flag="--use_gpu"
else
use_gpu_flag=""
fi
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

This if block is redundant as you are checking for ${gpu_inference} again, right after a similar check in lines 1155-1161. To improve maintainability and avoid duplicated logic, you can merge this into the existing if block.

This would involve removing lines 1163-1167 and modifying lines 1155-1161 to look like this:

        if ${gpu_inference}; then
            _cmd="${cuda_cmd}"
            _ngpu=1
            use_gpu_flag="--use_gpu"
        else
            _cmd="${decode_cmd}"
            _ngpu=0
            use_gpu_flag=""
        fi

This makes the logic for GPU-related setup reside in a single place, making it easier to maintain.

@codecov
Copy link

codecov bot commented Aug 28, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 55.82%. Comparing base (412aa11) to head (82137fa).
⚠️ Report is 313 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff             @@
##           master    #6226       +/-   ##
===========================================
+ Coverage   20.63%   55.82%   +35.19%     
===========================================
  Files          95      884      +789     
  Lines       10347    84007    +73660     
===========================================
+ Hits         2135    46900    +44765     
- Misses       8212    37107    +28895     
Flag Coverage Δ
test_integration_espnet2 46.16% <ø> (?)
test_integration_espnetez 36.94% <ø> (?)
test_python_espnet2 50.51% <ø> (?)
test_python_espnetez 12.83% <ø> (?)
test_utils 18.77% <ø> (-1.87%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Removed redundant if blocks for use_gpu_flag assignment in tts.sh.
@dosubot dosubot bot added size:XS This PR changes 0-9 lines, ignoring generated files. and removed size:S This PR changes 10-29 lines, ignoring generated files. labels Aug 28, 2025
@Fhrozen Fhrozen added this to the v.202509 milestone Aug 28, 2025
@sw005320 sw005320 requested a review from ftshijt August 28, 2025 09:45
@sw005320
Copy link
Contributor

@ftshijt, please check it

@ftshijt
Copy link
Collaborator

ftshijt commented Aug 28, 2025

Many thanks for catching the bug. I'm good with the usegpu, but not pretty sure for the reason of removing the gt_files for the evaluation, as some metrics will be not available if that is removed. Could you please share your rationale to that?

@ZhuoyanTao
Copy link
Contributor Author

Many thanks for catching the bug. I'm good with the usegpu, but not pretty sure for the reason of removing the gt_files for the evaluation, as some metrics will be not available if that is removed. Could you please share your rationale to that?

Sorry the deletion was by accident. I've added it back. Thanks for catching that!

@sw005320 sw005320 merged commit 9679cbd into espnet:master Aug 29, 2025
32 checks passed
@sw005320
Copy link
Contributor

Thanks!

@Fhrozen Fhrozen mentioned this pull request Sep 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug bug should be fixed ESPnet2 size:XS This PR changes 0-9 lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants