I try to use from keras.utils import multi_gpu_model, but i have error: “cannot import name ‘multi_gpu_model’ from ‘keras.utils’”. I tried to install previous versions of keras, but it didn’t helps.

Do you know, how can i replace it?

Can you tell us the Keras or Tensorflow version you are using?

multi_gpu_utils has been removed since the introduction of distribution strategies. Please refer to the Distributed training with TensorFlow guide to know more about using multi GPU’s for training.

If you wish to use only some of the GPUs on your machine, you can do so like this:

mirrored_strategy = tf.distribute.MirroredStrategy(devices=["/gpu:0", "/gpu:1"])

I tried different version of Keras: 2.2.4, 2.9.0. And this error occurs on all of them, although, as I understand it, this should work on version 2.2.4.

First remove keras from your system and install the new version keras 2.2.4 as described below.

pip uninstall keras 
pip install keras==2.2.4

For more details please refer to the gist. Thank you.