Deactivate GPU in machine learning with TensorFlow or Keras.
When our machine learning code does not run, we may estimate program bugs.
Sometimes it is caused by library version unmatch with GPU.
So today I share how to deactivate GPU and run your code with CPU.
In order to deactivate GPU on Python, you can prohibit CUDA to use device by writing it in environment variables.
You can write below before importing Keras.
Then Python can't use GPU and run code with CPU.
import os os.environ["CUDA_VISIBLE_DEVICES"] = "-1" import keras
Set environment variables before importing Keras.
How to deactivate GPU when you use Keras on Jupyter
- If you want to deactivate GPU in Python, set environment variables