title: How to fix error: Cannot register 2 metrics with the same name: /tensorflow/api/keras/optimizers
body: <p>When I am trying to run a Python code for deep learning utilizing the TensorFlow library, I am getting the following error:</p>
  <pre><code>2021-10-24 10:07:13.619481: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'cudart64_110.dll'; dlerror: cudart64_110.dll not found
  2021-10-24 10:07:13.619752: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
  2021-10-24 10:07:18.797570: E tensorflow/core/lib/monitoring/collection_registry.cc:77] `Cannot register 2 metrics with the same name: /tensorflow/api/keras/optimizers`
  Traceback (most recent call last):
    File &quot;C:\Users\Admin\Downloads\Compressed\Face-Mask-Detection-master\detect_mask_image.py&quot;, line 5, in &lt;module&gt;
      from tensorflow.keras.applications.mobilenet_v2 import preprocess_input
    File &quot;C:\Python39\lib\site-packages\keras\api\_v2\keras\__init__.py&quot;, line 8, in &lt;module&gt;
      from keras import __version__
    File &quot;C:\Python39\lib\site-packages\keras\__init__.py&quot;, line 25, in &lt;module&gt;
      from keras import models
    File &quot;C:\Python39\lib\site-packages\keras\models.py&quot;, line 20, in &lt;module&gt;
      from keras import metrics as metrics_module
    File &quot;C:\Python39\lib\site-packages\keras\metrics.py&quot;, line 26, in &lt;module&gt;
      from keras import activations
    File &quot;C:\Python39\lib\site-packages\keras\activations.py&quot;, line 20, in &lt;module&gt;
      from keras.layers import advanced_activations
    File &quot;C:\Python39\lib\site-packages\keras\layers\__init__.py&quot;, line 23, in &lt;module&gt;
      from keras.engine.input_layer import Input
    File &quot;C:\Python39\lib\site-packages\keras\engine\input_layer.py&quot;, line 21, in &lt;module&gt;
      from keras.engine import base_layer
    File &quot;C:\Python39\lib\site-packages\keras\engine\base_layer.py&quot;, line 43, in &lt;module&gt;
      from keras.mixed_precision import loss_scale_optimizer
    File &quot;C:\Python39\lib\site-packages\keras\mixed_precision\loss_scale_optimizer.py&quot;, line 18, in &lt;module&gt;
      from keras import optimizers
    File &quot;C:\Python39\lib\site-packages\keras\optimizers.py&quot;, line 26, in &lt;module&gt;
      from keras.optimizer_v2 import adadelta as adadelta_v2
    File &quot;C:\Python39\lib\site-packages\keras\optimizer_v2\adadelta.py&quot;, line 22, in &lt;module&gt;
      from keras.optimizer_v2 import optimizer_v2
    File &quot;C:\Python39\lib\site-packages\keras\optimizer_v2\optimizer_v2.py&quot;, line 36, in &lt;module&gt;
      keras_optimizers_gauge = tf.__internal__.monitoring.BoolGauge(
    File &quot;C:\Python39\lib\site-packages\tensorflow\python\eager\monitoring.py&quot;, line 360, in __init__
      super(BoolGauge, self).__init__('BoolGauge', _bool_gauge_methods,
    File &quot;C:\Python39\lib\site-packages\tensorflow\python\eager\monitoring.py&quot;, line 135, in __init__
      self._metric = self._metric_methods[self._label_length].create(*args)
  tensorflow.python.framework.errors_impl.
  AlreadyExistsError: Another metric with the same name already exists.
  </code></pre>
  <p>Environment:</p>
  <p>Python version: 3.9</p>
  <p>OS: Windows</p>
  <p>Library: TensorFlow API</p>