如何 运行 在不同的 GPU 上进行多个训练任务?
How to run multiple training tasks on different GPUs?
我的服务器上有 2 个 GPU,我想在它们上 运行 不同的训练任务。
在第一个任务中,试图强制 Tensorflow 仅使用一个 GPU,我在脚本顶部添加了以下代码:
import os
os.environ['CUDA_VISIBLE_DEVICES'] = '0'
在第一个任务 运行 之后,当我尝试 运行 在另一个 GPU 上执行第二个任务时,(使用相同的两行代码)我得到错误 "No device GPU:1"
。
有什么问题?
Q : "What is the problem?"
系统需要查看卡片 - 使用对 (hwloc
-tool) lstopo
的调用来验证服务器的当前状态:
$ lstopo --only osdev
GPU L#0 "card1"
GPU L#1 "renderD128"
GPU L#2 "card2"
GPU L#3 "renderD129"
GPU L#4 "card3"
GPU L#5 "renderD130"
GPU L#6 "card0"
GPU L#7 "controlD64"
Block(Disk) L#8 "sda"
Block(Disk) L#9 "sdb"
Net L#10 "eth0"
Net L#11 "eno1"
GPU L#12 "card4"
GPU L#13 "renderD131"
GPU L#14 "card5"
GPU L#15 "renderD132"
如果显示的不仅仅是上面提到的card0
,请继续正确命名/id#
-s
和
一定要在 之前设置它 做任何其他 import
-s,就像 pycuda
和 tensorflow
.
import os
os.environ['CUDA_VISIBLE_DEVICES'] = '1' # MUST PRECEDE ANY IMPORT-s
#---------------------------------------------------------------------
import pycuda as pyCUDA
import tensorflow as tf
...
#----------------------------------------------------------------------
我的服务器上有 2 个 GPU,我想在它们上 运行 不同的训练任务。
在第一个任务中,试图强制 Tensorflow 仅使用一个 GPU,我在脚本顶部添加了以下代码:
import os
os.environ['CUDA_VISIBLE_DEVICES'] = '0'
在第一个任务 运行 之后,当我尝试 运行 在另一个 GPU 上执行第二个任务时,(使用相同的两行代码)我得到错误 "No device GPU:1"
。
有什么问题?
Q : "What is the problem?"
系统需要查看卡片 - 使用对 (hwloc
-tool) lstopo
的调用来验证服务器的当前状态:
$ lstopo --only osdev
GPU L#0 "card1"
GPU L#1 "renderD128"
GPU L#2 "card2"
GPU L#3 "renderD129"
GPU L#4 "card3"
GPU L#5 "renderD130"
GPU L#6 "card0"
GPU L#7 "controlD64"
Block(Disk) L#8 "sda"
Block(Disk) L#9 "sdb"
Net L#10 "eth0"
Net L#11 "eno1"
GPU L#12 "card4"
GPU L#13 "renderD131"
GPU L#14 "card5"
GPU L#15 "renderD132"
如果显示的不仅仅是上面提到的card0
,请继续正确命名/id#
-s
和
一定要在 之前设置它 做任何其他 import
-s,就像 pycuda
和 tensorflow
.
import os
os.environ['CUDA_VISIBLE_DEVICES'] = '1' # MUST PRECEDE ANY IMPORT-s
#---------------------------------------------------------------------
import pycuda as pyCUDA
import tensorflow as tf
...
#----------------------------------------------------------------------