serizba / cppflow

Run TensorFlow models in C++ without installation and without Bazel
https://serizba.github.io/cppflow/
MIT License
781 stars 177 forks source link

How do I disable Tensorflow logging Output #107

Closed seungtaek94 closed 3 years ago

seungtaek94 commented 3 years ago

Hi.

Is there any way to disable tensorflow logging information that like below?

2021-03-25 14:54:21.311840: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cudart64_110.dll
2021-03-25 14:54:21.520673: I tensorflow/core/platform/cpu_feature_guard.cc:142] This TensorFlow binary is optimized with oneAPI Deep Neural Network Library (oneDNN) to use the following CPU instructions in performance-critical operations:  AVX2
To enable them in other operations, rebuild TensorFlow with the appropriate compiler flags.
2021-03-25 14:54:21.544056: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library nvcuda.dll
2021-03-25 14:54:21.629101: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1720] Found device 0 with properties:
pciBusID: 0000:02:00.0 name: GeForce RTX 2080 SUPER computeCapability: 7.5
coreClock: 1.845GHz coreCount: 48 deviceMemorySize: 8.00GiB deviceMemoryBandwidth: 462.00GiB/s
2021-03-25 14:54:21.642665: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cudart64_110.dll
2021-03-25 14:54:21.659783: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cublas64_11.dll
...
...
...

In python i can disable Tensorflow logging information like blow

import os
os.environ["TF_CPP_MIN_LOG_LEVEL"] = "3"

I tried using putenv("TF_CPP_MIN_LOG_LEVEL=3"); when i using c++ with cppflow2 but it doesn't work :(

serizba commented 3 years ago

Hi,

For me using putenv("TF_CPP_MIN_LOG_LEVEL=3") works perfectly. Perhaps you added it to your code late, and TF already started? Also you can try to run your executable like this:

TF_CPP_MIN_LOG_LEVEL=3 ./executable
seungtaek94 commented 3 years ago

I put putenv("TF_CPP_MIN_LOG_LEVEL=3") code in top of my main function.

But i think TF already run. Even if i set the breakpoint before putenv, TF logs are come up.. image

sorry for many questions. actually I m not friendly with c++..

Can u tell me when TF start..?

serizba commented 3 years ago

Are you running your code with optimization flags like -O3. If so, can you try without?

seungtaek94 commented 3 years ago

Are you running your code with optimization flags like -O3. If so, can you try without?

I tried run the code with optimization flags /Od(disable) in VS but it shows same result .

seungtaek94 commented 3 years ago

I solved this problem.

Set /DELAYLOAD:"tensorflow.dll(linker -> input -> DelayLoadDLLs in visual studio project setting).

Then write code that putenv("TF_CPP_MIN_LOG_LEVEL=3"); top of my main function.

serizba commented 3 years ago

I'm glad you finally made it work!