随笔 - 214  文章 - 12  评论 - 40  阅读 - 38万

TensorFlow Python3.7环境下的源码编译(三)编译

这里要为仅支持 CPU 的 TensorFlow 构建一个 pip 软件包,需要调用以下命令:
$ bazel build --cxxopt="-D_GLIBCXX_USE_CXX11_ABI=0" --config=opt --verbose_failures //tensorflow/tools/pip_package:build_pip_package
 
大概编译15分钟后,输出错误信息如下:
ERROR: /private/var/tmp/_bazel_mazhiyong/54650f23f4cec88510e7895c92a68913/external/protobuf_archive/BUILD:659:1: C++ compilation of rule '@protobuf_archive//:python/google/protobuf/pyext/_message.so' failed (Exit 1)
external/protobuf_archive/python/google/protobuf/pyext/message.cc:547:11: error: assigning to 'char *' from incompatible type 'const char *'
      if (PyString_AsStringAndSize(key, &key_str_data, &key_str_size) != 0)
          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
external/protobuf_archive/python/google/protobuf/pyext/message.cc:82:22: note: expanded from macro 'PyString_AsStringAndSize'
       ((*(charpp) = PyUnicode_AsUTF8AndSize(ob, (sizep))) == NULL? -1: 0): \
                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
external/protobuf_archive/python/google/protobuf/pyext/message.cc:998:7: error: assigning to 'char *' from incompatible type 'const char *'
  if (PyString_AsStringAndSize(name, &field_name, &size) < 0) {
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
external/protobuf_archive/python/google/protobuf/pyext/message.cc:82:22: note: expanded from macro 'PyString_AsStringAndSize'
       ((*(charpp) = PyUnicode_AsUTF8AndSize(ob, (sizep))) == NULL? -1: 0): \
                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
external/protobuf_archive/python/google/protobuf/pyext/message.cc:1035:9: error: assigning to 'char *' from incompatible type 'const char *'
    if (PyString_AsStringAndSize(value, &enum_label, &size) < 0) {
        ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
external/protobuf_archive/python/google/protobuf/pyext/message.cc:82:22: note: expanded from macro 'PyString_AsStringAndSize'
       ((*(charpp) = PyUnicode_AsUTF8AndSize(ob, (sizep))) == NULL? -1: 0): \
                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
external/protobuf_archive/python/google/protobuf/pyext/message.cc:1532:16: error: assigning to 'char *' from incompatible type 'const char *'
  field_name = PyUnicode_AsUTF8AndSize(arg, &size);
               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
external/protobuf_archive/python/google/protobuf/pyext/message.cc:2048:7: warning: 'PyObject_AsReadBuffer' is deprecated [-Wdeprecated-declarations]
  if (PyObject_AsReadBuffer(arg, &data, &data_length) < 0) {
      ^
bazel-out/darwin-opt/genfiles/external/local_config_python/python_include/abstract.h:492:39: note: 'PyObject_AsReadBuffer' has been explicitly marked deprecated here
                                      Py_DEPRECATED(3.0);
                                      ^
bazel-out/darwin-opt/genfiles/external/local_config_python/python_include/pyport.h:493:54: note: expanded from macro 'Py_DEPRECATED'
#define Py_DEPRECATED(VERSION_UNUSED) __attribute__((__deprecated__))
                                                     ^
external/protobuf_archive/python/google/protobuf/pyext/message.cc:2119:7: error: assigning to 'char *' from incompatible type 'const char *'
  if (PyString_AsStringAndSize(arg, &name_data, &name_size) < 0)
      ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
external/protobuf_archive/python/google/protobuf/pyext/message.cc:82:22: note: expanded from macro 'PyString_AsStringAndSize'
       ((*(charpp) = PyUnicode_AsUTF8AndSize(ob, (sizep))) == NULL? -1: 0): \
                     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 warning and 5 errors generated.
Target //tensorflow/tools/pip_package:build_pip_package failed to build
Use --verbose_failures to see the command lines of failed build steps.
INFO: Elapsed time: 771.278s, Critical Path: 26.15s
INFO: 2156 processes: 2156 local.
FAILED: Build did NOT complete successfully
 
这个错误我估计是编译器与代码兼容的问题,查找了半天暂时没找到解决办法,所以就暂时搁置了TensorFlow主分支代码在Python3.7环境下的代码编译,过一段时间再试试。
posted on   麦克煎蛋  阅读(1847)  评论(0编辑  收藏  举报
编辑推荐:
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· AI技术革命,工作效率10个最佳AI工具
< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

点击右上角即可分享
微信分享提示