Skip to content

Syntax Error on bazel build #27

Description

@metal3d

System information

  • Have I written custom code (as opposed to using a stock example script provided in TensorFlow):
  • OS Platform and Distribution (e.g., Linux Ubuntu 16.04): Fedora 31
  • TensorFlow installed from (source or binary): source
  • TensorFlow version (use command below): your latest git version
  • Python version: 3.7.5
  • Bazel version (if compiling from source): 0.16.0
  • GCC/Compiler version (if compiling from source): 9.2.1
  • CUDA/cuDNN version: none
  • GPU model and memory: Intel
  • Exact command to reproduce: bazel build --verbose_failures --jobs=6 --config=sycl --config=opt //tensorflow/tools/pip_package:build_pip_package

Describe the problem

I try to build with SYSCL support following https://developer.codeplay.com/products/computecpp/ce/guides/tensorflow-guide/tensorflow-native-compilation, it fails

Source code / logs

$ bazel build --verbose_failures --jobs=6 --config=sycl --config=opt //tensorflow/tools/pip_package:build_pip_package

WARNING: /home/pafer/.cache/bazel/_bazel_pafer/e35f46a077ab640c6c436e2e9faf4c45/external/grpc/BUILD:1960:1: in srcs attribute of cc_library rule @grpc//:grpc_nanopb: please do not import '@grpc//third_party/nanopb:pb_common.c' directly. You should either move the file to this package or depend on an appropriate rule there. Since this rule was created by the macro 'grpc_generate_one_off_targets', the error might have been caused by the macro implementation in /home/pafer/.cache/bazel/_bazel_pafer/e35f46a077ab640c6c436e2e9faf4c45/external/grpc/bazel/grpc_build_system.bzl:172:12
WARNING: /home/pafer/.cache/bazel/_bazel_pafer/e35f46a077ab640c6c436e2e9faf4c45/external/grpc/BUILD:1960:1: in srcs attribute of cc_library rule @grpc//:grpc_nanopb: please do not import '@grpc//third_party/nanopb:pb_decode.c' directly. You should either move the file to this package or depend on an appropriate rule there. Since this rule was created by the macro 'grpc_generate_one_off_targets', the error might have been caused by the macro implementation in /home/pafer/.cache/bazel/_bazel_pafer/e35f46a077ab640c6c436e2e9faf4c45/external/grpc/bazel/grpc_build_system.bzl:172:12
WARNING: /home/pafer/.cache/bazel/_bazel_pafer/e35f46a077ab640c6c436e2e9faf4c45/external/grpc/BUILD:1960:1: in srcs attribute of cc_library rule @grpc//:grpc_nanopb: please do not import '@grpc//third_party/nanopb:pb_encode.c' directly. You should either move the file to this package or depend on an appropriate rule there. Since this rule was created by the macro 'grpc_generate_one_off_targets', the error might have been caused by the macro implementation in /home/pafer/.cache/bazel/_bazel_pafer/e35f46a077ab640c6c436e2e9faf4c45/external/grpc/bazel/grpc_build_system.bzl:172:12
WARNING: /home/pafer/Projects/TfOpenCL/tensorflow/tensorflow/contrib/learn/BUILD:17:1: in py_library rule //tensorflow/contrib/learn:learn: target '//tensorflow/contrib/learn:learn' depends on deprecated target '//tensorflow/contrib/session_bundle:exporter': No longer supported. Switch to SavedModel immediately.
WARNING: /home/pafer/Projects/TfOpenCL/tensorflow/tensorflow/contrib/learn/BUILD:17:1: in py_library rule //tensorflow/contrib/learn:learn: target '//tensorflow/contrib/learn:learn' depends on deprecated target '//tensorflow/contrib/session_bundle:gc': No longer supported. Switch to SavedModel immediately.
INFO: Analysed target //tensorflow/tools/pip_package:build_pip_package (0 packages loaded).
INFO: Found 1 target...
ERROR: /home/pafer/Projects/TfOpenCL/tensorflow/tensorflow/python/BUILD:5199:1: Executing genrule //tensorflow/python:framework/fast_tensor_util.pyx_cython_translation failed (Exit 1): bash failed: error executing command 
  (cd /home/pafer/.cache/bazel/_bazel_pafer/e35f46a077ab640c6c436e2e9faf4c45/execroot/org_tensorflow && \
  exec env - \
    LD_LIBRARY_PATH=/home/pafer/Projects/TfOpenCL/ComputeCpp-CE-1.3.0-CentOS-x86_64/lib \
    PATH=/home/pafer/bin:/home/pafer/.nvm/versions/node/v12.10.0/bin:/home/pafer/Envs/google-cloud-sdk/bin:/home/pafer/.local/bin:/home/pafer/bin:/home/pafer/.local/bin:/home/pafer/bin:/usr/share/Modules/bin:/usr/condabin:/home/pafer/.go/path/go-1.13/bin:/home/pafer/.go/root/go-1.13/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin \
  /bin/bash -c 'source external/bazel_tools/tools/genrule/genrule-setup.sh; PYTHONHASHSEED=0 bazel-out/host/bin/external/cython/cython_binary --cplus tensorflow/python/framework/fast_tensor_util.pyx --output-file bazel-out/host/genfiles/tensorflow/python/framework/fast_tensor_util.cpp')
