Sein-Kim / Gaudi-Git

0 stars 1 forks source link

RuntimeError: Output 0 of torch::autograd::CppNode<DropoutFunction> is a view and is being modified inplace. #1

Closed Sein-Kim closed 2 months ago

Sein-Kim commented 2 months ago

Error Message (at Commit Version: Hash)


RuntimeError: Output 0 of torch::autograd::CppNode is a view and is being modified inplace. This view was created inside a custom Function (or because an input was returned as-is) and the autograd logic to handle view+inplace would override the custom backward associated with the custom Function, leading to incorrect gradients. This behavior is forbidden. You can fix this by cloning the output of the custom Function.

The error message occurs when performing evaluations (validations or tests) after training the models.

Sein-Kim commented 2 months ago

We added torch.no_grad() to fix the error.

Original Version:

t_test = evaluate(model, dataset, args)
t_valid = evaluate_valid(model, dataset, args)

Modified Version - main.py:

with torch.no_grad():
    t_test = evaluate(model, dataset, args)
    t_valid = evaluate_valid(model, dataset, args)
Sein-Kim commented 2 months ago

Fixed