Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Running CPU 2.4.1 on Ubuntu, what is the correct process to add the Tensorflow C libraries? #811

Closed
ADH-LukeBollam opened this issue May 14, 2021 · 5 comments

Comments

@ADH-LukeBollam
Copy link
Contributor

ADH-LukeBollam commented May 14, 2021

I've got this working on my local windows machine, however our build server which is running Ubuntu fails to load the library

System.DllNotFoundException : Unable to load shared library 'tensorflow' or one of its dependencies. 
In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable:
 libtensorflow: cannot open shared object file: No such file or directory

I've got SciSharp.Tensorflow.Redist 2.4.1 installed, and the .dll's + .so's are being copied to netcoreapp3.1\runtimes as expected on my local machine.

I've tried adding a build step to copy the .so files to the run directory

  <Target Name="copylibtf" AfterTargets="AfterBuild">
    <Copy SourceFiles="$(outDir)runtimes\linux-x64\native\libtensorflow.so" DestinationFolder="$(OutDir)" />
  </Target>
  <Target Name="copylibtfframework" AfterTargets="AfterBuild">
    <Copy SourceFiles="$(outDir)runtimes\linux-x64\native\libtensorflow_framework.so.2"
          DestinationFiles="$(OutDir)libtensorflow_framework.so" />
  </Target>

I confirmed the presence of the files in /netcoreapp3.1 after building, but still the same error.

What should I do here?

@ADH-LukeBollam ADH-LukeBollam changed the title Running CPU 2.4.1 on Ubuntu, what is the correct process to add the libraries? Running CPU 2.4.1 on Ubuntu, what is the correct process to add the Tensorflow C libraries? May 14, 2021
@Oceania2018
Copy link
Member

@ADH-LukeBollam
Copy link
Contributor Author

Is this file in any of the Nugets? GitHub doesn't allow committing files bigger than 100Mb, so I need to pull it remotely. Can I confirm that release/netcoreapp3.1/ is the correct directory to put the libtensorflow.so and libtensorflow_framework.so?

@ADH-LukeBollam
Copy link
Contributor Author

ADH-LukeBollam commented May 14, 2021

I've just tested with the .so's from that version, using this to copy and rename the files

wget https://storage.googleapis.com/tensorflow/libtensorflow/libtensorflow-cpu-linux-x86_64-2.5.0.tar.gz
tar -xzvf libtensorflow-cpu-linux-x86_64-2.5.0.tar.gz

cp "./lib/libtensorflow.so.2.5.0" "test/MyProj/bin/Release/netcoreapp3.1/"
cp "./lib/libtensorflow_framework.so.2.5.0" "test/MyProj/bin/Release/netcoreapp3.1/"
mv "test/MyProj/bin/Release/netcoreapp3.1/libtensorflow.so.2.5.0" "test/MyProj/bin/Release/netcoreapp3.1/libtensorflow.so"
mv "test/MyProj/bin/Release/netcoreapp3.1/libtensorflow_framework.so.2.5.0" "test/MyProj/bin/Release/netcoreapp3.1/libtensorflow_framework.so"

I've verified the files are in the run directory
image

and I still get the error:

System.AggregateException : 
One or more errors occurred. (Unable to load shared library 'tensorflow' or one of its dependencies. 
In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable: 
libtensorflow: cannot open shared object file: No such file or directory)
---- System.DllNotFoundException : Unable to load shared library 'tensorflow' or one of its dependencies. 
In order to help diagnose loading problems, consider setting the LD_DEBUG environment variable:
libtensorflow: cannot open shared object file: No such file or directory

@ADH-LukeBollam
Copy link
Contributor Author

ADH-LukeBollam commented May 17, 2021

After finding this, migueldeicaza/TensorFlowSharp#476 I tried copying all the files (.so, .so.2, .so.2.5.0) even though they appear to be the same, and it now works. It seems like there are missing files for Linux in the Redist Nuget.

@Oceania2018
Copy link
Member

Released tf 2.5.0 nuget.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants