Reputation: 642
I have the code for CSEvalClientTest.csproj from Microsoft's CNTK on GitHub. I've created a new Visual Studio 2015 c# console app, pasted in the code from CSEvalClientTest.csproj, fixed the references and got it to run. It doesn't get very far though. On this line of source code: using (var model = new IEvaluateModelManagedF()) It throws this exception:
System.Runtime.InteropServices.SEHException was unhandled
Any help resolving this issue will be very much appreciated!
Upvotes: 2
Views: 1056
Reputation: 3149
Most likely, you are missing some of the referenced native DLLs. Have a look at this related SO question for a list of DLLs. Those need to reside in the same directory as your main executable.
Note that you will have to add the correct set of references for all DLLs or EXEs that use EvalWrapper
, which is a cumbersome. I've found it helpful to work with a props
file, that you reference in your project files. Here's how my cntk_evalwrapper.props
looks like (you need to adjust the location of your CNTK build)
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<ItemGroup>
<None Include="c:/git/cntk/x64/Release_CpuOnly/EvalDll.dll">
<Link>evaldll.dll</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="c:/git/cntk/x64/Release_CpuOnly/EvalDll.lib">
<Link>EvalDll.lib</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="c:/git/cntk/x64/Release_CpuOnly/Math.dll">
<Link>Math.dll</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="c:/git/cntk/x64/Release_CpuOnly/libiomp5md.dll">
<Link>libiomp5md.dll</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<None Include="c:/git/cntk/x64/Release_CpuOnly/mkl_cntk_p.dll">
<Link>mkl_cntk_p.dll</Link>
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
</None>
<Reference Include="EvalWrapper">
<HintPath>c:/git/cntk/x64/Release_CpuOnly/EvalWrapper.dll</HintPath>
</Reference>
</ItemGroup>
</Project>
In your project file yourproject.csproj
, include this props file, so that the top of your project file looks like:
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="14.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="..\cntk_evalwrapper.props" />
Again, adjust the relative path such that it correctly points from your project file to the props file. If that worked correctly, you should see a reference to EvalWrapper
in your project's references once you re-load the project.
Upvotes: 0
Reputation: 556
Would you be able to use CNTK Nuget Package for your C# application? This would remove most headaches regarding dll references. You can look at the example in https://github.com/Microsoft/CNTK/tree/master/Examples/Evaluation/CSEvalClient for more information.
Upvotes: 1