Issues importing QRNN in Google Colab

Hello!

Much like the thread here: Can't import QRNN or QRNNLayer, I’m having issues importing the qrrn model (same error, ImportError: No module named 'forget_mult_cuda'). I’ve tried to reinstall fastai and to manually import the QRNN function from source code, to no success.

Doing a new thread since I’m using google colab, so the issue might pop up again for some other users also who are dependent on the google colab system.

Thanks,

Lorentz

There is no module forget_mult_cuda in the library. I’m guessing it’s the JIT command to compile the custom CUDA kernels that fails on colab, nothing much we can do about it if that’s the case.

Thanks for fast reply (sorry for my slow one).

Looking here: https://github.com/fastai/fastai/blob/master/fastai/text/models/qrnn.py on line 10-11, it seems to try to import/compile forget_mult_cuda.cpp/cu. It’s also called at the forward function on line 110.

I noticed that the awd-lstm version (https://github.com/fastai/fastai/blob/master/fastai/text/models/awd_lstm.py) has qrnn “baked” into it, but I’m trying to import the separate qrnn model since it’s indicated to do so in the part 2 translation notebook. Will try to solve it by using modified awd-lstm instead.

‘learn_c = text_classifier_learner(data_clas, AWD_LSTM, config=config, drop_mult=0.5)’

Getting the same error

“ImportError: No module named ‘forget_mult_cuda’”

I ran into this problem as well and in looking at the PyTorch code it says that it uses Ninja to build the module. It seems that Ninja is missing in the Colab package list so you need to do a !pip install ninja in a cell before trying to load the learner.

After that I was able to make the QRNN function in Colab.

1 Like

Sorry, my last answer wasn’t quite correct.

You need to do a pip install ninja and then a pip install -U fastai to get the QRNN to work. It seems that Ninja needs to be present before the FastAI package is installed so that it detects it.

3 Likes

Hello!

I’m getting the same error… Is this problem really specific to Google Colab? Did someone find any kind of solution?

Thanks!

I found a fix based on @nsecord 's reply when I ran into this error on Google Colab: I ran pip install ninja and then pip install --upgrade --force-reinstall fastai. Colab prompts the user to restart the runtime, which solved the issue for me. @matheuscosta hope this helps!

3 Likes