Stop Installing Tensorflow Using pip for Performance Sake!

If you aren’t already using conda, I recommend that you start as it makes managing your
c
comments

By Michael Nguyen, Software and Machine Learning Engineer

Stop installing Tensorflow using pip! Use conda instead. If you don’t know what conda is, it’s an open source package and environment management system that runs cross-platform. So it works on Mac, Windows, and Linux. If you aren’t already using conda, I recommend that you start as it makes managing your
Chart taken from https://www.anaconda.com/blog/developer-blog/tensorflow-in-anaconda/
 

As you can see, the performance of the conda installation can give over 8X the speed boost compared to the pip installation. That is great for people who still frequently use their CPU for training and inferencing. As a Machine Learning Engineer, I use my CPU to run a test train on my code before pushing it to a GPU enabled machine. This increase in speed will help me iterate faster. I also do a lot of inference on a CPU when I can, so this will help my models performance.

Not only does the MKL library speed up your Tensorflow packages, it also speeds up other widely used libraries like NumPy, NumpyExr, SciPy, and Scikit-Learn! See how you can get that set up from links below.

Simpler install for the GPU version

The conda install will automatically install the CUDA and CuDNN libraries needed for GPU support. The pip install will require you to do that manually. Everybody likes a one step process, especially when it comes to downloading libraries.

Quick Start

 
So I hope those two reasons are good enough for you to switch over to using conda. If you’re convinced here are the steps to get started.

pip uninstall tensorflow


Install Anaconda or Miniconda if you haven’t already. Miniconda is just installing conda and it’s dependencies while Anaconda will pre-install a lot of packages for you. I prefer Miniconda to get started. After conda is installed try this.

conda install tensorflow


Replace tensorflow with tensorflow-gpu if you want the GPU enabled version.

Besides being faster and simpler to use for Tensorflow, conda provides other sets of tools that makes it so much easier to integrate into your workflow. One of my favorites is their virtual environment features. You can read more about conda and tensorflow here. And more on the MKL optimization here. Hope this helps and as always, thanks for reading!

 
Follow me for tips, stories, and content on all things software and machine learning.

Catch me on the web: www.learnedvector.com

 
Bio: Michael Nguyen is a Software and Machine Learning Engineer in A.I. Voice Assistant space. Teacher of Humans and Machines. Here to make complex things simple.

Original. Reposted with permission.

Related:

  • Setting up your AI Dev Environment in 5 Minutes
  • Deep Learning Framework Power Scores 2018
  • Ultimate Guide to Getting Started with TensorFlow