Rate This Document
Findability
Accuracy
Completeness
Readability

Failed to Compile the hwloc Dependency When Compiling TensorFlow 1.15.5

Symptom

When compiling TensorFlow 1.15.5, an error is reported stating "external/hwloc/hwloc/topology.c:45:10: fatal error: sys/sysctl.h: No such file or directory."

Key Process and Cause Analysis

Key error information: When compiling the hwloc dependency, an error is reported indicating that header file sys/sysctl.h is not found.

1
2
external/hwloc/hwloc/topology.c:45:10: fatal error: sys/sysctl.h: No such file or directory
   45 | #include <sys/sysctl.h>

Root cause analysis: Header file sys/sysctl.h is deleted from glibc 2.32 and later, and sys/sysctl.h calls have been deleted from Linux kernel 5.5 and later. Because the kernel version is 5.10.0, an error is reported on the hwloc dependency.

Conclusion and Solution

  1. Open and edit the tensorflow/third_party/hwloc/BUILD.bazel file.
    1
    vi tensorflow/third_party/hwloc/BUILD.bazel
    
  2. Press i to enter the insert mode and delete line 113.
    "#undef HAVE_SYS_SYSCTL_H": "#define HAVE_SYS_SYSCTL_H 1",

    Before deletion:

    After deletion:

  3. Press Esc, type :wq!, and press Enter to save the file and exit.
  4. Recompile TensorFlow.
    1
    bazel build --config=v1 --cxxopt="-D_GLIBCXX_USE_CXX11_ABI=0"  //tensorflow/tools/pip_package:build_pip_package