# Error when importing keras

**URL:** <https://community.drivendata.org/t/error-when-importing-keras/6842>\
**Category:** On Cloud N\
**Created:** [December 11, 2021, 10:39am UTC](https://community.drivendata.org/t/error-when-importing-keras/6842 "2021-12-11T10:39:59Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![AhmedA](https://avatars.discourse-cdn.com/v4/letter/a/f05b48/32.png) [@AhmedA](https://community.drivendata.org/u/AhmedA)\
**Post date:** [December 11, 2021, 10:39am UTC](https://community.drivendata.org/t/error-when-importing-keras/6842/1 "2021-12-11T10:39:59Z")

</div>

Hi,

I’m getting this error in the submission file when trying to import keras or tf.keras:

E tensorflow/core/lib/monitoring/collection\_registry.cc:77] Cannot register 2 metrics with the same name: /tensorflow/api/keras/optimizers  
tensorflow.python.framework.errors\_impl.AlreadyExistsError: Another metric with the same name already exists.

is anyone having a similar issue?

---

<div class="post-metadata">

**Author:** ![ibanez](https://avatars.discourse-cdn.com/v4/letter/i/a4c791/32.png) [@ibanez](https://community.drivendata.org/u/ibanez)\
**Post date:** [December 12, 2021, 8:55am UTC](https://community.drivendata.org/t/error-when-importing-keras/6842/2 "2021-12-12T08:55:57Z")

</div>

Hi,

I’m having the same issue.

In the log, in the packages in environment at /srv/conda/envs/condaenv: section it is listed:

tensorflow-gpu 2.6.0 pypi\_0 pypi

Listed here : [Cannot register 2 metrics with the same name: /tensorflow/api/keras/optimizers · Issue #52951 · tensorflow/tensorflow · GitHub](https://github.com/tensorflow/tensorflow/issues/52951)  
Comment: This should be fixed by TF 2.6.2 or TF 2.7.0

Here: [How to fix error: Cannot register 2 metrics with the same name: /tensorflow/api/keras/optimizers - Stack Overflow](https://stackoverflow.com/questions/69694944/how-to-fix-error-cannot-register-2-metrics-with-the-same-name-tensorflow-api)  
This specific bug was fixed in version [2.6.2] though actually.

So it looks like it could be a bug with 2.6.0, that could be resolved with 2.6.2.

---

<div class="post-metadata">

**Author:** ![rbgb](https://avatars.discourse-cdn.com/v4/letter/r/898d66/32.png) [@rbgb](https://community.drivendata.org/u/rbgb)\
**Post date:** [December 14, 2021, 4:42pm UTC](https://community.drivendata.org/t/error-when-importing-keras/6842/3 "2021-12-14T16:42:07Z")

</div>

Thanks for pointing this out. I believe this should be fixed in the newest version of the runtime now that [Fix keras version bug by r-b-g-b · Pull Request #14 · drivendataorg/cloud-cover-runtime · GitHub](https://github.com/drivendataorg/cloud-cover-runtime/pull/14) is merged. Let me know if it continues to act up!
