Skip to content

Installation instructions

Negro Michela edited this page Aug 7, 2025 · 1 revision

Installation

This course makes extensive use of python and python packages. We want to create an Anaconda (or Miniconda) environment and install the needed packages in it. If you don't have Anaconda or Miniconda already installed, the simplest option is to install Miniconda (see next section), otherwise you can skip "Installing Miniconda" step.

Note that you can also fall the same instructions provided here.

Installing Miniconda

Visit the Miniconda website and determine the appropriate version for your system based on your Python 3.x version and machine architecture. Suppose that your Python version is 3.9 (our tested version).

  • If you are using macOS, you would download the bash script whose name contains the strings “MacOSX”, navigate to the download location, and execute the installation as follows (taking Intel Macs as an example):

     sh Miniconda3-py39_4.12.0-MacOSX-x86_64.sh -b
    
  • A Linux user would download the file whose name contains the strings “Linux” and execute the following at the download location:

     sh Miniconda3-py39_4.12.0-Linux-x86_64.sh -b
    
  • A Windows user would download and install Miniconda by following its online instructions. On Windows, you may search for cmd to open the Command Prompt (command-line interpreter) for running commands.

Next, initialize the shell so we can run conda directly.

~/miniconda3/bin/conda init

Then close and reopen your current shell.

Create the new Conda environment

You should be able to create a new environment as follows:

conda create --name d2l python=3.9 -y

Now we can activate the d2l environment:

conda activate d2l

Installing the Deep Learning Framework and the d2l Package

You can install PyTorch (the specified versions are tested at the time of writing) with either CPU or GPU support as follows:

pip install torch==2.0.0 torchvision==0.15.1

Our next step is to install the d2l package that we developed in order to encapsulate frequently used functions and classes found throughout this book:

pip install d2l==1.0.3

Clone this wiki locally