Fix GPU flag handling in tts.sh script#6226
Conversation
There was a problem hiding this comment.
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.
egs2/TEMPLATE/tts1/tts.sh
Outdated
| if ${gpu_inference}; then | ||
| use_gpu_flag="--use_gpu" | ||
| else | ||
| use_gpu_flag="" | ||
| fi |
There was a problem hiding this comment.
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=""
fiThis makes the logic for GPU-related setup reside in a single place, making it easier to maintain.
Codecov Report✅ All modified and coverable lines are covered by tests. 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
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Removed redundant if blocks for use_gpu_flag assignment in tts.sh.
|
@ftshijt, please check it |
|
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! |
|
Thanks! |
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