chatchat-space / Langchain-Chatchat

Langchain-Chatchat(原Langchain-ChatGLM)基于 Langchain 与 ChatGLM, Qwen 与 Llama 等语言模型的 RAG 与 Agent 应用 | Langchain-Chatchat (formerly langchain-ChatGLM), local knowledge based LLM (like ChatGLM, Qwen and Llama) RAG and Agent app with langchain
Apache License 2.0
31.9k stars 5.56k forks source link

[BUG] Mac M2 "Protobuf only supports C++14 and newer" #695

Closed guozan closed 1 year ago

guozan commented 1 year ago

问题描述 / Problem Description 在安装依赖时报错,pip install -r requirements.txt

主要有两个: warning: Protobuf compiler version 23.3 doesn't match library version 4.23.3 error: "Protobuf only supports C++14 and newer."

环境信息 / Environment Information

附加信息 / Additional Information

Building wheels for collected packages: onnx Building wheel for onnx (setup.py) ... error error: subprocess-exited-with-error

× python setup.py bdist_wheel did not run successfully. │ exit code: 1 ╰─> [619 lines of output] fatal: not a git repository (or any of the parent directories): .git /Users/youben/anaconda3/envs/chatglm/lib/python3.8/site-packages/setuptools/init.py:84: _DeprecatedInstaller: setuptools.installer and fetch_build_eggs are deprecated. !!

          ********************************************************************************
          Requirements should be satisfied by a PEP 517 installer.
          If you are using pip, you can try `pip install --use-pep517`.
          ********************************************************************************

  !!
    dist.fetch_build_eggs(dist.setup_requires)
  running bdist_wheel
  running build
  running build_py
  running create_version
  running cmake_build
  Using cmake args: ['/opt/homebrew/bin/cmake', '-DPYTHON_INCLUDE_DIR=/Users/youben/anaconda3/envs/chatglm/include/python3.8', '-DPYTHON_EXECUTABLE=/Users/youben/anaconda3/envs/chatglm/bin/python', '-DBUILD_ONNX_PYTHON=ON', '-DCMAKE_EXPORT_COMPILE_COMMANDS=ON', '-DONNX_NAMESPACE=onnx', '-DPY_EXT_SUFFIX=.cpython-38-darwin.so', '-DCMAKE_BUILD_TYPE=Release', '-DONNX_ML=1', '/private/var/folders/kr/rzl42jg10w39d9cbxf3g7rdh0000gn/T/pip-install-nl9he8z0/onnx_29b3d88db478417c87a9850d30da1590']
  -- The C compiler identification is AppleClang 14.0.3.14030022
  -- The CXX compiler identification is AppleClang 14.0.3.14030022
  -- Detecting C compiler ABI info
  -- Detecting C compiler ABI info - done
  -- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc - skipped
  -- Detecting C compile features
  -- Detecting C compile features - done
  -- Detecting CXX compiler ABI info
  -- Detecting CXX compiler ABI info - done
  -- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++ - skipped
  -- Detecting CXX compile features
  -- Detecting CXX compile features - done
  -- Found PythonInterp: /Users/youben/anaconda3/envs/chatglm/bin/python (found version "3.8.16")
  -- Found PythonLibs: /Users/youben/anaconda3/envs/chatglm/lib/libpython3.8.dylib (found version "3.8.16")
  CMake Warning at /opt/homebrew/Cellar/cmake/3.26.4/share/cmake/Modules/FindProtobuf.cmake:524 (message):
   **Protobuf compiler version 23.3 doesn't match library version 4.23.3****
  Call Stack (most recent call first):
    CMakeLists.txt:175 (find_package)

  -- Found Protobuf: /opt/homebrew/lib/libprotobuf.dylib (found version "4.23.3")
  Generated: /private/var/folders/kr/rzl42jg10w39d9cbxf3g7rdh0000gn/T/pip-install-nl9he8z0/onnx_29b3d88db478417c87a9850d30da1590/.setuptools-cmake-build/onnx/onnx-ml.proto
  Generated: /private/var/folders/kr/rzl42jg10w39d9cbxf3g7rdh0000gn/T/pip-install-nl9he8z0/onnx_29b3d88db478417c87a9850d30da1590/.setuptools-cmake-build/onnx/onnx-operators-ml.proto
  Generated: /private/var/folders/kr/rzl42jg10w39d9cbxf3g7rdh0000gn/T/pip-install-nl9he8z0/onnx_29b3d88db478417c87a9850d30da1590/.setuptools-cmake-build/onnx/onnx-data.proto
  -- Found PythonInterp: /Users/youben/anaconda3/envs/chatglm/bin/python (found suitable version "3.8.16", minimum required is "3.6")
  -- Found PythonLibs: /Users/youben/anaconda3/envs/chatglm/lib/libpython3.8.dylib
  -- Performing Test HAS_FLTO
  -- Performing Test HAS_FLTO - Success
  -- Performing Test HAS_FLTO_THIN
  -- Performing Test HAS_FLTO_THIN - Success
  -- Found pybind11: /Users/youben/anaconda3/envs/chatglm/include (found version "2.10.4")
  --
  -- ******** Summary ********
  --   CMake version             : 3.26.4
  --   CMake command             : /opt/homebrew/Cellar/cmake/3.26.4/bin/cmake
  --   System                    : Darwin
  --   C++ compiler              : /Library/Developer/CommandLineTools/usr/bin/c++
  --   C++ compiler version      : 14.0.3.14030022
  --   CXX flags                 :  -Wnon-virtual-dtor
  --   Build type                : Release
  --   Compile definitions       : __STDC_FORMAT_MACROS
  --   CMAKE_PREFIX_PATH         :
  --   CMAKE_INSTALL_PREFIX      : /usr/local
  --   CMAKE_MODULE_PATH         :
  --
  --   ONNX version              : 1.12.0
  --   ONNX NAMESPACE            : onnx
  --   ONNX_USE_LITE_PROTO       : OFF
  --   USE_PROTOBUF_SHARED_LIBS  : OFF
  --   Protobuf_USE_STATIC_LIBS  : ON
  --   ONNX_DISABLE_EXCEPTIONS   : OFF
  --   ONNX_WERROR               : OFF
  --   ONNX_BUILD_TESTS          : OFF
  --   ONNX_BUILD_BENCHMARKS     : OFF
  --   ONNXIFI_DUMMY_BACKEND     : OFF
  --   ONNXIFI_ENABLE_EXT        : OFF
  --
  --   Protobuf compiler         : /opt/homebrew/bin/protoc
  --   Protobuf includes         : /opt/homebrew/include
  --   Protobuf libraries        : /opt/homebrew/lib/libprotobuf.dylib
  --   BUILD_ONNX_PYTHON         : ON
  --     Python version        :
  --     Python executable     : /Users/youben/anaconda3/envs/chatglm/bin/python
  --     Python includes       : /Users/youben/anaconda3/envs/chatglm/include/python3.8
  -- Configuring done (1.0s)
  -- Generating done (0.0s)
  -- Build files have been written to: /private/var/folders/kr/rzl42jg10w39d9cbxf3g7rdh0000gn/T/pip-install-nl9he8z0/onnx_29b3d88db478417c87a9850d30da1590/.setuptools-cmake-build
  [  1%] Running gen_proto.py on onnx/onnx.in.proto
  [  4%] Building C object CMakeFiles/onnxifi_dummy.dir/onnx/onnxifi_dummy.c.o
  [  4%] Building C object CMakeFiles/onnxifi_loader.dir/onnx/onnxifi_loader.c.o
  Processing /private/var/folders/kr/rzl42jg10w39d9cbxf3g7rdh0000gn/T/pip-install-nl9he8z0/onnx_29b3d88db478417c87a9850d30da1590/onnx/onnx.in.proto
  Writing /private/var/folders/kr/rzl42jg10w39d9cbxf3g7rdh0000gn/T/pip-install-nl9he8z0/onnx_29b3d88db478417c87a9850d30da1590/.setuptools-cmake-build/onnx/onnx-ml.proto
  Writing /private/var/folders/kr/rzl42jg10w39d9cbxf3g7rdh0000gn/T/pip-install-nl9he8z0/onnx_29b3d88db478417c87a9850d30da1590/.setuptools-cmake-build/onnx/onnx-ml.proto3
  generating /private/var/folders/kr/rzl42jg10w39d9cbxf3g7rdh0000gn/T/pip-install-nl9he8z0/onnx_29b3d88db478417c87a9850d30da1590/.setuptools-cmake-build/onnx/onnx_pb.py
  [  5%] Running C++ protocol buffer compiler on /private/var/folders/kr/rzl42jg10w39d9cbxf3g7rdh0000gn/T/pip-install-nl9he8z0/onnx_29b3d88db478417c87a9850d30da1590/.setuptools-cmake-build/onnx/onnx-ml.proto
  [  7%] Linking C static library libonnxifi_loader.a
  [  8%] Linking C shared library libonnxifi_dummy.dylib
  [  8%] Built target onnxifi_loader
  [  9%] Building C object CMakeFiles/onnxifi_wrapper.dir/onnx/onnxifi_wrapper.c.o
  [  9%] Built target onnxifi_dummy
  [ 11%] Linking C shared module libonnxifi.dylib
  [ 11%] Built target onnxifi_wrapper
  Writing mypy to onnx/onnx_ml_pb2.pyi
  [ 11%] Built target gen_onnx_proto
  [ 14%] Running gen_proto.py on onnx/onnx-operators.in.proto
  [ 14%] Running gen_proto.py on onnx/onnx-data.in.proto
  Processing /private/var/folders/kr/rzl42jg10w39d9cbxf3g7rdh0000gn/T/pip-install-nl9he8z0/onnx_29b3d88db478417c87a9850d30da1590/onnx/onnx-operators.in.proto
  Writing /private/var/folders/kr/rzl42jg10w39d9cbxf3g7rdh0000gn/T/pip-install-nl9he8z0/onnx_29b3d88db478417c87a9850d30da1590/.setuptools-cmake-build/onnx/onnx-operators-ml.proto
  Writing /private/var/folders/kr/rzl42jg10w39d9cbxf3g7rdh0000gn/T/pip-install-nl9he8z0/onnx_29b3d88db478417c87a9850d30da1590/.setuptools-cmake-build/onnx/onnx-operators-ml.proto3
  generating /private/var/folders/kr/rzl42jg10w39d9cbxf3g7rdh0000gn/T/pip-install-nl9he8z0/onnx_29b3d88db478417c87a9850d30da1590/.setuptools-cmake-build/onnx/onnx_operators_pb.py
  Processing /private/var/folders/kr/rzl42jg10w39d9cbxf3g7rdh0000gn/T/pip-install-nl9he8z0/onnx_29b3d88db478417c87a9850d30da1590/onnx/onnx-data.in.proto
  Writing /private/var/folders/kr/rzl42jg10w39d9cbxf3g7rdh0000gn/T/pip-install-nl9he8z0/onnx_29b3d88db478417c87a9850d30da1590/.setuptools-cmake-build/onnx/onnx-data.proto
  Writing /private/var/folders/kr/rzl42jg10w39d9cbxf3g7rdh0000gn/T/pip-install-nl9he8z0/onnx_29b3d88db478417c87a9850d30da1590/.setuptools-cmake-build/onnx/onnx-data.proto3
  generating /private/var/folders/kr/rzl42jg10w39d9cbxf3g7rdh0000gn/T/pip-install-nl9he8z0/onnx_29b3d88db478417c87a9850d30da1590/.setuptools-cmake-build/onnx/onnx_data_pb.py
  [ 16%] Running C++ protocol buffer compiler on /private/var/folders/kr/rzl42jg10w39d9cbxf3g7rdh0000gn/T/pip-install-nl9he8z0/onnx_29b3d88db478417c87a9850d30da1590/.setuptools-cmake-build/onnx/onnx-operators-ml.proto
  [ 16%] Running C++ protocol buffer compiler on /private/var/folders/kr/rzl42jg10w39d9cbxf3g7rdh0000gn/T/pip-install-nl9he8z0/onnx_29b3d88db478417c87a9850d30da1590/.setuptools-cmake-build/onnx/onnx-data.proto
  Writing mypy to onnx/onnx_operators_ml_pb2.pyi
  Writing mypy to onnx/onnx_data_pb2.pyi
  [ 16%] Built target gen_onnx_operators_proto
  [ 16%] Built target gen_onnx_data_proto
  [ 18%] Building CXX object CMakeFiles/onnx_proto.dir/onnx/onnx-ml.pb.cc.o
  [ 19%] Building CXX object CMakeFiles/onnx_proto.dir/onnx/onnx-operators-ml.pb.cc.o
  [ 21%] Building CXX object CMakeFiles/onnx_proto.dir/onnx/onnx-data.pb.cc.o
  In file included from /private/var/folders/kr/rzl42jg10w39d9cbxf3g7rdh0000gn/T/pip-install-nl9he8z0/onnx_29b3d88db478417c87a9850d30da1590/.setuptools-cmake-build/onnx/onnx-operators-ml.pb.cc:4:
  In file included from /private/var/folders/kr/rzl42jg10w39d9cbxf3g7rdh0000gn/T/pip-install-nl9he8z0/onnx_29b3d88db478417c87a9850d30da1590/.setuptools-cmake-build/onnx/onnx-operators-ml.pb.h:11:
  **/opt/homebrew/include/google/protobuf/port_def.inc:205:1: error: In file included from static_assert failed due to requirement '201103L >= 201402L' "Protobuf only supports C++14 and newer."**
  /private/var/folders/kr/rzl42jg10w39d9cbxf3g7rdh0000gn/T/pip-install-nl9he8z0/onnx_29b3d88db478417c87a9850d30da1590/.setuptools-cmake-build/onnx/onnx-data.pb.cc:4:
  In file included from /private/var/folders/kr/rzl42jg10w39d9cbxf3g7rdh0000gn/T/pip-install-nl9he8z0/onnx_29b3d88db478417c87a9850d30da1590/.setuptools-cmake-build/onnx/onnx-data.pb.h:11:
  /opt/homebrew/include/google/protobuf/port_def.inc:205:1: error: static_assert failed due to requirement '201103L >= 201402L' "Protobuf only supports C++14 and newer."
  static_assert(PROTOBUF_CPLUSPLUS_MIN(201402L), "Protobuf only supports C++14 and newer.");
  ^             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  static_assert(PROTOBUF_CPLUSPLUS_MIN(201402L), "Protobuf only supports C++14 and newer.");
  ^             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  In file included from /private/var/folders/kr/rzl42jg10w39d9cbxf3g7rdh0000gn/T/pip-install-nl9he8z0/onnx_29b3d88db478417c87a9850d30da1590/.setuptools-cmake-build/onnx/onnx-ml.pb.cc:4:
  In file included from /private/var/folders/kr/rzl42jg10w39d9cbxf3g7rdh0000gn/T/pip-install-nl9he8z0/onnx_29b3d88db478417c87a9850d30da1590/.setuptools-cmake-build/onnx/onnx-ml.pb.h:11:
  /opt/homebrew/include/google/protobuf/port_def.inc:205:1: error: static_assert failed due to requirement '201103L >= 201402L' "Protobuf only supports C++14 and newer."
  static_assert(PROTOBUF_CPLUSPLUS_MIN(201402L), "Protobuf only supports C++14 and newer.");
