Prevent TensorFlow from accessing the GPU?
Look at this question or this one.
To summarize, you can add this piece of code:
import os
os.environ["CUDA_VISIBLE_DEVICES"]="-1"
import tensorflow as tf
EDIT: Quoting this comment , playing with an environment variable CUDA_VISIBLE_DEVICES
is one (if not) way to go when you have a GPU tensorflow and don't want to use your graphics card at all.
You want to either export CUDA_VISIBLE_DEVICES = or alternatively virtualenv with non-GPU TensorFlow. See also: # 2175 (comment)
source to share
You can only use processors by opening a session with a GPU limit of 0:
sess = tf.Session(config=tf.ConfigProto(device_count={'GPU': 0}))
See https://www.tensorflow.org/api_docs/python/tf/ConfigProto for details .
Proof that it works for @Nicolas:
In Python, write:
import tensorflow as tf
sess_cpu = tf.Session(config=tf.ConfigProto(device_count={'GPU': 0}))
Then in the terminal:
nvidia-smi
You will see something like:
+-----------------------------------------------------------------------------+
| Processes: GPU Memory |
| GPU PID Type Process name Usage |
|=============================================================================|
| 0 24869 C /.../python 99MiB |
+-----------------------------------------------------------------------------+
Then repeat the process: In Python, write:
import tensorflow as tf
sess_gpu = tf.Session()
Then in the terminal:
nvidia-smi
You will see something like:
+-----------------------------------------------------------------------------+
| Processes: GPU Memory |
| GPU PID Type Process name Usage |
|=============================================================================|
| 0 25900 C /.../python 5775MiB |
+-----------------------------------------------------------------------------+
source to share