Several years ago when I was in college, I used Matlab to study Machine Learning. I just would like to pick up Deep Learning again to catch up the AI trend. The first step is to set up the tools and environment. In this post I will share how to set up my Deep Learning environment with Anaconda and Jupyter Notebook, and then install TensorFlow.

Why Jupyter Notebook and Anaconda

Jupyter Notebook is not a pre-requisite for Deep Learning, but it is really helpful to create rich documents that contain live code, equations, visualizations and narrative text for your experiment. It is just like a white broad where you can put your idea on and continuously evolve the project code.Anaconda a platform which can help you to create virtual environments and install packages needed for data science and deep learning. As you may know, version conflict is quite normal in Python/DL world because different Deep Learning frameworks may require different projects or packages. I tried with native Python and pip environment before, but it is really a nightmare for me. With virtual environments I can install specific package versions for a particular project or a tutorial without worrying about the annoying version conflicts.

Install Anaconda and Create Virtual Environment

Download Anaconda for your platform from here. Anaconda Distribution has Conda package manager and thousands packages integrated. After installation, I created a virtual environment as below:

Setup Jupyter Notebook Kernels for Specific Environment.

A ‘kernel’ of Jupyter Notebook is a program that runs and introspects the user’s code. If you want to have multiple IPython kernels for different virtualenvs or conda environments in Jupyter, you will need to specify unique names for the kernelspecs.Please note, the default kernel and python executable file of Jupyter is listed in base environment.

Update: Use nb_conda Extension to Manage Kernels

nb_conda Provides Conda environment and package access extension from within Jupyter. This extension adds a Conda Packages item to the Kernel menu. Selecting this item displays the list of Conda packages in the environment associated with the running kernel, and the list of available packages. You can perform the same actions as in the Conda tab, but only against the current environment.

12

# Install nb_condaconda install nb_conda

Install TensorFlow

We choose TensorFlow GPU support version. Follow the instruction to install the pre-requisites.

Notes

1. Conda Install or Pip Install

Pip is focused around Python. It is a package manager that facilitates installation, upgrade, and uninstallation of python packages. But Conda is a packaging tool and installer for any software that aims to do more than what pip does; handle library dependencies outside of the Python packages as well as the Python packages themselves.

2. ModuleNotFound Error Troubleshooting

You may hit ModuleNotFoundError: No module named 'lightgbm' sometimes.Check the sys.executable in Jupyter Notebook to verify the kernel path first:Or you can check the kernel spec via command jupyter kernelspec list.