Skip to content

torch.set_grad_enabled fails to work in test_step #15326

Discussion options

You must be logged in to vote

@bennyguo It may be related to #14497. With Lightning 1.8 release, you will be able to disable PyTorch's inference mode (which is enabled by Lightning by default):

# default used by the Trainer
trainer = Trainer(inference_mode=True)

# Use `torch.no_grad` instead
trainer = Trainer(inference_mode=False)

Replies: 2 comments 2 replies

Comment options

You must be logged in to vote
2 replies
@akihironitta
Comment options

@bennyguo
Comment options

Answer selected by bennyguo
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment