Setting a deep learning working environment

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 

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.   

Setup overview 

The setup process will be simply composed of three main steps:  

  1. Download Anaconda 
  2. Install Anaconda 
  3. 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)

$ bash Anaconda3-5.2.0-Linux-x86_64.sh

You should receive the following output:  

Welcome to Anaconda3 5.2.0 
In order to continue the installation process, please review the license 
agreement. 
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:

Do you approve the license terms? [yes|no]

Next, you will be asked about the location of the installation. It is ok if you accept the default location by pressing ENTER: 

Anaconda3 will now be installed into this
location:/home/arturo/anaconda3   
   - Press ENTER to confirm the location
   - Press CTRL-C to abort the installation
   - Or specify a different location below[/home/arturo/anaconda3] >>>

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:

... 
installation finished. 
Do you wish the installer to prepend the Anaconda3 install location 
to PATH in your /home/arturo/.bashrc ? [yes|no] 
[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:

Prepending PATH=/home/arturo/anaconda3/bin to PATH in
/home/arturo/.bashrc 
A backup will be made to: /home/arturo/.bashrc-anaconda3.bak
… 

To test the installation we will run the following commands:

$ source ~/.bashrc 
$ conda list

You should receive an output with all the packages you have available through the Anaconda installation 

# packages in environment at
/home/arturo/anaconda3:#_ipyw_jlab_nb_ext_conf        0.1.0           
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:

$ conda create –-name ai_fun

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:

$ source activate ai_fun

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.  

 

Arturo Amador

Arturo Amador

Senior Data Scientist
arturo.amador@acando.no

 

Om bloggeren:
Arturo er en data scientist med en doktorgrad i fysikk fra NTNU. Arturo's tekniske ekspertise ligger innen datadrevet analyse, statistikk, big data, personvern, og kunstig intelligens, slik som deep learning. Arturo har opparbeidet seg erfaring innen mobilitetsanalyse med ansvar for flere prosjekt, blant annet innen kollektiv transport, byplanlegging, turisme og forsking.

comments powered by Disqus