<p dir="auto"><em>Please make sure that this is a bug. As per our <a href="https://github.com/tensorflow/tensorflow/blob/master/ISSUES.md">GitHub Policy</a>, we only address code/doc bugs, performance issues, feature requests and build/installation issues on GitHub. tag:bug_template</em></p>
<p dir="auto"><strong>System information</strong></p>
<ul dir="auto">
<li>OS Platform and Distribution (e.g., Linux Ubuntu 16.04): mac OS Mojave</li>
<li>TensorFlow installed from (source or binary): pip</li>
<li>TensorFlow version (use command below): 2.0.0 alpha-0</li>
<li>Python version: 3.7.2</li>
</ul>
<p dir="auto"><strong>Describe the current behavior</strong><br>
When using Python internal "logging" module with Tensorflow, a logging module emits below warning message.</p>
<blockquote>
<p dir="auto">WARNING: Logging before flag parsing goes to stderr.</p>
</blockquote>
<p dir="auto">Also, it prints out duplicate logging message with my own formatter and something internally defined format(I guess) as below.</p>
<blockquote>
<p dir="auto">$ python3 test.py<br>
[INFO|test.py:29] 2019-03-14 17:30:14,402 &gt;&gt; Hello World.<br>
WARNING: Logging before flag parsing goes to stderr.<br>
I0314 17:30:14.402168 4528047552 test.py:29] Hello World.<br>
[INFO|test.py:30] 2019-03-14 17:30:14,402 &gt;&gt; This is message 1<br>
I0314 17:30:14.402369 4528047552 test.py:30] This is message 1</p>
</blockquote>
<p dir="auto">When I try without importing Tensorflow, then it works properly.</p>
<blockquote>
<p dir="auto">$ python3 test.py<br>
[INFO|test.py:29] 2019-03-14 17:37:40,172 &gt;&gt; Hello World.<br>
[INFO|test.py:30] 2019-03-14 17:37:40,172 &gt;&gt; This is message 1</p>
</blockquote>
<p dir="auto"><strong>Describe the expected behavior</strong><br>
Maybe stream handler is colliding each other.</p>
<p dir="auto"><strong>Code to reproduce the issue</strong></p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="import logging
import tensorflow as tf

formatter = logging.Formatter('[%(levelname)s|%(filename)s:%(lineno)s] %(asctime)s &gt;&gt; %(message)s')

stream_logger = logging.getLogger('logger_stream')
stream_logger.setLevel(logging.INFO)

# Set handler
streamHandler = logging.StreamHandler()
streamHandler.setFormatter(formatter)
stream_logger.addHandler(streamHandler)

stream_logger.info(&quot;Hello World&quot;)
stream_logger.info(&quot;This is message 1&quot;)"><pre class="notranslate"><code class="notranslate">import logging
import tensorflow as tf

formatter = logging.Formatter('[%(levelname)s|%(filename)s:%(lineno)s] %(asctime)s &gt;&gt; %(message)s')

stream_logger = logging.getLogger('logger_stream')
stream_logger.setLevel(logging.INFO)

# Set handler
streamHandler = logging.StreamHandler()
streamHandler.setFormatter(formatter)
stream_logger.addHandler(streamHandler)

