代码之家  ›  专栏  ›  技术社区  ›  le4m

当2个GPU可用但没有特定选择时,使用哪个GPU

  •  1
  • le4m  · 技术社区  · 7 年前

    我有两个GPU安装在我的电脑,因为他们是并行使用(没有任何SLI或喜欢)。假设我在tensorflow中运行一个简单的代码,就像在 this . 那么使用哪个gpu呢?两个都用了吗?这是运行日志。

    2018-09-15 02:55:36.314345: I T:\src\github\tensorflow\tensorflow\core\platform\cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
    2018-09-15 02:55:36.675657: I T:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:1405] Found device 0 with properties: 
    name: GeForce GTX 1080 Ti major: 6 minor: 1 memoryClockRate(GHz): 1.6705
    pciBusID: 0000:17:00.0
    totalMemory: 11.00GiB freeMemory: 9.08GiB
    2018-09-15 02:55:36.798520: I T:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:1405] Found device 1 with properties: 
    name: GeForce GTX 1080 Ti major: 6 minor: 1 memoryClockRate(GHz): 1.6705
    pciBusID: 0000:65:00.0
    totalMemory: 11.00GiB freeMemory: 9.08GiB
    2018-09-15 02:55:36.799044: I T:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:1484] Adding visible gpu devices: 0, 1
    2018-09-15 02:55:38.234984: I T:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:965] Device interconnect StreamExecutor with strength 1 edge matrix:
    2018-09-15 02:55:38.235236: I T:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:971]      0 1 
    2018-09-15 02:55:38.235392: I T:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:984] 0:   N N 
    2018-09-15 02:55:38.235559: I T:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:984] 1:   N N 
    2018-09-15 02:55:38.235849: I T:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:1097] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 8783 MB memory) -> physical GPU (device: 0, name: GeForce GTX 1080 Ti, pci bus id: 0000:17:00.0, compute capability: 6.1)
    2018-09-15 02:55:38.601267: I T:\src\github\tensorflow\tensorflow\core\common_runtime\gpu\gpu_device.cc:1097] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:1 with 8783 MB memory) -> physical GPU (device: 1, name: GeForce GTX 1080 Ti, pci bus id: 0000:65:00.0, compute capability: 6.1)
    
    1 回复  |  直到 7 年前
        1
  •  1
  •   David Parks    7 年前

    Tensorflow的默认设置是消耗所有可见GPU的内存,但是除非您编写使用多个GPU的代码,否则只有两个GPU中的第一个将用于计算。

    通常设置环境变量 export CUDA_VISIBLE_DEVICES=0 例如,在运行python将tensorflow限制为只看到gpu0之前。(0=gpu0,1=gpu1等,-1=cpu专用)

    使用这两个GPU进行计算需要为多个GPU编写代码(并决定这在模型中意味着什么),关于这个主题有很多教程,下面是一个快速的教程: http://blog.s-schoener.com/2017-12-15-parallel-tensorflow-intro/

    推荐文章