fastprogress: AttributeError: 'NoneType' object has no attribute 'update' using Python 3.7

Issue #20 already described this problem for Python versions pre-3.7, but for me it also happens in Python 3.7. Even the history of issue #24 (which just bumped the version requirement) shows that the connection between the Python version and the bug is uncertain.

System info:

(click triangle on the left to expand/collapse)

=== Software === 
python        : 3.7.3
fastai        : 1.0.59
fastprogress  : 0.1.21
torch         : 1.3.0
nvidia driver : 418.40
torch cuda    : 10.1.243 / is **Not available** 

=== Hardware === 
nvidia gpus   : 1
Have 1 GPU(s), but torch can't use them (check nvidia driver) 

=== Environment === 
platform      : Linux-4.14.133-113.112.amzn2.x86_64-x86_64-with-Ubuntu-18.04-bionic
distro        : #1 SMP Tue Jul 30 18:29:50 UTC 2019
conda env     : python3.6
python        : /usr/bin/python3.7
sys.path      : 
/usr/lib/python37.zip
/usr/lib/python3.7
/usr/lib/python3.7/lib-dynload
/home/username/.local/lib/python3.7/site-packages
/home/username/.conda/envs/python3.7/lib/python3.7/site-packages
/usr/local/lib/python3.7/dist-packages
/usr/lib/python3/dist-packages
/opt/cloudera/parcels/CDH/lib/spark/python
/home/username/.ipython

Stack trace:

(click triangle on the left to expand/collapse)

/home/username/.local/lib/python3.7/site-packages/fastai/train.py in fit_one_cycle(learn, cyc_len, max_lr, moms, div_factor, pct_start, final_div, wd, callbacks, tot_epochs, start_epoch)
     21     callbacks.append(OneCycleScheduler(learn, max_lr, moms=moms, div_factor=div_factor, pct_start=pct_start,
     22                                        final_div=final_div, tot_epochs=tot_epochs, start_epoch=start_epoch))
---> 23     learn.fit(cyc_len, max_lr, wd=wd, callbacks=callbacks)
     24 
     25 def fit_fc(learn:Learner, tot_epochs:int=1, lr:float=defaults.lr,  moms:Tuple[float,float]=(0.95,0.85), start_pct:float=0.72,

/home/username/.local/lib/python3.7/site-packages/fastai/basic_train.py in fit(self, epochs, lr, wd, callbacks)
    198         else: self.opt.lr,self.opt.wd = lr,wd
    199         callbacks = [cb(self) for cb in self.callback_fns + listify(defaults.extra_callback_fns)] + listify(callbacks)
--> 200         fit(epochs, self, metrics=self.metrics, callbacks=self.callbacks+callbacks)
    201 
    202     def create_opt(self, lr:Floats, wd:Floats=0.)->None:

/home/username/.local/lib/python3.7/site-packages/fastai/basic_train.py in fit(epochs, learn, callbacks, metrics)
     97             cb_handler.set_dl(learn.data.train_dl)
     98             cb_handler.on_epoch_begin()
---> 99             for xb,yb in progress_bar(learn.data.train_dl, parent=pbar):
    100                 xb, yb = cb_handler.on_batch_begin(xb, yb)
    101                 loss = loss_batch(learn.model, xb, yb, learn.loss_func, learn.opt, cb_handler)

/home/username/.local/lib/python3.7/site-packages/fastprogress/fastprogress.py in __init__(self, gen, total, display, leave, parent, auto_update)
    157     def __init__(self, gen, total=None, display=True, leave=True, parent=None, auto_update=True):
    158         self.progress = html_progress_bar(0, len(gen) if total is None else total, "")
--> 159         super().__init__(gen, total, display, leave, parent, auto_update)
    160 
    161     def on_iter_begin(self):

/home/username/.local/lib/python3.7/site-packages/fastprogress/fastprogress.py in __init__(self, gen, total, display, leave, parent, auto_update)
     55         else:
     56             self.leave,self.display=False,False
---> 57             parent.add_child(self)
     58         self.comment = ''
     59         if not self.auto_update:

/home/username/.local/lib/python3.7/site-packages/fastprogress/fastprogress.py in add_child(self, child)
    207         self.child = child
    208         self.inner_dict['pb2'] = self.child.progress
--> 209         self.show()
    210 
    211     def show(self):

/home/username/.local/lib/python3.7/site-packages/fastprogress/fastprogress.py in show(self)
    214         to_show = [name for name in self.order if name in self.inner_dict.keys()]
    215         self.html_code = '\n'.join([self.inner_dict[n] for n in to_show])
--> 216         self.out.update(HTML(self.html_code))
    217 
    218     def write(self, line, table=False):

AttributeError: 'NoneType' object has no attribute 'update'

I may be mistaken, but it seems to me that:

  • self.out is only set in NBMasterBar.on_iter_begin, but NBMasterBar.show may try use it regardless.
  • NBMasterBar.show can be called by NBMasterBar.add_child, which happens from ProgressBar.__init__ as parent.add_child(self).

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 18 (5 by maintainers)

Most upvoted comments

Error on colab, with fastai2, @ learn.fit_one_cycle(4):

AttributeError: ‘NBMasterBar’ object has no attribute ‘out’ AttributeError: ‘NBMasterBar’ object has no attribute ‘start_t’

@tunner007 The reason why upgrading doesn’t help is that the interactive REPL prompt ignores the user’s enviroment for its dependencies, so even after an upgrade it still uses the old version:

> !pip3 freeze | grep ipython
ipython==7.9.0
ipython-genutils==0.2.0
> print(IPython.version_info)
(5, 1, 0, '')