diff --git a/beginner_source/introyt/autogradyt_tutorial.py b/beginner_source/introyt/autogradyt_tutorial.py index 6320af08672..304890ccce0 100644 --- a/beginner_source/introyt/autogradyt_tutorial.py +++ b/beginner_source/introyt/autogradyt_tutorial.py @@ -490,7 +490,7 @@ def add_tensors2(x, y): y = torch.rand(2, 3, requires_grad=True) z = torch.ones(2, 3, requires_grad=True) -with torch.autograd.profiler.profile(use_cuda=run_on_gpu) as prf: +with torch.autograd.profiler.profile(use_device="cuda" if run_on_gpu else None) as prf: for _ in range(1000): z = (z / x) * y