Setting up and running Jupyter notebooks for the FastAI book locally on Windows or on a Google Cloud Linux Instance

I decided to learn a little bit more about deep learning in practice and bought the Deep Learning for Coders with fastai and PyTorch: AI Applications Without a PhD book to help me get some hands-on exposure to deep learning. I did get the notebook and first examples running on gradient but I was also curious to figure out if I can get the examples to run on my local hardware. The only viable GPU I have for this purpose is an nVidia GTX 750TI with 2 GB GPU memory that is in my primary Windows desktop at home. My Linux server has a Kaveri APU but it looks like AMD support in libraries like PyTorch is minimal or non-existent – while I am a glutton for punishment in trying esoteric combinations to work, I am not that much of a masochist.

The first big challenge was setting up the environment and dependencies – in the end the incantations required are fairly simple but it took me a while to figure out the exact steps – hope this saves time for others who go through the same process. The best approach is to use Anaconda to setup the environment for this book and the projects. Here are the steps to setup the environment:

# Download and Install Anaconda
# Open the Anaconda 3 Powershell Prompt and type in order:
# Create a new Anaconda Environment for the FastAI Book
conda create --name fastbook
# Switch to the new environment
conda activate fastbook
# Install pytorch, fastai and dependencies
conda install -c pytorch -c fastai fastai2
# Install fastbook notebooks and dependencies
conda install -c fastai fastbook
# Clone the FastAI book repo - Install git if needed
git clone https://github.com/fastai/fastbook

At this point, you should have a working environment that has all the dependencies, jupyter, pytorch, fastai and the fastai book contents and notebooks all setup and ready to go. You can check that you are able to launch jupyter and open the first notebook:

# Launch Jupyter and check the first notebook in the book
cd fastbook
jupyter notebook

At this point, the environment should be setup and you should be able to execute the basic import statements in the notebook.

Turns out these instructions work just fine for the Google Cloud Linux instance with dedicated T4 GPU as well – I did see a warning that sm_75 is not supported in pytorch 1.6 but everything seems to work fine in spite of that warning.

Edit Oct. 2022 – See this link for how to set up a local Linux machine with nVidia GPU for running the fastai notebooks.

2 Replies to “Setting up and running Jupyter notebooks for the FastAI book locally on Windows or on a Google Cloud Linux Instance”

Leave a Reply

Your email address will not be published. Required fields are marked *