fastai / fastprogress

Simple and flexible progress bar for Jupyter Notebook and console
Apache License 2.0
1.08k stars 105 forks source link

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

Closed sri9s closed 4 years ago

sri9s commented 4 years ago

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

Help me out!

sgugger commented 4 years ago

fastai v2 requires the latest version of fastprogress so you should install it from master:

!pip install git+https://github.com/fastai/fastprogress

There will be a release of fastprogress today or tomorrow, which will make things easier.

muellerzr commented 4 years ago

@sgugger this suddenly started happening yesterday (see the v2 chat thread). I was able to have it run fine in Colab until this point. I haven’t tried your master version you show above however. (Just making you aware there was a sudden change that broke everything in the last 48/72 hrs somewhere)

Edit: verified that this fixed the issue. Thanks!

sri9s commented 4 years ago

fastai v2 requires the latest version of fastprogress so you should install it from master:

!pip install git+https://github.com/fastai/fastprogress

There will be a release of fastprogress today or tomorrow, which will make things easier.

Thanks, that worked.

jakubLangr commented 4 years ago

I just got the same issue even after installing fastprogress from github and upgrading IPython.

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
~/daisy-gan/venv/lib/python3.6/site-packages/fastai2/learner.py in fit(self, n_epoch, lr, wd, cbs, reset_opt)
    284             try:
--> 285                 self._do_begin_fit(n_epoch)
    286                 for epoch in range(n_epoch):

~/daisy-gan/venv/lib/python3.6/site-packages/fastai2/learner.py in _do_begin_fit(self, n_epoch)
    258     def _do_begin_fit(self, n_epoch):
--> 259         self.n_epoch,self.loss = n_epoch,tensor(0.);         self('begin_fit')
    260 

~/daisy-gan/venv/lib/python3.6/site-packages/fastai2/learner.py in __call__(self, event_name)
    222 
--> 223     def __call__(self, event_name): L(event_name).map(self._call_one)
    224     def _call_one(self, event_name):

~/daisy-gan/venv/lib/python3.6/site-packages/fastcore/foundation.py in map(self, f, *args, **kwargs)
    361              else f.__getitem__)
--> 362         return self._new(map(g, self))
    363 

~/daisy-gan/venv/lib/python3.6/site-packages/fastcore/foundation.py in _new(self, items, *args, **kwargs)
    314     def _xtra(self): return None
--> 315     def _new(self, items, *args, **kwargs): return type(self)(items, *args, use_list=None, **kwargs)
    316     def __getitem__(self, idx): return self._get(idx) if is_indexer(idx) else L(self._get(idx), use_list=None)

~/daisy-gan/venv/lib/python3.6/site-packages/fastcore/foundation.py in __call__(cls, x, *args, **kwargs)
     40 
---> 41         res = super().__call__(*((x,) + args), **kwargs)
     42         res._newchk = 0

~/daisy-gan/venv/lib/python3.6/site-packages/fastcore/foundation.py in __init__(self, items, use_list, match, *rest)
    305         if (use_list is not None) or not _is_array(items):
--> 306             items = list(items) if use_list else _listify(items)
    307         if match is not None:

~/daisy-gan/venv/lib/python3.6/site-packages/fastcore/foundation.py in _listify(o)
    241     if isinstance(o, str) or _is_array(o): return [o]
--> 242     if is_iter(o): return list(o)
    243     return [o]

~/daisy-gan/venv/lib/python3.6/site-packages/fastcore/foundation.py in __call__(self, *args, **kwargs)
    207         fargs = [args[x.i] if isinstance(x, _Arg) else x for x in self.pargs] + args[self.maxi+1:]
--> 208         return self.fn(*fargs, **kwargs)
    209 

~/daisy-gan/venv/lib/python3.6/site-packages/fastai2/learner.py in _call_one(self, event_name)
    225         assert hasattr(event, event_name)
--> 226         [cb(event_name) for cb in sort_by_run(self.cbs)]
    227 

~/daisy-gan/venv/lib/python3.6/site-packages/fastai2/learner.py in <listcomp>(.0)
    225         assert hasattr(event, event_name)
--> 226         [cb(event_name) for cb in sort_by_run(self.cbs)]
    227 

~/daisy-gan/venv/lib/python3.6/site-packages/fastai2/learner.py in __call__(self, event_name)
     24                (self.run_valid and not getattr(self, 'training', False)))
---> 25         if self.run and _run: getattr(self, event_name, noop)()
     26 

~/daisy-gan/venv/lib/python3.6/site-packages/fastai2/callback/schedule.py in begin_fit(self)
    151         super().begin_fit()
--> 152         self.learn.save('_tmp')
    153         self.best_loss = float('inf')

~/daisy-gan/venv/lib/python3.6/site-packages/fastai2/learner.py in save(self, file, with_opt)
    355         if rank_distrib(): return # don't save if slave proc
--> 356         file = join_path_file(file, self.path/self.model_dir, ext='.pth')
    357         save_model(file, self.model, getattr(self,'opt',None), with_opt)

TypeError: unsupported operand type(s) for /: 'str' and 'str'

During handling of the above exception, another exception occurred:

AttributeError                            Traceback (most recent call last)
<ipython-input-13-d81c6bd29d71> in <module>
----> 1 learn.lr_find()

~/daisy-gan/venv/lib/python3.6/site-packages/fastai2/callback/schedule.py in lr_find(self, start_lr, end_lr, num_it, stop_div, show_plot)
    194     n_epoch = num_it//len(self.dls.train) + 1
    195     cb=LRFinder(start_lr=start_lr, end_lr=end_lr, num_it=num_it, stop_div=stop_div)
