AttributeError: type object 'Tensor' has no attribute 'as_subclass'

I am posting here because, even though the answer can be found on the forums, it took me several hours to muddle through to a solution.


  1. Update PyTorch to v 1.6+ from the PyTorch website
  2. Restart Linux (otherwise the import hangs)

It could be helpful to non-expert users if fastai would detect the problem and print the solution.


fastai’s requirements are all torch >= 1.7, so when installing the library when done correctly this shouldn’t happen… (as a result torch < 1.6 is outright not supported anymore)

I copied someone else’s code and used

git a fastai directory
git pull
pip install -e .

and it turned out this way. But honestly I do not understand much about how git and pip work.