rust
rust copied to clipboard
libtensorflow_framework.so.2 cannot open
Hi
I tried to make a new binary package in which I will have just the code from the example.
I made the package with cargo new test_tf --bin and in Cargo.tomlI added tensorflow dependency tensorflow = { version = "0.19.0", features = ["eager"] }.
After this I made cargo build and tried cargo run but I keep getting this:
error while loading shared libraries: libtensorflow_framework.so.2: cannot open shared object file: No such file or directory
And I have libtensorflow_framework.so.2 under:
test_tf/target/debug/build/tensorflow-sys-9b61d66e8ef366b9/out/libtensorflow-cpu-linux-x86_64-2.9.1/lib/libtensorflow_framework.so.2 test_tf/target/debug/build/tensorflow-sys-9b61d66e8ef366b9/out/libtensorflow_framework.so.2
I do not know why is this happening, from what I have understood, this is a linker error, but the linking should be taken care of by tensorflow crate?
For what is worth, my OS is Ubuntu 22.04.1 LTS
when I try to check shared dependencies, I get this:
ldd target/debug/test_tf linux-vdso.so.1 (0x00007fff68bc6000) libtensorflow_framework.so.2 => not found libtensorflow.so.2 => not found libssl.so.3 => /lib/x86_64-linux-gnu/libssl.so.3 (0x00007f4e68e77000) libcrypto.so.3 => /lib/x86_64-linux-gnu/libcrypto.so.3 (0x00007f4e68a35000) libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f4e68a15000) libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f4e6892c000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f4e68704000) /lib64/ld-linux-x86-64.so.2 (0x00007f4e69e47000)
For some reason there is no tensorflow lib in lib64 directory?
Should I install libs there manually or this should be done by Tensorflow crate?
I checked the target/build directory and in there I can find these .so files:
find . -name libtensorflow* ./target/debug/build/tensorflow-sys-ca44951ca657176c/out/libtensorflow.so.2 ./target/debug/build/tensorflow-sys-ca44951ca657176c/out/libtensorflow.so.2.9.1 ./target/debug/build/tensorflow-sys-ca44951ca657176c/out/libtensorflow_framework.so ./target/debug/build/tensorflow-sys-ca44951ca657176c/out/libtensorflow.so ./target/debug/build/tensorflow-sys-ca44951ca657176c/out/libtensorflow-cpu-linux-x86_64-2.9.1 ./target/debug/build/tensorflow-sys-ca44951ca657176c/out/libtensorflow-cpu-linux-x86_64-2.9.1/lib/libtensorflow.so.2 ./target/debug/build/tensorflow-sys-ca44951ca657176c/out/libtensorflow-cpu-linux-x86_64-2.9.1/lib/libtensorflow.so.2.9.1 ./target/debug/build/tensorflow-sys-ca44951ca657176c/out/libtensorflow-cpu-linux-x86_64-2.9.1/lib/libtensorflow_framework.so ./target/debug/build/tensorflow-sys-ca44951ca657176c/out/libtensorflow-cpu-linux-x86_64-2.9.1/lib/libtensorflow.so ./target/debug/build/tensorflow-sys-ca44951ca657176c/out/libtensorflow-cpu-linux-x86_64-2.9.1/lib/libtensorflow_framework.so.2.9.1 ./target/debug/build/tensorflow-sys-ca44951ca657176c/out/libtensorflow-cpu-linux-x86_64-2.9.1/lib/libtensorflow_framework.so.2 ./target/debug/build/tensorflow-sys-ca44951ca657176c/out/libtensorflow-cpu-linux-x86_64-2.9.1.tar.gz ./target/debug/build/tensorflow-sys-ca44951ca657176c/out/libtensorflow_framework.so.2.9.1 ./target/debug/build/tensorflow-sys-ca44951ca657176c/out/libtensorflow_framework.so.2 ./target/debug/deps/libtensorflow_sys-e16cb75c7f8b73a0.rmeta ./target/debug/deps/libtensorflow_internal_macros-b8659c46ccf653d2.so ./target/debug/deps/libtensorflow_sys-e16cb75c7f8b73a0.rlib ./target/debug/deps/libtensorflow-0a540bc9efa06f00.rmeta ./target/debug/deps/libtensorflow-0a540bc9efa06f00.rlib
What could cause the linking problem?
Hello,
I will keep this open just in case you can provide a better solution. But for now I have solved the problem by manually installing missing libraries from the Tensorflow C lib and adding those *.so files to the /lib/x86_64-linux-gnu/ .
I am not sure if this is the right way or it should be handled by the cargo build but anyways, now it works.
I seem to have the same issue when trying to build a docker. It works fine on compiling but then at runtime crashes with error while loading shared libraries: libtensorflow_framework.so.2: cannot open shared object file: No such file or directory
Dockrfile is fairly simple: https://github.com/MTRNord/matrix-spam-ml/blob/1f40222d1723b7f59a053f2813518454944e2faf/Dockerfile
It happened to me once because the download failed. It worked for me removing the directory with the shared library and repeating cargo build.
Is there any updates on this? I can not get my project to work in a docker container due to this error.
@day-mon Could you share your Dockerfile?
@day-mon Could you share your Dockerfile?
I just fixed it by downgrading the tensorflow version