Skip to content

Conversation

@frank-dong-ms-zz
Copy link
Contributor

  1. upgrade SciSharp.TensorFlow.Redist version to 2.3.1 same as ml.net
  2. fix tf not running on netcore 2.1 exception by introducing reference to "System.Runtime.CompilerServices.Unsafe" package

@frank-dong-ms-zz
Copy link
Contributor Author

Merge this PR until we upgrade the ML.NET to 1.5.3 used in samples repro as Antonio pointed out.

<PackageReference Include="Microsoft.ML.TensorFlow" Version="$(MicrosoftMLVersion)" />
<PackageReference Include="SciSharp.TensorFlow.Redist" Version="2.3.0" />
<PackageReference Include="SciSharp.TensorFlow.Redist" Version="2.3.1" />
<PackageReference Condition="'$(TargetFramework)'=='netcoreapp2.1'" Include="System.Runtime.CompilerServices.Unsafe" Version="4.5.3" />
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is kind of odd. Can you explain what the problem is here? In general, this smells like a packaging issue...

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, when we try to run TF related samples in netcore 2.1 in recent build (with upgrade to use tensorflow 2 from this PR: dotnet/machinelearning#5404) we will see below exception so I added the missing reference and that fix the exception:
System.IO.FileLoadException: "Could not load file or assembly "System.Runtime.CompilerServices.Unsafe, Version=4.0.4.1, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" or one of it's dependences

One interesting thing is this exception only happens on netcore2.1 but not netcore 3.1.


In reply to: 540966485 [](ancestors = 540966485)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My guess is package "SciSharp.TensorFlow.Redist" take dependency on "System.Runtime.CompilerServices.Unsafe" with version 4.5.3 and package "System.Runtime.CompilerServices.Unsafe" is not loaded by default on netcore2.1? We will really appreciate if you can help us understand the root cause of this issue.


In reply to: 541388519 [](ancestors = 541388519,540966485)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you send me an app that reproduces the failure? I would need to debug it to figure out the problem.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks Eric, use below ml.net sample with netcore2.1 and take "1.5.3-preview.20611.3" version of ml.net as dependency you should see the error:

https://github.com/dotnet/machinelearning-samples/tree/master/samples/csharp/getting-started/DeepLearning_ImageClassification_TensorFlow

Copy link
Contributor Author

@frank-dong-ms-zz frank-dong-ms-zz Dec 15, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@eerhardt I will merge this PR first to unblock others. If you can figure out the root cause and have better fix we can discuss later, thanks.


In reply to: 541452261 [](ancestors = 541452261)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logged dotnet/runtime#46082 for this problem.

@frank-dong-ms-zz frank-dong-ms-zz merged commit afa7a4d into master Dec 15, 2020
Elizabethhanson pushed a commit to Elizabethhanson/machinelearning-samples that referenced this pull request Sep 10, 2021
* upgrade SciSharp.TensorFlow.Redist version and fix tf not working on netcore 2.1 exception

* update ml.net version
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants