Cannot import multi_gpu_model from keras.utils

21,843

Solution 1

pip uninstall keras 
pip install keras==2.2.4

this helped me ... working on keras hrnetv2

Solution 2

for Tensorflow 2.7.0 this works:

from tensorflow.python.keras.utils.multi_gpu_utils import multi_gpu_model

Solution 3

To close this issue: I installed the latest version of Keras from github and got the multi_gpu_model module working as expected.

pip install git+git://github.com/fchollet/keras.git --upgrade

Solution 4

This function was added on October 11, and there have been no Keras releases that include it. Currently the last Keras release is 2.0.8 released on Aug 25, 2017.

Your only options are to wait until a release is made, or to use a Keras version directly from git master.

Share:
21,843
Sharanya Arcot Desai
Author by

Sharanya Arcot Desai

I'm a technical neuroscientist who applies deep learning and machine learning algorithms to understand the human brain.

Updated on July 25, 2022

Comments

  • Sharanya Arcot Desai
    Sharanya Arcot Desai almost 2 years

    I have tensorflow-gpu 1.2.1 and keras on ubuntu 16.04.

    I am not able to perform:

    from kears.utils import multi_gpu_model 
    

    Has anyone had success with multi_gpu_model as described in their documentation's FAQ section?

    I have a 4 GPU machine with 4 GeForce GTX 1080 Ti cards and want to use all of them.

    Here's the error I get:

    import keras.utils.multi_gpu_model
    
    ---------------------------------------------------------------------------
    ModuleNotFoundError                       Traceback (most recent call last)
    <ipython-input-7-0174878249b1> in <module>()
    ----> 1 import keras.utils.multi_gpu_model
          2 
    
    ModuleNotFoundError: No module named 'keras.utils.multi_gpu_model'
    

    I can import keras and keras.utils successfully.

  • Sharanya Arcot Desai
    Sharanya Arcot Desai over 6 years
    Thanks you Matias. I installed the latest version from git and the function is working like a charm.