Untar_data not working: need to import from fastai

I just pulled the latest course repo plus fastai library and noticed untar_data is not working. Seeing a NameError:


I was able to fix this by adding a top level import from fastai:
from fastai import *

@sgugger @jeremy - IIRC this line was present in the earlier notebooks. Was it removed intentionally? If not, would you like me to add it back in and create a pull request? (hopefully i can figure out how to without breaking anything else!). Thanks.


Ok, looking at checkin history it appears to be an intentional change. What am I missing then? Why didn’t it work for me?

1 Like

from fastai.vision import * should be all you need. Have you run that? Is it missing in the notebook? If so, which one is it?

If from fastai.vision import * isn’t fixing it for you, then you don’t have the latest conda. Do a search of the forum or docs to see how to check.

Have checked multiple times (conda version 4.6, conda update conda issued, pulled fastai library to the latest) this strange problem persists for me.

from fastai.vision.import * isn’t getting untar_data causing NameError.
Only from fastai import * is fixing it, getting it & many others (like np etc) in the namespace.
This indeed is weird.

1 Like

Likewise. Just to be sure I did a conda update conda again after which ssh kept failing. Turns out conda update messed up my jupyter installation (known issue)! So I installed jupyter and the conda kernels manually and tried again. Then realised it also wiped out my pytorch installation. :woman_facepalming: :sob:

Going to create a new GCP instance and try afresh and report back later today.

@maya - with a brand new GCP instance things are working fine for me (as Jeremy indicated, with fastai.vision import alone). Note that I did not have to update conda or install/update fastai libraries - this is what I got as-is with the new instance:

jupyter@fastai-instance-nb2019:~$ conda --version
conda 4.5.12
jupyter@fastai-instance-nb2019:~$ conda list
# packages in environment at /opt/anaconda3:
# Name                    Version                   Build  Channel
fastai                    1.0.40                        1    fastai
jupyter                   1.0.0                    py37_7  
jupyter-contrib-core      0.3.3                     <pip>
jupyter-contrib-nbextensions 0.5.1                     <pip>
jupyter-highlight-selected-word 0.2.0                     <pip>
jupyter-http-over-ws      0.0.2                     <pip>
jupyter-latex-envs        1.4.6                     <pip>
jupyter-nbextensions-configurator 0.4.1                     <pip>
jupyter_client            5.2.3                    py37_0  
jupyter_console           5.2.0                    py37_1  
jupyter_core              4.4.0                    py37_0  
jupyterlab                0.34.9                   py37_0  
jupyterlab                0.35.4                    <pip>
jupyterlab-git            0.5.0                     <pip>
jupyterlab-server         0.2.0                     <pip>
jupyterlab_launcher       0.13.1                   py37_0  
python                    3.7.2                h0371630_0  
pytorch                   1.0.0           py3.7_cuda10.0.130_cudnn7.4.1_1  [cuda100]  pytorch

My conda version on the earlier instance is actually higher:

jupyter@fastai-instance-nb:~$ conda --version
conda 4.6.1

Now I need to decide if I should try to debug my older instance and get it to this state, or abandon it and move my config/setup to this new one. Sigh.

1 Like

Thanks @nbharatula
As I’m installing it on a local machine with GPU I wanted to get this working.
And this got it to work:

conda update conda -y --all
pip install fastai --upgrade

conda update -c fastai fastai failed to provide the necessary updates I think which is odd. But the above (pip update) resulted in fixing the issue.

To note, this issue is addressed in the forum FAQ for this version v3 (2019). Good! Thanks, Jerome.


Yes! This worked for me!

Hi, I have setup a new instance in crestle.ai and I’m experiencing the same issue with the untar_data function not found.

The version of conda after executing conda update conda is 4.2.6 and the installed version after running conda install -c fastai fastai is 1.0.34.

Running conda update fastai doesn’t upgrade the version of fastai so I guess conda version of fastai is not up to date. I can confirm however that the pip install fastai --upgrade resolved the issue by upgrading fastai to 1.0.42 version.


This is weird. I have my own local linux box that I used to do the 2018 course, so it has a bunch of fasta v0.7 stuff. I did Maya’s two lines of code and it did seem to work but my pytorch version disappeared!

$ conda list pytorch // showed nothing

I fixed the situation successfully with:

$ conda install -c pytorch pytorch=1.0

Now all is well

For the peeps that are having issues with running untar_data(), I found out that I have to import the fastai library as a whole to make it work - from fastai import *.

That doesn’t work for me. Anything else?

1 Like

@danaludwig - conda update wiping out jupyter and pytorch is a known issue. :woman_shrugging:

@francislata - as jeremy said earlier in this thread, this should not be required. it does fix the issue, but not the intended behavior.

@Cats - can you check your conda version and that of the other packages esp fastai? I’m assuming you used conda to install fastai.

This worked for me as well. I had just recently built the environment and installed fastai and pytorch so I assumed I was at the latest version. FYI: I do need to add that I was confused about the NVIDIA GPU issue. I’m on a MacBook Pro 2017 Mojave. So, it maybe possible I followed the wrong installation path. Anyways I did the upgrade and restarted the kernel

I had the same issue, adding the from fastai import * fixed it for me, thanks. I have had to juggle a few version changes just to get things working due to an intel mkl error, which ended up requiring an mkl downgrade to fix. Everything is working now except matplotlib, which is sufficient progress for tonight’s troubleshooting :frowning:

Edit: Gah, I pushed it and tried to update fastai, as in the first post in the FAQ. That promptly broke mkl_intel_thread.dll again with the “ordinal 242” error.

It turned out I needed to follow this post and add the indicated line to my system variables to finally resolve the MKL errors. In case anyone else runs across something similar.

Same issue, non of the fixes worked, I have:

  • fastai 1.0.51
  • conda 4.6.9
  • pytorch 1.0

Conda installed max 1.0.38 I used pip to get 1.0.51, neither works

Funny thing is, I got it to work once, but when I copied lesson1 to make my own dataset, the “NameError: name ‘untar_data’ is not defined” came back on both notebooks

Check to see which version of fastai your python kernel is using:
in jupyter:
"import fastai; fastai. _ _ version_ _ [no spaces for underscores; post formatting workaroud]
in terminal (of your deeplearning environment):

python [opens up python command line]
import fastai; fastai. _ _ version _ _

if untar_data() is not working you haven’t got an updated version. Another way to see this is use the following command and scroll to fastai row: >conda list

pip install wasn’t able able to update the package for me either; I think conda overrides it.

The following line got me running (on GCP):

conda update conda
conda install fastai -c fastai -c pytorch

There are other suggestions I dug but didn’t need:

[sudo] conda update fastai -c fastai -c pytorch
[sudo] conda update fastai -c fastai -c pytorch -c conda-forge

Thanks @sut
I think this line helped (after reboot though)
conda update fastai -c fastai -c pytorch -c conda-forge

Tried the line above, but did not fix it. Then I just re-ran

conda install -c pytorch -c fastai fastai
and that worked for me.

This works for me too!