9951 explained code solutions for 126 technologies


python-tensorflowHow can I use Python TensorFlow with Nvidia GPUs?


Using Python TensorFlow with Nvidia GPUs

  1. Install the latest version of TensorFlow with GPU support: pip install tensorflow-gpu.
  2. Install the latest Nvidia GPU drivers and CUDA Toolkit.
  3. Verify your system has a compatible GPU.
  4. Configure the GPU environment variables:
export CUDA_VISIBLE_DEVICES=0
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:/usr/local/cuda/lib64:/usr/local/cuda/extras/CUPTI/lib64"
  1. Run Python code with TensorFlow-GPU:
import tensorflow as tf
tf.test.is_gpu_available()

# Output
True
  1. Train and evaluate models on the GPU.
  2. Monitor the GPU usage with the nvidia-smi command line tool.

Helpful links

Edit this code on GitHub