Tensorflow GPU 与 CPU 安装库的区别 [英] Difference between installation libraries of Tensorflow GPU vs CPU

查看:84
本文介绍了Tensorflow GPU 与 CPU 安装库的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

最近,我想将我的 Python 库移动到一个随身碟,以便在我的工作站和笔记本电脑之间切换时保持所有库不变.(另外,如果我更新一个,它也会更新其他.)

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.)

为此,我在我的 Pendrive 上安装了 tensorflow-gpu 版本(我的笔记本电脑没有 GPU).在 PC(它可以毫无问题地检测并使用我的 GPU)和笔记本电脑(它会自动使用我的 CPU)上一切正常,没有问题.

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 

而且只是

tensorflow

?(因为当没有找到 GPU 时,tensorflow-gpu 会自动使用 CPU 版本.)

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

区别仅在于GPU支持吗?那么为什么要使用非 GPU 版本的 tensorflow?

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

还有,这样下去可以吗?还是应该创建虚拟环境来分别安装 CPU 和 GPU?

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

我能找到的最接近的答案是如何在没有 GPU 的情况下使用 gpu 开发张量流gpu.

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

但它只说明在CPU平台上使用tensorflow-gpu是完全可以的,但它仍然没有回答我的第一个问题.此外,随着 tensorflow 不断发布新的更新,答案可能已经过时.

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.

我已经在我的 GTX 1070 工作站上安装了 tensorflow-gpu 版本(因此安装成功).

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

我也理解不同之处在于 pip install tensorflow-gpu 需要安装支持 CUDA 的设备,但我的问题更多是关于库的使用,因为我在使用时没有遇到任何问题我的笔记本电脑上的 tensorflow-gpu 版本(没有 GPU)和我所有的脚本都运行没有任何错误.

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.

(也从上面删除了 pip install 以避免混淆)

(Also removed pip install from above to avoid confusion)

此外,在没有 GPU 的系统上运行 tensorflow-gpu 是否与设置 CUDA_VISIBLE_DEVICES=-1 相同?

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

推荐答案

需要注意的一点:即使您的系统中没有 GPU,也可以安装 CUDA.

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

对于包 tensorflowtensorflow-gpu 我希望这能消除混淆.是/否的意思是在执行import tensorflow as tf时,包会开箱即用吗?"?区别如下:

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) |

cpu-only 系统和 gpu 未安装 cuda+cudnn 上确认 no 答案(通过删除 CUDA+CuDNN环境变量).

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

~tf-like 意味着即使库是 tensorflow-gpu,它的行为也会像 tensorflow 库.

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

这篇关于Tensorflow GPU 与 CPU 安装库的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