0

This could be a trivial question. The problem is, I only have 1 GPU device. To test if tensorflow is using GPU as the accelerator, like discussed in this question, I run:

import tensorflow as tf
sess = tf.Session(config=tf.ConfigProto(log_device_placement=True))

and similar to that answer, I have such device mapping information appeared twice:

Device mapping:
/job:localhost/replica:0/task:0/device:GPU:0 -> device: 0, name: Tesla K80, pci bus id: 0000:00:04.0, compute capability: 3.7
2018-11-01 22:00:25.678626: I tensorflow/core/common_runtime/direct_session.cc:291] Device mapping:
/job:localhost/replica:0/task:0/device:GPU:0 -> device: 0, name: Tesla K80, pci bus id: 0000:00:04.0, compute capability: 3.7

So what makes this happen?

Milo Lu
  • 3,176
  • 3
  • 35
  • 46
Bs He
  • 717
  • 1
  • 10
  • 22

1 Answers1

0

The reason it is printed twice, is the first time the C code is doing a printf to screen and the 2nd time it is doing a log statement that also gets directed to the screen.

If you want to disable all logging from C code run:

export TF_CPP_MIN_LOG_LEVEL=3

before running your python program.

This is the code from tensorflow/core/common_runtime/direct_session.cc

  if (options.config.log_device_placement()) {
    const string mapping_str = device_mgr_->DeviceMappingString();
    if (mapping_str.empty()) {
      printf("Device mapping: no known devices.\n");
    } else {
      printf("Device mapping:\n%s", mapping_str.c_str());
    }
    LOG(INFO) << "Device mapping:\n" << mapping_str;

from here: https://github.com/tensorflow/tensorflow/blob/master/tensorflow/core/common_runtime/direct_session.cc#L301-L309

William D. Irons
  • 2,244
  • 1
  • 18
  • 19