Installation¶
In order to get you up and running for hands-on learning experience, we need to set you up with an environment for running Python, Jupyter notebooks, the relevant libraries, and the code needed to run the book itself.
Installing Miniconda¶
The simplest way to get going will be to install
Miniconda. The Python
3.x version is required. You can skip the following steps if conda has
already been installed. Download the corresponding Miniconda sh file
from the website and then execute the installation from the command line
using sh <FILENAME> -b. For macOS users:
# The file name is subject to changes
sh Miniconda3-latest-MacOSX-x86_64.sh -b
For Linux users:
# The file name is subject to changes
sh Miniconda3-latest-Linux-x86_64.sh -b
Next, initialize the shell so we can run conda directly.
~/miniconda3/bin/conda init
Now close and re-open your current shell. You should be able to create a new environment as following:
conda create --name d2l -y
Downloading the D2L Notebooks¶
Next, we need to download the code of this book. You can click the “All
Notebooks” tab on the top of any HTML page to download and unzip the
code. Alternatively, if you have unzip (otherwise run
sudo apt install unzip) available:
mkdir d2l-en && cd d2l-en
curl https://d2l.ai/d2l-en.zip -o d2l-en.zip
unzip d2l-en.zip && rm d2l-en.zip
Now we will want to activate the d2l environment and install
pip. Enter y for the queries that follow this command.
conda activate d2l
conda install python=3.7 pip -y
Installing the Framework and the d2l Package¶
We also install the d2l package that encapsulates frequently used
functions and classes in this book.
pip install -U d2l
Once they are installed, we now open the Jupyter notebook by running:
jupyter notebook
At this point, you can open http://localhost:8888 (it usually opens
automatically) in your Web browser. Then we can run the code for each
section of the book. Please always execute conda activate d2l to
activate the runtime environment before running the code of the book or
updating the deep learning framework or the d2l package. To exit the
environment, run conda deactivate.
GPU Support¶
Exercises¶
Download the code for the book and install the runtime environment.