Windows 10

Tensorflow 2 Installation

*Step 1-3 can be skipped if python3 has been installed.

1) Install the Microsoft Visual C++ Redistributable for Visual Studio 2015, 2017, and 2019.

2) Enable longpath for windows.

3) Install 64-bit python3.

4) Create virtual environment:

python -m venv --system-site-packages .\venv #Create a new virtual environment by choosing a Python interpreter and making a .\venv directory to hold it

> .\venv\Scripts\activate # Activate the virtual environment

> pip install --upgrade pip # upgrade pip in virtual environment

> pip list # show packages installed within the virtual environment

> deactivate # Deactivate virtual environment. don't exit until you're done using TensorFlow


5) Install Tensorflow via pip:

> pip install --upgrade tensorflow

> python -c "import tensorflow as tf;print(tf.reduce_sum(tf.random.normal([1000, 1000])))" # verifying installation


6) GPU setup:

  • Install NVIDIA GPU driver: CUDA 11 requires > 450.x (* can skip this as CUDA toolkit includes GPU driver)

  • Install CUDA Toolkit: Tensorflow 2.4.0 supports CUDA 11.0 (Tensorflow 2.3 supports 10.2)

  • Download cuDNN that matches with the CUDA version, and move those files (lib, bin, include) into the CUDA folder.

  • Add the CUDA®, CUPTI, and cuDNN installation directories to the %PATH% environmental variable.


SET PATH=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.0\bin;%PATH%

SET PATH=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.0\extras\CUPTI\lib64;%PATH%

SET PATH=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.0\include;%PATH%


** Note, use import tensorflow.compat.v1 as tf. instead of import tensorflow as tf. for tensorflow 1.x code.