mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-05-14 20:48:00 +00:00
C# Gpu : Minor updates to exception message (#201)
* Minor updates to exception message * update models folder to new location * update copy to preservenewest
This commit is contained in:
parent
71c56b6d7c
commit
0287019c1d
4 changed files with 20 additions and 14 deletions
|
|
@ -26,7 +26,6 @@ namespace Microsoft.ML.OnnxRuntime
|
|||
InvalidGraph = 10,
|
||||
ShapeInferenceNotRegistered = 11,
|
||||
RequirementNotRegistered = 12,
|
||||
ExecutionProviderDLLNotFound = 13
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
@ -49,7 +48,6 @@ namespace Microsoft.ML.OnnxRuntime
|
|||
{ ErrorCode.InvalidGraph, "InvalidGraph" },
|
||||
{ ErrorCode.ShapeInferenceNotRegistered, "ShapeInferenceNotRegistered" },
|
||||
{ ErrorCode.RequirementNotRegistered, "RequirementNotRegistered" },
|
||||
{ ErrorCode.ExecutionProviderDLLNotFound, "ExecutionProviderDLLNotFound" }
|
||||
};
|
||||
|
||||
internal OnnxRuntimeException(ErrorCode errorCode, string message)
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
// Licensed under the MIT License.
|
||||
|
||||
using System;
|
||||
using System.Text;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace Microsoft.ML.OnnxRuntime
|
||||
|
|
@ -125,9 +126,12 @@ namespace Microsoft.ML.OnnxRuntime
|
|||
}
|
||||
}
|
||||
|
||||
// Declared, but called only if OS = Windows.
|
||||
[DllImport("kernel32.dll")]
|
||||
private static extern IntPtr LoadLibrary(string dllToLoad);
|
||||
|
||||
[DllImport("kernel32.dll")]
|
||||
static extern uint GetSystemDirectory([Out] StringBuilder lpBuffer, uint uSize);
|
||||
private static bool CheckCudaExecutionProviderDLLs()
|
||||
{
|
||||
if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
|
||||
|
|
@ -135,14 +139,15 @@ namespace Microsoft.ML.OnnxRuntime
|
|||
foreach (var dll in cudaDelayLoadedLibs)
|
||||
{
|
||||
IntPtr handle = LoadLibrary(dll);
|
||||
if (handle == IntPtr.Zero)
|
||||
{
|
||||
throw new OnnxRuntimeException(
|
||||
ErrorCode.ExecutionProviderDLLNotFound,
|
||||
$"Dll not found: {dll}. CUDA 10.0 is required for GPU execution. " +
|
||||
$"Verify that the library is available on system path."
|
||||
);
|
||||
}
|
||||
if (handle != IntPtr.Zero)
|
||||
continue;
|
||||
var sysdir = new StringBuilder(String.Empty, 2048);
|
||||
GetSystemDirectory(sysdir, (uint)sysdir.Capacity);
|
||||
throw new OnnxRuntimeException(
|
||||
ErrorCode.NoSuchFile,
|
||||
$"kernel32.LoadLibrary():'{dll}' not found. CUDA 10.0 is required for GPU execution. " +
|
||||
$". Verify it is available in the system directory={sysdir}. Else copy it to the output folder."
|
||||
);
|
||||
}
|
||||
}
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -226,7 +226,10 @@ namespace Microsoft.ML.OnnxRuntime.Tests
|
|||
if (modelNames[0].ToString() == "._resnet34v2.onnx")
|
||||
modelNames[0] = modelNames[1];
|
||||
else
|
||||
throw new Exception($"Opset {opset}: Model {model}: error = can't determine model file name.");
|
||||
{
|
||||
var modelNamesList = string.Join(",", modelNames.Select(x => x.ToString()));
|
||||
throw new Exception($"Opset {opset}: Model {model}. Can't determine model file name. Found these :{modelNamesList}");
|
||||
}
|
||||
}
|
||||
|
||||
var session = new InferenceSession($"{opset}\\{model}\\{modelNames[0].ToString()}");
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp2.0</TargetFramework>
|
||||
|
|
@ -38,8 +38,8 @@
|
|||
<Visible>false</Visible>
|
||||
</None>
|
||||
|
||||
<None Include="$(buildDirectory)\$(Configuration)\models\**\*">
|
||||
<CopyToOutputDirectory>Always</CopyToOutputDirectory>
|
||||
<None Include="$(buildDirectory)\models\**\*">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
<Visible>false</Visible>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
|
|
|
|||
Loading…
Reference in a new issue