Cannot import multi_gpu_model from keras.utils

狂风中的少年 提交于 2021-02-08 03:28:05

问题


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.


回答1:


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



回答2:


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.




回答3:


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.



来源:https://stackoverflow.com/questions/46840037/cannot-import-multi-gpu-model-from-keras-utils

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!