Python 機械学習

Deactivate GPU in machine learning with TensorFlow or Keras

Deactivate GPU in machine learning with TensorFlow or Keras

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.


Deactivate GPU

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


Finally

  • If you want to deactivate GPU in Python, set environment variables


コチラもオススメ

KRSW

駆け出し機械学習エンジニア。機械学習、DB、WEBと浅く広い感じ。 Junior machine learning engineer. Not a specialist but a generalist who knows DB, WEB too.

If you felt this article is useful, please share.

にほんブログ村 IT技術ブログへ

-Python, 機械学習
-

Translate »

Copyright© ITips , 2020 All Rights Reserved.