새소식

TroubleShooting

[Warning] Successfully opened dynamic library(TensorFlow2)

  • -

 

 

tensorflow를 쓰면서 아래와 같은 Success 메시지가 너무 많아서 불편함을 느꼈습니다..(tf2.4.1, RTX 2070S 사용 중)

 

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
2021-01-30 07:26:55.594322: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cudart64_110.dll
2021-01-30 07:26:57.504207: I tensorflow/compiler/jit/xla_cpu_device.cc:41] Not creating XLA devices, tf_xla_enable_xla_devices not set   
2021-01-30 07:26:57.511165: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library nvcuda.dll
2021-01-30 07:26:57.566351: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1720] Found device 0 with properties: 
pciBusID: 0000:01:00.0 name: GeForce RTX 2070 SUPER computeCapability: 7.5
coreClock: 1.8GHz coreCount: 40 deviceMemorySize: 8.00GiB deviceMemoryBandwidth: 417.29GiB/s
2021-01-30 07:26:57.577778: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cudart64_110.dll
2021-01-30 07:26:57.588696: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cublas64_11.dll  
2021-01-30 07:26:57.594819: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cublasLt64_11.dll
2021-01-30 07:26:57.603444: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cufft64_10.dll
2021-01-30 07:26:57.624293: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library curand64_10.dll
2021-01-30 07:26:57.643202: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cusolver64_10.dll
2021-01-30 07:26:57.653462: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cusparse64_11.dll
2021-01-30 07:26:57.665108: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cudnn64_8.dll
2021-01-30 07:26:57.671025: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1862] Adding visible gpu devices: 0
2021-01-30 07:26:57.688128: 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-01-30 07:26:57.722035: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1720] Found device 0 with properties:
pciBusID: 0000:01:00.0 name: GeForce RTX 2070 SUPER computeCapability: 7.5
coreClock: 1.8GHz coreCount: 40 deviceMemorySize: 8.00GiB deviceMemoryBandwidth: 417.29GiB/s
2021-01-30 07:26:57.761537: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cudart64_110.dll
2021-01-30 07:26:57.775320: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cublas64_11.dll
2021-01-30 07:26:57.789245: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cublasLt64_11.dll
2021-01-30 07:26:57.803960: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cufft64_10.dll
2021-01-30 07:26:57.810109: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library curand64_10.dll
2021-01-30 07:26:57.826738: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cusolver64_10.dll
2021-01-30 07:26:57.853859: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cusparse64_11.dll
2021-01-30 07:26:57.867859: I tensorflow/stream_executor/platform/default/dso_loader.cc:49] Successfully opened dynamic library cudnn64_8.dll
2021-01-30 07:26:57.873703: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1862] Adding visible gpu devices: 0
2021-01-30 07:26:58.432363: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1261] Device interconnect StreamExecutor with strength 1 edge matrix:
2021-01-30 07:26:58.439391: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1267]      0
2021-01-30 07:26:58.443921: I tensorflow/core/common_runtime/gpu/gpu_device.cc:12800:   N 
2021-01-30 07:26:58.459328: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1406] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 6611 MB memory) -> physical GPU (device: 0, name: GeForce RTX 2070 SUPER, pci bus id: 0000:01:00.0, compute capability: 7.5)
2021-01-30 07:26:58.473618: I tensorflow/compiler/jit/xla_gpu_device.cc:99] Not creating XLA devices, tf_xla_enable_xla_devices not set
cs

 

 

그래서 이를 필터링으로 안 보이게 처리하고자 방법을 찾아보았습니다.

 

import os

os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'

 

이 2줄만 추가해서 해결합니다.

이 때, 중요한 것은 import하는 tensorflow보다 위에 선언해줘야 메시지가 뜨지 않는다.

 

1
2
3
4
5
6
7
import numpy as np
import os
os.environ['TF_CPP_MIN_LOG_LEVEL'= '2'
import tensorflow as tf
 
t2 = tf.ones(shape=(103))
print(t2)
cs

 

위와 같이 선언의 순서를 적어도 tensorflow보다는 위에 os 메시지를 처리해야줘야 합니다.

바로 os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'을 import tensorflow 부분보다 위에 선언하라는 것이다.

궁금하면 3, 4라인만 바꿔서 실행해봐도 알 수 있다.

 

 

실행한 결과값

 

 

 

메시지가 안 떠서 해결했으나 os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'가 어떤 의미인지 간단히 알고 가면

아래와 같습니다.(본 글에서는 2로 WARNING을 필터링하였습니다.

 

  기본값   0
  INFO 로그 필터링   1
  WARNING 로그 필터링   2
  ERROR 로그 필터링   3

 

 

 

결론

tensorflow 라이브러리 선언 전에 상단에 아래와 같이 선언하여 사용합니다.

 

import os

os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'

 

 

 

 

 

 

 

Reference

 

 

 

 

 

 

Contents

포스팅 주소를 복사했습니다

이 글이 도움이 되었다면 공감 부탁드립니다.