How to disable GPU in tensor flow cores?

I want to compare the processing time of my code with and without gpu. My keras backend is Tensorflow. Therefore, it automatically uses the graphics processor. For comparison, I use the model keras/examples/mnist_mlp.py.

I checked the processing time as below. Then how to disable my GPU? Should it be changed ~/.keras/keras.json?

$ time python mnist_mlp.py 
Test loss: 0.109761892007
Test accuracy: 0.9832
python mnist_mlp.py  38.22s user 3.18s system 162% cpu 25.543 total
+4
source share
2 answers

Have you tried something like this?

$ CUDA_VISIBLE_DEVICES='' time python mnist_mlp.py 

CUDA_VISIBLE_DEVICEScommonly used to hide some GPUs before cuda. Here you hide them all, since you do not place any visible devices.

+8
source
$ CUDA_VISIBLE_DEVICES=-1 time python mnist_mlp.py

) , ) , Windows, Linux.

0

Source: https://habr.com/ru/post/1673410/


All Articles