TensorFlow is a Python library for high-performance numerical calculations that allows users to create sophisticated deep learning and machine learning applications. Released as open source software in 2015, TensorFlow has seen tremendous growth and popularity in the data science community.
Conda is an open source package management system and environment management system that runs on Windows, macOS, and Linux. Conda quickly installs, runs, and updates packages and their dependencies. Conda easily creates, saves, loads and switches between environments on. The Anaconda-native TensorFlow 2.0 packages are now available in the main conda repository. So, let's see how we can install TensorFlow 2.0 on Anaconda Python. This method will work on both Windows and Linux. And, if you have a CUDA capable NVIDIA GPU, you can enable GPU support as well. Step 1.Creating a New Conda Environment. Protip: use conda list to see the list of packages installed and whether they are installed with conda or pip. Install TensorFlow (including Keras) Next we will install TenslowFlow in the virtual environment you created with conda. Note: we will be using pip install instead of conda install per the TensorFlow official installation documentation. 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.
There are a number of methods that can be used to install TensorFlow, such as using pip to install the wheels available on PyPI. 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. These packages are available via the Anaconda Repository, and installing them is as easy as running “conda install tensorflow” or “conda install tensorflow-gpu” from a command line interface.
Conda activate gputensorflow. Install the ipykernel. To install the kernel, enter the following command; pip install ipykernel. Then: python –m ipykernel install -user -name gputensorflow -display-name “gputensorflow” 5. Installing Tensorflow-GPU conda install tensorflow-gpu. Anaconda installs Tensorflow-GPU and a number of libraries.
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, conda installs all the necessary and compatible dependencies for the packages as well. 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. These packages are installed into an isolated conda environment whose contents do not impact other environments.
Like other packages in the Anaconda repository, TensorFlow is supported on a number of platforms. TensorFlow conda packages are available for Windows, Linux, and macOS. The Linux packages for the 1.10.0 release support a number of Linux distributions including older distributions such as CentOS 6. This is a further benefit of the conda packages: in spite of being labeled as manylinux1-compatible (works on many versions of linux), the wheels available on PyPI support only a minimum of Ubuntu 16.04, which is much newer than many enterprise Linux installations.
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, by the command “conda install tensorflow-gpu”, these libraries are installed automatically, with versions known to be compatible with the tensorflow-gpu 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. Regardless of using pip or conda-installed tensorflow-gpu, the NVIDIA driver must be installed separately.
For many versions of TensorFlow, conda packages are available for multiple CUDA versions. For example, packages for CUDA 8.0, 9.0, and 9.2 are available for the latest release at this time, version 1.10.0. The pip packages only supports the CUDA 9.0 library. This can be important when working on systems which do not support the newer version of the CUDA libraries. Finally, because these libraries are installed via conda, users can easily create multiple environments and compare the performance of different CUDA versions.
The conda TensorFlow packages are also designed for better performance on CPUs through the use of the Intel® Math Kernel Library for Deep Neural Networks (Intel® MKL-DNN). Starting with version 1.9.0, the conda TensorFlow packages are built using the Intel® MKL-DNN library, which demonstrates considerable performance improvements. For example, Figure 1 compares the performance of training and inference on two different image classification models using TensorFlow installed using conda verses the same version installed using pip. The performance of the conda installed version is over eight times the speed of the pip installed package in many of the benchmarks.
Figure 1: Training performance of TensorFlow on a number of common deep learning models using synthetic data. Benchmarks were performed on an Intel® Xeon® Gold 6130.
Anaconda is proud of our efforts to deliver 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. As a result, our TensorFlow packages may not be available concurrently with the official TensorFlow wheels. We are, however, committed to maintaining our TensorFlow packages, and work to have updates available as soon as we can.
Interested in trying out these TensorFlow packages? After installing Anaconda or Miniconda, create a new conda environment containing TensorFlow and activate it
Or for the GPU version
TensorFlow is now installed and ready for use. For those new to TensorFlow, the tutorials offer a great place to get started.