Comments (38)
the download URL is not working anymore.
from tensorflowsharp.
@asimshankar dll seems fine; I re-wrote this post with correct integration steps.
Successful steps:
- download and unzip a 1.2 dll build e.g. I used http://ci.tensorflow.org/view/Nightly/job/nightly-libtensorflow-windows/lastSuccessfulBuild/artifact/lib_package/libtensorflow-cpu-windows-x86_64.zip
- drag tensorflow.dll onto the Visual Studio project (e.g. SampleTest). This will copy the dll file to the project
- In VS rename tensorflow.dll to libtensorflow.dll (it must match the TensorFlowLibrary value in Tensorflow.cs)
- In VS set libtensorflow.dll properties > Advanced > Copy to Output Directory > Copy Always
After this SampleTest successfully loads the dll and runs until the the line helpfully commented as "// Current failing test" for which you can't blame the dll!
fyi my original mistake when integrating with Visual Studio was trying to Add Reference to the dll which gives the error "A reference to ...\tensorflow.dll could not be added. Please make sure that the file is accessible, and that it is a valid assembly or COM component" (this is the wrong method to add a native dll).
from tensorflowsharp.
@MovGP0 That exception is most likely because your platform target is not x64; libtensorflow.dll
is 64bit.
from tensorflowsharp.
If anyone is willing to give the .dll mentioned in tensorflow/tensorflow#7258 (comment) a spin and leave any feedback on that issue, that would be great.
from tensorflowsharp.
I created a NuGet package that should contain the Windows binary. A simple test shows it works.
from tensorflowsharp.
The JNI builds do not export the C/C++ API, they only export the functions required by JNI:
> dumpbin /EXPORTS tensorflow_jni.dll
Microsoft (R) COFF/PE Dumper Version 14.00.24215.1
Copyright (C) Microsoft Corporation. All rights reserved.
Dump of file tensorflow_jni.dll
File Type: DLL
Section contains the following exports for libtensorflow_jni.so
00000000 characteristics
58D31E6B time date stamp Thu Mar 23 01:01:31 2017
0.00 version
1 ordinal base
50 number of functions
50 number of names
ordinal hint RVA name
1 0 0188CAB0 ?DEVICE_CPU@tensorflow@@3QEBDEB
2 1 0188CAB8 ?DEVICE_GPU@tensorflow@@3QEBDEB
3 2 0188CAC0 ?DEVICE_SYCL@tensorflow@@3QEBDEB
4 3 000F4CD0 Java_org_tensorflow_Graph_allocate
5 4 000F4CE0 Java_org_tensorflow_Graph_delete
6 5 000F4CF0 Java_org_tensorflow_Graph_importGraphDef
7 6 000F4E30 Java_org_tensorflow_Graph_operation
8 7 000F4ED0 Java_org_tensorflow_Graph_toGraphDef
...
Currently, only the cmake builds export the C/C++ API. If you do not want to build Tensorflow yourself, you can extract it from the CI whl artifact here:
- download the wheel and unzip it
- cd into
.\*.data\purelib\tensorflow\python\
- copy
_pywrap_tensorflow_internal.pyd
aslibtensorflow.dll
- copy
libtensorflow.dll
to your .NET project and you're all set!
> dumpbin /EXPORTS libtensorflow.dll
Microsoft (R) COFF/PE Dumper Version 14.00.24215.1
Copyright (C) Microsoft Corporation. All rights reserved.
Dump of file libtensorflow.dll
File Type: DLL
Section contains the following exports for _pywrap_tensorflow_internal.pyd
00000000 characteristics
58E45416 time date stamp Wed Apr 5 03:19:02 2017
0.00 version
1 ordinal base
42374 number of functions
42374 number of names
ordinal hint RVA name
1 0 02783468 ?$TSS0@?1???$Initialize@$00@?$SparseSlice@Ubfloat16@tensorflow@@@?A0xa2b9e076@tensorflow@@QEAAXAEBV?$TensorMap@V?$Tensor@$$CBUbfloat16@tensorflow@@$01$00_J@Eigen@@$0BA@UMakePointer@2@@Eigen@@H@Z@4HA
2 1 02783470 ?$TSS0@?1???$Initialize@$0A@@?$SparseSlice@Ubfloat16@tensorflow@@@?A0xa2b9e076@tensorflow@@QEAAXAEBV?$TensorMap@V?$Tensor@$$CBUbfloat16@tensorflow@@$01$00_J@Eigen@@$0BA@UMakePointer@2@@Eigen@@H@Z@4HA
3 2 027812F0 ?$TSS0@?1???$locale_independent_strtonum@M@?A0x1bfb4b96@tensorflow@@YAMPEBDPEAPEBD@Z@4HA
...
42247 A506 0013FC10 PyInit__pywrap_tensorflow_internal
42248 A507 001239B0 TF_AbortWhile
42249 A508 001239F0 TF_AddControlInput
42250 A509 00123A00 TF_AddInput
42251 A50A 00123A10 TF_AddInputList
42252 A50B 00123CA0 TF_AllocateTensor
42253 A50C 00123D10 TF_CloseDeprecatedSession
42254 A50D 00123D10 TF_CloseSession
42255 A50E 00123D60 TF_ColocateWith
42256 A50F 00123EB0 TF_DataTypeSize
42257 A510 00123EC0 TF_DeleteBuffer
42258 A511 00123EF0 TF_DeleteDeprecatedSession
42259 A512 00123F70 TF_DeleteGraph
42260 A513 00123FE0 TF_DeleteImportGraphDefOptions
42261 A514 00124010 TF_DeleteLibraryHandle
42262 A515 018411A0 TF_DeletePRunHandle
42263 A516 00124040 TF_DeleteSession
42264 A517 00124140 TF_DeleteSessionOptions
42265 A518 00124180 TF_DeleteStatus
42266 A519 001241D0 TF_DeleteTensor
42267 A51A 00124230 TF_Dim
42268 A51B 00124240 TF_ExtendGraph
...
from tensorflowsharp.
that seems overly complicated. there should be a powershell build script which determines the windows version, downloads the proper files and puts the dll in the proper location, builds everything, and executes the tests. shouldn't be too hard.
from tensorflowsharp.
@MovGP0 You do not need to manually copy the native files, it should be done for you.
The warnings are normal.
from tensorflowsharp.
My suggestion is to build and integrate a lowest-common-denominator x86 dll with TensorFlowSharp until Google distributes an official Windows dll. That missing dll is a big barrier for C# development right now. (I'm assuming the PR to fix python dependencies works)
My guess is the TF dev team will eventually switch to a universal x86 library with runtime switches for the CPU optimizations -- nothing else really works for app distribution. If that happens then the C API dll becomes NuGet and off we go :)
from tensorflowsharp.
thank you,I will further test.
from tensorflowsharp.
You could run the SampleTest, as per the README.
from tensorflowsharp.
I suggest opening another issue to track those failures.
from tensorflowsharp.
deprecated:
you can download [libtensorflow.dll] taken from:
https://storage.googleapis.com/tensorflow/windows/cpu/tensorflow-1.1.0rc1-cp35-cp35m-win_amd64.whl
from tensorflowsharp.
t.WhileTest (); of SimpleTest will not work until this address????? Anyone as different view?
#26
from tensorflowsharp.
operating system:window
I can't run, I'll libtensorflow_jni libtensorflow.dll and then put it into the bin folder, I do this right?
Error: untreated exception: System.DllNotFoundException: could not load DLL 'libtensorflow': the specified module could not be found. (exception from HRESULT:0x8007007E).
In TensorFlow.TFCore.TF_Version ()
In TensorFlow.TFCore.get_Version () position E:\Code\TensorFlow\Csharp\TensorFlowSharp-master\TensorFlowSharp\Tensorflow.cs: line number 54
In SampleTest.MainClass.Main (String[] args) location E:\Code\TensorFlow\Csharp\TensorFlowSharp-master\SampleTest\SampleTest.cs: line number 556
from tensorflowsharp.
@szdree the JNI library will not work; follow steps I detailed above to get the correct libtensorflow.dll.
Edit: make sure to copy the library to the bin directory!
from tensorflowsharp.
@andykernahan
Same result
operating system:window 10 64bit
CPU : Intel Core
Error: untreated exception: System.DllNotFoundException: could not load DLL 'libtensorflow': the specified module could not be found. (exception from HRESULT:0x8007007E).
Use:
HTTPS: //storage.googleapis.com/tensorflow/windows/cpu/tensorflow-1.1.0rc1-cp35-cp35m-win_amd64.whl
(purelib \ tensorflow \ python_pywrap_tensorflow_internal.pyd - > libtensorflow.dll)
copy libtensorflow.dll to bin\Debug
And SampleTest.exe in bin\Debug\
from tensorflowsharp.
@szdree, I had the same issue. Running Dependency Walker revealed missing Python35. I installed Python3.5 and then copied that dll alongside in the Debug\Bin and it resolved the DllNotFoundException.
from tensorflowsharp.
@vsjc91 Mine is Python3.5 I haven't solved the problem yet.
from tensorflowsharp.
try installing Anaconda:
https://github.com/tensorflow/tensorflow/blob/master/tensorflow/contrib/cmake/README.md#known-good-configurations
from tensorflowsharp.
@goloskokovic I was originally installed Anaconda
and
I installed the tensorflow python version, which can be run on the window.
from tensorflowsharp.
Running SampleTest (1.1.0-rc1) on Windows 10 / VS2015 using the above instructions (thanks!) I'm getting a System.AccessViolationException when it hits TestOuputShape->GetShape->TF_GraphGetTensorShape (TensorFlow.cs line 546) for the second constant.
I'm not seeing any obvious nulls, and the prior tests complete - has anybody else stubbed their toe on this one yet?
from tensorflowsharp.
@avrshawn same issue here , have no clue.
from tensorflowsharp.
Indeed. Unfortunately there isn't an official Windows build which can be downloaded; the best option is still to build it yourself using cmake.
Note that the Python related dependency issues above may be mitigated by this PR (although I've not tried it).
from tensorflowsharp.
Can't get it to work. I did the following:
- Creating a new console project and setting .NET target version to 4.6.1
- adding the TensorFlowSharp 0.96.0 nuget package
- adding a reference to the
packages\TensorFlowSharp.0.96.0\lib\net461\libtensorflow.dll
- including all files in
packages\TensorFlowSharp.0.96.0\native\
and setting build action toContent
andCopy if newer
When starting the project, I get the following error:
System.BadImageFormatException occurred
HResult=0x8007000B
Message=Could not load file or assembly 'TensorFlowSharp, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null' or one of its dependencies. An attempt was made to load a program with an incorrect format.
Windows version 10.0.15063.0
from tensorflowsharp.
@andykernahan that worked. now only get a lot of warnings. nothing problematic:
2017-05-21 10:22:25.310807: W C:\tmp\_bazel_system\6fx6hpz4\execroot\nightly-libtensorflow-windows\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE instructions, but these are available on your machine and could speed up CPU computations.
2017-05-21 10:22:25.311268: W C:\tmp\_bazel_system\6fx6hpz4\execroot\nightly-libtensorflow-windows\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE2 instructions, but these are available on your machine and could speed up CPU computations.
2017-05-21 10:22:25.313023: W C:\tmp\_bazel_system\6fx6hpz4\execroot\nightly-libtensorflow-windows\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE3 instructions, but these are available on your machine and could speed up CPU computations.
2017-05-21 10:22:25.313090: W C:\tmp\_bazel_system\6fx6hpz4\execroot\nightly-libtensorflow-windows\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations.
2017-05-21 10:22:25.313154: W C:\tmp\_bazel_system\6fx6hpz4\execroot\nightly-libtensorflow-windows\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.
2017-05-21 10:22:25.313218: W C:\tmp\_bazel_system\6fx6hpz4\execroot\nightly-libtensorflow-windows\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX instructions, but these are available on your machine and could speed up CPU computations.
2017-05-21 10:22:25.313279: W C:\tmp\_bazel_system\6fx6hpz4\execroot\nightly-libtensorflow-windows\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use AVX2 instructions, but these are available on your machine and could speed up CPU computations.
2017-05-21 10:22:25.313332: W C:\tmp\_bazel_system\6fx6hpz4\execroot\nightly-libtensorflow-windows\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use FMA instructions, but these are available on your machine and could speed up CPU computations.
from tensorflowsharp.
@MovGP0 Yes, they are expected as the CI builds are not built with march=native
.
from tensorflowsharp.
GPU one?
from tensorflowsharp.
I've just tried running SampleTest under Win10 / MS .NET Framework 4.6.1 and I get the following runtime error:
TensorFlow version: 1.2.0-rc0
Testing Parameters with indexes
2017-05-24 22:16:50.519124: W C:\tmp\_bazel_system\6fx6hpz4\execroot\nightly-libtensorflow-windows\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE instructions, but these are available on your machine and could speed up CPU computations.
2017-05-24 22:16:50.519645: W C:\tmp\_bazel_system\6fx6hpz4\execroot\nightly-libtensorflow-windows\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE2 instructions, but these are available on your machine and could speed up CPU computations.
2017-05-24 22:16:50.519684: W C:\tmp\_bazel_system\6fx6hpz4\execroot\nightly-libtensorflow-windows\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE3 instructions, but these are available on your machine and could speed up CPU computations.
2017-05-24 22:16:50.519719: W C:\tmp\_bazel_system\6fx6hpz4\execroot\nightly-libtensorflow-windows\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations.
2017-05-24 22:16:50.519754: W C:\tmp\_bazel_system\6fx6hpz4\execroot\nightly-libtensorflow-windows\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.
success
Testing AddControlInput for assertions
Success, got the expected exception when using tensorflow control inputs to assert
Handle: 2007385971504
FinishHandle: 2007384924392
Handle: 2007385985616
FinishHandle: 2007384924392
Variables
Result of variable read 0 -> 1.5
Result of variable read 1 -> 2
Result of variable read 2 -> 2.5
Result of variable read 3 -> 3
Result of variable read 4 -> 3.5
Unhandled Exception: System.EntryPointNotFoundException: Unable to find an entry point named 'TF_NewWhile' in DLL 'tensorflow.dll'.
at TensorFlow.TFGraph.TF_NewWhile(IntPtr g, TFOutput[] inputs, Int32 ninputs, IntPtr status)
at TensorFlow.TFGraph.While(TFOutput[] inputs, WhileConstructor constructor, TFStatus status) in C:\Users\pawelgorczynski\Repos\TensorFlowSharp\TensorFlowSharp\Tensorflow.cs:line 846
at SampleTest.MainClass.WhileTester.Init(Int32 ninputs, WhileConstructor constructor) in C:\Users\pawelgorczynski\Repos\TensorFlowSharp\SampleTest\LowLevelTests.cs:line 189
at SampleTest.MainClass.WhileTest() in C:\Users\pawelgorczynski\Repos\TensorFlowSharp\SampleTest\LowLevelTests.cs:line 220
at SampleTest.MainClass.Main(String[] args) in C:\Users\pawelgorczynski\Repos\TensorFlowSharp\SampleTest\SampleTest.cs:line 319
Press any key to continue . . .
The behavior is the same for both
https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-cpu-windows-x86_64-1.2.0-rc0.zip
and
http://ci.tensorflow.org/view/All/job/nightly-libtensorflow-windows/
from tensorflowsharp.
Ah, it seems that the TF_While
related symbols aren't being exported in the .dll
. I'll try to get that fixed for 1.2-rc1 or 1.3.
In the mean time, any while loop functionality will not be available on Windows.
from tensorflowsharp.
@asimshankar would it be possible to have a tensorflow.dll 32 bits too ?
from tensorflowsharp.
Properly using TensorFlow.dll from Harbour:
http://forums.fivetechsupport.com/viewtopic.php?p=202354#p202354
many thanks :-)
from tensorflowsharp.
I get this when using the TensorFlow.dll:
2017-06-06 12:48:43.269929: W C:\tmp_bazel_system\6fx6hpz4\execroot\nightly-libtensorflow-windows\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE instructions, but these are available on your machine and could speed up CPU computations.
2017-06-06 12:48:43.270149: W C:\tmp_bazel_system\6fx6hpz4\execroot\nightly-libtensorflow-windows\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE2 instructions, but these are available on your machine and could speed up CPU computations.
2017-06-06 12:48:43.272532: W C:\tmp_bazel_system\6fx6hpz4\execroot\nightly-libtensorflow-windows\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE3 instructions, but these are available on your machine and could speed up CPU computations.
2017-06-06 12:48:43.273426: W C:\tmp_bazel_system\6fx6hpz4\execroot\nightly-libtensorflow-windows\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.1 instructions, but these are available on your machine and could speed up CPU computations.
2017-06-06 12:48:43.273932: W C:\tmp_bazel_system\6fx6hpz4\execroot\nightly-libtensorflow-windows\tensorflow\core\platform\cpu_feature_guard.cc:45] The TensorFlow library wasn't compiled to use SSE4.2 instructions, but these are available on your machine and could speed up CPU computations.
from tensorflowsharp.
@FiveTechSoft That is expected.
from tensorflowsharp.
how to compile the dll from the latest tf source code?
from tensorflowsharp.
how to compile the 32bit dll from the latest tf source code? I want to use the 32bit dll in my own c/c++ project on windows7. @andykernahan thanks very much.
from tensorflowsharp.
I am downloading the binaries from the daily build hosts from TensorFlow.
I feel that questions on how to download the native bits should go into the tensorflow github repo, not here.
from tensorflowsharp.
@mwk888 Thanks for your post. It solved my problem.
When I was using tensorflowSharp 1.3, I had no problems but when I updated to version 1.5, I got this error.
1 year later, using tensorflowSharp 1.5 downloaded using nuGet packages manager in vs2015 and still need to do this? Why it was working tensorflowSharp 1.3 without have to do this but when I upgraded, the error came out? just curious about this.
from tensorflowsharp.
Related Issues (20)
- Provide a NuGet package for TensorFlowSharp without precompiled native binaries HOT 1
- TensorFlowSharp Gpu use HOT 3
- TensorFlowSharp is flexible and portable, Can it supply with NMT sample?
- The type initializer for 'TensorFlow.TFDisposable' threw an exception.
- I run into below exception message in some of image
- Build TensorFlowSharp for iOS
- tensorflowsharp load model(pb file) and predict, the results are always same HOT 1
- How can I feed batch of data to the model when predicting? HOT 1
- Cannot load savedmodel in tf# ERROR: "Note:Users need to ‘import tensorflow.contrib.decent_q’explicitly in the evaluation python script to register the custom quantize operation as tensorflow.contrib is lazy loaded now."
- How to load large model ?
- How to change tensor's value order
- I can run tensorflowgpu by python. How should my C code execute GPU? HOT 2
- ROCm support for AMD GPUs
- nuget.org missing v1.15.3
- How to load PB file saved by Keras model ? HOT 1
- Error when i run my-app on linux CENTOS 7
- Any plans to update to TensorFlow 2 C API? HOT 1
- Cannot Load the Model
- TensorFlow
- Tersorflow dllnotfoundExseption
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from tensorflowsharp.