Traceback (most recent call last):
  File "/home/pafer/.cache/bazel/_bazel_pafer/e35f46a077ab640c6c436e2e9faf4c45/execroot/org_tensorflow/bazel-out/host/bin/external/cython/cython_binary.runfiles/cython/cython.py", line 17, in <module>
    main(command_line = 1)
  File "/home/pafer/.cache/bazel/_bazel_pafer/e35f46a077ab640c6c436e2e9faf4c45/external/cython/Cython/Compiler/Main.py", line 720, in main
    result = compile(sources, options)
  File "/home/pafer/.cache/bazel/_bazel_pafer/e35f46a077ab640c6c436e2e9faf4c45/external/cython/Cython/Compiler/Main.py", line 695, in compile
    return compile_multiple(source, options)
  File "/home/pafer/.cache/bazel/_bazel_pafer/e35f46a077ab640c6c436e2e9faf4c45/external/cython/Cython/Compiler/Main.py", line 666, in compile_multiple
    context = options.create_context()
  File "/home/pafer/.cache/bazel/_bazel_pafer/e35f46a077ab640c6c436e2e9faf4c45/external/cython/Cython/Compiler/Main.py", line 590, in create_context
    self.cplus, self.language_level, options=self)
  File "/home/pafer/.cache/bazel/_bazel_pafer/e35f46a077ab640c6c436e2e9faf4c45/external/cython/Cython/Compiler/Main.py", line 75, in __init__
    from . import Builtin, CythonScope
  File "/home/pafer/.cache/bazel/_bazel_pafer/e35f46a077ab640c6c436e2e9faf4c45/external/cython/Cython/Compiler/CythonScope.py", line 5, in <module>
    from .UtilityCode import CythonUtilityCode
  File "/home/pafer/.cache/bazel/_bazel_pafer/e35f46a077ab640c6c436e2e9faf4c45/external/cython/Cython/Compiler/UtilityCode.py", line 3, in <module>
    from .TreeFragment import parse_from_strings, StringParseContext
  File "/home/pafer/.cache/bazel/_bazel_pafer/e35f46a077ab640c6c436e2e9faf4c45/external/cython/Cython/Compiler/TreeFragment.py", line 17, in <module>
    from .Visitor import VisitorTransform
  File "/home/pafer/.cache/bazel/_bazel_pafer/e35f46a077ab640c6c436e2e9faf4c45/external/cython/Cython/Compiler/Visitor.py", line 15, in <module>
    from . import ExprNodes
  File "/home/pafer/.cache/bazel/_bazel_pafer/e35f46a077ab640c6c436e2e9faf4c45/external/cython/Cython/Compiler/ExprNodes.py", line 2875
    await = None
          ^
SyntaxError: invalid syntax
Target //tensorflow/tools/pip_package:build_pip_package failed to build
INFO: Elapsed time: 0.714s, Critical Path: 0.28s
INFO: 3 processes: 3 local.
FAILED: Build did NOT complete successfully

My bazel config:

