# How to Run the Code in Microsoft AI-For-Beginners: 4 Setup Methods Explained

> Learn how to run the code in Microsoft AI-For-Beginners using 4 setup methods: local Jupyter, Docker, GitHub Codespaces, or cloud GPUs for fast AI learning.

- Repository: [Microsoft/AI-For-Beginners](https://github.com/microsoft/AI-For-Beginners)
- Tags: how-to-guide
- Published: 2026-08-24

---

**Clone the repository, create the Conda environment from [`environment.yml`](https://github.com/microsoft/AI-For-Beginners/blob/main/environment.yml), and launch Jupyter locally—or use Docker, GitHub Codespaces, or cloud GPUs for GPU-accelerated lessons.**

The Microsoft **AI-For-Beginners** repository delivers a comprehensive machine-learning curriculum as Jupyter notebooks, Python scripts, and a Vue-based quiz application. Whether you prefer local development, containerized environments, or cloud execution, the repository provides multiple pathways to run the code with reproducible dependencies.

## Prerequisites: The AI-For-Beginners Environment File

All execution methods rely on **[`environment.yml`](https://github.com/microsoft/AI-For-Beginners/blob/main/environment.yml)** at the repository root. This file pins exact versions of Python 3.8+, scientific libraries (NumPy, SciPy, scikit-learn, OpenCV), deep-learning frameworks (PyTorch, TorchVision, TorchText, TorchData), and visualization tools (Matplotlib, ipywidgets). Creating this environment ensures your runtime matches the curriculum exactly.

## Method 1: Local Conda Setup (Recommended)

The most straightforward approach uses **conda** to replicate the author's environment.

### Step 1: Clone and Create Environment

```bash
git clone https://github.com/microsoft/AI-For-Beginners.git
cd AI-For-Beginners
conda env create --name ai4beg --file environment.yml
conda activate ai4beg

```

### Step 2: Launch Jupyter

```bash
jupyter notebook

```

This opens `http://localhost:8888` in your browser. Navigate to the `lessons/` directory and open any `.ipynb` file. Notebooks in `lessons/*/` are self-contained and download datasets lazily on first execution.

### Alternative: VS Code with Python Extension

```bash
code .

```

VS Code detects the Python environment and prompts you to select the `ai4beg` interpreter for IntelliSense and debugging.

## Method 2: VS Code Dev Containers (Docker)

For a containerized, reproducible workspace without manual dependency management:

1. Install Docker Desktop and VS Code with the Remote Containers extension.
2. Open the repository folder:

```bash
code .

```

3. When prompted, click **"Reopen in Container"**. VS Code builds the container from `.devcontainer/` configuration and mounts your workspace with all dependencies pre-installed.

This method is ideal if you want to avoid polluting your local Python installation or need to switch between projects with conflicting dependencies.

## Method 3: GitHub Codespaces (Cloud Development)

The repository includes a **GitHub Codespaces** entry point for zero-installation development:

1. Navigate to the repository on GitHub.
2. Click **Code → Codespaces → Create codespace on main**.
3. A pre-configured Jupyter server launches in your browser with the [`environment.yml`](https://github.com/microsoft/AI-For-Beginners/blob/main/environment.yml) dependencies already resolved.

This runs in Microsoft's cloud infrastructure without consuming local resources.

## Method 4: Cloud GPU Platforms (For Deep Learning Lessons)

GPU-intensive lessons—such as CNN training in `lessons/4-Computer-Vision/` or transformer fine-tuning—require CUDA-capable hardware. The repository supports three cloud platforms:

### Azure Data Science VM

```bash

# After provisioning a DSVM with GPU:

ssh user@ds_vm_ip
git clone https://github.com/microsoft/AI-For-Beginners.git
cd AI-For-Beginners
conda env create --name ai4beg --file environment.yml
conda activate ai4beg
jupyter notebook --ip=0.0.0.0 --no-browser

```

Forward port 8888 via SSH tunnel to access the notebook interface locally.

### Google Colab

1. Open [colab.research.google.com](https://colab.research.google.com).
2. Execute in a cell:

```python
!git clone https://github.com/microsoft/AI-For-Beginners.git
!conda env update -n base -f AI-For-Beginners/environment.yml

```

3. Upload the target `.ipynb` from `lessons/` and run.

### Azure Machine Learning

Deploy the repository as an AML notebook VM with GPU Compute Instance. The [`lessons/0-course-setup/how-to-run.md`](https://github.com/microsoft/AI-For-Beginners/blob/main/lessons/0-course-setup/how-to-run.md) file contains Azure-specific provisioning instructions.

## Method 5: Binder (No Installation)

For quick experiments without any setup, click the **Launch Binder** badge on the repository homepage or navigate directly to:

```

https://mybinder.org/v2/gh/microsoft/ai-for-beginners/HEAD

```

Binder builds a temporary environment from [`environment.yml`](https://github.com/microsoft/AI-For-Beginners/blob/main/environment.yml) and serves Jupyter. Note: Sessions time out after inactivity and lack persistent storage.

## Key Files for Running AI-For-Beginners Code

| Path | Purpose |
|------|---------|
| [`environment.yml`](https://github.com/microsoft/AI-For-Beginners/blob/main/environment.yml) | Conda environment specification with pinned dependency versions |
| [`lessons/0-course-setup/how-to-run.md`](https://github.com/microsoft/AI-For-Beginners/blob/main/lessons/0-course-setup/how-to-run.md) | Primary documentation for all execution methods |
| [`lessons/0-course-setup/setup.md`](https://github.com/microsoft/AI-For-Beginners/blob/main/lessons/0-course-setup/setup.md) | Supplementary miniconda installation guide |
| `.devcontainer/` | Docker configuration for VS Code Remote Containers |
| [`requirements.txt`](https://github.com/microsoft/AI-For-Beginners/blob/main/requirements.txt) | Pip dependencies referenced by [`environment.yml`](https://github.com/microsoft/AI-For-Beginners/blob/main/environment.yml) |
| `lessons/*/*.ipynb` | Executable lesson notebooks with embedded exercises |

## Troubleshooting Common Issues

- **Import errors**: Ensure you activated the `ai4beg` environment (`conda activate ai4beg`) before launching Jupyter.
- **GPU not detected**: Verify CUDA drivers or switch to CPU fallback in notebook settings.
- **Dataset download failures**: Check internet connectivity; notebooks cache downloads to `~/.cache/`.

## Summary

- **Clone the repository** from `https://github.com/microsoft/AI-For-Beginners.git`.
- **Create the Conda environment** using `conda env create --name ai4beg --file environment.yml` to lock dependency versions.
- **Run locally** with `jupyter notebook`, **containerize** with VS Code Dev Containers, or **deploy to cloud** via GitHub Codespaces, Azure DSVM, or Google Colab.
- **Use GPU platforms** for lessons requiring CUDA acceleration (CNNs, transformers).
- **Reference [`lessons/0-course-setup/how-to-run.md`](https://github.com/microsoft/AI-For-Beginners/blob/main/lessons/0-course-setup/how-to-run.md)** for platform-specific guidance maintained by the Microsoft curriculum team.

## Frequently Asked Questions

### Does AI-For-Beginners require a GPU to run the code?

No. Most foundational lessons run on CPU-only hardware. GPU acceleration is only necessary for deep-learning modules involving convolutional neural networks, recurrent networks, and transformer fine-tuning. The notebooks detect GPU availability automatically and gracefully degrade to CPU execution.

### What Python version does AI-For-Beginners require?

The [`environment.yml`](https://github.com/microsoft/AI-For-Beginners/blob/main/environment.yml) specifies Python 3.8 or newer. Using the Conda environment guarantees compatibility with all curriculum dependencies, including PyTorch and scientific libraries with compiled extensions.

### Can I run AI-For-Beginners notebooks in Google Colab?

Yes. Colab supports the repository with minor adaptation: clone the repo, update the base environment using [`environment.yml`](https://github.com/microsoft/AI-For-Beginners/blob/main/environment.yml), and upload individual notebooks. GPU runtimes in Colab provide free access to CUDA-capable hardware for intensive lessons.

### Where are the lesson notebooks located in the repository?

All instructional content resides under `lessons/` with subdirectories organized by topic (e.g., `1-Intro/`, `4-Computer-Vision/`). Each subdirectory contains `.ipynb` files paired with optional Python scripts and lab instructions. The `lessons/0-course-setup/` folder contains execution documentation rather than curriculum material.