How to properly install FastAI on a Windows 11 Machine (WSL) - A 2023 guide

Hi All,

Here is a step-by-step guide to set up FastAI on your Windows 11 Machine using WSL.

Step 1: First and foremost you need to enable WSL on your windows machine following the below process:

  • The easiest way is to open your Powershell in admin mode and type this command wsl --install

In most cases, this should work, but I have seen few cases where this didn’t work due to the internet provider blocking the configuration file that is needed for the above command.

  • If the above option didn’t work for you then you might need to follow the manual install process following this official guide

Step 2: Installing Python using Mambaforge

I highly recommend you first watch this walk-through session from Jeremy before you continue with the other steps.

  • Download Mamba forge from the Github repo using this link and install by following Jeremy’s guide from the above video.

Step 3: Install Pytorch

In order to utilize our GPU properly we need to install a host of other libraries so that FastAI works seamlessly.

  • Install PyTorch by following the official documentation

  • At the time of writing this guide FastAI & Pytorch worked seamlessly with PyTorch v1.12.0. So for now you could use this command if you have GPU installed conda install pytorch==1.12.0 torchvision==0.13.0 torchaudio==0.12.0 cudatoolkit=11.6 -c pytorch -c conda-forge

Step 4 Install FastAI

Again, please follow FastAI’s official documentation here but at the time of writing this guide the command was conda install -c fastchan fastai

Step 5 Install JupyterLab

And the last step is to install Jupyter Lab using the command conda install jupyterlab

Notes:

  • Just to keep it consistent I have used conda solver for this tutorial but you could just replace conda with mamba they both work interchangeably.

  • If you install Pytorch > v1.12.0 then sometimes Vision Learner may not work properly, if that is the case (it was for me) then you need to add this code export LD_LIBRARY_PATH=/usr/lib/wsl/lib:$LD_LIBRARY_PATH to your .bashrc file and restart WSL - here is a link if you need more details.

Please let me know if I missed anything to include here or if you have any better ideas to share.

6 Likes

Works perfect. I would suggest to do a pip install -Uqq fastbook like in the beggining of the notebooks because it wont work from inside, and also mamba install --channel conda-forge pygraphviz

If I already have conda installed, should i still install mamba?

you can keep using conda if you prefer. But mamba is generally quicker (and command-wise is meant to be drop-in compatible)

One tip for those who like using IDEs and want to make the integrated terminal use WSL by default:

  1. PyCharm
    • Settings > Tools > Terminal
    • Under the section Application Settings, set the Shell path to wsl.exe
  2. VS Code
    • Settings > terminal.integrated.defaultProfile.windows
    • Set it to your desired WSL, for example I set mine to Ubuntu-22.04
1 Like