Lesson1.ipynb: Can someone tell me what is going wrong

Can someone tell me why this error is occurring? It happens at the second cell in section Our first model: quick start

I thank you all in advance

I am pasting the whole trace:


JSONDecodeError 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)

~/Documents/fastai/courses/dl1/fastai/conv_learner.py in pretrained(cls, f, data, ps, xtra_fc, xtra_cut, custom_head, precompute, **kwargs)
99 models = ConvnetBuilder(f, data.c, data.is_multi, data.is_reg,
100 ps=ps, xtra_fc=xtra_fc, xtra_cut=xtra_cut, custom_head=custom_head)
–> 101 return cls(data, models, precompute, **kwargs)
102
103 @property

~/Documents/fastai/courses/dl1/fastai/conv_learner.py in init(self, data, models, precompute, **kwargs)
91 elif self.metrics is None:
92 self.metrics = [accuracy_thresh(0.5)] if self.data.is_multi else [accuracy]
—> 93 if precompute: self.save_fc1()
94 self.freeze()
95 self.precompute = precompute

~/Documents/fastai/courses/dl1/fastai/conv_learner.py in save_fc1(self)
140
141 def save_fc1(self):
–> 142 self.get_activations()
143 act, val_act, test_act = self.activations
144 m=self.models.top_model

~/Documents/fastai/courses/dl1/fastai/conv_learner.py in get_activations(self, force)
135 names = [os.path.join(self.tmp_path, p+tmpl) for p in (‘x_act’, ‘x_act_val’, ‘x_act_test’)]
136 if os.path.exists(names[0]) and not force:
–> 137 self.activations = [bcolz.open§ for p in names]
138 else:
139 self.activations = [self.create_empty_bcolz(self.models.nf,n) for n in names]

~/Documents/fastai/courses/dl1/fastai/conv_learner.py in (.0)
135 names = [os.path.join(self.tmp_path, p+tmpl) for p in (‘x_act’, ‘x_act_val’, ‘x_act_test’)]
136 if os.path.exists(names[0]) and not force:
–> 137 self.activations = [bcolz.open§ for p in names]
138 else:
139 self.activations = [self.create_empty_bcolz(self.models.nf,n) for n in names]

/usr/local/lib/python3.6/dist-packages/bcolz/toplevel.py in open(rootdir, mode)
138 return bcolz.ctable(rootdir=rootdir, mode=mode)
139 else:
–> 140 return bcolz.carray(rootdir=rootdir, mode=mode)
141
142

bcolz/carray_ext.pyx in bcolz.carray_ext.carray.cinit (bcolz/carray_ext.c:14879)()

bcolz/carray_ext.pyx in bcolz.carray_ext.carray._read_meta (bcolz/carray_ext.c:19733)()

bcolz/carray_ext.pyx in bcolz.carray_ext.carray._read_meta (bcolz/carray_ext.c:19673)()

/usr/lib/python3.6/json/init.py in loads(s, encoding, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw)
352 parse_int is None and parse_float is None and
353 parse_constant is None and object_pairs_hook is None and not kw):
–> 354 return _default_decoder.decode(s)
355 if cls is None:
356 cls = JSONDecoder

/usr/lib/python3.6/json/decoder.py in decode(self, s, _w)
337
338 “”"
–> 339 obj, end = self.raw_decode(s, idx=_w(s, 0).end())
340 end = _w(s, end).end()
341 if end != len(s):

/usr/lib/python3.6/json/decoder.py in raw_decode(self, s, idx)
355 obj, end = self.scan_once(s, idx)
356 except StopIteration as err:
–> 357 raise JSONDecodeError(“Expecting value”, s, err.value) from None
358 return obj, end

JSONDecodeError: Expecting value: line 1 column 1 (char 0)

1 Like

It seems that a string is expected by the JSON decoder but there is nothing.

Try checking the parameters that you are passing, maybe data is empty or something else.

Another reason could be that you need to change the permissions if you are running the code on your computer.

Thank you @Jacek,
I think it was the challenge with permissions. I followed a set of instruction for installing Python3.6 on ubuntu 16.04 (http://ubuntuhandbook.org/index.php/2017/07/install-python-3-6-1-in-ubuntu-16-04-lts/). This does not use a virtual environment. It went downhill thereafter (having to run notebook as sudo etc.)
I have had better result with these instruction using a virtual environment (https://www.caseylabs.com/how-to-create-a-python-3-6-virtual-environment-on-ubuntu-16-04/)
Thanks for your help sir !

2 Likes

I have same issue. I tried many different method, but I can’t solve it.
Anyone has ideas?

1 Like

I am too getting the same error. Is there some efficient way to solve this error?

1 Like

make sure you do git pull and conda env update. That may help.

I had the same problem, my PC was running out of memory and crashing, resulting in some incomplete leftover temporary files. I managed to figure out the issue by looking at the stack trace, though I must admit it isn’t too comprehensive. What I would suggest is to delete the temporary folder altogether, so that you give it a chance to start over without looking at the “corrupted” files.

You’d need to cd to your fastai root directory, and cd to courses/dl1. Assuming you have data directory in there (or symlink). You’d need to cd to data/dogscats/. If you run ls you can see that you have a tmp folder. Run rm -r tmp.

tldr;

cd ~/fastai/courses/dl1/data/dogscats
rm -r tmp

Also if you keep on having the crashing problem check out CUDA Out of Memory Error
Matthew’s advice to decrease batch size is good. I’m using 2 GTX1080 Ti GPUs and still managed to crash… might be because I’m running it on an nvidia-docker container :thinking:

1 Like

This helped me with my issue! Thanks!