Tensorflow / keras multi_gpu_model is not splitted to more than one gpu2019 Community Moderator ElectionHow do you split a list into evenly sized chunks?TensorFlow-Slim Multi-GPU trainingrun tensorflow textsum model on gpukeras with tensorflow on GPU machine - some parts are very slowHow to fix low volatile GPU-Util with Tensorflow-GPU and Keras?Keras run predict_generator on multiple GPUsKeras is not Using Tensorflow GPUautomatically choose a device keras tensorflowkeras(-gpu) + tensorflow-gpu + anaconda on KubuntuWhy does TensorFlow always use GPU 0?

Time travel short story where dinosaur doesn't taste like chicken

How could a female member of a species produce eggs unto death?

Decoding assembly instructions in a Game Boy disassembler

Time dilation for a moving electronic clock

Unreachable code, but reachable with exception

What injury would be of little consequence to a biped but terrible for a quadruped?

Does anyone draw a parallel between Haman selling himself to Mordechai and Esav selling the birthright to Yaakov?

Am I not good enough for you?

What is the blue range indicating on this manifold pressure gauge?

What is the definition of "Natural Selection"?

What is the difference between "shut" and "close"?

Good allowance savings plan?

Extension of Splitting Fields over An Arbitrary Field

Do f-stop and exposure time perfectly cancel?

Deleting missing values from a dataset

My story is written in English, but is set in my home country. What language should I use for the dialogue?

"However" used in a conditional clause?

What is the dot in “1.2.4."

What exactly is the purpose of connection links straped between the rocket and the launch pad

Can you reject a postdoc offer after the PI has paid a large sum for flights/accommodation for your visit?

Does Linux have system calls to access all the features of the file systems it supports?

What has been your most complicated TikZ drawing?

How does Dispel Magic work against Stoneskin?

How do anti-virus programs start at Windows boot?



Tensorflow / keras multi_gpu_model is not splitted to more than one gpu



2019 Community Moderator ElectionHow do you split a list into evenly sized chunks?TensorFlow-Slim Multi-GPU trainingrun tensorflow textsum model on gpukeras with tensorflow on GPU machine - some parts are very slowHow to fix low volatile GPU-Util with Tensorflow-GPU and Keras?Keras run predict_generator on multiple GPUsKeras is not Using Tensorflow GPUautomatically choose a device keras tensorflowkeras(-gpu) + tensorflow-gpu + anaconda on KubuntuWhy does TensorFlow always use GPU 0?










0















I'm encountered the problem, that I can not successfully split my training batches to more than one GPU. If multi_gpu_model from tensorflow.keras.utils is used, tensorflow allocates the full memory on all available (for example 2) gpus, but only the first one (gpu[0]) is utilized to 100% if nvidia-smi is watched.



I'm using tensorflow 1.12 right now.



Test on single device



model = getSimpleCNN(... some parameters)

model .compile()
model .fit()


As expected, data is loaded by cpu and the model runs on gpu[0] with 97% - 100% gpu utilization:
enter image description here



Create a multi_gpu model



As described in the tensorflow api for multi_gpu_model here, the device scope for model definition is not changed.



from tensorflow.keras.utils import multi_gpu_model

model = getSimpleCNN(... some parameters)
parallel_model = multi_gpu_model(model, gpus=2, cpu_merge=False) # weights merge on GPU (recommended for NV-link)

parallel_model.compile()
parallel_model.fit()


As seen in the timeline, cpu now not only loads the data, but is doing some other calculations. Notice: the second gpu is nearly doing nothing:
enter image description here



The question



The effect even worsens as soon as four gpus are used. Utilization of the first one goes up to 100% but for the rest there are only short peeks.



Is there any solution to fix this? How to properly train on multiple gpus?



Is there any difference between tensorflow.keras.utils and keras.utils which causes the unexpected behavior?










