Sharanya Arcot Desai
Sharanya Arcot Desai

Reputation: 685

Cannot import multi_gpu_model from keras.utils

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.

Upvotes: 10

Views: 32814

Answers (5)

Andrei Belousov
Andrei Belousov

Reputation: 631

for Tensorflow 2.7.0 this works:

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

Upvotes: 3

Bharath Kumar
Bharath Kumar

Reputation: 971

pip uninstall keras 
pip install keras==2.2.4

this helped me ... working on keras hrnetv2

Upvotes: 8

VikoTse
VikoTse

Reputation: 47

You could reinstall tensorflow-estimator and keras like this:

pip uninstall tensorflow-estimator
pip install tensorflow-estimator
pip uninstall keras
pip install keras

I was able to resolve the issue by this.

Upvotes: -1

Sharanya Arcot Desai
Sharanya Arcot Desai

Reputation: 685

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

Upvotes: 2

Dr. Snoopy
Dr. Snoopy

Reputation: 56357

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.

Upvotes: 2

Related Questions