Browse Source

fix: error caused by dll check in c_api.

tags/v0.110.0-LSTM-Model
Yaohui Liu 2 years ago
parent
commit
9f8f3d87d0
No known key found for this signature in database GPG Key ID: E86D01E1809BD23E
6 changed files with 16 additions and 15 deletions
  1. +0
    -15
      src/TensorFlowNET.Core/APIs/c_api.cs
  2. +12
    -0
      src/TensorFlowNET.Core/tensorflow.cs
  3. +1
    -0
      test/TensorFlowNET.Graph.UnitTest/TensorFlowNET.Graph.UnitTest.csproj
  4. +1
    -0
      test/TensorFlowNET.Keras.UnitTest/Tensorflow.Keras.UnitTest.csproj
  5. +1
    -0
      test/TensorFlowNET.Native.UnitTest/Tensorflow.Native.UnitTest.csproj
  6. +1
    -0
      test/TensorflowNET.Hub.Unittest/Tensorflow.Hub.Unittest.csproj

+ 0
- 15
src/TensorFlowNET.Core/APIs/c_api.cs View File

@@ -45,21 +45,6 @@ namespace Tensorflow
{
public const string TensorFlowLibName = "tensorflow";

static c_api()
{
try
{
var handle = TF_Version();
}
catch (DllNotFoundException)
{
throw new RuntimeError("Tensorflow.NET cannot find a backend. Please install one of the following packages for your program: " +
"SciSharp.TensorFlow.Redist, SciSharp.TensorFlow.Redist-Linux-GPU, SciSharp.TensorFlow.Redist-Windows-GPU. For more details, " +
"please visit https://github.com/SciSharp/TensorFlow.NET. If it still not work after installing the backend, please submit an " +
"issue to https://github.com/SciSharp/TensorFlow.NET/issues");
}
}

public static string StringPiece(IntPtr handle)
{
return handle == IntPtr.Zero ? String.Empty : Marshal.PtrToStringAnsi(handle);


+ 12
- 0
src/TensorFlowNET.Core/tensorflow.cs View File

@@ -86,6 +86,18 @@ namespace Tensorflow

OpDefLib = new OpDefLibrary();
InitGradientEnvironment();

try
{
var handle = c_api.TF_Version();
}
catch (DllNotFoundException)
{
throw new RuntimeError("Tensorflow.NET cannot find a backend. Please install one of the following packages for your program: " +
"SciSharp.TensorFlow.Redist, SciSharp.TensorFlow.Redist-Linux-GPU, SciSharp.TensorFlow.Redist-Windows-GPU. For more details, " +
"please visit https://github.com/SciSharp/TensorFlow.NET. If it still not work after installing the backend, please submit an " +
"issue to https://github.com/SciSharp/TensorFlow.NET/issues");
}
}

public string VERSION => c_api.StringPiece(c_api.TF_Version());


+ 1
- 0
test/TensorFlowNET.Graph.UnitTest/TensorFlowNET.Graph.UnitTest.csproj View File

@@ -35,6 +35,7 @@

<ItemGroup>
<ProjectReference Include="..\..\src\TensorFlowNET.Core\Tensorflow.Binding.csproj" />
<ProjectReference Include="..\..\tools\Tensorflow.UnitTest.RedistHolder\Tensorflow.UnitTest.RedistHolder.csproj" />
<ProjectReference Include="..\TensorFlowNET.Keras.UnitTest\Tensorflow.Keras.UnitTest.csproj" />
</ItemGroup>



+ 1
- 0
test/TensorFlowNET.Keras.UnitTest/Tensorflow.Keras.UnitTest.csproj View File

@@ -24,6 +24,7 @@

<ItemGroup>
<ProjectReference Include="..\..\src\TensorFlowNET.Keras\Tensorflow.Keras.csproj" />
<ProjectReference Include="..\..\tools\Tensorflow.UnitTest.RedistHolder\Tensorflow.UnitTest.RedistHolder.csproj" />
</ItemGroup>

<ItemGroup>


+ 1
- 0
test/TensorFlowNET.Native.UnitTest/Tensorflow.Native.UnitTest.csproj View File

@@ -55,6 +55,7 @@

<ItemGroup>
<ProjectReference Include="..\..\src\TensorFlowNET.Core\Tensorflow.Binding.csproj" />
<ProjectReference Include="..\..\tools\Tensorflow.UnitTest.RedistHolder\Tensorflow.UnitTest.RedistHolder.csproj" />
</ItemGroup>

</Project>

+ 1
- 0
test/TensorflowNET.Hub.Unittest/Tensorflow.Hub.Unittest.csproj View File

@@ -17,6 +17,7 @@

<ItemGroup>
<ProjectReference Include="..\..\src\TensorflowNET.Hub\Tensorflow.Hub.csproj" />
<ProjectReference Include="..\..\tools\Tensorflow.UnitTest.RedistHolder\Tensorflow.UnitTest.RedistHolder.csproj" />
</ItemGroup>

</Project>

Loading…
Cancel
Save