How do I use TensorFlow GPU?
Follow this tutorial Tensorflow GPU I did it and it works perfect.
Attention! - install version 9.0! newer version is not supported by Tensorflow-gpu
Steps:
- Uninstall your old tensorflow
- Install tensorflow-gpu
pip install tensorflow-gpu
- Install Nvidia Graphics Card & Drivers (you probably already have)
- Download & Install CUDA
- Download & Install cuDNN
- Verify by simple program
from tensorflow.python.client import device_lib print(device_lib.list_local_devices())
The 'new' way to install tensorflow GPU if you have Nvidia, is with Anaconda. Works on Windows too. With 1 line.
conda create --name tf_gpu tensorflow-gpu
This is a shortcut for 3 commands, which you can execute separately if you want or if you already have a conda environment and do not need to create one.
Create an anaconda environment
conda create --name tf_gpu
Activate the environment
conda activate tf_gpu
Install tensorflow-GPU
conda install tensorflow-gpu
You can use the conda environment.
First you need to install tensorflow-gpu, because this package is responsible for gpu computations. Also remember to run your code with environment variable CUDA_VISIBLE_DEVICES = 0 (or if you have multiple gpus, put their indices with comma). There might be some issues related to using gpu. if your tensorflow does not use gpu anyway, try this