@stas, thanks for the hint the pytorch version was correct but
“** torchtext**” version was not compatible it has to be “torchtext==0.2.3.” for pytorch 0.3.1.
I’m on 18.04, freshly installed.
Installed fastai v1 first, in a dedicated env (it seems to work). Then I installed fastai 0.7 following the procedure described (which is the usual procedure).
As I try to import fastai modules, it complains what follows:
It starts from:
and ends with:
The symlink seems to be OK…
So, what’s wrong?
OK, solved.
It was torchtext
. Downgrade it to the previous version with pip
.
Source (for example): Google Colab-AttributeError: module 'torch' has no attribute 'float32'
FYI, environment*.yml
were just updated to pin torchtext=0.2.3
. Thank you all for the input and testing.
I am using clouderizer.com Fast.ai project template for the course and to run the template I use google colab like a backend and I am not able to import the library properly. I have already posted my query here and the solution I received was for the case when we run the complete notebook on google colab itself or I may not be able to understand it because these things are new to me. If someone in the forum is using clouderizer and has found a solution, please help!.
Thanks in advance.
Edit: Finally found a solution. Click on edit project, go to the setup section, in the setup script column, add pip install torchtext==0.2.3
. Now I am able to run the notebooks without any problem.
I was getting error related to torchtext=0.2.3.
I replaced it with torchtext==0.2.3 in the enviornment.yml file and it worked
will that work with !pip install fastai==0.7.0
in kaggle kernels?
no, the pip package is from May-2018. you need to use the source:
git clone https://github.com/fastai/fastai.git
cd fastai
conda env create -f environment.yml
(or environment-cpu.yml
for cpu)
or just install it from the nb:
!pip install fastai==0.7.0
!pip install torchtext==0.2.3
I don’t think you can do that in kaggle kernels AFAIK.
thanks stas!
tried that in kaggle kernels but got error: AttributeError: ‘torch.dtype’ object has no attribute ‘type’
but also seems somewhat random, i managed to get it work once, then it showed error, some other people also reported errors.
ML lesson 1 worked with !pip install fastai==0.7.0, however DL v2 lessons are not running on kernels reliably. the more i look forward to v3 course. noticed v3 notebooks started to appear on github repo!
I noted that the setup is slightly different from what Jeremy posted in Wiki thread: lesson 1 for the Machine Learning MOOC:
Would you mind explain a bit about the difference between these two ways of setting up fast.ai v0.7?
Error:
AttributeError: module ‘torch’ has no attribute ‘float32’.
Generated by:
from fastai.transforms import *
Caused by:
A newer version of torchtext (>0.3.0) in the requirments.txt (>=0.2.3)
Resolved by:
!pip install fastai==0.7.0
!pip install torchtext==0.2.3
Order matters
Thank you for the PR, @Cesare.montresor
It looks like everybody has been using environment*yml
files, so requirements.txt
got out of sync. I synced it to match environment.yaml
.
Thanks, really fast!
I use it on Colab for giving classes with my 2 study groups.
As it requires to reinstall dependencies every time, using pip is somehow faster
Wiki mode has been turned on for the first post so you can edit it to improve it. Thank you.
hey, after i used the 2 lines which you specified, I got a lot of lines of the form: Requirement Already Satisfied…
After that there was the following code snippet:
mxnet 1.3.0.post0 has requirement numpy<1.15.0,>=1.8.2, but you'll have numpy 1.15.2 which is incompatible.
kmeans-smote 0.1.0 has requirement imbalanced-learn<0.4,>=0.3.1, but you'll have imbalanced-learn 0.5.0.dev0 which is incompatible.
kmeans-smote 0.1.0 has requirement numpy<1.15,>=1.13, but you'll have numpy 1.15.2 which is incompatible.
anaconda-client 1.7.2 has requirement python-dateutil>=2.6.1, but you'll have python-dateutil 2.6.0 which is incompatible.
imbalanced-learn 0.5.0.dev0 has requirement scikit-learn>=0.20, but you'll have scikit-learn 0.19.1 which is incompatible.
Installing collected packages: torch
Found existing installation: torch 0.4.1
Uninstalling torch-0.4.1:
Successfully uninstalled torch-0.4.1
Successfully installed torch-0.3.1
You are using pip version 10.0.1, however version 18.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
/bin/sh: 1: cannot open =0.3.0: No such file
But then I executed all the other cells,it worked fine. So do I need to upgrade pip or any other package? Also, I didn’t understand that last line (cannot open =0.3.0…)
Also, why does it ask to update pip? Doesn’t the kernel have the latest version by default?
Apart from this I encountered 2 other warning messages regarding deprecated module/function in pandas,numpy. I had forked @miwojc’s kernel : https://www.kaggle.com/miwojc/fast-ai-machine-learning-lesson-1/
Because of > or < you must quote the string in bash:
!pip install "torchtext<=0.3.0"
Otherwise:
$ pip install torchtext<=0.3.0
bash: =0.3.0: No such file or directory
tries to read from file “=0.3.0”
Ho sorry, it was with a \, but it got escaped by the forum, I doubled it or yes, with quotes.
Even better:
!pip install torchtext==0.2.3