share|improve this question


























    0















    I'm encountered the problem, that I can not successfully split my training batches to more than one GPU. If multi_gpu_model from tensorflow.keras.utils is used, tensorflow allocates the full memory on all available (for example 2) gpus, but only the first one (gpu[0]) is utilized to 100% if nvidia-smi is watched.



    I'm using tensorflow 1.12 right now.



    Test on single device



    model = getSimpleCNN(... some parameters)

    model .compile()
    model .fit()


    As expected, data is loaded by cpu and the model runs on gpu[0] with 97% - 100% gpu utilization:
    enter image description here



    Create a multi_gpu model



    As described in the tensorflow api for multi_gpu_model here, the device scope for model definition is not changed.



    from tensorflow.keras.utils import multi_gpu_model

    model = getSimpleCNN(... some parameters)
    parallel_model = multi_gpu_model(model, gpus=2, cpu_merge=False) # weights merge on GPU (recommended for NV-link)

    parallel_model.compile()
    parallel_model.fit()


    As seen in the timeline, cpu now not only loads the data, but is doing some other calculations. Notice: the second gpu is nearly doing nothing:
    enter image description here



    The question



    The effect even worsens as soon as four gpus are used. Utilization of the first one goes up to 100% but for the rest there are only short peeks.



    Is there any solution to fix this? How to properly train on multiple gpus?



    Is there any difference between tensorflow.keras.utils and keras.utils which causes the unexpected behavior?










    share|improve this question
























      0












      0








      0








      I'm encountered the problem, that I can not successfully split my training batches to more than one GPU. If multi_gpu_model from tensorflow.keras.utils is used, tensorflow allocates the full memory on all available (for example 2) gpus, but only the first one (gpu[0]) is utilized to 100% if nvidia-smi is watched.



      I'm using tensorflow 1.12 right now.



      Test on single device



      model = getSimpleCNN(... some parameters)

      model .compile()
      model .fit()


      As expected, data is loaded by cpu and the model runs on gpu[0] with 97% - 100% gpu utilization:
      enter image description here



      Create a multi_gpu model



      As described in the tensorflow api for multi_gpu_model here, the device scope for model definition is not changed.



      from tensorflow.keras.utils import multi_gpu_model

      model = getSimpleCNN(... some parameters)
      parallel_model = multi_gpu_model(model, gpus=2, cpu_merge=False) # weights merge on GPU (recommended for NV-link)

      parallel_model.compile()
      parallel_model.fit()


      As seen in the timeline, cpu now not only loads the data, but is doing some other calculations. Notice: the second gpu is nearly doing nothing:
      enter image description here



      The question



      The effect even worsens as soon as four gpus are used. Utilization of the first one goes up to 100% but for the rest there are only short peeks.



      Is there any solution to fix this? How to properly train on multiple gpus?



      Is there any difference between tensorflow.keras.utils and keras.utils which causes the unexpected behavior?










      share|improve this question














      I'm encountered the problem, that I can not successfully split my training batches to more than one GPU. If multi_gpu_model from tensorflow.keras.utils is used, tensorflow allocates the full memory on all available (for example 2) gpus, but only the first one (gpu[0]) is utilized to 100% if nvidia-smi is watched.



      I'm using tensorflow 1.12 right now.



      Test on single device



      model = getSimpleCNN(... some parameters)

      model .compile()
      model .fit()


      As expected, data is loaded by cpu and the model runs on gpu[0] with 97% - 100% gpu utilization:
      enter image description here



      Create a multi_gpu model



      As described in the tensorflow api for multi_gpu_model here, the device scope for model definition is not changed.



      from tensorflow.keras.utils import multi_gpu_model

      model = getSimpleCNN(... some parameters)
      parallel_model = multi_gpu_model(model, gpus=2, cpu_merge=False) # weights merge on GPU (recommended for NV-link)

      parallel_model.compile()
      parallel_model.fit()


      As seen in the timeline, cpu now not only loads the data, but is doing some other calculations. Notice: the second gpu is nearly doing nothing:
      enter image description here



      The question



      The effect even worsens as soon as four gpus are used. Utilization of the first one goes up to 100% but for the rest there are only short peeks.



      Is there any solution to fix this? How to properly train on multiple gpus?



      Is there any difference between tensorflow.keras.utils and keras.utils which causes the unexpected behavior?







      python tensorflow keras multi-gpu






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Mar 6 at 17:46









      johni07johni07

      395316




      395316






















          0






          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55029279%2ftensorflow-keras-multi-gpu-model-is-not-splitted-to-more-than-one-gpu%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55029279%2ftensorflow-keras-multi-gpu-model-is-not-splitted-to-more-than-one-gpu%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          1928 у кіно

          Захаров Федір Захарович

          Ель Греко