title: TensorFlow keras callback using tensorboard. ProfilerNotRunningError: Cannot stop profiling. No profiler is running
body: <p>I am running into this  error: <code>Cannot stop profiling. No profiler is running</code>. Can it be related to <code>log_dir</code> ?</p>
  <p>Before this issue, I had a problem with creating a directory. I have fixed it by manual creating dir. Can the error &quot;Cannot stop profiling. No profiler is running&quot; be related?</p>
  <p>Please help</p>
  <p>here is the code</p>
  <pre><code>import tensorflow as tf
  from tensorflow.keras.models import Sequential
  from tensorflow.keras.datasets import cifar10
  from tensorflow.keras.preprocessing.image import ImageDataGenerator
  from tensorflow.keras.layers import Dense, Dropout, Activation, Flatten,Conv2D, MaxPooling2D
  from tensorflow.keras.callbacks import TensorBoard
  
  import pickle
  import time
  
  NAME = &quot;car_and_sign&quot;#.format(int(time.time()))
  
  tensorboard=TensorBoard(log_dir='logs/{}'.format(NAME))
  
  X=pickle.load(open(&quot;X.pickle&quot;,&quot;rb&quot;))
  y=pickle.load(open(&quot;y.pickle&quot;,&quot;rb&quot;))
  
  X=X/255
  
  model = Sequential()
  
  model.add(Conv2D(64,(3,3),input_shape=X.shape[1:]))
  model.add(Activation(&quot;relu&quot;))
  model.add(MaxPooling2D(pool_size=(2,2)))
  
  model.add(Conv2D(64,(3,3)))
  model.add(Activation(&quot;relu&quot;))
  model.add(MaxPooling2D(pool_size=(2,2)))
  
  model.add(Flatten())
  model.add(Dense(64))
  
  model.add(Dense(1))
  model.add(Activation('sigmoid'))
  
  tensorboard = TensorBoard(log_dir=&quot;logs/{}&quot;.format(NAME))
  
  model.compile(loss=&quot;binary_crossentropy&quot;,
               optimizer=&quot;adam&quot;,
               metrics=['accuracy'])
  
  model.fit(X,y,
            batch_size=32,
            epochs=3,
            validation_split=0.3,
            callbacks=[tensorboard])
  </code></pre>
  <p>The ERROR:</p>
  <pre><code>Train on 2935 samples, validate on 1258 samples
  Epoch 1/3
  WARNING:tensorflow:Trace already enabled
  32/2935 [..............................] - ETA: 35s - loss: 0.7010 - 
  accuracy: 0.5312Traceback (most recent call last):
  
  File &quot;F:\Python\lib\site- 
  packages\tensorflow_core\python\keras\engine\training_v2.py&quot;, line 753, in on_start
  yield
  
  File &quot;F:\Python\lib\site-packages\tensorflow_core\python\keras\engine\training_v2.py&quot;, line 342, in fit
  total_epochs=epochs)
  
  File &quot;F:\Python\lib\site-packages\tensorflow_core\python\keras\engine\training_v2.py&quot;, line 181, in run_one_epoch
  step += 1
  
  File &quot;F:\Python\lib\contextlib.py&quot;, line 119, in __exit__
  next(self.gen)
  
  File &quot;F:\Python\lib\site-packages\tensorflow_core\python\keras\engine\training_v2.py&quot;, line 788, in on_batch
  mode, 'end', step, batch_logs)
  
  File &quot;F:\Python\lib\site-packages\tensorflow_core\python\keras\callbacks.py&quot;, line 239, in _call_batch_hook
  batch_hook(batch, logs)
  
  File &quot;F:\Python\lib\site-packages\tensorflow_core\python\keras\callbacks.py&quot;, line 1695, in on_train_batch_end
  self._log_trace()
  
  File &quot;F:\Python\lib\site-packages\tensorflow_core\python\keras\callbacks.py&quot;, line 1747, in _log_trace
  profiler_outdir=os.path.join(self._log_write_dir, 'train'))
  
  File &quot;F:\Python\lib\site-packages\tensorflow_core\python\ops\summary_ops_v2.py&quot;, line 1240, in trace_export
  _profiler.save(profiler_outdir, _profiler.stop())
  
  File &quot;F:\Python\lib\site-packages\tensorflow_core\python\eager\profiler.py&quot;, line 99, in stop
  'Cannot stop profiling. No profiler is running.')
  
  ProfilerNotRunningError: Cannot stop profiling. No profiler is running.
  </code></pre>
  <p>During handling of the above exception, another exception occurred:</p>
  <pre><code>Traceback (most recent call last):
  
  File &quot;C:\Users\malic\Documents\projects\Spide\train_loaddata.py&quot;, line 47, in &lt;module&gt;
  callbacks=[tensorboard])
  
  File &quot;F:\Python\lib\site-packages\tensorflow_core\python\keras\engine\training.py&quot;, line 819, in fit
  use_multiprocessing=use_multiprocessing)
  
  File &quot;F:\Python\lib\site-packages\tensorflow_core\python\keras\engine\training_v2.py&quot;, line 397, in fit
  prefix='val_')
  
  File &quot;F:\Python\lib\contextlib.py&quot;, line 130, in __exit__
  self.gen.throw(type, value, traceback)
  
  File &quot;F:\Python\lib\site-packages\tensorflow_core\python\keras\engine\training_v2.py&quot;, line 757, in on_start
  self.callbacks._call_end_hook(mode)
  
  File &quot;F:\Python\lib\site-packages\tensorflow_core\python\keras\callbacks.py&quot;, line 262, in _call_end_hook
  self.on_train_end()
  
  File &quot;F:\Python\lib\site-packages\tensorflow_core\python\keras\callbacks.py&quot;, line 379, in on_train_end
  callback.on_train_end(logs)
  
  File &quot;F:\Python\lib\site-packages\tensorflow_core\python\keras\callbacks.py&quot;, line 1720, in on_train_end
  self._log_trace()
  
  File &quot;F:\Python\lib\site-packages\tensorflow_core\python\keras\callbacks.py&quot;, line 1747, in _log_trace
  profiler_outdir=os.path.join(self._log_write_dir, 'train'))
  
  File &quot;F:\Python\lib\site-packages\tensorflow_core\python\ops\summary_ops_v2.py&quot;, line 1240, in trace_export
  _profiler.save(profiler_outdir, _profiler.stop())
  
  File &quot;F:\Python\lib\site-packages\tensorflow_core\python\eager\profiler.py&quot;, line 99, in stop
  'Cannot stop profiling. No profiler is running.')
  
  ProfilerNotRunningError: Cannot stop profiling. No profiler is running.
  </code></pre>