Skip to content

Commit

Permalink
Fix crash in CPU mode.
Browse files Browse the repository at this point in the history
Signed-off-by: Daniel Galvez <[email protected]>
  • Loading branch information
galv committed Apr 29, 2024
1 parent e64f9bb commit f2debc1
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions nemo/collections/asr/parts/preprocessing/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,12 @@ def normalize_batch(x, seq_len, normalize_type):
batch_size = x.shape[0]
max_time = x.shape[2]

# When doing stream capture to a graph, item() is not allowed becuase it calls cudaStreamSynchronize()
if not torch.cuda.is_current_stream_capturing() and torch.any(seq_len == 1).item():
# When doing stream capture to a graph, item() is not allowed
# becuase it calls cudaStreamSynchronize(). Therefore, we are
# sacrificing some error checking when running with cuda graphs.
if (torch.cuda.is_available()
and not torch.cuda.is_current_stream_capturing()
and torch.any(seq_len == 1).item()):
raise ValueError(
"normalize_batch with `per_feature` normalize_type received a tensor of length 1. This will result "
"in torch.std() returning nan. Make sure your audio length has enough samples for a single "
Expand Down

0 comments on commit f2debc1

Please sign in to comment.