Fastai and fastbook on Ubuntu 20.04 with Nvidia GeForce RTX 3090

Disclaimer: this is part blog post, and part “note to self.” I’m leaving this here as it may be useful for others, but it’s a bit hacky so YMMV.

The new rig arrived yesterday, an Alienware Aurora R12 sporting the 11th gen i9 and an RTX 3090. I bought it for the 3090 – the only way to get a GPU these days is to buy a computer that comes with one.

After making a USB recovery disk so I can (one day) reinstall Windows and try some games, I installed Ubuntu 20.04, the latest NVIDIA drivers and CUDA. As a first test, I trained a Keras + TensorFlow model that I created during a recent class with the NVIDIA Deep Learning Institute. During training, I could tell when the GPU kicked in because the lights in my room started flickering.

A little scary, but very cool.

Pleased that Keras and TensorFlow worked with no fuss aside from basic driver installs and flickring lights, I tried Fastai, which is built on PyTorch. This is where things got complicated.

Fastai requires (expects) torch 1.7.1 which doesn’t seem compatible with CUDA 11.1. It’s each to get a PyTorch 1.8 install with CUDA 11 by following the instructions on the PyTorch install page, but as soon as you pip install fastai, torch gets downgraded to 1.7.1.

After a bit of finagling, I managed to get things working, so here are the steps for when I need to do this again (tomorrow) and can’t remember the magic incantation.

Create a virtual environment with Python 3.8.5 however you like to manage venvs, I’m using miniconda at the moment:

conda create --name fastbook

Install fastai, fastbook and graphviz:

sudo apt -y install graphviz
conda activate fastai
pip install fastai
pip install fastbook
pip install graphviz

Install torch==1.8.1+cu111 and ignore the warnings about compatibility:

pip install torch==1.8.1+cu111 torchvision==0.9.1+cu111 -f

Make sure Jupyter Lab is using your new venv for its kernel:

ipython kernel install --name "fastbook" --user

Fire up Jupyter Lab and try to train a model:

screen -S lab
jupyter lab

Note: if you’re running fastbook, modify the first cell to avoid downgrading back to torch 1.7.1, since the first cell in all of the Fastbook notebooks does a pip install of fastbook.

Leave a comment

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.