How to run the p2 notebooks locally on a mac

I was running into all kinds of dependency mismatches. I created a blog post here:

Here are the relevant steps to get the correct library installed:

  1. Get Python 3.10
  • brew install python@3.10
  1. Create a virtual environment which is python3.10 based
  • In the terminal window run
    • python3.10 -m venv .fastai2
    • source ~/.fastai2/bin/activate
  • Note: this creates a virtual environment from which you can install pre-reqs which could be incompatible with the currently installed default python version. For example, pytorch 2.0.1 is incompatible with python3.12.
  1. Install the pre-reqs (in terminal using Python env)
  • pip3 install -Uqq git+https://github.com/fastai/course22p2
    • (Installs all of the miniai components created in earlier notebooks)
  • pip3 install torch==2.0.1 torchvision==0.15.2 torchaudio==2.0.2
  • pip3 install matplotlib
  • pip3 install jupyter
  • pip3 install numpy==1.23
  1. Run jupyter (in terminal using Python env)
  1. Launch colab in browser
  • Open notebook from github repo (I verified these on Google Colab)
  • Select “Connect to local runtime”
  • Paste in string from step 4b.
  1. Run the cells in the notebook, voila!
3 Likes

Hello,
Your steps seem quite thorough. Here are a few additional tips that might help:

Use requirements.txt or environment.yml: These files can help manage dependencies more effectively. You can create them using:
pip freeze > requirements.txt
or for conda environments:
conda env export > environment.yml

Check for Conflicts: Tools like pipdeptree can help visualize dependency conflicts:
pip install pipdeptree
pipdeptree

Use Docker: For an even more isolated environment, consider using Docker. It allows you to package your application with all its dependencies, ensuring consistency across different setups. SecureSpend card
Virtual Environment Naming: To avoid confusion, name your virtual environments clearly, especially if you have multiple projects.
Best Regards
esther598

3 Likes