Suppress output in python?

4,722 views
Skip to first unread message

Dmitry Ulyanov

unread,
Feb 6, 2015, 1:57:07 AM2/6/15
to caffe...@googlegroups.com
Hello, I use python wrapper and I don't want to see any of caffe info it always prints about setup and so on. But whatever I do to suppress the output does not work for me, I tried many of standard python moves to switch stdout to something like 
sys.stdout = os.devnull
and then restore it, but it does not work, any ideas? Thanks!

Steven Clark

unread,
Feb 6, 2015, 12:25:42 PM2/6/15
to caffe...@googlegroups.com
Did you try stderr rather than stdout? I know at least some of the output goes to stderr.

Dmitry Ulyanov

unread,
Feb 9, 2015, 7:05:36 AM2/9/15
to caffe...@googlegroups.com
Yes, I tried both

Andriy Lysak

unread,
Feb 9, 2015, 1:59:13 PM2/9/15
to caffe...@googlegroups.com
you can also try this:

python /your/script 2> /dev/null

when i run my python wrapper all the set up is piped through stderr so i just use the command above

Best Regards,
Andriy

Dmitry Ulyanov

unread,
Feb 12, 2015, 3:38:31 AM2/12/15
to caffe...@googlegroups.com
Thank you for the comment. This way works, but my workflow is like that: I run a server which should process incoming queries, so I  do 

net = caffe.Net(train_test, snapshot_path)

and that is the only time I want to suppress everything, but then I have some logs, that I want to see, so I tried methods to redirect output inside the script but got no luck 

Luke Yeager

unread,
May 22, 2015, 7:48:29 PM5/22/15
to caffe...@googlegroups.com
I found a workaround. See the code here:


It would be kinda nice if caffe turned off the output when using python by default.

Luke Yeager

unread,
May 22, 2015, 8:36:45 PM5/22/15
to caffe...@googlegroups.com
Reply all
Reply to author
Forward
0 new messages