简体   繁体   English

如何通过 Tensorflow 使用多个 GPU 进行单独训练?

[英]How to use multiple GPUs for separate training with Tensorflow?

I have looked through many articles and posts about using multiple GPUs with TensorFlow.我浏览了许多关于在 TensorFlow 中使用多个 GPU 的文章和帖子。 It helps me more here on "how to use parallel GPUs to train NN (neural network)".“如何使用并行 GPU 训练 NN(神经网络)”方面对我有更多帮助。 But I have a different question.但我有一个不同的问题。 Can a separate GPU be used to train different NNs at the same time?可以使用单独的 GPU 同时训练不同的 NN 吗?

More details:更多细节:

I have neural networks A , B , and GPU1 , GPU2 .我有神经网络ABGPU1GPU2 I want to train A NN on GPU1 and B NN on GPU2 at the same time.我想同时在GPU1上训练A NN 和在GPU2上训练B NN。 Is it possible?可能吗?

I suggest using two separate python scripts to train both networks, such as trainA.py and trainB.py .我建议使用两个单独的 python 脚本来训练这两个网络,例如trainA.pytrainB.py

In the first two lines of trainA.py you select your preferred GPU.在 trainA.py 的前两行中,您选择trainA.py您首选的 GPU。

import os
os.environ["CUDA_VISIBLE_DEVICES"] = "0"

For trainB.py you select the other GPU:对于trainB.py你 select 另一个 GPU:

import os
os.environ["CUDA_VISIBLE_DEVICES"] = "1"

Now you should be able to run both train scripts at the same time.现在您应该能够同时运行两个训练脚本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 训练深度网络时如何有效使用多个GPU? - How to use multiple GPUs effectively when training deep networks? 使用 Keras API 在 Tensorflow 2.0 中的多个 GPU 上加载模型后如何继续训练? - How to continue training after loading model on multiple GPUs in Tensorflow 2.0 with Keras API? 单机多GPU训练的Tensorflow分段故障 - Tensorflow segmentation fault with single machine multiple GPUs training 使用Google Colab中的多个GPU在Tensorflow中进行分布式培训 - Distributed training in Tensorflow using multiple GPUs in Google Colab 在 TensorFlow 中使用多个 GPU 来推断 pb 模型 - Use multiple GPUs in TensorFlow to inference with pb model 在张量流的C ++版本上使用多个gpus - Use multiple gpus on the C++ version of tensorflow TensorFlow 从多个 GPU 中选择要使用的 GPU - TensorFlow Choose GPU to use from multiple GPUs 如何在Tensorflow中的多个GPU中更新BatchNorm的变量 - How to update variable of BatchNorm in multiple GPUs in Tensorflow 如何将推理与在多个GPU上使用的张量流并行化? - How to parallelize inference with tensorflow serving on multiple GPUs? 如何使用TensorFlow后端在Keras中使用其他GPU? - How to use other GPUs in Keras with a TensorFlow backend?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM