Reputation: 4083
I want to compare processing time of my code with and without gpu. My backend of keras is Tensorflow. So it uses a GPU automatically. I use a model of keras/examples/mnist_mlp.py
for comparing.
I checked the processing time like below. Then, how do I disable my GPU? Should ~/.keras/keras.json
be modified?
$ 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
Upvotes: 13
Views: 16673
Reputation: 26139
$ CUDA_VISIBLE_DEVICES=-1 time python mnist_mlp.py
seems to be a) either the new way, or b) a way that works on both Windows and Linux.
Upvotes: 4
Reputation: 11553
Have you tried something like this? :
$ CUDA_VISIBLE_DEVICES='' time python mnist_mlp.py
CUDA_VISIBLE_DEVICES
is usually used to hide some GPU's to cuda. Here you hide them all as you don't put any visible device.
Upvotes: 13