abetlen / llama-cpp-python

Python bindings for llama.cpp
https://llama-cpp-python.readthedocs.io
MIT License
8.21k stars 979 forks source link

Failed building wheel for llama-cpp-python #676

Open schoemantian opened 1 year ago

schoemantian commented 1 year ago

llama-cpp-python, Fails to build wheels, Any help or guideance on Windows Server?

PS C:\development\localGPT> pip install llama-cpp-python
...
  note: This error originates from a subprocess, and is likely not a problem with pip.
  ERROR: Failed building wheel for llama-cpp-python
Failed to build llama-cpp-python
ERROR: Could not build wheels for llama-cpp-python, which is required to install pyproject.toml-based projects
c469591 commented 1 year ago

I also have similar error messages, I am using the Windows 10 system.

teicheld commented 1 year ago

also on linux:

` × Building wheel for llama-cpp-python (pyproject.toml) did not run successfully. │ exit code: 1 ╰─> [130 lines of output]

  --------------------------------------------------------------------------------
  -- Trying 'Ninja' generator
  --------------------------------
  ---------------------------
  ----------------------
  -----------------
  ------------
  -------
  --
  CMake Deprecation Warning at CMakeLists.txt:1 (cmake_minimum_required):
    Compatibility with CMake < 3.5 will be removed from a future version of
    CMake.

    Update the VERSION argument <min> value or use a ...<max> suffix to tell
    CMake that the project does not need compatibility with older versions.

  Not searching for unused variables given on the command line.

  -- The C compiler identification is GNU 12.2.0
  -- Detecting C compiler ABI info
  -- Detecting C compiler ABI info - done
  -- Check for working C compiler: /usr/bin/cc - skipped
  -- Detecting C compile features
  -- Detecting C compile features - done
  -- The CXX compiler identification is GNU 12.2.0
  -- Detecting CXX compiler ABI info
  -- Detecting CXX compiler ABI info - done
  -- Check for working CXX compiler: /usr/bin/c++ - skipped
  -- Detecting CXX compile features
  -- Detecting CXX compile features - done
  -- Configuring done (0.4s)
  -- Generating done (0.0s)
  -- Build files have been written to: /tmp/pip-install-jl4ad3m8/llama-cpp-python_ca9bc60790b6457f9fcae378517a8747/_cmake_test_compile/build
  --
  -------
  ------------
  -----------------
  ----------------------
  ---------------------------
  --------------------------------
  -- Trying 'Ninja' generator - success
  --------------------------------------------------------------------------------

  Configuring Project
    Working directory:
      /tmp/pip-install-jl4ad3m8/llama-cpp-python_ca9bc60790b6457f9fcae378517a8747/_skbuild/linux-x86_64-3.11/cmake-build
    Command:
      /tmp/pip-build-env-jrgjh240/overlay/lib/python3.11/site-packages/cmake/data/bin/cmake /tmp/pip-install-jl4ad3m8/llama-cpp-python_ca9bc60790b6457f9fcae378517a8747 -G Ninja -DCMAKE_MAKE_PROGRAM:FILEPATH=/tmp/pip-build-env-jrgjh240/overlay/lib/python3.11/site-packages/ninja/data/bin/ninja --no-warn-unused-cli -DCMAKE_INSTALL_PREFIX:PATH=/tmp/pip-install-jl4ad3m8/llama-cpp-python_ca9bc60790b6457f9fcae378517a8747/_skbuild/linux-x86_64-3.11/cmake-install -DPYTHON_VERSION_STRING:STRING=3.11.2 -DSKBUILD:INTERNAL=TRUE -DCMAKE_MODULE_PATH:PATH=/tmp/pip-build-env-jrgjh240/overlay/lib/python3.11/site-packages/skbuild/resources/cmake -DPYTHON_EXECUTABLE:PATH=/home/debian/kivy_venv/bin/python -DPYTHON_INCLUDE_DIR:PATH=/usr/include/python3.11 -DPYTHON_LIBRARY:PATH=/usr/lib/x86_64-linux-gnu/libpython3.11.so -DPython_EXECUTABLE:PATH=/home/debian/kivy_venv/bin/python -DPython_ROOT_DIR:PATH=/home/debian/kivy_venv -DPython_FIND_REGISTRY:STRING=NEVER -DPython_INCLUDE_DIR:PATH=/usr/include/python3.11 -DPython3_EXECUTABLE:PATH=/home/debian/kivy_venv/bin/python -DPython3_ROOT_DIR:PATH=/home/debian/kivy_venv -DPython3_FIND_REGISTRY:STRING=NEVER -DPython3_INCLUDE_DIR:PATH=/usr/include/python3.11 -DCMAKE_MAKE_PROGRAM:FILEPATH=/tmp/pip-build-env-jrgjh240/overlay/lib/python3.11/site-packages/ninja/data/bin/ninja -DCMAKE_BUILD_TYPE:STRING=Release

  Not searching for unused variables given on the command line.
  -- The C compiler identification is GNU 12.2.0
  -- The CXX compiler identification is GNU 12.2.0
  -- Detecting C compiler ABI info
  -- Detecting C compiler ABI info - done
  -- Check for working C compiler: /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: /usr/bin/c++ - skipped
  -- Detecting CXX compile features
  -- Detecting CXX compile features - done
  -- Configuring done (0.2s)
  -- Generating done (0.0s)
  -- Build files have been written to: /tmp/pip-install-jl4ad3m8/llama-cpp-python_ca9bc60790b6457f9fcae378517a8747/_skbuild/linux-x86_64-3.11/cmake-build
  [1/2] Generating /tmp/pip-install-jl4ad3m8/llama-cpp-python_ca9bc60790b6457f9fcae378517a8747/vendor/llama.cpp/libllama.so
  FAILED: /tmp/pip-install-jl4ad3m8/llama-cpp-python_ca9bc60790b6457f9fcae378517a8747/vendor/llama.cpp/libllama.so
  cd /tmp/pip-install-jl4ad3m8/llama-cpp-python_ca9bc60790b6457f9fcae378517a8747/vendor/llama.cpp && make libllama.so
  I llama.cpp build info:
  I UNAME_S:  Linux
  I UNAME_P:  unknown
  I UNAME_M:  x86_64
  I CFLAGS:   -I.            -O3 -std=c11   -fPIC -DNDEBUG -Wall -Wextra -Wpedantic -Wcast-qual -Wdouble-promotion -Wshadow -Wstrict-prototypes -Wpointer-arith -Wmissing-prototypes -pthread -march=native -mtune=native -DGGML_USE_K_QUANTS
  I CXXFLAGS: -I. -I./common -O3 -std=c++11 -fPIC -DNDEBUG -Wall -Wextra -Wpedantic -Wcast-qual -Wno-unused-function -Wno-multichar -pthread -march=native -mtune=native -DGGML_USE_K_QUANTS
  I LDFLAGS:
  I CC:       cc (Debian 12.2.0-14) 12.2.0
  I CXX:      g++ (Debian 12.2.0-14) 12.2.0

  g++ -I. -I./common -O3 -std=c++11 -fPIC -DNDEBUG -Wall -Wextra -Wpedantic -Wcast-qual -Wno-unused-function -Wno-multichar -pthread -march=native -mtune=native -DGGML_USE_K_QUANTS -c llama.cpp -o llama.o
  cc  -I.            -O3 -std=c11   -fPIC -DNDEBUG -Wall -Wextra -Wpedantic -Wcast-qual -Wdouble-promotion -Wshadow -Wstrict-prototypes -Wpointer-arith -Wmissing-prototypes -pthread -march=native -mtune=native -DGGML_USE_K_QUANTS   -c ggml.c -o ggml.o
  In file included from /usr/lib/gcc/x86_64-linux-gnu/12/include/immintrin.h:105,
                   from ggml.c:298:
  /usr/lib/gcc/x86_64-linux-gnu/12/include/fmaintrin.h: In function ‘ggml_vec_dot_q4_0_q8_0’:
  /usr/lib/gcc/x86_64-linux-gnu/12/include/fmaintrin.h:63:1: error: inlining failed in call to ‘always_inline’ ‘_mm256_fmadd_ps’: target specific option mismatch
     63 | _mm256_fmadd_ps (__m256 __A, __m256 __B, __m256 __C)
        | ^~~~~~~~~~~~~~~
  ggml.c:2523:15: note: called from here
   2523 |         acc = _mm256_fmadd_ps( d, q, acc );
        |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
  /usr/lib/gcc/x86_64-linux-gnu/12/include/fmaintrin.h:63:1: error: inlining failed in call to ‘always_inline’ ‘_mm256_fmadd_ps’: target specific option mismatch
     63 | _mm256_fmadd_ps (__m256 __A, __m256 __B, __m256 __C)
        | ^~~~~~~~~~~~~~~
  ggml.c:2523:15: note: called from here
   2523 |         acc = _mm256_fmadd_ps( d, q, acc );
        |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
  /usr/lib/gcc/x86_64-linux-gnu/12/include/fmaintrin.h:63:1: error: inlining failed in call to ‘always_inline’ ‘_mm256_fmadd_ps’: target specific option mismatch
     63 | _mm256_fmadd_ps (__m256 __A, __m256 __B, __m256 __C)
        | ^~~~~~~~~~~~~~~
  ggml.c:2523:15: note: called from here
   2523 |         acc = _mm256_fmadd_ps( d, q, acc );
        |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
  /usr/lib/gcc/x86_64-linux-gnu/12/include/fmaintrin.h:63:1: error: inlining failed in call to ‘always_inline’ ‘_mm256_fmadd_ps’: target specific option mismatch
     63 | _mm256_fmadd_ps (__m256 __A, __m256 __B, __m256 __C)
        | ^~~~~~~~~~~~~~~
  ggml.c:2523:15: note: called from here
   2523 |         acc = _mm256_fmadd_ps( d, q, acc );
        |               ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
  make: *** [Makefile:349: ggml.o] Fehler 1
  ninja: build stopped: subcommand failed.
  Traceback (most recent call last):
    File "/tmp/pip-build-env-jrgjh240/overlay/lib/python3.11/site-packages/skbuild/setuptools_wrap.py", line 674, in setup
      cmkr.make(make_args, install_target=cmake_install_target, env=env)
    File "/tmp/pip-build-env-jrgjh240/overlay/lib/python3.11/site-packages/skbuild/cmaker.py", line 697, in make
      self.make_impl(clargs=clargs, config=config, source_dir=source_dir, install_target=install_target, env=env)
    File "/tmp/pip-build-env-jrgjh240/overlay/lib/python3.11/site-packages/skbuild/cmaker.py", line 742, in make_impl
      raise SKBuildError(msg)

  An error occurred while building with CMake.
    Command:
      /tmp/pip-build-env-jrgjh240/overlay/lib/python3.11/site-packages/cmake/data/bin/cmake --build . --target install --config Release --
    Install target:
      install
    Source directory:
      /tmp/pip-install-jl4ad3m8/llama-cpp-python_ca9bc60790b6457f9fcae378517a8747
    Working directory:
      /tmp/pip-install-jl4ad3m8/llama-cpp-python_ca9bc60790b6457f9fcae378517a8747/_skbuild/linux-x86_64-3.11/cmake-build
  Please check the install target is valid and see CMake's output for more information.`
Pablo-Dominguez commented 1 year ago

I had a similar problem I managed to solved by upgrading the system version of gcc-c++. Please make sure you're using c++ 4.9 or greater.