bug5-os.environ无效

    科技2024-07-23  66

    文章目录

    由于Tensorflow特有的原因,在打印是会打印一大推无效信息,其中包括INFO,WARNING,ERROR,FATAL 我的如下

    2020-10-07 16:11:20.472324: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library cudart64_100.dll 2020-10-07 16:11:22.047611: I tensorflow/stream_executor/platform/default/dso_loader.cc:44] Successfully opened dynamic library nvcuda.dll 2020-10-07 16:11:22.075530: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1618] Found device 0 with properties: name: GeForce GTX 1650 major: 7 minor: 5 memoryClockRate(GHz): 1.56 pciBusID: 0000:01:00.0 2020-10-07 16:11:22.075766: I tensorflow/stream_executor/platform/default/dlopen_checker_stub.cc:25] GPU libraries are statically linked, skip dlopen check. 2020-10-07 16:11:22.075956: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1746] Adding visible gpu devices: 0 2020-10-07 16:11:22.076293: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 2020-10-07 16:11:22.079354: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1618] Found device 0 with properties: name: GeForce GTX 1650 major: 7 minor: 5 memoryClockRate(GHz): 1.56 pciBusID: 0000:01:00.0 2020-10-07 16:11:22.079541: I tensorflow/stream_executor/platform/default/dlopen_checker_stub.cc:25] GPU libraries are statically linked, skip dlopen check. 2020-10-07 16:11:22.079736: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1746] Adding visible gpu devices: 0 2020-10-07 16:11:22.541337: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1159] Device interconnect StreamExecutor with strength 1 edge matrix: 2020-10-07 16:11:22.541480: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1165] 0 2020-10-07 16:11:22.541611: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1178] 0: N 2020-10-07 16:11:22.541844: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1304] Created TensorFlow device (/job:localhost/replica:0/task:0/device:GPU:0 with 1335 MB memory) -> physical GPU (device: 0, name: GeForce GTX 1650, pci bus id: 0000:01:00.0, compute capability: 7.5)

    通过在最开始添加,即置于导入Tensorflow前

    import os # 将无效信息屏蔽掉 # 取值有四个:0,1,2,3,分别对应INFO,WARNING,ERROR,FATAL os.environ['TF_CPP_MIN_LOG_LEVEL'] = '2'

    如果仍然无效,一般是未置于最开始

    Processed: 0.015, SQL: 8