Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix device setting to allow using accelerator cpu #8084

Merged
merged 3 commits into from
Dec 31, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions nemo/collections/asr/modules/wav2vec_modules.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@
from nemo.core.classes.module import NeuralModule
from nemo.core.neural_types import AcousticEncodedRepresentation, AudioSignal, LengthsType, NeuralType, SpectrogramType

DEVICE = torch.device("cuda" if torch.cuda.is_available() else "cpu")


class TransposeLast(torch.nn.Module):
"""
Expand Down Expand Up @@ -341,7 +339,7 @@ def apply_transformer(self, x, padding_mask=None):
def create_padding_mask(self, length):
# Broadcast to vectorize creating the padding mask
max_len = max(length)
padding_mask = torch.arange(max_len, device=DEVICE)
padding_mask = torch.arange(max_len, device=length.device)

# Switch to binary for transformer, 1 for valid tokens, 0 for padding
padding_mask = (padding_mask.expand(len(length), max_len) < length.unsqueeze(1)).type(torch.uint8)
Expand Down
Loading