Skip to content

Commit 9e13c0d

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

File tree

2 files changed

+12
-15
lines changed

2 files changed

+12
-15
lines changed

src/TensorFlowNET.Core/APIs/c_api.cs

Lines changed: 0 additions & 15 deletions
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

Lines changed: 12 additions & 0 deletions
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());

0 commit comments

Comments
 (0)