TensorFlowSharp icon indicating copy to clipboard operation
TensorFlowSharp copied to clipboard

missing libtensorflow.dll

Open nonlin opened this issue 8 years ago • 15 comments

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.

nonlin avatar Mar 04 '18 18:03 nonlin

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

Hutipeti avatar Mar 11 '18 10:03 Hutipeti

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

kurophali avatar Mar 21 '18 10:03 kurophali

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.

Hutipeti avatar Mar 21 '18 10:03 Hutipeti

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

dgerding avatar Apr 11 '18 23:04 dgerding

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. 👎

bjornkihlberg avatar Apr 12 '18 09:04 bjornkihlberg

@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...

sjnorval avatar May 08 '18 12:05 sjnorval

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.

bjornkihlberg avatar May 08 '18 13:05 bjornkihlberg

Where's the lib libtensorflow.dll?

Thanks.

homerokzam avatar Jun 06 '18 17:06 homerokzam

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 [email protected] 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 .

lurium avatar Jun 06 '18 18:06 lurium

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/

hanabi1224 avatar Jul 16 '18 07:07 hanabi1224

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.

nrandell avatar Oct 06 '18 13:10 nrandell

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.

captainst avatar Mar 15 '19 15:03 captainst

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

PeterPann23 avatar May 24 '19 09:05 PeterPann23

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

sdg002 avatar Jul 11 '19 13:07 sdg002

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)

KannaKim avatar Jan 03 '20 07:01 KannaKim