Ask questionsThe flag 'log_dir' is defined twice.

System information

  • Have I written custom code (as opposed to using a stock example script provided in TensorFlow): Yes
  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Linux Ubuntu 16.04
  • Mobile device (e.g. iPhone 8, Pixel 2, Samsung Galaxy) if the issue happens on mobile device: No
  • TensorFlow installed from (source or binary): binary
  • TensorFlow version (use command below): 1.14.0
  • Python version: Python 3.5
  • Bazel version (if compiling from source):
  • GCC/Compiler version (if compiling from source):
  • CUDA/cuDNN version: No
  • GPU model and memory: N/A

Describe the current behavior DuplicateFlagError: The flag 'log_dir' is defined twice.

Code to reproduce the issue import tensorflow as tf from absl import flags flags.DEFINE_string('log_dir', './log', 'Log directory')


Answer questions jackwish

Encountered similar issue when using PocketFlow which is running on top of TensorFlow. The message

wzh@docker2[✓]PocketFlow (r1.14*) $ ./scripts/ nets/
Python script: nets/
# of GPUs: 1
extra arguments:  --model_http_url --data_dir_local /home/wzh/datasets/cifar/cifar-10-batches-bin
Traceback (most recent call last):
  File "utils/", line 38, in <module>
    gpu_smi_output = subprocess.check_output(cmd, shell=True)
  File "/usr/lib/python3.6/", line 356, in check_output
  File "/usr/lib/python3.6/", line 438, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command 'nvidia-smi --query-gpu=index,memory.used, --format=csv,noheader,nounits' returned non-zero exit status 9.
'nets/' -> ''
multi-GPU training disabled
[WARNING] TF-Plus & Horovod cannot be imported; multi-GPU training is unsupported
Traceback (most recent call last):
  File "", line 27, in <module>'log_dir', './logs', 'logging directory')
  File "/home/wzh/toolchain/venv/pocket/lib/python3.6/site-packages/tensorflow/python/platform/", line 58, in wrapper
    return original_function(*args, **kwargs)
  File "/home/wzh/toolchain/venv/pocket/lib/python3.6/site-packages/absl/flags/", line 241, in DEFINE_string
    DEFINE(parser, name, default, help, flag_values, serializer, **args)
  File "/home/wzh/toolchain/venv/pocket/lib/python3.6/site-packages/absl/flags/", line 82, in DEFINE
    flag_values, module_name)
  File "/home/wzh/toolchain/venv/pocket/lib/python3.6/site-packages/absl/flags/", line 104, in DEFINE_flag
    fv[] = flag
  File "/home/wzh/toolchain/venv/pocket/lib/python3.6/site-packages/absl/flags/", line 430, in __setitem__
    raise _exceptions.DuplicateFlagError.from_flag(name, self)
absl.flags._exceptions.DuplicateFlagError: The flag 'log_dir' is defined twice. First from absl.logging, Second from  Description from first occurrence: directory t
o write logfiles into

When with TF 1.12, there is no such issue. With TF 1.14, the absl.flags._exceptions.DuplicateFlagError is raised.


Related questions

ModuleNotFoundError: No module named 'tensorflow.contrib' hot 8
Error occurred when finalizing GeneratorDataset iterator
ModuleNotFoundError: No module named 'tensorflow.contrib'
Lossy conversion from float32 to uint8. Range [0, 1]. Convert image to uint8 prior to saving to suppress this warning. hot 4
TF2.0 AutoGraph issue hot 4
When importing TensorFlow, error loading Hadoop hot 4
tensorflow2.0 detected 'xla_gpu' , but 'gpu' expected hot 3
[TF 2.0] Dataset has no attribute 'make_one_shot_iterator' hot 3
ImportError: No module named '' hot 3
Tensorflow 2.0 error when used via pyinstaller build - ImportError: cannot import name 'pywrap_tensorflow' from 'tensorflow_core.python' hot 3
Tf.Keras metrics issue hot 3
Error loading tensorflow hot 3
AttributeError: module 'tensorflow' has no attribute 'set_random_seed' hot 3
AttributeError: module &#39;tensorflow&#39; has no attribute &#39;Session&#39; hot 3
module 'tensorflow' has no attribute 'ConfigProto' hot 3
Github User Rank List