How do I use TensorFlow GPU?

Guruku picture Guruku · Jul 12, 2018 · Viewed 136.5k times · Source

How do I use TensorFlow GPU version instead of CPU version in Python 3.6 x64?

import tensorflow as tf

Python is using my CPU for calculations.
I can notice it because I have an error:

Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2

I have installed tensorflow and tensorflow-gpu.

How do I switch to GPU version?

Answer

Ashwel picture Ashwel · Jul 12, 2018

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:

  1. Uninstall your old tensorflow
  2. Install tensorflow-gpu pip install tensorflow-gpu
  3. Install Nvidia Graphics Card & Drivers (you probably already have)
  4. Download & Install CUDA
  5. Download & Install cuDNN
  6. Verify by simple program

from tensorflow.python.client import device_lib print(device_lib.list_local_devices())