You could try to use os.environ to set this env var at the beginning of the notebook.
Note, that you would have to set it before importing PyTorch, as it won’t have any effect otherwise.
Alternatively you could export the notebook as a Python script and run it in the terminal, which should work as well.