How to run Tensorflow on CPU
You can apply device_count
parameter per tf.Session
:
config = tf.ConfigProto(
device_count = {'GPU': 0}
)
sess = tf.Session(config=config)
See also protobuf config file:
tensorflow/core/framework/config.proto
You can also set the environment variable to
CUDA_VISIBLE_DEVICES=""
without having to modify the source code.
If the above answers don't work, try:
os.environ['CUDA_VISIBLE_DEVICES'] = '-1'