SEHException in CNTK.CNTKLibPINVOKE.Trainer__TrainMinibatch__SWIG_2
I'm trying to deploy an ASP.Net application to production in IIS but i have the following error:
SEHException External component has thrown an exception.
at CNTK.CNTKLibPINVOKE.Trainer__TrainMinibatch__SWIG_2(HandleRef jarg1, HandleRef jarg2, Boolean jarg3, HandleRef jarg4)
at CNTK.Trainer._TrainMinibatch(UnorderedMapVariableValuePtr arguments, Boolean isSweepEndInArguments, DeviceDescriptor computeDevice)
at Signum.Engine.MachineLearning.CNTK.CNTKNeuralNetworkPredictorAlgorithm.Train(PredictorTrainingContext ctx) in C:\Solutions\IntTec_Live\Extensions\Signum.Engine.MachineLearning.CNTK\CNTKNeuralNetworkPredictor.cs:line 99
at Signum.Engine.MachineLearning.PredictorLogic.DoTraining(PredictorTrainingContext ctx) in C:\Solutions\IntTec_Live\Extensions\Signum.Engine.Extensions\MachineLearning\PredictorLogic.cs:line 381
What I've checked already:
- The application is working in IIS locally and in test, so the project is correctly compiling to x64.
- I have Visual Studio c++ Redistributable 2017 installed.
- The Path Enviroment variable is Ok, thanks to this peace of code:
var dir = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "bin");
var oldPath = Environment.GetEnvironmentVariable("Path");
if (!oldPath.Contains(dir + ";"))
Environment.SetEnvironmentVariable("Path", dir + ";" + oldPath, EnvironmentVariableTarget.Process);
- All the dlls look like in place:

The exception message looks quite opaque...
Any idea?
Could you tell us what the application logic is doing at Signum.Engine.Extensions\MachineLearning\PredictorLogic.cs:line 381?
Is trying to access some data on a file?
Hi @jaliyae, this a re the two files involved:
https://github.com/signumsoftware/extensions/blob/master/Signum.Engine.MachineLearning.CNTK/CNTKNeuralNetworkPredictor.cs
https://github.com/signumsoftware/extensions/blob/master/Signum.Engine.Extensions/MachineLearning/PredictorLogic.cs
Everything is configurable from the UI, but at this moment is training a minibatch:
trainer.TrainMinibatch(new Dictionary<Variable, Value>()
{
{ inputVariable, inputValue },
{ outputVariable, outputValue },
}, false, device);
This code with the same configuration works on local and test. I assume is some environment/installation/deployment issue.
And no, it’s not trying to read or write any data
We have been the whole day playing with the problem, to the point of creating a new server where we installed the prerequesites from https://docs.microsoft.com/en-us/cognitive-toolkit/Setup-Windows-Binary-Manual
Still failed, BTW the HResult is 0x80004005
We have also tried installing VS 2017 Community in the server, no luck.
Tomorrow we'll try to install CNTK 2.2 first and then upgrade to 2.3, that'S the process that happened in the servers that work.
Also, maybe installing CPU only version.
Any other ideas?
The problem has been fixed in one server by installing VS 2017 Community...
Fund!!! You need to install Visual Studio C++ 2013 Redistributable (x64)
Alleluja!
In my case there were other dependencies (MKL) missing. Just adding the NuGet package isn't working... Seems that NuGet dependencies/build is borked.