stream_logger.info("Hello World")
stream_logger.info("This is message 1")
</code></pre></div>
<h3 dir="auto">System information</h3>
<ul dir="auto">
<li><strong>Have I written custom code (as opposed to using a stock example script provided in TensorFlow)</strong>: Yes, I have created two CNN models</li>
<li><strong>OS Platform and Distribution (e.g., Linux Ubuntu 16.04)</strong>: Linux Ubuntu 16.04</li>
<li><strong>TensorFlow installed from (source or binary)</strong>: I installed tensorflow via pip install (Python 3)</li>
<li><strong>TensorFlow version (use command below)</strong>: 1.4.0</li>
<li><strong>Python version</strong>: 3</li>
<li><strong>Bazel version (if compiling from source)</strong>:</li>
<li><strong>GCC/Compiler version (if compiling from source)</strong>:</li>
<li><strong>CUDA/cuDNN version</strong>: 8.0/6</li>
<li><strong>GPU model and memory</strong>: NVIDIA Tesla k80 totalMemory: 11.17GiB freeMemory: 11.09GiB</li>
<li><strong>Exact command to reproduce</strong>: See below:</li>
</ul>
<h3 dir="auto">Below is the log:</h3>
<blockquote>
<p dir="auto">keep_dims is deprecated, use keepdims instead</p>
<hr>
<h1 dir="auto">Layer (type)                 Output Shape              Param #</h1>
<p dir="auto">input_1 (InputLayer)         (None, 7, 264)            0</p>
<hr>
<p dir="auto">reshape_1 (Reshape)          (None, 7, 264, 1)         0</p>
<hr>
<p dir="auto">conv2d_1 (Conv2D)            (None, 7, 264, 64)        16960</p>
<hr>
<p dir="auto">max_pooling2d_1 (MaxPooling2 (None, 7, 132, 64)        0</p>
<hr>
<p dir="auto">flatten_1 (Flatten)          (None, 59136)             0</p>
<hr>
<p dir="auto">dense_1 (Dense)              (None, 1024)              60556288</p>
<hr>
<p dir="auto">dropout_1 (Dropout)          (None, 1024)              0</p>
<hr>
<p dir="auto">dense_2 (Dense)              (None, 512)               524800</p>
<hr>
<p dir="auto">dropout_2 (Dropout)          (None, 512)               0</p>
<hr>
<h1 dir="auto">dense_3 (Dense)              (None, 88)                45144</h1>
<p dir="auto">Total params: 61,143,192<br>
Trainable params: 61,143,192<br>
Non-trainable params: 0</p>
<hr>
<p dir="auto">/home/hpnhxxwn/miniconda3/envs/carnd-term1/lib/python3.5/site-packages/keras/engine/training.py:2057: UserWarning: Using a generator with <code class="notranslate">use_multiprocessing=True</code> and multiple worker<br>
s may duplicate your data. Please consider using the<code class="notranslate">keras.utils.Sequence class. UserWarning('Using a generator with </code>use_multiprocessing=True`'<br>
ld: learning rate is now 0.01<br>
2017-11-29 04:58:20.964015: I tensorflow/core/platform/cpu_feature_guard.cc:137] Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2 AVX A<br>
VX2 FMA<br>
2017-11-29 04:58:21.094051: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:900] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUM<br>
A node, so returning NUMA node zero<br>
2017-11-29 04:58:21.094719: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1062] Found device 0 with properties:<br>
name: Tesla K80 major: 3 minor: 7 memoryClockRate(GHz): 0.8235<br>
pciBusID: 0000:00:04.0<br>
totalMemory: 11.17GiB freeMemory: 11.09GiB<br>
2017-11-29 04:58:21.094744: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1152] Creating TensorFlow device (/device:GPU:0) -&gt; (device: 0, name: Tesla K80, pci bus id: 0000:00:04.0<br>
, compute capability: 3.7)<br>
Epoch 1/1000<br>
5180/6944 [=====================&gt;........] - ETA: 3:43 - loss: 0.1382 - acc: 0.9637 - mean_absolute_error: 0.0715 - sparse_categorical_accuracy: 7.1640e-05switching to  ['AkPnStgb']<br>
5212/6944 [=====================&gt;........] - ETA: 3:39 - loss: 0.1384 - acc: 0.9636 - mean_absolute_error: 0.0715 - sparse_categorical_accuracy: 7.1200e-052017-11-29 05:09:22.210897: F<br>
tensorflow/stream_executor/cuda/cuda_dnn.cc:444] could not convert BatchDescriptor {count: 0 feature_map_count: 64 spatial: 7 264  value_min: 0.000000 value_max: 0.000000 layout: Batc<br>
hDepthYX} to cudnn tensor descriptor: CUDNN_STATUS_BAD_PARAM</p>
</blockquote>
<h3 dir="auto">Below is the model.</h3>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="def baseline_model():
    inputs = Input(shape=input_shape)
    reshape = Reshape(input_shape_channels)(inputs)
    #normal convnet layer (have to do one initially to get 64 channels)
    conv1 = Conv2D(50,(5,25),activation='tanh')(reshape)
    do1 = Dropout(0.5)(conv1)
    pool1 = MaxPooling2D(pool_size=(1,3))(do1)
    conv2 = Conv2D(50,(3,5),activation='tanh')(pool1)
    do2 = Dropout(0.5)(conv2)
    pool2 = MaxPooling2D(pool_size=(1,3))(do2)
    flattened = Flatten()(pool2)
    fc1 = Dense(1000, activation='sigmoid')(flattened)
    do3 = Dropout(0.5)(fc1)
    fc2 = Dense(200, activation='sigmoid')(do3)
    do4 = Dropout(0.5)(fc2)
    outputs = Dense(note_range, activation='sigmoid')(do4)
    model = Model(inputs=inputs, outputs=outputs)
    return model"><pre class="notranslate"><code class="notranslate">def baseline_model():
    inputs = Input(shape=input_shape)
    reshape = Reshape(input_shape_channels)(inputs)
    #normal convnet layer (have to do one initially to get 64 channels)
    conv1 = Conv2D(50,(5,25),activation='tanh')(reshape)
    do1 = Dropout(0.5)(conv1)
    pool1 = MaxPooling2D(pool_size=(1,3))(do1)
    conv2 = Conv2D(50,(3,5),activation='tanh')(pool1)
    do2 = Dropout(0.5)(conv2)
    pool2 = MaxPooling2D(pool_size=(1,3))(do2)
    flattened = Flatten()(pool2)
    fc1 = Dense(1000, activation='sigmoid')(flattened)
    do3 = Dropout(0.5)(fc1)
    fc2 = Dense(200, activation='sigmoid')(do3)
    do4 = Dropout(0.5)(fc2)
    outputs = Dense(note_range, activation='sigmoid')(do4)
    model = Model(inputs=inputs, outputs=outputs)
    return model
</code></pre></div>
<p dir="auto">I have found other github issue created for the same issue, not so far seems like there is no fix yet. I heard the workaround is to use tf.cond, can someone show me how to use it in such case.</p>