Skip to content

Commit 9f8f3d8

Browse files
committed
fix: error caused by dll check in c_api.
1 parent 634860d commit 9f8f3d8

File tree

6 files changed

+16
-15
lines changed

6 files changed

+16
-15
lines changed

src/TensorFlowNET.Core/APIs/c_api.cs

-15
Original file line numberDiff line numberDiff line change
@@ -45,21 +45,6 @@ public partial class c_api
4545
{
4646
public const string TensorFlowLibName = "tensorflow";
4747

48-
static c_api()
49-
{
50-
try
51-
{
52-
var handle = TF_Version();
53-
}
54-
catch (DllNotFoundException)
55-
{
56-
throw new RuntimeError("Tensorflow.NET cannot find a backend. Please install one of the following packages for your program: " +
57-
"SciSharp.TensorFlow.Redist, SciSharp.TensorFlow.Redist-Linux-GPU, SciSharp.TensorFlow.Redist-Windows-GPU. For more details, " +
58-
"please visit https://github.com/SciSharp/TensorFlow.NET. If it still not work after installing the backend, please submit an " +
59-
"issue to https://github.com/SciSharp/TensorFlow.NET/issues");
60-
}
61-
}
62-
6348
public static string StringPiece(IntPtr handle)
6449
{
6550
return handle == IntPtr.Zero ? String.Empty : Marshal.PtrToStringAnsi(handle);

src/TensorFlowNET.Core/tensorflow.cs

+12
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,18 @@ public tensorflow()
8686

8787
OpDefLib = new OpDefLibrary();
8888
InitGradientEnvironment();
89+
90+
try
91+
{
92+
var handle = c_api.TF_Version();
93+
}
94+
catch (DllNotFoundException)
95+
{
96+
throw new RuntimeError("Tensorflow.NET cannot find a backend. Please install one of the following packages for your program: " +
97+
"SciSharp.TensorFlow.Redist, SciSharp.TensorFlow.Redist-Linux-GPU, SciSharp.TensorFlow.Redist-Windows-GPU. For more details, " +
98+
"please visit https://github.com/SciSharp/TensorFlow.NET. If it still not work after installing the backend, please submit an " +
99+
"issue to https://github.com/SciSharp/TensorFlow.NET/issues");
100+
}
89101
}
90102

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

test/TensorFlowNET.Graph.UnitTest/TensorFlowNET.Graph.UnitTest.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535

3636
<ItemGroup>
3737
<ProjectReference Include="..\..\src\TensorFlowNET.Core\Tensorflow.Binding.csproj" />
38+
<ProjectReference Include="..\..\tools\Tensorflow.UnitTest.RedistHolder\Tensorflow.UnitTest.RedistHolder.csproj" />
3839
<ProjectReference Include="..\TensorFlowNET.Keras.UnitTest\Tensorflow.Keras.UnitTest.csproj" />
3940
</ItemGroup>
4041

test/TensorFlowNET.Keras.UnitTest/Tensorflow.Keras.UnitTest.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
<ItemGroup>
2626
<ProjectReference Include="..\..\src\TensorFlowNET.Keras\Tensorflow.Keras.csproj" />
27+
<ProjectReference Include="..\..\tools\Tensorflow.UnitTest.RedistHolder\Tensorflow.UnitTest.RedistHolder.csproj" />
2728
</ItemGroup>
2829

2930
<ItemGroup>

test/TensorFlowNET.Native.UnitTest/Tensorflow.Native.UnitTest.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555

5656
<ItemGroup>
5757
<ProjectReference Include="..\..\src\TensorFlowNET.Core\Tensorflow.Binding.csproj" />
58+
<ProjectReference Include="..\..\tools\Tensorflow.UnitTest.RedistHolder\Tensorflow.UnitTest.RedistHolder.csproj" />
5859
</ItemGroup>
5960

6061
</Project>

test/TensorflowNET.Hub.Unittest/Tensorflow.Hub.Unittest.csproj

+1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
<ItemGroup>
1919
<ProjectReference Include="..\..\src\TensorflowNET.Hub\Tensorflow.Hub.csproj" />
20+
<ProjectReference Include="..\..\tools\Tensorflow.UnitTest.RedistHolder\Tensorflow.UnitTest.RedistHolder.csproj" />
2021
</ItemGroup>
2122

2223
</Project>

0 commit comments

Comments
 (0)