Solved by ptrblck in post #2 
              
              
                Are you using different PyTorch versions in Colab and on your local machine? 
If so, I guess your local installation might be older so could you update it?