- 1 year ago
How to get tensorflow-gpu v2 working on Windows with NVidia GPU
Comment
1 / 1
To get TensorFlow-GPU v2 working on Windows with an NVIDIA GPU, you need to follow these steps:
Install CUDA Toolkit:
- Visit the NVIDIA Developer website (https://developer.nvidia.com/cuda-downloads) and download the CUDA Toolkit that matches your GPU model and Windows version.
- Run the CUDA Toolkit installer and follow the instructions to install it.
Install cuDNN:
- Register for a free NVIDIA Developer account (https://developer.nvidia.com/).
- Download the cuDNN library for Windows from the cuDNN download page (https://developer.nvidia.com/cudnn).
- Extract the downloaded cuDNN package and copy the files (
cudnn.h
,cudnn.lib
,cudnn64_*.dll
) to the CUDA Toolkit installation directory.
Install Anaconda:
- Download and install Anaconda for Windows from the Anaconda website (https://www.anaconda.com/products/individual).
- Follow the installation instructions to set up Anaconda.
Create a new Anaconda environment:
- Open the Anaconda Prompt (from the Start menu) as administrator.
- Create a new conda environment for TensorFlow-GPU by running the following command:lua
conda create -n tf-gpu python=3.8
- Activate the new environment:
conda activate tf-gpu
Install TensorFlow-GPU:
- Install TensorFlow-GPU within the activated conda environment:
conda install tensorflow-gpu
- Install TensorFlow-GPU within the activated conda environment:
Verify the installation:
- Launch Python within the conda environment:
python
- Import TensorFlow and verify that it detects and utilizes your GPU:python
import tensorflow as tf
print(tf.config.list_physical_devices('GPU'))
- Launch Python within the conda environment:
If the GPU information is displayed correctly, then TensorFlow-GPU is installed and configured successfully on your Windows system.
Remember to activate the conda environment (conda activate tf-gpu
) whenever you want to use TensorFlow-GPU in your projects.
Please note that you may need to adjust the CUDA Toolkit and cuDNN versions depending on the specific requirements of your NVIDIA GPU and TensorFlow-GPU version. Refer to the TensorFlow-GPU documentation for compatibility details.