Skip to content

Executing genrule //tensorflow:tf_python_api_gen_v2 failed #1

Description

@xlla

Hi @llv22 , I want to build tensorflow@2.9 for my macos 10.13 on x86_64.

After a long time compiling, it failure on last step, here is the error log:

ERROR: /Volumes/Data/git/tensorflow-osx/tensorflow/BUILD:1263:19: Executing genrule //tensorflow:tf_python_api_gen_v2 failed: (Segmentation fault): bash failed: error executing command 
  (cd /private/var/tmp/_bazel_xlla/5e0f44411be79c51a887c448365c0535/execroot/org_tensorflow && \
  exec env - \
    CUDA_TOOLKIT_PATH=/usr/local/cuda \
    GCC_HOST_COMPILER_PATH=/usr/bin/gcc \
    PYTHON_BIN_PATH=/usr/local/opt/python@3.9/bin/python3.9 \
    PYTHON_LIB_PATH=/usr/local/opt/python@3.9/Frameworks/Python.framework/Versions/3.9/lib/python3.9/site-packages \
    TF2_BEHAVIOR=1 \
    TF_CUDA_COMPUTE_CAPABILITIES=6.1 \
  /bin/bash -c 'source external/bazel_tools/tools/genrule/genrule-setup.sh; bazel-out/host/bin/tensorflow/create_tensorflow.python_api_tf_python_api_gen_v2 --root_init_template=tensorflow/api_template.__init__.py --apidir=bazel-out/darwin-opt/bin/tensorflow_api/v2/ --apiname=tensorflow --apiversion=2 --compat_apiversion=1 --compat_apiversion=2  --compat_init_template=tensorflow/compat_template_v1.__init__.py 

...

very long list of __init__.py

...

# Configuration: 0a57a666022e7b1152ea8b54fcf24ecaaf686df88c7befcfa936094e6446de84
# Execution platform: @local_execution_config_platform//:platform
2026-03-13 00:10:02.727965: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcudart.10.1.dylib'; dlerror: dlopen(libcudart.10.1.dylib, 6): image not found
2026-03-13 00:10:02.728021: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
/bin/bash: line 1: 99847 Segmentation fault: 11  


Target //tensorflow/tools/pip_package:build_pip_package failed to build

I'v tried export these env variable and manual execute the last error command,

export DYLD_LIBRARY_PATH=/usr/local/cuda/lib
export LD_LIBRARY_PATH=$DYLD_LIBRARY_PATH
export PATH=$DYLD_LIBRARY_PATH:$PATH

it still raise same errors, and popup a dialog window says "Python quit unexpectedly."

2026-03-13 01:07:31.312113: W tensorflow/stream_executor/platform/default/dso_loader.cc:64] Could not load dynamic library 'libcudart.10.1.dylib'; dlerror: dlopen(libcudart.10.1.dylib, 6): image not found
2026-03-13 01:07:31.312137: I tensorflow/stream_executor/cuda/cudart_stub.cc:29] Ignore above cudart dlerror if you do not have a GPU set up on your machine.
Segmentation fault: 11

I'v build and install tensorflow@2.4 base on TomHeaven's repo, so I believe my cuda lib is right.

System information

  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): macosx 10.13.6
  • TensorFlow installed from (source or binary): source use this repo
  • Python version: 3.9.18
  • Bazel version (if compiling from source): 5.2.1-homebrew , build use your fixed bazel repo.
  • GCC/Compiler version (if compiling from source):
gcc -v
Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk/usr/include/c++/4.2.1
Apple LLVM version 10.0.1 (clang-1001.0.46.4)
Target: x86_64-apple-darwin17.7.0
Thread model: posix
InstalledDir: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin
Found CUDA installation: /Developer/NVIDIA/CUDA-10.1, version unknown
  • CUDA/cuDNN version:
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2019 NVIDIA Corporation
Built on Sun_Jul_28_19:14:47_PDT_2019
Cuda compilation tools, release 10.1, V10.1.243
  • GPU model and memory: gtx 1080ti 11GB

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions