当试图用c#拦截时如何处理0xC0000409崩溃运行tensorflow重新训练?

时间:2016-12-08 06:54:42

标签: c# python tensorflow python-3.5

我的目标是为tensorflow创建一个小gui。我在DOS中的命令是

"C:\pythonpath\python.exe" "E:\retrainpath\retrain.py" --image_dir "D:\picturepath"

按原样运作

I c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\stream_executor\dso_loader.cc:128] successfully opened CUDA library cublas64_80.dll locally
I c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\stream_executor\dso_loader.cc:128] successfully opened CUDA library cudnn64_5.dll locally
I c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\stream_executor\dso_loader.cc:128] successfully opened CUDA library cufft64_80.dll locally
I c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\stream_executor\dso_loader.cc:128] successfully opened CUDA library nvcuda.dll locally
I c:\tf_jenkins\home\workspace\release-win\device\gpu\os\windows\tensorflow\stream_executor\dso_loader.cc:128] successfully opened CUDA library curand64_80.dll locally
>> Downloading inception...

然而,使用

试图拦截c#中的输出
private void button1_Click(object sender, EventArgs e)
{
    ParameterizedThreadStart pts = new ParameterizedThreadStart(trainieren);
    Thread thread = new Thread(pts);
    thread.Start(@"D:\picturepath");
}

string python = @"C:\pythonpath\python.exe";
string retrain = @"E:\retrainpath\retrain.py";


void trainieren(Object bildv)
{
    this.Invoke((MethodInvoker)delegate
    {
        button1.Enabled = false;
    });
    string bildverzeichnis = (string)bildv;
    string ApplicationPath = python;
    string ApplicationArguments = "\""+retrain + "\" --image_dir \"" + bildverzeichnis+"\"";
    Console.WriteLine(ApplicationPath + " " + ApplicationArguments);
    Process ProcessObj = new Process();
    ProcessObj.StartInfo.FileName = ApplicationPath;
    ProcessObj.StartInfo.Arguments = ApplicationArguments;
    ProcessObj.StartInfo.UseShellExecute = false;
    ProcessObj.StartInfo.RedirectStandardOutput = true;
    ProcessObj.StartInfo.RedirectStandardError = true;
    ProcessObj.StartInfo.RedirectStandardInput = true;
    ProcessObj.StartInfo.CreateNoWindow = true;
    ProcessObj.ErrorDataReceived += build_ErrorDataReceived;
    ProcessObj.OutputDataReceived += build_ErrorDataReceived;

    ProcessObj.EnableRaisingEvents = true;
    ProcessObj.Start();
    ProcessObj.BeginOutputReadLine();
    ProcessObj.BeginErrorReadLine();
    ProcessObj.WaitForExit();
    this.Invoke((MethodInvoker)delegate
    {
        button1.Enabled = true;
        this.Text = "Fertig";
    });
    statusInnen("Beendet");
    pb(0, 100, 0);
}

void build_ErrorDataReceived(object sender, DataReceivedEventArgs e)
{
    string zeile = e.Data;
    Console.WriteLine(zeile);
}

点击button1时发生的一切是:button1被禁用然后启用,调试窗口中的输出是两个空行。

我在python的minidump中发现因为0xC0000409,一个STATUS_STACK_BUFFER_OVERRUN而崩溃。

运行替代文件

import sys

s = 'Hello, world.'
print(s)

打印Hello,world。在c#中,所以这是tensorflows重新训练的问题,但只有从c#调用时才会出现。

0 个答案:

没有答案