Open MaxCarlson opened 6 years ago
Were you able to solve this?
I'd thought I had after I re-routed stderr (the stream CNTK uses to printout the device) temporarily around the code where CNTK calls UseDefaultDevice() (Which prints out the device). However, after more testing it appears I closed the issue prematurely as despite successfully rerouting stderr to a file I still have the same or similar conflict with the GUI sabaki that uses GTP.
I was able to reroute stderr (on windows) with this code, but it doesn't appear to have fixed the issue:
#include <stdio.h>
#include <io.h>
#define STDIN_FILENO 0
#define STDOUT_FILENO 1
#define STDERR_FILENO 2
#pragma warning( push )
#pragma warning(disable : 4996)
// Scoped redirect of a standard stream
// StdFile = the stream code for the std stream
// you wish to redirect
struct RedirectStream
{
RedirectStream(int StdFile = STDOUT_FILENO) : FileCode(StdFile)
{
std_dupfd = _dup(FileCode);
temp_out = fopen("file.txt", "w");
_dup2(_fileno(temp_out), FileCode);
fflush(__acrt_iob_func(FileCode));
}
~RedirectStream()
{
fclose(temp_out);
/* Now restore stdout */
_dup2(std_dupfd, FileCode);
_close(std_dupfd);
}
int FileCode;
int std_dupfd;
FILE *temp_out;
};
#pragma warning( pop )
Can't you just run your executable with 2> nul
(this will redirect stderr to null on Windows)?
As in in the console type 2> nul exec.exe? That crashes the exe. I actually need to use stderr (at least the c++ stream version) as that's how GTP GUI's handle printing info that's not a direct reply to the GTP command.
I meant exec.exe 2> nul
.
The message is printed here: https://github.com/Microsoft/CNTK/blob/f49c174f2d3ac7d724b47f911f1626d2f9b01800/Source/CNTKv2LibraryDll/Common.cpp#L715, and it should be probably wrapped in if (GetTraceLevel() >= TraceLevel::Info)
and not be printed by default. I'll look into this.
Thanks for looking into it! As it turns out, shutting off the stderr stream temporarily was enough to solve this issue for my engine+sabaki GUI. It was another issue which was preventing sabaki from loading my engine correctly once I'd removed the nets output.
When a model is loaded in C++ a message like the one below is printed to the console. This is causing me issues with the protocol, GTP, my program uses to communicate with GUI's. Is it possible to stop CNTK from printing out the default device? Or possibly change (or block) the output? Which output method is CNTK using to print this message?