Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 270
Sharanya Arcot Desai Avatar asked Oct 19 '17 22:10

Sharanya Arcot Desai


4 Answers

pip uninstall keras 
pip install keras==2.2.4

this helped me ... working on keras hrnetv2

like image 117
Bharath Kumar Avatar answered Sep 21 '22 17:09

Bharath Kumar


for Tensorflow 2.7.0 this works:

from tensorflow.python.keras.utils.multi_gpu_utils import multi_gpu_model
like image 38
Андрей Белоусов Avatar answered Sep 23 '22 17:09

Андрей Белоусов


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.

like image 44
Dr. Snoopy Avatar answered Sep 20 '22 17:09

Dr. Snoopy


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
like image 24
Sharanya Arcot Desai Avatar answered Sep 21 '22 17:09

Sharanya Arcot Desai