Skip to content

Commit c378772

Browse files
Update to Onnxruntime 1.2 and reenable its support for GPU (#4919)
* Update Onnxruntime.managed version to 1.2 * Added dependencies to Onnxruntime (CPU) in test projects * Reenabled GPU support
1 parent 497708a commit c378772

File tree

8 files changed

+20
-6
lines changed

8 files changed

+20
-6
lines changed

build/Dependencies.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
<GoogleProtobufPackageVersion>3.10.1</GoogleProtobufPackageVersion>
1717
<LightGBMPackageVersion>2.2.3</LightGBMPackageVersion>
1818
<MicrosoftExtensionsPackageVersion>2.1.0</MicrosoftExtensionsPackageVersion>
19-
<MicrosoftMLOnnxRuntimePackageVersion>1.1.2</MicrosoftMLOnnxRuntimePackageVersion>
19+
<MicrosoftMLOnnxRuntimePackageVersion>1.2</MicrosoftMLOnnxRuntimePackageVersion>
2020
<MlNetMklDepsPackageVersion>0.0.0.9</MlNetMklDepsPackageVersion>
2121
<ParquetDotNetPackageVersion>2.1.3</ParquetDotNetPackageVersion>
2222
<SystemDrawingCommonPackageVersion>4.5.0</SystemDrawingCommonPackageVersion>

docs/samples/Microsoft.ML.Samples/Microsoft.ML.Samples.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -968,6 +968,7 @@
968968
<ItemGroup>
969969
<PackageReference Include="Microsoft.ML.Onnx.TestModels" Version="$(MicrosoftMLOnnxTestModelsVersion)" />
970970
<PackageReference Include="SciSharp.TensorFlow.Redist" Version="$(TensorFlowVersion)" />
971+
<PackageReference Include="Microsoft.ML.OnnxRuntime" Version="$(MicrosoftMLOnnxRuntimePackageVersion)" />
971972
</ItemGroup>
972973

973974
<ItemGroup>

pkg/Microsoft.ML.OnnxTransformer/Microsoft.ML.OnnxTransformer.nupkgproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
<ItemGroup>
99
<ProjectReference Include="../Microsoft.ML/Microsoft.ML.nupkgproj" />
1010
<PackageReference Include="Google.Protobuf" Version="$(GoogleProtobufPackageVersion)" />
11-
<PackageReference Include="Microsoft.ML.OnnxRuntime" Version="$(MicrosoftMLOnnxRuntimePackageVersion)"/>
11+
<PackageReference Include="Microsoft.ML.OnnxRuntime.Managed" Version="$(MicrosoftMLOnnxRuntimePackageVersion)"/>
1212
</ItemGroup>
1313

1414
</Project>

src/Microsoft.ML.OnnxTransformer/Microsoft.ML.OnnxTransformer.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
<ItemGroup>
1010
<ProjectReference Include="..\Microsoft.ML.Core\Microsoft.ML.Core.csproj" />
1111
<ProjectReference Include="..\Microsoft.ML.Data\Microsoft.ML.Data.csproj" />
12-
<PackageReference Include="Microsoft.ML.OnnxRuntime" Version="$(MicrosoftMLOnnxRuntimePackageVersion)" />
12+
<PackageReference Include="Microsoft.ML.OnnxRuntime.Managed" Version="$(MicrosoftMLOnnxRuntimePackageVersion)" />
1313
<PackageReference Include="Google.Protobuf" Version="$(GoogleProtobufPackageVersion)" />
1414
</ItemGroup>
1515

src/Microsoft.ML.OnnxTransformer/OnnxUtils.cs

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -179,9 +179,19 @@ public OnnxModel(string modelFile, int? gpuDeviceId = null, bool fallbackToCpu =
179179

180180
if (gpuDeviceId != null)
181181
{
182-
// The onnxruntime v1.0 currently does not support running on the GPU on all of ML.NET's supported platforms.
183-
// This code path will be re-enabled when there is appropriate support in onnxruntime
184-
throw new NotSupportedException("Running Onnx models on a GPU is temporarily not supported!");
182+
try
183+
{
184+
_session = new InferenceSession(modelFile,
185+
SessionOptions.MakeSessionOptionWithCudaProvider(gpuDeviceId.Value));
186+
}
187+
catch(OnnxRuntimeException)
188+
{
189+
if (fallbackToCpu)
190+
_session = new InferenceSession(modelFile);
191+
else
192+
// If called from OnnxTransform, is caught and rethrown
193+
throw;
194+
}
185195
}
186196
else
187197
{

test/Microsoft.ML.Functional.Tests/Microsoft.ML.Functional.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040

4141
<ItemGroup>
4242
<PackageReference Include="Microsoft.ML.Onnx.TestModels" Version="$(MicrosoftMLOnnxTestModelsVersion)" />
43+
<PackageReference Include="Microsoft.ML.OnnxRuntime" Version="$(MicrosoftMLOnnxRuntimePackageVersion)" />
4344
</ItemGroup>
4445

4546
<ItemGroup>

test/Microsoft.ML.OnnxTransformerTest/Microsoft.ML.OnnxTransformerTest.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
</ItemGroup>
1111
<ItemGroup>
1212
<PackageReference Include="Microsoft.ML.Onnx.TestModels" Version="$(MicrosoftMLOnnxTestModelsVersion)" />
13+
<PackageReference Include="Microsoft.ML.OnnxRuntime" Version="$(MicrosoftMLOnnxRuntimePackageVersion)" />
1314
</ItemGroup>
1415

1516
<ItemGroup>

test/Microsoft.ML.Tests/Microsoft.ML.Tests.csproj

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@
4949
<PackageReference Include="Microsoft.ML.TestModels" Version="$(MicrosoftMLTestModelsPackageVersion)" />
5050
<PackageReference Include="SciSharp.TensorFlow.Redist" Version="$(TensorFlowVersion)" />
5151
<PackageReference Include="System.Data.SqlClient" Version="$(SystemDataSqlClientVersion)" />
52+
<PackageReference Include="Microsoft.ML.OnnxRuntime" Version="$(MicrosoftMLOnnxRuntimePackageVersion)" />
5253
</ItemGroup>
5354

5455
<ItemGroup>

0 commit comments

Comments
 (0)