migueldeicaza / TensorFlowSharp

TensorFlow API for .NET languages
MIT License
3.14k stars 578 forks source link

missing libtensorflow.dll #236

Open nonlin opened 6 years ago

nonlin commented 6 years ago

I've tried downloading the cpu and gpu versions of it and renaming the cpu versions tensorflow.dll to libtensorflow.dll and it always says I'm missing the .dll.

I add the .dll to the debug folder and I'm running the build as a debug build.

Hutipeti commented 6 years ago

Did you make sure you copied libtensorflow.dll to the bin/Debug folder of your project?

kurophali commented 6 years ago

I'm having the same problem, too. I searched libtensorflow in the project folder but nothing was there. Did you find the dll?

Hutipeti commented 6 years ago

just search for it in the downloaded tensorflowsharp folder. Than, just cpoy this file to your bin/debug folder before you run the application it will work.

dgerding commented 6 years ago

I'm looking through the zip and not finding "libtensor" anything. Including dll. Doing something not smart I suspect but would love any hints.

bjornkihlberg commented 6 years ago

There is a libtensorflow.dll in packages\TensorFlowSharp.1.5.0\runtimes\win7-x64\native but it isn't copied to the bin dir when compiling you application so you have to do this manually. 👎

sjnorval commented 6 years ago

@bjornkihlberg, the latest clone from the 'master' brunch does not yield anything of the like 'packages\TensorFlowSharp.1.5.0\runtimes\win7-x64\native'... I cannot seem to find anything like 'libtensorflow.dll'. Any help would be great...

bjornkihlberg commented 6 years ago

Sorry, I wasn't clear. This is when you install the TensorFlowSharp nuget-package in your solution. There will be a "packages"-folder in the solution root. Restore your nuget-packages for your solution and have a look in there.

homerokzam commented 6 years ago

Where's the lib libtensorflow.dll?

Thanks.

lurium commented 6 years ago

I spent a bunch of time trying to build this library on vs2017 but there is some compiler bug that prevented it. Best I've found is:

go here: https://github.com/fo40225/tensorflow-windows-wheel/

Look for tf 1.x for your version of python, then cpu/gpu, then sse or avx

Download the whl file, it can be opened with 7zip, then go to tensorflow-1.x.0.data\purelib\tensorflow\python\

and rename the _pywrap_tensorflow_internal.pyd to libtensorflow.dll

Note that this 'dll' has a dependency on at least python3.dll and python3x.dll for the python3.x case.

On Wed, Jun 6, 2018 at 1:23 PM, homerokzam notifications@github.com wrote:

Where's the lib libtensorflow.dll?

Thanks.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/migueldeicaza/TensorFlowSharp/issues/236#issuecomment-395148226, or mute the thread https://github.com/notifications/unsubscribe-auth/AQekfTji4ELQwGi0YrOrSiOj-l9p7KgDks5t6BAhgaJpZM4Sbbpc .

hanabi1224 commented 6 years ago

I had similar issues recently, I tried to automate the process @lurium described with appveyor build and published renamed dlls as nuget packages https://www.nuget.org/packages/tensorflow-batteries-windows-x64-cpu/

nrandell commented 5 years ago

Just to add to this. I'm using netstandard2.1 on windows and in order to get this to work, I had to do the following.

  1. Download a python wheel for the correct version from https://github.com/fo40225/tensorflow-windows-wheel
  2. Copy tensorflow-1.11.0.data/purelib/tensorflow/python/_pywrap_tensorflow_internal.pyd to libtensorflow.dll in my project
  3. Copy python36.dll from my python distribution to my project
  4. Copy both the dlls to the output directory. I added this to my csproj.
    <None Include="..\Lib\runtimes\win7-x64\native\libtensorflow.dll" Link="runtimes\win7-x64\native\libtensorflow.dll">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </None>
    <None Include="..\Lib\runtimes\win7-x64\native\python36.dll" Link="runtimes\win7-x64\native\python36.dll">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </None>
    </ItemGroup>

Once that is done, when running it I can see (using process explorer from system internals) that it has loaded the correct dll.

captainst commented 5 years ago

Just came across this issue. And this is how I made it work:

OS: win10 GPU: GForce 1050ti Tensorflow-gpu: 1.10.0 Python: 3.6 (Anaconda) CUDA: 9.0 cudnn: 7.1.4 visual studio: 2013

The tensorflow-gpu works well on win10, I installed the latest tensorflowsharp with nuget (1.12.0). With CPU, the example works well, but following @lurium 's comments, I could not get gpu version of libtensorflow.dll to work (complains DLL not found, as usual)

The whole process was quite tedious and frustrating. To cut it short, this is what I've done:

  1. Upgrade tensorflow-gpu to version 1.12.0 using the whl from this link: https://pypi.org/project/tensorflow-gpu/1.12.0/#files
  2. Update the cudnn library to v7.3.1 (which is a must to make work tensorflow-gpu version 1.12.0)
  3. Unzip the above whl to find that magic _pywrap_tensorflow_internal.pyd file, rename it to libtensorflow.dll, copy it to the debug/release folder of tensorflowsharp project.

And it works just like that.

reminder1: after re-compiling the project, the original libtensorflow.dll file will be copied to debug folder, so you'd better make a one-time change when your project is done.

reminder2: for some unknown reason, if you are using the tensorflow pre-built binary, up to tensorflow-gpu 1.12.0, stick to CUDA 9.0, never go to other version like 9.1 or 9.2, none of them will work with pre-build binary of tensorflow-gpu.

Many thanks to the project.

PeterPann23 commented 5 years ago

have a look at Microsoft.ML.TensorFlow.Redist, contains a recent version of the dll as well as header files , might be compatible

sdg002 commented 5 years ago

Hi All, Environment Windows 10 .NET Standard 20 class library Visual Studio 2017

Overview I had a similar issue. We are using CopyLocalLockFileAssemblies to ensure that all assemblies get copied over to the output folder.

<CopyLocalLockFileAssemblies>true</CopyLocalLockFileAssemblies>

The managed DLL TensorFlowSharp.dll got copied over without any problems. However the unmanaged file libtensorflow.dll was not getting copied over.

Attempt 1 Include the file libtensorflow.dll into the CSPROJ and set the property Copy Always to True. This worked but libtensorflow.dll is over 50 MB and GitHub issued warnings about breaching file limits.

Attempt 2 I modified the CSPROJ and added a CopyToOutputDirectory step which would copy over libtensorflow.dll directly from the Nuget packages folder.

  <ItemGroup>
    <None Include="$(NugetPackageRoot)\tensorflowsharp\1.13.0\runtimes\win7-x64\native\libtensorflow.dll">
      <CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
    </None>
  </ItemGroup>

The variable NugetPackageRoot You can find some information here. This is set to the default Nuget packages folder. There are some challenges as mentioned in this link https://github.com/NuGet/Home/issues/6301 You will have t keep your CSPROJ manually uptodate if you are updating the reference of your package.

Better approach - Using the GeneratePathProperty https://blog.dangl.me/archive/accessing-nuget-package-paths-in-your-net-sdk-based-csproj-files/ I like this solution. But, I could not get it work. Possibly because I am not on VS2019. Not sure.

Hope this helps. Thanks, Sau

KannaKim commented 4 years ago

Good workaround I found is that

create project -> download tensorflowsharp from nuget packages -> packages -> runtimes -> win7-64 -> native -> libtensorflow.dll

and copy & paste that dll to test folder (in my case it is TensorFlowSharp.Tests.CSharp\bin\x64\Debug)