FastAI library v1 with Google Colab FastAI library v1 with Google Colab python-3.x python-3.x

FastAI library v1 with Google Colab


You are using previous version of torch torch-0.3.0.post4 which didn't have as_tensor.

So you can use other version of torch like torch-0.4.1 which have this method.

After running following snippet:

!pip3 install fastai!apt-get -qq install -y libsm6 libxext6 && pip install -q -U opencv-pythonimport cv2from os import pathfrom wheel.pep425tags import get_abbr_impl, get_impl_ver, get_abi_tagplatform = '{}{}-{}'.format(get_abbr_impl(), get_impl_ver(), get_abi_tag())accelerator = 'cu80' if path.exists('/opt/bin/nvidia-smi') else 'cpu'# !pip install -q http://download.pytorch.org/whl/{accelerator}/torch-0.3.0.post4-{platform}-linux_x86_64.whl torchvision!pip3 install http://download.pytorch.org/whl/cpu/torch-0.4.1-cp36-cp36m-linux_x86_64.whlimport torch!pip install Pillow==4.1.1!pip install image%matplotlib inline

You can use :

from fastai.imports import *


from os import pathfrom wheel.pep425tags import get_abbr_impl, get_impl_ver, get_abi_tagplatform = '{}{}-{}'.format(get_abbr_impl(), get_impl_ver(), get_abi_tag())accelerator = 'cu80' if path.exists('/opt/bin/nvidia-smi') else 'cpu'!pip3 install torch_nightly -f https://download.pytorch.org/whl/nightly/{accelerator}/torch_nightly.htmlimport torchprint(torch.__version__)print(torch.cuda.is_available())print(torch.backends.cudnn.enabled)

If this part is okay, as of today you should see the following output:

1.0.0.dev20181019TrueTrue

Then move on to installing the latest release of fastai:

!pip3 install fastai

and test with:

from fastai.imports import *


I was missing dependencies. I have made an awkward workaround that installs the previous version of the library (with dependancies), then uninstalls the library and replaces it with the updated version.

Code as follows.

!pip install "fastai==0.7.0"!pip uninstall "fastai==0.7.0"!pip install fastai !apt-get -qq install -y libsm6 libxext6 && pip install -q -U opencv-pythonimport cv2from os import pathfrom wheel.pep425tags import get_abbr_impl, get_impl_ver, get_abi_tagplatform = '{}{}-{}'.format(get_abbr_impl(), get_impl_ver(), get_abi_tag())!apt update && apt install -y libsm6 libxext6accelerator = 'cu80' if path.exists('/opt/bin/nvidia-smi') else 'cpu'!pip install -q http://download.pytorch.org/whl/{accelerator}/torch-0.3.0.post4- {platform}-linux_x86_64.whl torchvisionimport torch!pip install Pillow==4.1.1!pip install image%matplotlib inlinefrom fastai.imports import *