Call + (44) 0843 289 4539

0
  • No products in the cart.

Set up Anaconda, Jupyter Notebook, Tensorflow for Deep Learning

Data Science is one of those disciplines of Computer Science where there is just a whole lot going on, loads to learn and where things just don’t always seem to work the way you would expect.

There are a multitude of tools and frameworks one needs to learn and become familiar with in order to try and get the best out of them. You can spend and waste countless hours learning how to install and configure the various data science packages like Numpy, Matplotlib, spacy, nltk etc. , trying to solve the various package dependencies.

This is where Anaconda becomes your best friend and eases the frustration of getting started. The Anaconda distribution comes with more than 1000 data packages and includes the conda package and virtual environment manager. Check out Getting Started with Python and Artificial Intelligence on Ubuntu to find out how to install Anaconda on your Ubuntu desktop.

In this post, we’ll explore how to get started with Tensorflow & Keras using Jupyter Notebook to get started with Deep Learning.

Jupyter Notebook is really helpful to start getting familiar with whatever you want to try achieve in your data science project.

I, personally recommend using Anaconda Navigator, the desktop Graphical User Interface (GUI) that includes applications like RStudio, Jupyter Notebook, JupyterLab, Spyder, Glue and Orange and it has detailed documentation available and an excellent community of users that can provide additional support.

I recommend reading Hands-On Data Science with Anaconda , because it will provide you with a thorough grounding on Anaconda to get you up and running in no time.

Create a new Conda Environment

Although, I recommend using the Anaconda GUI to create and configure your data science environments. I also realise that developers will often prefer to use the terminal window to do so.

The following is the process I go through to create new environments using the terminal window.

Once you have installed Anaconda, all your environments will be located in

Shell

Before creating a new environment it’s always worth checking that you have the latest version conda installed

Shell

We can now create a new environment, by either using the default configured python version or a particular version of python

Shell

Information

At the time of writing Tensorflow is not compatible with Python 3.7, so if you would like to use Tensorflow in a Python3 project you will need to use Python 3.6

After your new environment has been created you will need to activate it.

Shell

Once activated you can check the configuration of your environment and explore what packages have been installed

Shell

You can now install any package you like using the terminal commands. In this instance we will install Numpy.

Shell

You can also explore to see what other environments you have created

Shell

If ever you need to delete an environment you can do so using

Shell

Install TensorFlow

There are a number of ways you can install TensorFlow and you can do so by making use of pip install . However, installing TensorFlow using conda packages offers a number of benefits, including a complete package management system, wider platform support, a more streamlined GPU experience, and better CPU performance.

One key benefit of installing TensorFlow using conda rather than pip is a result of the conda package management system. When TensorFlow is installed using conda, all the necessary and compatible dependencies for the packages are also installed. This is done automatically; users do not need to install any additional software via system packages managers or other means.

Additionally, any of the 1,400+ professionally built packages in the Anaconda repository can be installed alongside TensorFlow to provide a complete data science environment.

Information

These packages are installed into an isolated conda
environment whose contents do not impact other environments.  

You can install into you existing environment using

Shell

The -n is a switch to enable you to name the environment you would like to install a package too.

If you are already in your activated environment you can simply use

Shell

If you want to use the GPU package of tensorflow you can use

Shell

Many of the functions in TensorFlow can be accelerated using NVIDIA GPUs. The gain in acceleration can be especially large when running computationally demanding deep learning applications.

When installing TensorFlow using pip, the CUDA and CuDNN libraries needed for GPU support must be installed separately, adding a burden on getting started.

When the GPU accelerated version of TensorFlow is installed using conda these libraries are installed automatically, with versions known to be compatible with the tensorflowgpu package.

Furthermore, conda installs these libraries into a location where they will not interfere with other instances of these libraries that may have been installed via another method.

Advice

Regardless of using pip or conda-installed tensorflow -gpu
the NVIDIA driver must be installed separately.

To verify you have successfully installed Tensorflow, you can simply invoke you python shell in your environment.

Shell

Then create a simple tensorflow Hello World application

Python

If you see Hello, TensorFlow! printed then it confirms that TensorFlow is installed correctly.

Advice

Tensorflow 1.12 includes an implementation of the Keras API, known as tf.keras.

Previously Keras had to be installed as a secondary package, but it is now integrated within the main Tensorflow package.

The Tensorflow package available in the Anaconda-Navigator is Tensorflow 1.10 , it is, therefore, a better option to install using the terminal command because this will install Tensorflow 1.12

Installing Jupyter Notebook

If you’re using anaconda-navigator you can easily install Jupyter Notebook using the convenient UI , which you can also access a number great Data Science specific applications

If you create your new environment using anaconda-navigator Jupyter Notebook is installed by default.

However, when creating an environment using the terminal you will need to an additional step to install Jupyter Notebook

Shell

Once the installation is complete you can now start Jupyter Notebook

Shell

This will open a browser session and you will see your Jupyter Notebook available

Verify your Environment

You can now verify you have your environment configured correctly by creating a new python notebook and writing a simple application to verify the details.

Python

Your Jupyter Notebook should respond with

Python

Summary

Anaconda provides a simpler, faster experience using the excellent TensorFlow library. It takes significant time and effort to add support for the many platforms used in production, and to ensure that the accelerated code is still stable and mathematically correct.

Follow Me

Gary Woodfine

Helps businesses by improving their technical proficiencies and eliminating waste from the software development pipelines.

A unique background as business owner, marketing, software development and business development ensures that he can offer the optimum business consultancy services across a wide spectrum of business challenges.
Follow Me
Advertisements