Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between installation libraries of Tensorflow GPU vs CPU

Recently, I wanted to move my Python libraries to a pendrive to keep all the libraries constant while switching between my workstation and laptop. (Also so that if I update one, it's updated on other also.)

For this, I have installed a tensorflow-gpu version on my pendrive (my laptop doesn't have a GPU). Everything works fine without a problem on both PC (it detects and uses my GPU without a problem) and laptop (it automatically uses my CPU).

That's where my question lies. What is the difference between a

tensorflow-gpu  

AND just

tensorflow 

? (Because when no GPU is found, tensorflow-gpu automatically uses the CPU version.)

Does the difference lie only in the GPU support? Then why at all have a non GPU version of tensorflow?

Also, is it alright to proceed like this? Or should I create virtual environments to keep separate installations for CPU and GPU?

The closest answer I can find is How to develop for tensor flow with gpu without a gpu.

But it only specifies that it's completely okay to use tensorflow-gpu on a CPU platform, but it still does not answer my first question. Also, the answer might be outdated as tensorflow keeps releasing new updates.

I had installed the tensorflow-gpu version on my workstation with GTX 1070 (Thus a successful install).

Also I understand the difference is that pip install tensorflow-gpu will require CUDA enabled device to install, but my question is more towards the usage of the libraries because I am not getting any problems when using the tensorflow-gpu version on my laptop (with no GPU) and all my scripts run without any error.

(Also removed pip install from above to avoid confusion)

Also, isn't running tensorflow-gpu on a system with no GPU the same as setting CUDA_VISIBLE_DEVICES=-1?

like image 574
Rohan Pooniwala Avatar asked Oct 03 '18 10:10

Rohan Pooniwala


People also ask

Is TensorFlow better on CPU or GPU?

They noticed that the performance of TensorFlow depends significantly on the CPU for a small-size dataset. Also, they found it is more important to use a graphic processing unit (GPU) when training a large-size dataset.

Do I need to install TensorFlow GPU separately?

According to Difference between installation libraries of TensorFlow GPU vs CPU. Just a quick (unnecessary?) note... from TensorFlow 2.0 onwards these are not separated, and you simply install tensorflow (as this includes GPU support if you have an appropriate card/CUDA installed).

Are TensorFlow and TensorFlow GPU different?

The main difference is that you need the GPU enabled version of TensorFlow for your system. However, before you install TensorFlow into this environment, you need to setup your computer to be GPU enabled with CUDA and CuDNN. Show activity on this post. There are not many differences between the two libraries.


2 Answers

One thing to Note: CUDA can be installed even if you don't have a GPU in your system.

For packages tensorflow and tensorflow-gpu I hope this clears the confusion. yes/no means "Will the package work out of the box when executing import tensorflow as tf"? Here are the differences:

| Support for TensorFlow libraries | tensorflow | tensorflow-gpu  | | for hardware type:               |    tf      |     tf-gpu      | |----------------------------------|------------|-----------------| | cpu-only                         |    yes     |   no (~tf-like) | | gpu with cuda+cudnn installed    |    yes     |   yes           | | gpu without cuda+cudnn installed |    yes     |   no (~tf-like) | 

Edit: Confirmed the no answers on a cpu-only system and the gpu without cuda+cudnn installed (by removing CUDA+CuDNN env variables).

~tf-like means even though the library is tensorflow-gpu, it would behave like tensorflow library.

like image 200
burglarhobbit Avatar answered Oct 02 '22 14:10

burglarhobbit


Just a quick (unnecessary?) note... from TensorFlow2.0 onwards these are not separated, and you simply install tensorflow (as this includes GPU support if you have an appropriate card/CUDA installed).

like image 39
Oz_Ben Avatar answered Oct 02 '22 12:10

Oz_Ben