Can't use no_grad from fastai

Hello! I am getting this error when running pytroch inside fastai (after calling conda activate fastai): module 'torch' has no attribute 'no_grad'. If I run this before calling conda activate fastai, it works fine. I tried, after calling conda activate fastai, to run conda update pytorch torchvision, but I am getting this error:

PackageNotInstalledError: Package is not installed in prefix.
prefix: /om2/user/sudrescu/miniconda3/envs/fastai
package name: torchvision

What should I do?

Works fine for me:
image

Check that conda hasn’t done something weird with your pytorch version, it can sometimes be a bit wacky in it’s package selection, choosing to downgrade all your packages because of dependency stuff.
Also, conda update pytorch torchvision (or similar with install) will use the anaconda versions of pytorch, not the ones from pytorch. These are fairly new and I haven’t used them so not sure about compatibility. To use the pytorch ones you should do conda update -c pytorch pytorch torchvision, the -c pytorch uses the pytorch package channel.
You can also add the channel to your configuration files with conda config --prepend channels pytorch to make it a higher-priority channel for all environments or conda config --env --prepend channels pytorch to add it only for the currently activated environment (it only contains pytorch packages so not likely to be an issue globally, for other channels you may not want them globally).