Veken commented 1 year ago

你的M2安装成功了吗?我的M1一直提示模型未成功加载

andrewdavidmackenzie commented 1 year ago

I have this same problem in anoher project on my mac:

warning: Protobuf compiler version 23.3 doesn't match library version 4.23.3

Do you know of any fix?

FlyingBlazer commented 1 year ago

如果使用homebrew安装的protobuf,那么删除protobuf然后安装protobuf@21这个包,就不需要C++14

If you are using homebrew, then remove protobuf and install protobuf@21 instead. This package doesn't require C++14.

FlyingBlazer commented 1 year ago

版本不匹配的警告可以参考https://gitlab.kitware.com/cmake/cmake/-/merge_requests/8574/diffs,手动修改本地CMake的配置文件即可解决

@andrewdavidmackenzie Visit the previous link, and manually edit the configuration file /opt/homebrew/share/cmake/Modules/FindProtobuf.cmake(maybe).

wangy950 commented 1 year ago

这是mac没有安装protobuf环境,导致onnx构建失败,你看看这里 here This is because the mac does not install the protobuf environment, causing the onnx build to fail you can look like this

guozan commented 1 year ago

这个问题,本质是安装onnx过程中出现的,最终解决方式,绕过protobuf的问题,直接搞定onnx

由于是在conda环境,提前把onnx装上,不要用pip安装;具体原因暂不明 conda install onnx