I have a running installation of Keras & Theano on Windows (by following this tutorial). Now I've tried to switch the backend to Tensorflow which worked quite fine.
The only issue I have, is that Tensorflow does not detect my GPU, which Theano in contrast does:
from tensorflow.python.client import device_lib
def get_available_gpus():
local_device_protos = device_lib.list_local_devices()
return [x.name for x in local_device_protos if x.device_type == 'GPU']
yields no results but when running with Theano backend, it works quite nicely:
C:\Programming\Anaconda3\python.exe D:/cnn_classify_cifar10.py
Using Theano backend.
DEBUG: nvcc STDOUT nvcc warning : The 'compute_20', 'sm_20', and 'sm_21' architectures are deprecated, and may be removed in a future release (Use -Wno-deprecated-gpu-targets to suppress warning).
mod.cu
Creating library C:/Users/Alex/AppData/Local/Theano/compiledir_Windows-10-10.0.14393-SP0-Intel64_Family_6_Model_60_Stepping_3_GenuineIntel-3.5.2-64/tmpgsy496fe/m91973e5c136ea49268a916ff971b7377.lib and object C:/Users/Alex/AppData/Local/Theano/compiledir_Windows-10-10.0.14393-SP0-Intel64_Family_6_Model_60_Stepping_3_GenuineIntel-3.5.2-64/tmpgsy496fe/m91973e5c136ea49268a916ff971b7377.exp
Using gpu device 0: GeForce GTX 770 (CNMeM is enabled with initial size: 80.0% of memory, cuDNN 5005)
Apparently there is some configuration missing, but I don't know what. For Theano to run correctly, I needed a file called ~/.theanorc
with the following content:
[global]
device = gpu
floatX = float32
[cuda]
root = C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v8.0
[nvcc]
flags=-LC:C:\Programming\WinPython-64bit-3.5.2.2\python-3.5.2.amd64\libs
Maybe something similar is missing or maybe I need to add environment variables like for Theano?. Possibly related question on Linux (?).
The full installation log (which included a strange exception) can be found in this Gist.
Any ideas, how to make the GPU visible to Tensorflow?
This is most likely because the CUDA and CuDNN drivers are not being correctly detected in your system. In both cases, Tensorflow is not detecting your Nvidia GPU. This can be for a variety of reasons: Nvidia Driver not installed.
Then, TensorFlow runs operations on your GPUs by default. You can control how TensorFlow uses CPUs and GPUs: Logging operations placement on specific CPUs or GPUs. Instructing TensorFlow to run certain operations in a specific “device context”—a CPU or a specific GPU, if there are multiple GPUs on the machine.
Installing both tensorflow and tensorflow-gpu on the same machine might cause issues at the moment.
Install either tensorflow (for cpu only) or tensorflow-gpu (for gpu only) for version 1.0
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With