# How to Use GitHub Codespaces for the AI for Beginners Course

> Learn to use GitHub Codespaces for the AI for Beginners course. Get a pre-configured cloud dev environment in your browser instantly. No local setup needed.

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

---

**GitHub Codespaces provides a pre-configured cloud development environment that lets you run the Microsoft AI for Beginners curriculum immediately in your browser without installing Python, Conda, or Jupyter locally.**

The **microsoft/AI-For-Beginners** repository includes a complete `.devcontainer` definition that automatically provisions a reproducible development environment with all machine learning dependencies pre-installed. This eliminates local setup friction and ensures every learner works with identical versions of TensorFlow, PyTorch, and other libraries. Using **Codespaces for AI for Beginners** requires only a GitHub account and a web browser.

## Why Use Codespaces for This Course?

Traditional local setup for AI coursework involves managing complex dependency chains across operating systems. The repository's devcontainer configuration, defined in [`.devcontainer/devcontainer.json`](https://github.com/microsoft/AI-For-Beginners/blob/main/.devcontainer/devcontainer.json), automates the installation of Miniconda, Jupyter extensions, and the specific Python packages listed in [`.devcontainer/environment.yml`](https://github.com/microsoft/AI-For-Beginners/blob/main/.devcontainer/environment.yml).

Because the environment is defined as code, you avoid "works on my machine" inconsistencies. The container includes everything from OpenCV to Keras, ensuring that notebooks in `lessons/3-NeuralNetworks/` and other modules execute identically for every student.

## Prerequisites

Before launching your environment, ensure you have:

- A GitHub account with Codespaces access (the free tier includes a limited number of compute hours per month)
- A modern web browser
- Optional: A fork of the repository if you want to persist personal modifications

## Step-by-Step: Launching Your Codespace

Follow the workflow documented in [`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) and summarized in [`AGENTS.md`](https://github.com/microsoft/AI-For-Beginners/blob/main/AGENTS.md):

1. Navigate to the **microsoft/AI-For-Beginners** repository on GitHub
2. Click the **Code** button, then select the **Codespaces** tab
3. Click **Create codespace on main**
4. Wait for the container build to complete (this pulls the base image and runs the Conda environment creation script)

Once the VS Code interface loads in your browser, the terminal shows a fully configured Linux environment with all dependencies ready.

## Understanding the DevContainer Configuration

The heart of the setup lies in two key files. The [`.devcontainer/devcontainer.json`](https://github.com/microsoft/AI-For-Beginners/blob/main/.devcontainer/devcontainer.json) file defines the container orchestration:

```json
{
  "name": "AI-For-Beginners",
  "dockerFile": "Dockerfile",
  "settings": {
    "terminal.integrated.shell.linux": "/bin/bash"
  },
  "extensions": [
    "ms-python.python",
    "ms-toolsai.jupyter"
  ],
  "postCreateCommand": "conda env create -f .devcontainer/environment.yml && conda activate ai4beg"
}

```

The [`.devcontainer/environment.yml`](https://github.com/microsoft/AI-For-Beginners/blob/main/.devcontainer/environment.yml) file specifies the exact Conda packages installed during creation, including TensorFlow, PyTorch, Keras, and OpenCV. This declarative approach ensures that when you open any notebook—such as `lessons/3-NeuralNetworks/03-Perceptron/Perceptron.ipynb`—all imports resolve without additional `pip install` commands.

## Running Jupyter Notebooks in Codespaces

After the container initializes, start the Jupyter server:

```bash
conda activate ai4beg
jupyter lab

```

The VS Code interface automatically forwards port 8888 and opens a preview pane displaying JupyterLab. Alternatively, use `jupyter notebook` if you prefer the classic interface.

Navigate to the `lessons/` directory and open any `.ipynb` file. Execute cells directly in the browser; the Python kernel runs inside the container with access to all pre-installed GPU-accelerated libraries (if running on a GPU-enabled machine).

## Executing Notebooks Programmatically

For validation or continuous integration workflows, run notebooks from the terminal without the UI:

```bash
jupyter nbconvert --to notebook --execute lessons/5-NLP/18-Transformers/TransformersPyTorch.ipynb --output executed.ipynb

```

This command renders the notebook and executes all cells, saving the output to `executed.ipynb`.

## Customizing Your Environment

Advanced users can modify the Codespace configuration by editing [`.devcontainer/devcontainer.json`](https://github.com/microsoft/AI-For-Beginners/blob/main/.devcontainer/devcontainer.json) before rebuilding the container. For example, you might add GPU support by changing the Docker image to a CUDA-enabled base or install additional VS Code extensions for specific debugging needs.

Changes to the configuration require rebuilding the Codespace via the Command Palette (**Codespaces: Rebuild Container**).

## Summary

- **GitHub Codespaces** hosts the complete AI for Beginners environment in the cloud, requiring zero local installations
- The **[`.devcontainer/devcontainer.json`](https://github.com/microsoft/AI-For-Beginners/blob/main/.devcontainer/devcontainer.json)** file automates setup of Miniconda, Python dependencies, and Jupyter extensions
- Launch via **Code → Codespaces → Create codespace on main** and wait for the build to complete
- Run **`conda activate ai4beg`** followed by **`jupyter lab`** to start working with lesson notebooks
- All changes persist to your GitHub repository, enabling seamless collaboration and version control

## Frequently Asked Questions

### Do I need to install Python or Conda on my local machine to use Codespaces?

No. The Codespace provisions a cloud-hosted Linux container that includes Miniconda and all required Python packages. You only need a web browser to access the full development environment.

### How long does it take to build the Codespace for AI for Beginners?

Initial creation typically takes 2–5 minutes as the container pulls the base image and executes the `postCreateCommand` to install packages from [`.devcontainer/environment.yml`](https://github.com/microsoft/AI-For-Beginners/blob/main/.devcontainer/environment.yml). Subsequent launches of the same Codespace resume in seconds.

### Can I use the free GitHub tier for this course?

Yes. GitHub provides a monthly allotment of free Codespaces hours sufficient for completing the AI for Beginners curriculum. Monitor your usage in GitHub Settings to avoid exceeding the limit.

### Where are my notebook changes saved when working in a Codespace?

All file modifications occur within the container but sync automatically to the repository. You can commit and push changes directly from the VS Code interface, or they will persist in the Codespace until you delete it.