| @@ -45,21 +45,6 @@ namespace Tensorflow | |||||
| { | { | ||||
| public const string TensorFlowLibName = "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) | public static string StringPiece(IntPtr handle) | ||||
| { | { | ||||
| return handle == IntPtr.Zero ? String.Empty : Marshal.PtrToStringAnsi(handle); | return handle == IntPtr.Zero ? String.Empty : Marshal.PtrToStringAnsi(handle); | ||||
| @@ -86,6 +86,18 @@ namespace Tensorflow | |||||
| OpDefLib = new OpDefLibrary(); | OpDefLib = new OpDefLibrary(); | ||||
| InitGradientEnvironment(); | 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()); | public string VERSION => c_api.StringPiece(c_api.TF_Version()); | ||||
| @@ -35,6 +35,7 @@ | |||||
| <ItemGroup> | <ItemGroup> | ||||
| <ProjectReference Include="..\..\src\TensorFlowNET.Core\Tensorflow.Binding.csproj" /> | <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" /> | <ProjectReference Include="..\TensorFlowNET.Keras.UnitTest\Tensorflow.Keras.UnitTest.csproj" /> | ||||
| </ItemGroup> | </ItemGroup> | ||||
| @@ -24,6 +24,7 @@ | |||||
| <ItemGroup> | <ItemGroup> | ||||
| <ProjectReference Include="..\..\src\TensorFlowNET.Keras\Tensorflow.Keras.csproj" /> | <ProjectReference Include="..\..\src\TensorFlowNET.Keras\Tensorflow.Keras.csproj" /> | ||||
| <ProjectReference Include="..\..\tools\Tensorflow.UnitTest.RedistHolder\Tensorflow.UnitTest.RedistHolder.csproj" /> | |||||
| </ItemGroup> | </ItemGroup> | ||||
| <ItemGroup> | <ItemGroup> | ||||
| @@ -55,6 +55,7 @@ | |||||
| <ItemGroup> | <ItemGroup> | ||||
| <ProjectReference Include="..\..\src\TensorFlowNET.Core\Tensorflow.Binding.csproj" /> | <ProjectReference Include="..\..\src\TensorFlowNET.Core\Tensorflow.Binding.csproj" /> | ||||
| <ProjectReference Include="..\..\tools\Tensorflow.UnitTest.RedistHolder\Tensorflow.UnitTest.RedistHolder.csproj" /> | |||||
| </ItemGroup> | </ItemGroup> | ||||
| </Project> | </Project> | ||||
| @@ -17,6 +17,7 @@ | |||||
| <ItemGroup> | <ItemGroup> | ||||
| <ProjectReference Include="..\..\src\TensorflowNET.Hub\Tensorflow.Hub.csproj" /> | <ProjectReference Include="..\..\src\TensorflowNET.Hub\Tensorflow.Hub.csproj" /> | ||||
| <ProjectReference Include="..\..\tools\Tensorflow.UnitTest.RedistHolder\Tensorflow.UnitTest.RedistHolder.csproj" /> | |||||
| </ItemGroup> | </ItemGroup> | ||||
| </Project> | </Project> | ||||