Skip to content

Latest commit

 

History

History
115 lines (73 loc) · 4.7 KB

File metadata and controls

115 lines (73 loc) · 4.7 KB

ls

TensorFlow 2 with GPU on Windows: Step-by-step instructions

How to properly install CUDA and cuDNN on Windows to use TensorFlow with GPU support

Software requirements

  • Python 3.9–3.11
  • pip version 19.0 or higher for Linux (requires manylinux2014 support) and Windows. pip version 20.3 or higher for macOS.
  • Windows Native Requires Microsoft Visual C++ Redistributable for Visual Studio 2015, 2017 and 2019

The following NVIDIA® software required for GPU support

  • NVIDIA® GPU drivers version 450.80.02 or higher.
  • CUDA® Toolkit 11.8.
  • cuDNN SDK 8.6.0.

Prerequisites

Installation

  • Cuda Toolkit

    Open the downloaded file cuda_11.8.0_522.06_windows.exe and follow the installation instructions.

    Alt text

    In the options select express installation

    Alt text

  • CUDNN

    Unzip the archive cudnn-windows-x86_64-8.9.7.29_cuda11-archive.zip and move with replace all files in the lib, include and bin folders on C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.8 with files from the corresponding archive folders:

    Alt text

    Add the following lines to your system and user $Path variable:

        C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.8
        C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.8\bin
        C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.8\include
        C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.8\lib
        C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.8\lib\x64

    Alt text

  • NVIDIA Nsight Developer Tools

    Install all the NVIDIA Nsight developer tools that we downloaded earlier

    Alt text

Verifying installation success

  • Run the following commands in a terminal

    nvcc --version # Shows CUDA version

    Alt text

    nvidia-smi # Shows the NVIDIA system management interface

    Alt text

    Caution: TensorFlow 2.10 was the last TensorFlow release that supported GPU on native-Windows. Starting with TensorFlow 2.11, you will need to install TensorFlow in WSL2, or install tensorflow or tensorflow-cpu and, optionally, try the TensorFlow-DirectML-Plugin`

    # Upgrade pip to latest version
    python -m pip install --upgrade pip
    # Anything above 2.10 is not supported on the GPU on Windows Native
    python -m pip install "tensorflow<2.11"
    # Verify the installation:
    python -c "import tensorflow as tf; print(tf.config.list_physical_devices('GPU'))"
    # If a list of GPU devices is returned, you've installed TensorFlow successfully.

    Alt text

    # If a tensor is returned, you've installed TensorFlow successfully.
    python -c "import tensorflow as tf; print(tf.reduce_sum(tf.random.normal([1000, 1000])))"

    Alt text

    🎉 Thank you for your attention! 🎉

    🔝 Back to top 🔝