Jump to content

Connect Leeroopedia MCP: Equip your AI agents to search best practices, build plans, verify code, diagnose failures, and look up hyperparameter defaults.

Environment:Fastai Fastbook Python FastAI Environment

From Leeroopedia


Knowledge Sources
Domains Deep_Learning, Computer_Vision, NLP, Tabular
Last Updated 2026-02-09 17:00 GMT

Overview

Conda/pip environment with Python >= 3.6, PyTorch >= 1.6, and fastai >= 2.0 for running all Fastbook notebook exercises.

Description

This environment provides the core runtime for the entire Practical Deep Learning for Coders (fastbook) course. It is defined via both a Conda `environment.yml` and a pip `requirements.txt`. The stack centers on the fastai library (v2+), which wraps PyTorch and provides high-level APIs for computer vision, NLP, tabular modeling, and collaborative filtering. Additional dependencies include `graphviz` for decision tree visualization, `ipywidgets` for interactive notebook controls, `matplotlib` for plotting, `pandas` for data manipulation, and `sentencepiece` for subword tokenization.

Usage

Use this environment for all Fastbook workflows: Image Classification, NLP Text Classification, Tabular Modeling, Collaborative Filtering, and Neural Network From Scratch exercises. It is the mandatory prerequisite for every Implementation page in the Fastai_Fastbook wiki.

System Requirements

Category Requirement Notes
OS Linux, macOS, or Windows (WSL2) Linux preferred for GPU training
Hardware CPU sufficient for most exercises GPU recommended for image/NLP training (see CUDA_GPU_Environment)
Disk 10GB+ free space For datasets downloaded via `untar_data`
Python >= 3.6 Specified in environment.yml

Dependencies

Conda Channels

  • `fastai` (primary)
  • `pytorch`
  • `defaults`

System Packages

  • `python` >= 3.6
  • `pytorch` >= 1.6
  • `torchvision`

Python Packages

  • `fastai` >= 2.0.0
  • `graphviz`
  • `ipywidgets`
  • `matplotlib`
  • `nbdev` >= 0.2.12
  • `pandas`
  • `scikit_learn`
  • `azure-cognitiveservices-search-imagesearch`
  • `sentencepiece`
  • `scipy` (imported in utils.py for clustering)
  • `requests` (used for image search functions)

Credentials

The following environment variables may be required:

  • `AZURE_SEARCH_KEY`: Microsoft Azure Bing Image Search API key (required only for Ch2 image search via `search_images_bing`).

Quick Install

# Option 1: Conda (recommended)
conda env create -f environment.yml
conda activate fastbook

# Option 2: Pip
pip install fastai>=2.0.0 graphviz ipywidgets matplotlib nbdev>=0.2.12 pandas scikit_learn azure-cognitiveservices-search-imagesearch sentencepiece

Code Evidence

Conda environment definition from `environment.yml:1-12`:

name: fastbook
channels:
    - fastai
    - pytorch
    - defaults
dependencies:
  - python>=3.6
  - pytorch>=1.6
  - torchvision
  - pip
  - pip:
    - -r requirements.txt

Pip requirements from `requirements.txt:1-9`:

fastai>=2.0.0
graphviz
ipywidgets
matplotlib
nbdev>=0.2.12
pandas
scikit_learn
azure-cognitiveservices-search-imagesearch
sentencepiece

Azure API key retrieval from `02_production.md:146`:

key = os.environ['AZURE_SEARCH_KEY']

Imports in `utils.py:1-8`:

from fastai.vision.all import *
from nbdev.showdoc import *
from ipywidgets import widgets
from pandas.api.types import CategoricalDtype
import matplotlib as mpl
import json

Common Errors

Error Message Cause Solution
`ModuleNotFoundError: No module named 'fastai'` fastai not installed `pip install fastai>=2.0.0` or use the Conda environment
`ModuleNotFoundError: No module named 'azure'` Azure SDK not installed `pip install azure-cognitiveservices-search-imagesearch`
`KeyError: 'AZURE_SEARCH_KEY'` API key not set `export AZURE_SEARCH_KEY=your_key` or use `search_images_ddg` instead
`ModuleNotFoundError: No module named 'graphviz'` graphviz not installed `pip install graphviz` and install system graphviz package

Compatibility Notes

  • All platforms: The Conda environment file uses channels `fastai`, `pytorch`, `defaults` in that order. Ensure these channels are available.
  • Image search: The Azure Bing Image Search API (`search_images_bing`) requires a paid API key. The alternative `search_images_ddg` function uses DuckDuckGo and requires no key.
  • GPU acceleration: While not strictly required, a CUDA-capable GPU is strongly recommended for chapters involving model training. See the separate CUDA_GPU_Environment page.
  • Jupyter: All chapters are designed to run in Jupyter notebooks. See Jupyter_Notebook_Environment.

Related Pages

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment