How to run on GPU?
timmolter opened this issue · comments
I'm new to TensoFlow, and I really appreciated your tutorial. I'm pretty sure running the MNIST example on a GPU wouldn't really speed up the overall process, but I'm curious anyway: How would you convert the mnist_3.0_convolutional.py
example to run on a GPU? Is there a flag to set somewhere or do you have to change/add some method calls or???
Much appreciated!
just install the GPU version of Tensorflow(pip install tensorflow-gpu). There are a couple more things that you will need such as CUDA, CuDNN and an Nvidia GPU obviously. It does speed it up considerably.
Yes, I figured it out. If you have a GPU installed, TF will automatically run on it. If you want to toggle between CPU and GPU, you can you the following code:
import os
os.environ["CUDA_VISIBLE_DEVICES"]="-1" # this disables the GPU and it will run on the CPU only, set to "0" for GPU