ConvLearner.pretrained error for lesson1.ipynb

Hi all, I am a beginner for deeplearning and this forum. I followed Installation-on-windows/ and successfully loaded jupyter notebook and fastAI. torch.cuda.is_available() also returns True. However, when I followed lesson 1 (dogs-and-cats) and run learn = ConvLearner.pretrained(arch, data, precompute=True), error popped up as following:


TypeError Traceback (most recent call last)
in
1 arch=resnet34
2 data = ImageClassifierData.from_paths(PATH, tfms=tfms_from_model(arch, sz))
----> 3 learn = ConvLearner.pretrained(arch, data, precompute=True)
4 learn.fit(0.01, 2)

F:\deeplearning\fastAI\fastai\courses\dl1\fastai\conv_learner.py in pretrained(cls, f, data, ps, xtra_fc, xtra_cut, custom_head, precompute, pretrained, **kwargs)
112 models = ConvnetBuilder(f, data.c, data.is_multi, data.is_reg,
113 ps=ps, xtra_fc=xtra_fc, xtra_cut=xtra_cut, custom_head=custom_head, pretrained=pretrained)
→ 114 return cls(data, models, precompute, **kwargs)
115
116 @classmethod

F:\deeplearning\fastAI\fastai\courses\dl1\fastai\conv_learner.py in init(self, data, models, precompute, **kwargs)
98 if hasattr(data, ‘is_multi’) and not data.is_reg and self.metrics is None:
99 self.metrics = [accuracy_thresh(0.5)] if self.data.is_multi else [accuracy]
→ 100 if precompute: self.save_fc1()
101 self.freeze()
102 self.precompute = precompute

F:\deeplearning\fastAI\fastai\courses\dl1\fastai\conv_learner.py in save_fc1(self)
177 m=self.models.top_model
178 if len(self.activations[0])!=len(self.data.trn_ds):
→ 179 predict_to_bcolz(m, self.data.fix_dl, act)
180 if len(self.activations[1])!=len(self.data.val_ds):
181 predict_to_bcolz(m, self.data.val_dl, val_act)

F:\deeplearning\fastAI\fastai\courses\dl1\fastai\model.py in predict_to_bcolz(m, gen, arr, workers)
16 m.eval()
17 for x,*_ in tqdm(gen):
—> 18 y = to_np(m(VV(x)).data)
19 with lock:
20 arr.append(y)

F:\deeplearning\fastAI\fastai\courses\dl1\fastai\core.py in VV(x)
67 def VV(x):
68 ‘’‘creates a single or a list of pytorch tensors, depending on input x. ‘’’
—> 69 return map_over(x, VV_)
70
71 def to_np(v):

F:\deeplearning\fastAI\fastai\courses\dl1\fastai\core.py in map_over(x, f)
6 def is_listy(x): return isinstance(x, (list,tuple))
7 def is_iter(x): return isinstance(x, collections.Iterable)
----> 8 def map_over(x, f): return [f(o) for o in x] if is_listy(x) else f(x)
9 def map_none(x, f): return None if x is None else f(x)
10 def delistify(x): return x[0] if is_listy(x) else x

F:\deeplearning\fastAI\fastai\courses\dl1\fastai\core.py in VV_(x)
63 def VV_(x):
64 ‘’‘creates a volatile tensor, which does not require gradients. ‘’’
—> 65 return create_variable(x, True)
66
67 def VV(x):

F:\deeplearning\fastAI\fastai\courses\dl1\fastai\core.py in create_variable(x, volatile, requires_grad)
51 if type (x) != Variable:
52 if IS_TORCH_04: x = Variable(T(x), requires_grad=requires_grad)
—> 53 else: x = Variable(T(x), requires_grad=requires_grad, volatile=volatile)
54 return x
55

F:\deeplearning\fastAI\fastai\courses\dl1\fastai\core.py in T(a, half, cuda)
39 a = to_half(a) if half else torch.FloatTensor(a)
40 else: raise NotImplementedError(a.dtype)
—> 41 if cuda: a = to_gpu(a, non_blocking=True)
42 return a
43

F:\deeplearning\fastAI\fastai\courses\dl1\fastai\core.py in to_gpu(x, *args, **kwargs)
88 def to_gpu(x, *args, **kwargs):
89 ‘’‘puts pytorch variable to gpu, if cuda is available and USE_GPU is set to true. ‘’’
—> 90 return x.cuda(*args, **kwargs) if USE_GPU else x
91
92 def noop(*args, **kwargs): return

TypeError: _cuda() got an unexpected keyword argument ‘non_blocking’


It seems related to the gpu function. I did some search but didn’t have a clue. Thanks in advance.

2 Likes

I am also facing the same issue while running on paperspace

I also have the same issue

Same here…

update your fastai repo as this issue has been resolved

2 Likes

After git pull, the error no long exists, thanks for the help.

Hi all,

I am running the fast-ai 2018 lecture 1 notebook on colab. Upon trying to create the model instance for ConvLearner, I am receiving the following error:

NameError Traceback (most recent call last)

<ipython-input-17-63be6bf3fcfc> in <module>() ---->

1 learn = ConvLearner(data, models.resnet34, metrics=error_rate)

NameError: name ‘ConvLearner’ is not defined

Any suggestions on how to get through this are highly appreciated!

Did you get past this? I’m having the same problem, on Gradient

1 Like

No @ricknta, still stuck at that!

ConvLearner was replaced with create_cnn a few days ago - see:

https://forums.fast.ai/t/fixing-notebook-1-convlearner-not-found/28367

6 Likes

Thank you @ricknta!

How do we stay up to date with things like this? Will the trainings be updated to reflect changes?

Can you please let me which notebooks are you referring to?? Could you provide a link or something?? Because i’m actually trying to run the code in the open source lessons but seems like there is lot of change and i’m not sure where to refer to.

now create_cnn is replaced by cnn_learner. The notebook lesson1-pets.ipynb is not updated yet.

the line
learn = create_cnn(data, models.resnet34, metrics=error_rate)

should be replaced by
learn = cnn_learner(data, models.resnet34, metrics=error_rate)

see the changes in their library

1 Like

I just ran into this issue watching https://course.fast.ai/videos/?lesson=1 at 37 min into the lesson.
The video should be annotated or have the notebook updated so new users are aware…

Thanks