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
Comments