The repository includes a ready-to-use Docker configuration that lets you run the Hands-On ML notebooks without installing any Python dependencies on your host machine. All you need is Docker and docker-compose. The container is based onDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/ageron/handson-ml3/llms.txt
Use this file to discover all available pages before exploring further.
continuumio/miniconda3 and runs the same homl3 conda environment used for local installation, so your notebooks will behave identically.
Prerequisites
Install Docker and Docker Compose for your platform if you do not have them already. Some familiarity with Docker is helpful but is not required to run the notebooks.Prepare the image
You have two options: pull the prebuilt image from Docker Hub, or build it yourself.- Pull from Docker Hub
- Build yourself
This downloads roughly 1.9 GB of compressed data and is the fastest way to get started:
This is the CPU-only image. For GPU support, pull
ageron/handson-ml3:latest-gpu instead. See the GPU section below.Run the notebooks
From thedocker subdirectory of the cloned repository, start the Jupyter server:
jupyter_notebook_config.py, go to localhost:8888 instead.
The server runs with the notebooks directory mounted as a volume, so any changes you make in the browser are saved back to your local files.
To stop the server, press Ctrl-C in the terminal.
docker-compose.yml overview
The includeddocker-compose.yml configures the container with the following defaults:
- Port 8888 — Jupyter Notebook/Lab
- Port 6006 — TensorBoard
- Volume — the project directory is mounted into the container, so notebook changes persist on your host machine
Running additional commands inside the container
While the Jupyter server is running, open a bash shell inside the container:nbdiff to compare notebook versions, or run any other command in the homl3 environment.
Using make (optional)
If you havemake installed, you can use it as a shorthand for common docker-compose commands. For example:
Makefile in the docker directory for the full list of available targets.
GPU support on Linux
GPU acceleration inside Docker requires Linux and an NVIDIA GPU with Compute Capability 3.5 or higher.Install the NVIDIA driver and container toolkit
Download and install the latest NVIDIA driver for your card from nvidia.com.For Docker 19.03 and above, install
nvidia-container-toolkit. For earlier Docker versions, install nvidia-docker2 instead. See NVidia Docker support for instructions.Edit docker-compose.yml for GPU
Open
docker/docker-compose.yml in your editor and make two changes:- Replace
dockerfile: ./docker/Dockerfilewithdockerfile: ./docker/Dockerfile.gpu - Replace
image: ageron/handson-ml3:latestwithimage: ageron/handson-ml3:latest-gpu
deploy section:Running with docker run (older docker-compose)
If your docker-compose version is earlier than 1.28, usedocker run directly. For Docker 19.03 and above:
--gpus all with --runtime=nvidia.
When you are done and want to remove the container (this does not remove the image or your notebooks):