profile
viewpoint

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')

tensorflow/tensorflow

Answer questions jackwish

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

wzh@docker2[✓]PocketFlow (r1.14*) $ ./scripts/run_local.sh nets/resnet_at_cifar10_run.py
Python script: nets/resnet_at_cifar10_run.py
# of GPUs: 1
extra arguments:  --model_http_url https://api.ai.tencent.com/pocketflow --data_dir_local /home/wzh/datasets/cifar/cifar-10-batches-bin
Traceback (most recent call last):
  File "utils/get_idle_gpus.py", line 38, in <module>
    gpu_smi_output = subprocess.check_output(cmd, shell=True)
  File "/usr/lib/python3.6/subprocess.py", line 356, in check_output
    **kwargs).stdout
  File "/usr/lib/python3.6/subprocess.py", line 438, in run
    output=stdout, stderr=stderr)
subprocess.CalledProcessError: Command 'nvidia-smi --query-gpu=index,memory.used,memory.total --format=csv,noheader,nounits' returned non-zero exit status 9.
'nets/resnet_at_cifar10_run.py' -> 'main.py'
multi-GPU training disabled
[WARNING] TF-Plus & Horovod cannot be imported; multi-GPU training is unsupported
Traceback (most recent call last):
  File "main.py", line 27, in <module>
    tf.app.flags.DEFINE_string('log_dir', './logs', 'logging directory')
  File "/home/wzh/toolchain/venv/pocket/lib/python3.6/site-packages/tensorflow/python/platform/flags.py", line 58, in wrapper
    return original_function(*args, **kwargs)
  File "/home/wzh/toolchain/venv/pocket/lib/python3.6/site-packages/absl/flags/_defines.py", 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/_defines.py", line 82, in DEFINE
    flag_values, module_name)
  File "/home/wzh/toolchain/venv/pocket/lib/python3.6/site-packages/absl/flags/_defines.py", line 104, in DEFINE_flag
    fv[flag.name] = flag
  File "/home/wzh/toolchain/venv/pocket/lib/python3.6/site-packages/absl/flags/_flagvalues.py", 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 main.py.  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.

useful!

Related questions

Error occurred when finalizing GeneratorDataset iterator hot 4
AttributeError: module 'tensorflow' has no attribute 'set_random_seed' hot 3
Incorrect Error TypeError: padded_batch() missing 1 required positional argument: &#39;padded_shapes&#39; hot 3
tensorflow2.0 detected 'xla_gpu' , but 'gpu' expected hot 2
Using tensorflow gpu 2.1 with Cuda 10.2 hot 2
Restoring Keras model fails inside a distribution strategy scope hot 2
tf.strings.split bug hot 2
Cannot run tensorflow GPU 2.0 with cuda 9.2 hot 2
module 'tensorflow_core._api.v2.nn' has no attribute 'rnn_cell' hot 2
Lossy conversion from float32 to uint8. Range [0, 1]. Convert image to uint8 prior to saving to suppress this warning. hot 2
compiling c++ code with TFLite library gives error with cstring hot 2
Tensorflow 2.0 error when used via pyinstaller build - ImportError: cannot import name 'pywrap_tensorflow' from 'tensorflow_core.python' hot 2
ModuleNotFoundError: No module named 'tensorflow.contrib' hot 2
TF2.0 AutoGraph issue hot 2
TypeError: Cannot interpret feed_dict key as Tensor: Tensor Tensor("Placeholder:0", shape=(7, 7, 3, 64), dtype=float32) is not an element of this graph. hot 2
Github User Rank List