--> 196     with self.no_logging(): self.fit(n_epoch, cbs=cb)
    197     if show_plot: self.recorder.plot_lr_find()

~/daisy-gan/venv/lib/python3.6/site-packages/fastai2/learner.py in fit(self, n_epoch, lr, wd, cbs, reset_opt)
    293 
    294             except CancelFitException:             self('after_cancel_fit')
--> 295             finally:                               self('after_fit')
    296 
    297     def validate(self, ds_idx=1, dl=None, cbs=None):

~/daisy-gan/venv/lib/python3.6/site-packages/fastai2/learner.py in __call__(self, event_name)
    221     def ordered_cbs(self, cb_func:str): return [cb for cb in sort_by_run(self.cbs) if hasattr(cb, cb_func)]
    222 
--> 223     def __call__(self, event_name): L(event_name).map(self._call_one)
    224     def _call_one(self, event_name):
    225         assert hasattr(event, event_name)

~/daisy-gan/venv/lib/python3.6/site-packages/fastcore/foundation.py in map(self, f, *args, **kwargs)
    360              else f.format if isinstance(f,str)
    361              else f.__getitem__)
--> 362         return self._new(map(g, self))
    363 
    364     def filter(self, f, negate=False, **kwargs):

~/daisy-gan/venv/lib/python3.6/site-packages/fastcore/foundation.py in _new(self, items, *args, **kwargs)
    313     @property
    314     def _xtra(self): return None
--> 315     def _new(self, items, *args, **kwargs): return type(self)(items, *args, use_list=None, **kwargs)
    316     def __getitem__(self, idx): return self._get(idx) if is_indexer(idx) else L(self._get(idx), use_list=None)
    317     def copy(self): return self._new(self.items.copy())

~/daisy-gan/venv/lib/python3.6/site-packages/fastcore/foundation.py in __call__(cls, x, *args, **kwargs)
     39             return x
     40 
---> 41         res = super().__call__(*((x,) + args), **kwargs)
     42         res._newchk = 0
     43         return res

~/daisy-gan/venv/lib/python3.6/site-packages/fastcore/foundation.py in __init__(self, items, use_list, match, *rest)
    304         if items is None: items = []
    305         if (use_list is not None) or not _is_array(items):
--> 306             items = list(items) if use_list else _listify(items)
    307         if match is not None:
    308             if is_coll(match): match = len(match)

~/daisy-gan/venv/lib/python3.6/site-packages/fastcore/foundation.py in _listify(o)
    240     if isinstance(o, list): return o
    241     if isinstance(o, str) or _is_array(o): return [o]
--> 242     if is_iter(o): return list(o)
    243     return [o]
    244 

~/daisy-gan/venv/lib/python3.6/site-packages/fastcore/foundation.py in __call__(self, *args, **kwargs)
    206             if isinstance(v,_Arg): kwargs[k] = args.pop(v.i)
    207         fargs = [args[x.i] if isinstance(x, _Arg) else x for x in self.pargs] + args[self.maxi+1:]
--> 208         return self.fn(*fargs, **kwargs)
    209 
    210 # Cell

~/daisy-gan/venv/lib/python3.6/site-packages/fastai2/learner.py in _call_one(self, event_name)
    224     def _call_one(self, event_name):
    225         assert hasattr(event, event_name)
--> 226         [cb(event_name) for cb in sort_by_run(self.cbs)]
    227 
    228     def _bn_bias_state(self, with_bias): return bn_bias_params(self.model, with_bias).map(self.opt.state)

~/daisy-gan/venv/lib/python3.6/site-packages/fastai2/learner.py in <listcomp>(.0)
    224     def _call_one(self, event_name):
    225         assert hasattr(event, event_name)
--> 226         [cb(event_name) for cb in sort_by_run(self.cbs)]
    227 
    228     def _bn_bias_state(self, with_bias): return bn_bias_params(self.model, with_bias).map(self.opt.state)

~/daisy-gan/venv/lib/python3.6/site-packages/fastai2/learner.py in __call__(self, event_name)
     23         _run = (event_name not in _inner_loop or (self.run_train and getattr(self, 'training', True)) or
     24                (self.run_valid and not getattr(self, 'training', False)))
---> 25         if self.run and _run: getattr(self, event_name, noop)()
     26 
     27     @property

~/daisy-gan/venv/lib/python3.6/site-packages/fastai2/callback/progress.py in after_fit(self)
     37     def after_fit(self):
     38         if getattr(self, 'mbar', False):
---> 39             self.mbar.on_iter_end()
     40             delattr(self, 'mbar')
     41         self.learn.logger = self.old_logger

~/daisy-gan/venv/lib/python3.6/site-packages/fastprogress/fastprogress.py in on_iter_end(self)
    155             total_time = format_time(time.time() - self.main_bar.start_t)
    156             self.text = f'Total time: {total_time} <p>' + self.text
--> 157         self.out.update(HTML(self.text))
    158 
    159     def add_child(self, child):

AttributeError: 'NBMasterBar' object has no attribute 'out'

Maybe worth reopening?

muellerzr commented 4 years ago

On which notebook? You should just need to pip install, not build from git

jakubLangr commented 4 years ago

Apologies. This has been an issue with the Path. It is just somewhat confusing that the error message points somewhere else. But upon staring at it for longer it starts to make sense.

It simply assumes path to be type(Path) but does not enforce it unlike in some other places. So I just missed that. No re-opening necessary. It just manifests the same way.