tf.device("cpu:0") still runs on GPU

1,021 views
Skip to first unread message

Gary Huntress

unread,
Nov 30, 2017, 1:16:10 PM11/30/17
to Discuss
I have just completed installation of an Anaconda environment on Windows 10.   This includes a Quadro K620.   Tensorflow installs and loads fine.   I wanted to see the GPU speed up so I wrote a simple script in two parts.   One uses tf.device("gpu:0"):  and the other uses (obviously) tf.device("cpu:0"):

The meat of the test uses matrix operations of increasing size (matmul, and matrix_inverse) and I record the time vs size.    I quickly saw that the times for cpu:0 were equal to gpu:0.   When I look in the Jupyter console I see that it logs GPU:0 for every instance of all my tests.    It seems like no matter what I do, I cannot get my code to run on the CPU.

For my environment, I did a pip install tensorflow-gpu.    I did not also do a pip install tensorflow (no GPU support).   Could that be why?


Toby Boyd

unread,
Nov 30, 2017, 1:23:28 PM11/30/17
to Gary Huntress, Discuss
If you install the non-GPU version there is no way it can run on GPU, but that is not a fix I would want you to have to do.  I often do CPU tests using the GPU version and things stay on the CPU if I place the ops there.  I did not do any recent tests but my only guesses based on the info are:
 
1) You could make sure allow_soft_placement=False, but I think that is the default so that is likely not useful advice.
2) make sure you are not overriding tf.device later on in the code.  I know that seems like silly advice but worth double checking.  

I am sorry I do not have a direct answer, but I can say device placement worked fine for me in the recent past (last month or so).  I also do not use Jupyter so I am not sure if that would matter and it likely does not.  If you have the code snippet or a link to the notebook that might help someone. 

good luck if you have a link someone might be able to give it a try.

Toby



--
You received this message because you are subscribed to the Google Groups "Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to discuss+unsubscribe@tensorflow.org.
To post to this group, send email to dis...@tensorflow.org.
To view this discussion on the web visit https://groups.google.com/a/tensorflow.org/d/msgid/discuss/7ec1c426-931d-4a78-8ae8-7eba96932b27%40tensorflow.org.

Reply all
Reply to author
Forward
0 new messages