tensorflow_cc links against invalid version of openmp
| Task Info (Flyspray) | |
|---|---|
| Opened By | Arsen (menkaur) |
| Task ID | 79523 |
| Type | Bug Report |
| Project | Arch Linux |
| Category | Packages: Extra |
| Version | None |
| OS | x86_64 |
| Opened | 2023-08-31 00:52:58 UTC |
| Status | Assigned |
| Assignee | Sven-Hendrik Haase (Svenstaro) |
| Assignee | Konstantin Gizdov (kgizdov) |
Details
Description:
Additional info:
- package version(s) tensorflow-opt-cuda 2.13.0-1
Description:
When compiling c++ code that references tensorflow_cc.so library, following linking errors occur:
/usr/bin/ld: /usr/lib/libtensorflow_cc.so: undefined reference to omp_in_parallel@VERSION' /usr/bin/ld: /usr/lib/libtensorflow_cc.so: undefined reference to GOMP_barrier@VERSION'
/usr/bin/ld: /usr/lib/libtensorflow_cc.so: undefined reference to omp_get_max_threads@VERSION' /usr/bin/ld: /usr/lib/libtensorflow_framework.so: undefined reference to kmp_set_blocktime@VERSION'
/usr/bin/ld: /usr/lib/libtensorflow_cc.so: undefined reference to omp_get_num_threads@VERSION' /usr/bin/ld: /usr/lib/libtensorflow_cc.so: undefined reference to omp_get_thread_num@VERSION'
/usr/bin/ld: /usr/lib/libtensorflow_cc.so: undefined reference to GOMP_parallel@VERSION' /usr/bin/ld: /usr/lib/libtensorflow_framework.so: undefined reference to omp_set_num_threads@VERSION'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/my_project.dir/build.make:99: my_project] Error 1
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/my_project.dir/all] Error 2
make: *** [Makefile:91: all] Error 2
These errors are new and did not occur in the previous version of the package I had installed
I wrote a script to search for libraries referencing one of these symbols: File: /usr/lib/libcaffe2_detectron_ops_gpu.so 109: 0000000000000000 0 FUNC GLOBAL DEFAULT UND omp_in_parallel@OMP_1.0 (22)
File: /usr/lib/libdnnl.so 68: 0000000000000000 0 FUNC GLOBAL DEFAULT UND omp_in_parallel@OMP_1.0 (21)
File: /usr/lib/libgomp.so 208: 0000000000017140 24 FUNC GLOBAL DEFAULT 15 omp_in_parallel@@OMP_1.0
File: /usr/lib/libtensorflow_cc.so 2702: 0000000000000000 0 FUNC GLOBAL DEFAULT UND omp_in_parallel@VERSION (42)
File: /usr/lib/libtensorflow.so 1561: 0000000000000000 0 FUNC GLOBAL DEFAULT UND omp_in_parallel@VERSION (11)
File: /usr/lib/libtorch_cpu.so 213: 0000000000000000 0 FUNC GLOBAL DEFAULT UND omp_in_parallel@OMP_1.0 (29)
and it looks like in tensorflow libraries, library version is invalid for some reason (@VERSION where @OMP_1.0 would probably work) This doesn't interfere with python code loading tensorflow libraries, but c++ code becomes inoperable
Steps to reproduce: main.cpp: #include <tensorflow/cc/client/client_session.h> #include <tensorflow/cc/ops/standard_ops.h> #include <tensorflow/core/framework/tensor.h> #include <tensorflow/core/public/session.h>
using namespace tensorflow; using namespace tensorflow::ops;
int main() { // tensorflow::data::DataseT:: using namespace tensorflow; using namespace tensorflow::ops;
// Create a root scope.
Scope root = Scope::NewRootScope();
// Create a constant tensor of shape {2, 2}.
auto a = Const(root, {{1.f, 2.f}, {3.f, 4.f}});
// Create a graph.
GraphDef graph_def;
TF_CHECK_OK(root.ToGraphDef(&graph_def));
// Create a session and associate the graph with it.
SessionOptions session_options;
std::unique_ptr<Session> session(NewSession(session_options));
TF_CHECK_OK(session->Create(graph_def));
std::vector<Tensor> outputs;
// Evaluate the tensor `a`.
TF_CHECK_OK(
session->Run({/* No inputs */}, {a.node()->name()}, {}, &outputs));
// Print the result.
LOG(INFO) << outputs[0].matrix<float>();
// Close the session.
auto status = session->Close();
if (!status.ok()) {
std::cerr << "Error closing session: " << status.ToString()
<< std::endl;
}
return 0;
}
CMakeLists.txt: cmake_minimum_required(VERSION 3.8) project(my_project)
set(CMAKE_CXX_STANDARD 20) set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
tensorflow so files
find_library(TENSORFLOW_CC NAMES tensorflow_cc HINTS "/usr/lib/" ) find_library(TENSORFLOW_FRAMEWORK NAMES tensorflow_framework HINTS "/usr/lib/" )
add_executable(my_project main.cpp)
#adding library to the target in a way that doesn't generate warnings target_include_directories(my_project SYSTEM PRIVATE /usr/include/tensorflow)
target_link_libraries(my_project ${TENSORFLOW_CC} ${TENSORFLOW_FRAMEWORK} )