Your code snippet works fine if I add loss.backward(), so I guess you might be trying to call .backward() on another (detached) tensor?
Could you compare the posted code snippet and update it to reproduce this error, please?
tts_model, tts_decoder, _ = torch.hub.load(repo_or_dir='snakers4/silero-models',
model='silero_stt',
language='en', # also available 'de', 'es'
device=device)
When I restart the kernel and run the example provided with this line of code the problem occurs.
To reproduce the error try to put this line before your model initialization.
Does the newly posted line of code raise this error or do you see the failure in the previously posted model, if the silero_stt model is just loaded before?
the error raises when I call loss.backward() function. But it raises only when silero_stt model is loaded before. I tried to load both GPU and CPU versions.
I can reproduce the issue, which is raised by disabling the gradient calculation globally by the silero-models creation in this line of code.
I don’t know, why it’s disabling the gradient calculation, but you can enable it again via: