I thought that when doing any training, fastai/pytorch would use a GPU if available to speed up processing, but when trying to run this code in either Kaggle or Google Collab, it doesn’t seem to use the GPU:
In Google Colab, they only show the GPU RAM, but I didn’t see an increase in GPU RAM usage either. Also these runs typically seem to take ~ 30 seconds to run, which isn’t a big deal, but watching the vidoe course, they seem to take significantly less time to run, which also makes me think the GPU isn’t being used. Just curious why.
Issue:
When running this code:
interp.plot_top_losses(5, nrows=1)
both Kaggle and Google Collab have issues displaying the column headers correctly:
Welcome to the forums and thanks for posting your question , you might want to change the topic from “Site Feedback” to “Part 1 2022” since this relates to the course notebooks
You have to manually enable the GPU in both contexts before they can be used, which is my guess as to why you’re not seeing accelerated performance.
In Colab you can enable it from the “Runtime” menu & “Change Runtime Type” selection, where you can then enable a GPU/TPU.
Apologies if you’ve already followed those instructions, let me know what output you get from running the above torch.cuda code and we can see what devices are available and being used.
I probably should have demonstrated in my post that I had verified that I added a GPU to the runtime environment, but I did do the instructions you provided.
I also tried the code you provided and it does show that there is a GPU available, but it doesn’t really demonstrate whether the GPU is being used by the code. But at this point, this was just a curiosity. Maybe the Kaggle widget for the GPU display isn’t working correctly.
Any thoughts on fixing the display issue I mentioned above when running interp.plot_top_losses(5, nrows=1)?
Apologies to guide you through the GPU activation since you’d already done that, the other check you can look at is to see which device your dataloaders is on by running dls.device. I’m not sure if that is the actual deciding factor as to where your model gets trained but it rules out one other possibility that your dataloaders are on your cpu device instead of an accelerated device.
On the display of the losses with plot_top_losses, you could try play with the figsize, nrows parameters, however I’ve noticed those parameters are only shown/explained in the old docs and I can see **kwargs is in the new api, so it might accept these parameters or not, I haven’t tried it out. If I get time this afternoon I’ll come back and make a snippet to play with.