Setting a deep learning working environment
Deep learning is fun! Lately, there is a lot of excitement around Artificial Intelligence (AI), machine learning (ML) and deep learning (DL). In this blog entry, we will help you get started with deep learning. We hope you will find this blog easy to read, replicate and above all, we hope you will find it inspirational!
We will split the tutorial series in several parts. In the first part, we will work on setting up an environment where we play and work with DL techniques. This is necessary to be able to run the second part of the tutorial where we will go through the “Hello World” of DL.
Getting started with DL does not mean that you will have to go back to NTNU and start a degree in computer science. It does not mean that you will spend the next two years studying the mathematics of DL! What it will mean for us is to download the python distribution Anaconda and set it up. Once we are finished with the setup, we will be able to get our hands dirty with DL in the second part of the tutorial, where we will build cool and exciting things!
The instructions we will use in this tutorial are suitable for Windows, Mac OS, and Linux operating systems. I will demonstrate them on Linux, my personal favorite.
The setup process will be simply composed of three main steps:
- Download Anaconda
- Install Anaconda
- Install deep learning libraries (Setting up an AI environment)
1. Download Anaconda
Anaconda is a free and open source distribution of the Python programming language. The distribution has a focus on data science and machine learning related applications (also on scientific computing, among others). Anaconda aims to simplify package management and deployment.
First, let’s download the distribution from Anaconda’s homepage. Here you will be able to choose the download suitable for the operating system you are using.
Once you select the version that is right for your operating system, you will need to select the python version. We will select Python 3.6:
The installer file (Anaconda3-5.2.0-Linux-x86_64.sh) is about 622 MB so it could take some time to download, depending on the speed of your connection.
2. Install Anaconda
Once the download is finished, open your terminal (ctrl+alt+t should do the trick under Ubuntu Linux), and run the following command (from the folder containing the installation file)
You should receive the following output:
In order to continue the installation process, please review the license
Please, press ENTER to continue
Of course, press enter. This will prompt you to the license agreement which you need to accept in order to continue with the installation process. You accept the agreement by typing yes:
Next, you will be asked about the location of the installation. It is ok if you accept the default location by pressing ENTER:
The setup process should now continue. It may take some time before the installation is finished. Once it is done, you will receive the following output:
Do you wish the installer to prepend the Anaconda3 install location
to PATH in your /home/arturo/.bashrc ? [yes|no]
We want to type yes so that we can use the conda command. After typing yes and pressing ENTER we will receive the following message:
A backup will be made to: /home/arturo/.bashrc-anaconda3.bak
To test the installation we will run the following commands:
$ conda list
You should receive an output with all the packages you have available through the Anaconda installation
py36he11e457_0 alabaster 0.7.10 py36h306e16b_0
anaconda 5.2.0 py36hd30a520_1…
Next, let’s set-up an Anaconda environment and make it ready for AI fun!
3. Install deep learning libraries (Setting up an AI environment)
Anaconda virtual environments allow you to keep your projects organized by python versions and packages needed. We will now create an environment we will use to install the deep learning libraries we will need. We will call this environment “ai_fun”, and we create it with the following line:
We will receive a message with information about what is downloaded, and which packages will be installed. We will also be prompted to confirm the creation of the environment. In order to confirm it, we will type y and press ENTER.
Once the conda utility is done creating the environment, we can activate it:
If you really don’t like using the terminal, another option is to use Anaconda’s very neat graphical interface. Once Anaconda’s graphical user interphase is launched, we will go to the Environments tab:
Here we will find a list of all the environments created. The environment called “base (root)” is the one that Anaconda created by default. In order to create a new environment, we simply click/tap the “Create” button,
Creating the new environment should take a few minutes. Once our new environment is created, we will proceed to install a few required libraries. The advantage of having Anaconda as our package manager is that we just need to specify the library we intend to use and Anaconda solves all the dependencies for this library. In the environment tab, we will select “Not installed” to search for “Keras” and “Matplotlib”, we will select both of them for installation and go ahead with the “Apply” button.
The installation process might take a few minutes. Once it is finished, we will install “JupyterLab”. JupyterLab is an interactive environment, ideal for data science! In our future tutorials, we will make extensive use of it.
Once the installation of JupyterLab is finished, we will have an environment ready to work with AI in our next tutorial.