AttibuteError: 'Tensor' object has no attribute 'append'

Hi all
sorry for cross-posting 'Tensor' object has no attribute 'append' · Issue #3385 · fastai/fastai · GitHub

fastai version 2.2.5.

I am running a (flask) web app that does inference (image classification) with fastai.
Everything works fine if the images are given to the app sequentially.
When several requests to the app happen (almost) simultaneously, the app fails with the error:

AttibuteError: 'Tensor' object has no attribute 'append'

Here is a longer stacktrace:

    klass, idx, probs = self.model.predict(img)
  File "/zzz/venv/lib/python3.6/site-packages/fastai/", line 256, in predict
    inp,preds,_,dec_preds = self.get_preds(dl=dl, with_input=True, with_decoded=True)
  File "/zzz/venv/lib/python3.6/site-packages/fastai/", line 243, in get_preds
  File "/zzz/venv/lib/python3.6/site-packages/fastai/", line 193, in _do_epoch_validate
    with torch.no_grad(): self._with_events(self.all_batches, 'validate', CancelValidException)
  File "/zzz/venv/lib/python3.6/site-packages/fastai/", line 160, in _with_events
    try: self(f'before_{event_type}');  f()
  File "/zzz/venv/lib/python3.6/site-packages/fastai/", line 166, in all_batches
    for o in enumerate(self.dl): self.one_batch(*o)
  File "/zzz/venv/lib/python3.6/site-packages/fastai/", line 184, in one_batch
    self._with_events(self._do_one_batch, 'batch', CancelBatchException)
  File "/zzz/venv/lib/python3.6/site-packages/fastai/", line 162, in _with_events
    self(f'after_{event_type}');  final()
  File "/zzz/venv/lib/python3.6/site-packages/fastai/", line 141, in __call__
    def __call__(self, event_name): L(event_name).map(self._call_one)
  File "/zzz/venv/lib/python3.6/site-packages/fastcore/", line 154, in map
    def map(self, f, *args, gen=False, **kwargs): return self._new(map_ex(self, f, *args, gen=gen, **kwargs))
  File "/zzz/venv/lib/python3.6/site-packages/fastcore/", line 666, in map_ex
    return list(res)
  File "/zzz/venv/lib/python3.6/site-packages/fastcore/", line 651, in __call__
    return self.func(*fargs, **kwargs)
  File "/zzz/venv/lib/python3.6/site-packages/fastai/", line 145, in _call_one
    for cb in'order'): cb(event_name)
  File "/zzz/venv/lib/python3.6/site-packages/fastai/callback/", line 44, in __call__
    if and _run: res = getattr(self, event_name, noop)()
  File "/zzz/venv/lib/python3.6/site-packages/fastai/callback/", line 122, in after_batch
    if self.save_preds is None: self.preds.append(preds)

The model is loaded with load_learner().
The last thing that happens is a call to a Callback after_batch.
It looks to (unexperienced) me as if two different processes try to access the same memory simultaneously.

The issue is reproducible both on GPU and CPU.

I would appreciate any hints how it can be overcome. Thanks in advance.