Error while running intro notebook (imdb text classification)

I have started fastai book and was going through the first notebook 01_intro.ipynb. The imdb text classification is not executing and finally throws an error. I have tired with bs=32 and 16. Here is the code

from fastai.text.all import *

dls = TextDataLoaders.from_folder(untar_data(URLs.IMDB), valid='test', bs=16)
learn = text_classifier_learner(dls, AWD_LSTM, drop_mult=0.5, metrics=accuracy)
learn.fine_tune(4, 1e-2)

Here is the error

---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-1-c1b52624de93> in <module>()
      3 dls = TextDataLoaders.from_folder(untar_data(URLs.IMDB), valid='test', bs=16)
      4 learn = text_classifier_learner(dls, AWD_LSTM, drop_mult=0.5, metrics=accuracy)
----> 5 learn.fine_tune(4, 1e-2)

18 frames
/usr/local/lib/python3.7/dist-packages/torch/autograd/__init__.py in backward(tensors, grad_tensors, retain_graph, create_graph, grad_variables, inputs)
    147     Variable._execution_engine.run_backward(
    148         tensors, grad_tensors_, retain_graph, create_graph, inputs,
--> 149         allow_unreachable=True, accumulate_grad=True)  # allow_unreachable flag
    150 
    151 

RuntimeError: transform: failed to synchronize: cudaErrorIllegalAddress: an illegal memory access was encountered

Any idea on this?

Not sure if this will help but this is what I would try first.

  • Make sure you are resetting the kernel before each attempt
  • How much GPU memory are you using? Try with bs=1

Thanks for your reply. I was able to get this run. However it took me around 40 minutes to run. Did you have similar experience. if it was fast what GPU config are you using.