6

I have previously asked if it is possible to run tensor flow with gpu support on a cpu. I was told that it is possible and the basic code to switch which device I want to use but not how to get the initial code working on a computer that doesn't have a gpu at all. For example I would like to train on a computer that has a NVidia gpu but program on a laptop that only has a cpu. How would I go about doing this? I have tried just writing the code as normal but it crashes before I can even switch which device I want to use. I am using Python on Linux.

Drok_
  • 149
  • 1
  • 7

2 Answers2

0

What errors are you getting? It is very possible to train on a GPU but develop on a CPU- many people do it, including myself. In fact, Tensorflow will automatically put your code on a GPU if possible.

If you add the following code to your model, you can see which devices are being used:

# Creates a session with log_device_placement set to True.
sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))

This should change when you run your model on a computer with a GPU.

finbarr
  • 749
  • 4
  • 11
  • I have installed tensorflow-gpu via thonny and used the validation code which tensorflow provides and i get the following error: https://pastebin.com/5RxtH5Gx I get the same error with just the code: import tensorflow as tf – Drok_ Jul 24 '17 at 22:15
  • I have tried the code you provided and i get the same error. – Drok_ Jul 25 '17 at 01:13
  • The same error as the one i linked to in my other comment. pastebin.com/5RxtH5Gx – Drok_ Jul 25 '17 at 15:17
  • Which version of CUDA do you have installed? I had that same error when I first setup my computer as I had installed the wrong version. – finbarr Jul 25 '17 at 16:00
  • 1
    I have found the problems its like you said i should use the cpu version of tensorflow on my development computer and the gpu version of tensorflow on on the computer which has a gpu that can be used. – Drok_ Jul 25 '17 at 20:11
  • Okay, great. Another option you have is to use Docker to run your code; it's a one line change to switch from the CPU to GPU versions of Tensorflow: https://github.com/tensorflow/tensorflow/tree/master/tensorflow/tools/docker – finbarr Jul 25 '17 at 21:04
0

This thread might be helpful: Tensorflow: ImportError: libcusolver.so.8.0: cannot open shared object file: No such file or directory

I've tried to import tensorflow with tensorflow-gpu loaded in the uni's HPC login node, which does not have GPUs. It works well. I don't have Nvidia GPU in my laptop, so I never go through the installation process. But I think the cause is it cannot find relevant libraries of CUDA, cuDNN.

But, why don't you just use cpu version? As @Finbarr Timbers mentioned, you still can run a model in a computer with GPU.

Lujun Weng
  • 101
  • 5
  • I guess i am miss understanding something. Do i install the cpu version on my development computer, the one without the gpu, and install the gpu version on the computer i plan to train on? – Drok_ Jul 25 '17 at 15:16
  • Yes, that is exactly what you should do. – finbarr Jul 25 '17 at 16:00