0
$\begingroup$

I got 2 GPUs of type NVIDIA GTX 1070 Ti. I would like to train more models on them in such a way that half of the models are trained on one GPU only, and half on the other, at the same time. So as training goes, one model goes to GPU1, the next model goes to GPU2, ... I don't want to train one model on the two GPUs. I use Keras - Python with TensorFlow back-end. Can you please recommend resources where I can see how to do this? Most examples/articles online cover the case only if you want to distribute one model on the two GPUs. Thank you.

$\endgroup$
1
$\begingroup$

I would just create two separate scripts with one set of models that target one gpu and the other set of models target the other gpu. Then run the scripts as separate processes.That would easily get around Python's GIL.

$\endgroup$
  • $\begingroup$ I just saw you edited your response, as I was writing :) so the second approach with for loop in one notebook / file only is not possible? $\endgroup$ – MachineLearningGod Mar 13 at 1:06
  • $\begingroup$ I thought about it... the training for the first model will have to finish before the second model starts. Python executes commands in order and typically waits for the command to finish before continuing. $\endgroup$ – Brian Spiering Mar 13 at 12:29
0
$\begingroup$

I believe new-Tensorflow 2.0 alpha, released last week has this feature

https://www.tensorflow.org/guide/using_gpu

On a typical system, there are multiple computing devices. In TensorFlow, the supported device types are CPU and GPU. They are represented as strings. For example:

"/cpu:0": The CPU of your machine.
"/device:GPU:0": The GPU of your machine, if you have one.
"/device:GPU:1": The second GPU of your machine, etc.
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.