Installing TF with conda




With Conda (+pip) you can install the newest version of TensorFlow with GPU support in a single line.

conda create --name tensorflow-22 \\ 
 tensorflow-gpu=2.2 \\ 
 cudatoolkit=10.1 \\ 
 cudnn=7.6 \\ 
 python=3.8 \\ 
 pip=20.0

While the above one-line solution works great if you just want to get up and running quickly to try out some new feature of TensorFlow 2.2, if you are starting a new project using TensorFlow 2.2, then I would recommend creating an environment.yml file for your project and then installing your Conda environment as a sub-directory inside your project directory.


Create an environment.yml file in your project directory

name: null

channels: 
 - conda-forge 
 - defaults
 
dependencies: 
 - cudatoolkit=10.1 
 - cudnn=7.6 
 - nccl=2.4 
 - pip=20.0 
 - python=3.8 
 - tensorflow-gpu=2.2

Install the Conda environment inside your project directory

conda env create --prefix ./conda_tf22_env --file environment.yml --force

There are a number of benefits of using Conda (+pip) to install TensorFlow.


1. Most importantly there is no need to manually install the NVIDIA CUDA Toolkit, cuDNN, or NVIDIA Collective Communications Library (NCCL). Installing TensorFlow into a virtual Conda environment instead of installing system-wide avoids touching the system Python and allows you to have multiple versions of TensorFlow installed on your machine (if needed).


2. Secondly, if you elect to go with my preferred approach, you will also have an environment.yml that your colleagues and peers can use to rebuild your Conda environment on their machines or that you can use to re-build your Conda environment on public clouds such as AWS, GCP, Microsoft Azure.


Reference -

https://towardsdatascience.com/installing-tensorflow-bcbe6ef21213


About Author

✔ 13+ years of experience in the Software Industry; Over 6.5+ years of experience in machine learning and deep learning projects.


✔ Hands-on Data Science practitioner; a Leading team of data scientists, Python developers, UI developers, and business analysts for multi-million dollar projects


✔ Designed and developed DevOps enabled MLOPs strategy and components from scratch which had saved 80% data annotation and 40% development time for clients.

Featured Posts
Search By Tags
No tags yet.
Connect