1

I'm using a deep learning library, Caffe, which is written in C++ and has an interface to Python. One of my commands creates a lot of unnecessary output to the log and I would really like to remove that by temporarily disabling logging.

Caffe uses GLOG and I've tried usingos.environ["GLOG_minloglevel"] = "2" to only log important messages. However, that didn't work. I've also tried using the Python logging module to shut down all logging temporarily using the code below, which didn't work either.

root_logger = logging.getLogger()
root_logger.disabled = True    
net = caffe.Net(model_file, pretrained, caffe.TEST)
root_logger.disabled = False
Shai
  • 111,146
  • 38
  • 238
  • 371
pir
  • 5,513
  • 12
  • 63
  • 101
  • Possible duplicate of [Setting GLOG\_minloglevel=1 to prevent output in shell from Caffe](http://stackoverflow.com/questions/29788075/setting-glog-minloglevel-1-to-prevent-output-in-shell-from-caffe) – Shai May 19 '16 at 05:35

2 Answers2

2

GLOG_minloglevel=3 ,only by executing that line in Python before calling

so,you can try

os.environ["GLOG_minloglevel"] ="3"
import caffe
Ghasem
  • 14,455
  • 21
  • 138
  • 171
james chang
  • 53
  • 1
  • 6
0

You likely need to set the log level environmental variable before you start Python. Or at leastt this worked for me:

GLOG_minloglevel=3 python script.py

Which silenced loading messages.

Aaron Zinman
  • 2,696
  • 2
  • 19
  • 16
  • Yes, but how do I reenable them for other messages? – pir Jul 08 '15 at 20:52
  • Change the log level for your desired output. See http://stackoverflow.com/questions/29788075/setting-glog-minloglevel-1-to-prevent-output-in-shell-from-caffe – Aaron Zinman Nov 05 '15 at 04:41