Skip to content
This repository was archived by the owner on Mar 17, 2026. It is now read-only.
This repository was archived by the owner on Mar 17, 2026. It is now read-only.

libtensorflow_framework.so.2 cannot open #375

Open

Description

@mbajlo

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?

Activity

  1. mbajlo commented on Sep 4, 2022

    @mbajlo
    Author

    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.

  2. MTRNord commented on Oct 10, 2022

    @MTRNord

    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

  3. ramon-garcia commented on Oct 21, 2022

    @ramon-garcia
    Contributor

    It happened to me once because the download failed. It worked for me removing the directory with the shared library and repeating cargo build.

  4. day-mon commented on Nov 14, 2022

    @day-mon

    Is there any updates on this? I can not get my project to work in a docker container due to this error.

  5. lake-hope commented on Nov 21, 2022

    @lake-hope

    @day-mon Could you share your Dockerfile?

  6. day-mon commented on Nov 21, 2022

    @day-mon

    @day-mon Could you share your Dockerfile?

    I just fixed it by downgrading the tensorflow version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions