Fastaiimports


(Akash Bhadauria) #1



While executing the command from fastai.imports import * in colab, I am getting the error cannot import name as_tensor(image is attached)

Can anyone help me to resolve this?


(Kevin Bird) #2

I’m not 100% how colab works but that may be because it isn’t the most updated version of Torch. Is there a way to specify you want to use the nightly build of Torch? Unless you are trying to use the older version of fastai in which case, check this out and see if it helps you: ImportError: cannot import name ‘as_tensor’?


(Dana Ludwig) #3

I had this same problem: 'cannot import name ‘as_tensor’. Here is my reasoning that led to the fix:

  • as_tensor is missing from torch (pytorch)
  • maybe I don’t have the latest v1 of pytorch even though I followed the install instructions for the 2019 course. This is likely because I used the same machine to do the 2018 course, before pytorch v1 existed.
  • from within my new conda environment, I run: $ conda list pytorch
    and get response “pytorch 0.3.1”
  • $ conda install -c pytorch pytorch=1.0
    This solved the problem