$  cat .tf_configure.bazelrc 
build --action_env PYTHON_BIN_PATH="/usr/bin/python"
build --action_env PYTHON_LIB_PATH="/usr/lib64/python3.7/site-packages"
build --python_path="/usr/bin/python"
build --define with_jemalloc=true
build:gcp --define with_gcp_support=true
build:hdfs --define with_hdfs_support=true
build:s3 --define with_s3_support=true
build:kafka --define with_kafka_support=true
build:xla --define with_xla_support=true
build:gdr --define with_gdr_support=true
build:verbs --define with_verbs_support=true
build --action_env TF_NEED_OPENCL_SYCL="1"
build:sycl --copt=-DINTEL_GPU=1
build --action_env TF_SYCL_PLATFORM="INTEL_GPU"
build --action_env TF_SYCL_USE_HALF="0"
build:sycl --cxxopt=-DTENSORFLOW_SYCL_NO_HALF=1
build --action_env TF_SYCL_USE_DOUBLE="1"
build --action_env TF_SYCL_USE_LOCAL_MEM="1"
build:sycl --cxxopt=-DEIGEN_SYCL_LOCAL_MEM
build --action_env TF_SYCL_USE_SERIAL_MEMOP="0"
build:sycl --cxxopt=-no-serial-memop
build --action_env TF_SYCL_IMGDNN_DIR=""
build --action_env TF_SYCL_USE_TENSOROPT="0"
build --action_env COMPUTECPP_TOOLKIT_PATH="/home/pafer/Projects/TfOpenCL/ComputeCpp-CE-1.3.0-CentOS-x86_64"
build --action_env TF_SYCL_OFFLINE_COMPILER=""
build --action_env TF_SYCL_OFFLINE_COMPILER_ARGS=""
build:sycl --cxxopt=-fsycl-split-modules=20
build --action_env TF_SYCL_BITCODE_TARGET="spir64"
build:sycl --define using_trisycl=false
build --action_env TF_NEED_CUDA="0"
build --action_env TF_DOWNLOAD_CLANG="0"
build --define grpc_no_ares=true
build:opt --copt=-march=native
build:opt --host_copt=-march=native
build:opt --define with_default_optimizations=true
build:opt --strip=always

Regards,

