首页 > 学院 > 开发设计 > 正文

tensorflow 使用多块GPU同时训练多个模型

2019-11-06 08:46:38
字体:
来源:转载
供稿:网友

转自:http://stackoverflow.com/questions/34775522/tensorflow-mutiple-sessions-with-mutiple-gpus

TensorFlow will attempt to use (an equal fraction of the memory of) all GPU devices that are visible to it. If you want to run different sessions on different GPUs, you should do the following.

Run each session in a different Python PRocess.

Start each process with a different value for the CUDA_VISIBLE_DEVICES environment variable. For example, if your script is called my_script.py and you have 4 GPUs, you could run the following:

$ CUDA_VISIBLE_DEVICES=0 python my_script.py  # Uses GPU 0.$ CUDA_VISIBLE_DEVICES=1 python my_script.py  # Uses GPU 1.$ CUDA_VISIBLE_DEVICES=2,3 python my_script.py  # Uses GPUs 2 and 3.

Note the GPU devices in TensorFlow will still be numbered from zero (i.e. "/gpu:0" etc.), but they will correspond to the devices that you have made visible with CUDA_VISIBLE_DEVICES.

shareeditanswered Jan 13 '16 at 20:53mrry40.9k395142


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表