Dive into Deep Learning
Table Of Contents
Dive into Deep Learning
Table Of Contents

Getting started with Gluon

This section discusses how to download the codes in this book and to install the software needed to run them. Although skipping this section will not affect your theoretical understanding of sections to come, we strongly recommend that you get some hands-on experience. We believe that modifying codes and observing their results greatly enhances the benefit you can gain from the book.


For simplicity we recommend Conda, a popular Python package manager to install all libraries.

  1. Download and install Miniconda, based on your operating system. Make sure to add Anaconda to your PATH environment variable.
  2. Download the tarball containing the notebooks from this book. This can be found at https://www.diveintodeeplearning.org/d2l-en-1.0.zip. Alternatively feel free to clone the latest version from GitHub.
  3. Unzip the the tarball and move its contents to a folder for the tutorials.

GPU Support

By default MXNet is installed without GPU support to ensure that it will run on any computer (including most laptops). If you should be so lucky to have a GPU enabled computer, you should modify the Conda environment to download the CUDA enabled build. Obviously you need to have the appropriate drivers installed, such as CUDA, CUDNN and TensorRT, if appropriate.

Next update the environment description in environment.yml. Replace mxnet by mxnet-cu92 or whatever version of CUDA that you’ve got installed. For instance, if you’re on CUDA 8.0, you need to replace mxnet-cu92 with mxnet-cu80. You should do this before creating the Conda environment. Otherwise you will need to rebuild it later.


  1. Create and activate the environment using Conda. For convenience we created an environment.yml file to hold all configuration.
  2. Activate the environment.
  3. Open Jupyter notebooks to start experimenting.
conda env create -f environment.yml
activate gluon
jupyter notebook

Alternatively, you can open jupyter-lab instead of jupyter notebook. This will give you a more powerful Jupyter environment. If your browser integration is working properly, starting Jupyter will open a new window in your browser. If this doesn’t happen, go to http://localhost:8888 to open it manually.

Some notebooks will automatically download the data set and pre-training model. You can adjust the location of the repository by overriding the MXNET_GLUON_REPO variable.

Linux and macOS

Installation for both is very similar. We give a description of the workflow for Linux.

  1. Install Miniconda (and accepting the license terms), as available at https://conda.io/miniconda.html
  2. Update your shell by source ~/.bashrc (Linux) or source ~/.bash_profile (macOS) or open a new terminal.
  3. Download the tar file with all code and unpack it.
  4. Create the Conda environment
  5. Activate it and start Jupyter
sh Miniconda3-latest-Linux-x86_64.sh

mkdir d2l-en && cd d2l-en
curl https://www.diveintodeeplearning.org/d2l-en-1.0.zip -o d2l-en.zip
unzip d2l-en.zip && rm d2l-en.zip

conda env create -f environment.yml
source activate gluon
jupyter notebook

The main difference between Windows and other installations is that for the former you use activate gluon whereas for Linux and macOS you use source activate gluon.

conda env update -f environment.yml
activate gluon

Updating Gluon

In case you want to update the repository, if you installed a new version of CUDA and (or) MXNet, you can simply use the Conda commands to do this. As before, make sure you update the packages accordingly.

conda env update -f environment.yml


Download the code for the book and install the runtime environment. If you encounter any problems during installation, please scan the QR code to take you to the FAQ section of the discussion forum for further help.

Discuss on our Forum