Activity

  1. Rbiessy commented on Feb 3, 2020

    @Rbiessy

    The issue comes from the Python version used, we only support Python 3.5 for now. If you can use 3.5 then downgrading is the easiest way.

    If you want to try with 3.7 then I suggest you bump the Cython version to 0.29 (as suggested here):

    This may bring more issues which I could help with if needed.

  2. metal3d commented on Feb 4, 2020

    @metal3d
    Author

    Thanks, I'm trying. I'll give you some news in a couple of hours (bazel is not fast at all...)

  3. metal3d commented on Feb 4, 2020

    @metal3d
    Author

    Right, it goes further, but failed :)

    
    ERROR: /home/pafer/.cache/bazel/_bazel_pafer/e35f46a077ab640c6c436e2e9faf4c45/external/grpc/BUILD:502:1: C++ compilation of rule '@grpc//:gpr_base' failed (Exit 1): gcc failed: error executing command 
      (cd /home/pafer/.cache/bazel/_bazel_pafer/e35f46a077ab640c6c436e2e9faf4c45/execroot/org_tensorflow && \
      exec env - \
        LD_LIBRARY_PATH=../ComputeCpp-CE-1.3.0-CentOS-x86_64//lib \
        PATH=/home/pafer/.nvm/versions/node/v12.10.0/bin:/home/pafer/Envs/google-cloud-sdk/bin:/home/pafer/.local/bin:/home/pafer/bin:/home/pafer/.local/bin:/home/pafer/bin:/usr/share/Modules/bin:/usr/condabin:/home/pafer/.go/path/go-1.13/bin:/home/pafer/.go/root/go-1.13/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/usr/sbin \
        PWD=/proc/self/cwd \
      /usr/bin/gcc -U_FORTIFY_SOURCE -fstack-protector -Wall -B/usr/bin -B/usr/bin -Wunused-but-set-parameter -Wno-free-nonheap-object -fno-omit-frame-pointer -g0 -O2 '-D_FORTIFY_SOURCE=1' -DNDEBUG -ffunction-sections -fdata-sections '-std=c++0x' -MD -MF bazel-out/host/bin/external/grpc/_objs/gpr_base/log_linux.pic.d '-frandom-seed=bazel-out/host/bin/external/grpc/_objs/gpr_base/log_linux.pic.o' -fPIC '-DGRPC_ARES=0' -iquote external/grpc -iquote bazel-out/host/genfiles/external/grpc -iquote bazel-out/host/bin/external/grpc -iquote external/bazel_tools -iquote bazel-out/host/genfiles/external/bazel_tools -iquote bazel-out/host/bin/external/bazel_tools -isystem external/grpc/include -isystem bazel-out/host/genfiles/external/grpc/include -isystem bazel-out/host/bin/external/grpc/include -g0 '-march=native' -g0 -fno-canonical-system-headers -Wno-builtin-macro-redefined '-D__DATE__="redacted"' '-D__TIMESTAMP__="redacted"' '-D__TIME__="redacted"' -c external/grpc/src/core/lib/gpr/log_linux.cc -o bazel-out/host/bin/external/grpc/_objs/gpr_base/log_linux.pic.o)
    external/grpc/src/core/lib/gpr/log_linux.cc:43:13: error: ambiguating new declaration of 'long int gettid()'
       43 | static long gettid(void) { return syscall(__NR_gettid); }
          |             ^~~~~~
    In file included from /usr/include/unistd.h:1170,
                     from external/grpc/src/core/lib/gpr/log_linux.cc:41:
    /usr/include/bits/unistd_ext.h:34:16: note: old declaration '__pid_t gettid()'
       34 | extern __pid_t gettid (void) __THROW;
          |                ^~~~~~
    external/grpc/src/core/lib/gpr/log_linux.cc:43:13: warning: 'long int gettid()' defined but not used [-Wunused-function]
       43 | static long gettid(void) { return syscall(__NR_gettid); }
          |             ^~~~~~
    Target //tensorflow/tools/pip_package:build_pip_package failed to build
    INFO: Elapsed time: 60.054s, Critical Path: 15.39s
    INFO: 388 processes: 388 local.
    FAILED: Build did NOT complete successfully
    

    Don't know if I should open a new issue, or leave it like that and check when it will be possible to compile with Python 3.7.x

    Thanks for your help

  4. Rbiessy commented on Feb 5, 2020

    @Rbiessy

    Thank you for trying it :)

    So this is now hitting this issue: grpc/grpc#18950
    Similarly we would need to bump grpc to 1.24 by replacing in tensorflow/workspace.bzl:

    • d184fa229d75d336aedea0041bd59cb93e7e267f -> 2de2e8dd8921e1f7d043e01faf7fe8a291fbb072
    • 895b31310e718a61f7335759a778c068a6edde1c089883598a0830cbb7075673 -> c396cabdf18650a61c0ecb171fec8bae6580f686b52558f59f410809bdbe0bae

    I'm happy to keep this issue open to discuss on how to enable support for Python 3.7. I may give it a go myself at some point so that we have an experimental branch for 3.7.

  5. metal3d commented on Feb 6, 2020

    @metal3d
    Author

    Ok, I will try today (I'm a bit busy for a couple of hours)
    Thanks for your help

  6. Rbiessy commented on Jun 30, 2020

    @Rbiessy

    My experiments suggest that it will be to difficult to cherry pick the right changes. The only solution is to bump the fork to at least TF 1.11 which is not planned at the moment.

  7. ShreyasheeSinha commented on Nov 9, 2021

    @ShreyasheeSinha

    I am trying to build tensorflow on bazel 0.5.4 and bump into this error. I am running this on an ubuntu 16.04 instance. Python version is 3.6.3 and Cython is 0.29. Any idea how to go about this?

    root@c3c16b3207f1:/salus/tensorflow-salus# cython -V 
    Cython version 0.29.24
    root@c3c16b3207f1:/salus/tensorflow-salus# python -V
    Python 3.6.3
    root@c3c16b3207f1:/salus/tensorflow-salus# inv build
    bazel build -c opt --config=cuda  //tensorflow:libtensorflow_framework.so //tensorflow:libtensorflow_kernels.so //tensorflow/tools/pip_package:build_pip_package
    ...................
    WARNING: /salus/tensorflow-salus/tensorflow/core/BUILD:1814:1: in includes attribute of cc_library rule //tensorflow/core:framework_headers_lib: '../../external/nsync/public' resolves to 'external/nsync/public' not below the relative path of its package 'tensorflow/core'. This will be an error in the future. Since this rule was created by the macro 'cc_header_only_library', the error might have been caused by the macro implementation in /salus/tensorflow-salus/tensorflow/tensorflow.bzl:1138:30.
    WARNING: /salus/tensorflow-salus/tensorflow/contrib/learn/BUILD:15:1: in py_library rule //tensorflow/contrib/learn:learn: target '//tensorflow/contrib/learn:learn' depends on deprecated target '//tensorflow/contrib/session_bundle:exporter': No longer supported. Switch to SavedModel immediately.
    WARNING: /salus/tensorflow-salus/tensorflow/contrib/learn/BUILD:15:1: in py_library rule //tensorflow/contrib/learn:learn: target '//tensorflow/contrib/learn:learn' depends on deprecated target '//tensorflow/contrib/session_bundle:gc': No longer supported. Switch to SavedModel immediately.
    INFO: Found 3 targets...
    ERROR: /salus/tensorflow-salus/tensorflow/python/BUILD:4586:1: Executing genrule //tensorflow/python:framework_fast_tensor_util_cython_translation failed (Exit 1).
    Traceback (most recent call last):
      File "/root/.cache/bazel/_bazel_root/ef6f2d7aa9e625bf367e9f2cf4a24bad/execroot/org_tensorflow/bazel-out/host/bin/external/cython/cython_binary.runfiles/org_tensorflow/../cython/cython.py", line 17, in <module>
        main(command_line = 1)
      File "/root/.cache/bazel/_bazel_root/ef6f2d7aa9e625bf367e9f2cf4a24bad/external/cython/Cython/Compiler/Main.py", line 720, in main
        result = compile(sources, options)
      File "/root/.cache/bazel/_bazel_root/ef6f2d7aa9e625bf367e9f2cf4a24bad/external/cython/Cython/Compiler/Main.py", line 695, in compile
        return compile_multiple(source, options)
      File "/root/.cache/bazel/_bazel_root/ef6f2d7aa9e625bf367e9f2cf4a24bad/external/cython/Cython/Compiler/Main.py", line 666, in compile_multiple
        context = options.create_context()
      File "/root/.cache/bazel/_bazel_root/ef6f2d7aa9e625bf367e9f2cf4a24bad/external/cython/Cython/Compiler/Main.py", line 589, in create_context
        return Context(self.include_path, self.compiler_directives,
      File "/root/.cache/bazel/_bazel_root/ef6f2d7aa9e625bf367e9f2cf4a24bad/external/cython/Cython/Compiler/Main.py", line 75, in __init__
        from . import Builtin, CythonScope
      File "/root/.cache/bazel/_bazel_root/ef6f2d7aa9e625bf367e9f2cf4a24bad/external/cython/Cython/Compiler/CythonScope.py", line 5, in <module>
        from .UtilityCode import CythonUtilityCode
      File "/root/.cache/bazel/_bazel_root/ef6f2d7aa9e625bf367e9f2cf4a24bad/external/cython/Cython/Compiler/UtilityCode.py", line 3, in <module>
        from .TreeFragment import parse_from_strings, StringParseContext
      File "/root/.cache/bazel/_bazel_root/ef6f2d7aa9e625bf367e9f2cf4a24bad/external/cython/Cython/Compiler/TreeFragment.py", line 17, in <module>
        from .Visitor import VisitorTransform
      File "/root/.cache/bazel/_bazel_root/ef6f2d7aa9e625bf367e9f2cf4a24bad/external/cython/Cython/Compiler/Visitor.py", line 15, in <module>
        from . import ExprNodes
      File "/root/.cache/bazel/_bazel_root/ef6f2d7aa9e625bf367e9f2cf4a24bad/external/cython/Cython/Compiler/ExprNodes.py", line 2875
        await = None
              ^
    SyntaxError: invalid syntax
    INFO: Elapsed time: 44.710s, Critical Path: 7.53s
    
  8. rodburns commented on Nov 10, 2021

    @rodburns
    Collaborator

    @ShreyasheeSinha what target are you building for? Are you using the SYCL build option listed in the original report in this issue? If not then I would raise a new issue with the information about how you are trying to build TensorFlow.

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