【问题标题】:Does Docker image supporting Nvidia gpu on a cpu machineDocker 映像是否在 cpu 机器上支持 Nvidia gpu
【发布时间】:2018-10-04 22:19:19
【问题描述】:

我想在 Docker 容器上运行深度神经网络。我可以使用支持 GPU 的 Docker Hub 上公开可用的 TensorFlow 或 PyTorch 或 CNTK 图像。而且我可以在云端获得 NVIDA GPU。

当我在没有 GPU(或 Intel GPU)的 PC 上运行这些基于 GPU 的容器时会发生什么?基于 NVIDIA GPU 的 Docker 容器能否在我的 CPU 上正常运行(尽管速度较慢)?

如果我可以在没有 GPU 的情况下在本地进行开发,并在我准备好大规模运行时使用 GPU 进行扩展,那就太好了。

这行得通吗?想法?

【问题讨论】:

  • 除了下面给出的答案之外,我想补充一点,如果您使用 PyTorch,您必须手动决定您的数据在哪个设备上传输。准确说明您最终使用的内容将有助于您获得良好答案的机会。

标签: docker tensorflow gpu nvidia pytorch


【解决方案1】:

如果 Tensorflow 没有找到 GPU,它只会使用 CPU,所以这应该可以正常工作。

【讨论】:

    【解决方案2】:

    Tensorflow 有一个允许软放置的选项,这意味着如果设备不存在,它会自动选择现有且受支持的设备来运行操作。引用 tensorflow 中关于 Using GPUs 的文档,

    如果您希望 TensorFlow 自动选择现有的和 支持的设备在指定的情况下运行操作 不存在,您可以在 创建会话时的配置选项。

    # Creates a graph.
    with tf.device('/device:GPU:2'):
      a = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[2, 3], name='a')
      b = tf.constant([1.0, 2.0, 3.0, 4.0, 5.0, 6.0], shape=[3, 2], name='b')
      c = tf.matmul(a, b)
    # Creates a session with allow_soft_placement and log_device_placement set
    # to True.
    sess = tf.Session(config=tf.ConfigProto(
          allow_soft_placement=True, log_device_placement=True))
    # Runs the op.
    print(sess.run(c))
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-08-29
      • 2019-09-21
      • 2016-06-06
      • 2020-08-07
      • 1970-01-01
      • 1970-01-01
      • 2014-03-29
      • 1970-01-01
      相关资源
      最近更新 更多