zylon-ai / private-gpt

Interact with your documents using the power of GPT, 100% privately, no data leaks
https://privategpt.dev
Apache License 2.0
53.63k stars 7.21k forks source link

error in gpu support #1480

Closed dpenra closed 7 months ago

dpenra commented 8 months ago

system ubuntu,cpu ryzen 3600, GPU RTX 2060 super

CMAKE_ARGS='-DLLAMA_CUBLAS=on' poetry run pip install --force-reinstall --no-cache-dir llama-cpp-python Collecting llama-cpp-python Downloading llama_cpp_python-0.2.26.tar.gz (8.8 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 8.8/8.8 MB 5.6 MB/s eta 0:00:00 Installing build dependencies ... done Getting requirements to build wheel ... done Installing backend dependencies ... done Preparing metadata (pyproject.toml) ... done Collecting typing-extensions>=4.5.0 (from llama-cpp-python) Downloading typing_extensions-4.9.0-py3-none-any.whl.metadata (3.0 kB) Collecting numpy>=1.20.0 (from llama-cpp-python) Downloading numpy-1.26.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.metadata (61 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 61.2/61.2 kB 17.2 MB/s eta 0:00:00 Collecting diskcache>=5.6.1 (from llama-cpp-python) Downloading diskcache-5.6.3-py3-none-any.whl.metadata (20 kB) Downloading diskcache-5.6.3-py3-none-any.whl (45 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 45.5/45.5 kB 163.4 MB/s eta 0:00:00 Downloading numpy-1.26.3-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (18.3 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 18.3/18.3 MB 10.5 MB/s eta 0:00:00 Downloading typing_extensions-4.9.0-py3-none-any.whl (32 kB) Building wheels for collected packages: llama-cpp-python Building wheel for llama-cpp-python (pyproject.toml) ... error error: subprocess-exited-with-error

× Building wheel for llama-cpp-python (pyproject.toml) did not run successfully. │ exit code: 1 ╰─> [39 lines of output] scikit-build-core 0.7.1 using CMake 3.22.1 (wheel) Configuring CMake... 2024-01-03 12:38:20,333 - scikit_build_core - WARNING - libdir/ldlibrary: /usr/lib/x86_64-linux-gnu/libpython3.11.so is not a real file! 2024-01-03 12:38:20,333 - scikit_build_core - WARNING - Can't find a Python library, got libdir=/usr/lib/x86_64-linux-gnu, ldlibrary=libpython3.11.so, multiarch=x86_64-linux-gnu, masd=x86_64-linux-gnu loading initial cache file /tmp/tmpw13hw4ga/build/CMakeInit.txt -- The C compiler identification is GNU 11.4.0 -- The CXX compiler identification is GNU 11.4.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 -- Found Git: /usr/bin/git (found version "2.34.1") -- Looking for pthread.h -- Looking for pthread.h - found -- Performing Test CMAKE_HAVE_LIBC_PTHREAD -- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success -- Found Threads: TRUE -- Found CUDAToolkit: /usr/local/cuda/include (found version "12.3.103") -- cuBLAS found -- The CUDA compiler identification is unknown CMake Error at vendor/llama.cpp/CMakeLists.txt:268 (enable_language): No CMAKE_CUDA_COMPILER could be found.

    Tell CMake where to find the compiler by setting either the environment
    variable "CUDACXX" or the CMake cache entry CMAKE_CUDA_COMPILER to the full
    path to the compiler, or to the compiler name if it is in the PATH.

  -- Configuring incomplete, errors occurred!
  See also "/tmp/tmpw13hw4ga/build/CMakeFiles/CMakeOutput.log".
  See also "/tmp/tmpw13hw4ga/build/CMakeFiles/CMakeError.log".

  *** CMake configuration failed
  [end of output]

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

AIrabbit0 commented 8 months ago

I have a similar error ```Building wheels for collected packages: llama-cpp-python Building wheel for llama-cpp-python (pyproject.toml) ... error error: subprocess-exited-with-error

× Building wheel for llama-cpp-python (pyproject.toml) did not run successfully. │ exit code: 1 ╰─> [40 lines of output] scikit-build-core 0.7.1 using CMake 3.28.1 (wheel) Configuring CMake... 2024-01-04 06:46:45,834 - scikit_build_core - WARNING - Can't find a Python library, got libdir=None, ldlibrary=None, multiarch=None, masd=None loading initial cache file C:\Users\PCG\AppData\Local\Temp\tmpy64sqe8o\build\CMakeInit.txt -- Building for: Visual Studio 17 2022 -- Selecting Windows SDK version 10.0.22621.0 to target Windows 10.0.22631. -- The C compiler identification is MSVC 19.38.33133.0 -- The CXX compiler identification is MSVC 19.38.33133.0 -- Detecting C compiler ABI info -- Detecting C compiler ABI info - done -- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/Tools/MSVC/14.38.33130/bin/Hostx64/x64/cl.exe - 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: C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/Tools/MSVC/14.38.33130/bin/Hostx64/x64/cl.exe - skipped -- Detecting CXX compile features -- Detecting CXX compile features - done -- Found Git: C:/Program Files/Git/cmd/git.exe (found version "2.43.0.windows.1") -- Performing Test CMAKE_HAVE_LIBC_PTHREAD -- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed -- Looking for pthread_create in pthreads -- Looking for pthread_create in pthreads - not found -- Looking for pthread_create in pthread -- Looking for pthread_create in pthread - not found -- Found Threads: TRUE -- Found CUDAToolkit: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.2/include (found version "12.2.91") -- cuBLAS found CMake Error at C:/Users/PCG/AppData/Local/Temp/pip-build-env-1mh4nb2g/normal/Lib/site-packages/cmake/data/share/cmake-3.28/Modules/CMakeDetermineCompilerId.cmake:529 (message): No CUDA toolset found. Call Stack (most recent call first): C:/Users/PCG/AppData/Local/Temp/pip-build-env-1mh4nb2g/normal/Lib/site-packages/cmake/data/share/cmake-3.28/Modules/CMakeDetermineCompilerId.cmake:8 (CMAKE_DETERMINE_COMPILER_ID_BUILD) C:/Users/PCG/AppData/Local/Temp/pip-build-env-1mh4nb2g/normal/Lib/site-packages/cmake/data/share/cmake-3.28/Modules/CMakeDetermineCompilerId.cmake:53 (__determine_compiler_id_test) C:/Users/PCG/AppData/Local/Temp/pip-build-env-1mh4nb2g/normal/Lib/site-packages/cmake/data/share/cmake-3.28/Modules/CMakeDetermineCUDACompiler.cmake:135 (CMAKE_DETERMINE_COMPILER_ID) vendor/llama.cpp/CMakeLists.txt:268 (enable_language)

  -- Configuring incomplete, errors occurred!

  *** CMake configuration failed
  [end of output]

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```

hyperinx commented 8 months ago

CMAKE_ARGS="-DLLAMA_CUBLAS=on -DCUDA_PATH=/usr/local/cuda-12.2 -DCUDAToolkit_ROOT=/usr/local/cuda-12.2 -DCUDAToolkit_INCLUDE_DIR=/usr/local/cuda-12/include -DCUDAToolkit_LIBRARY_DIR=/usr/local/cuda-12.2/lib64" FORCE_CMAKE=1 pip install llama-cpp-python --no-cache-dir --verbose

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-12.2/compat (fixes the error with missing libcuda.so file)

Change path of cuda-12.X to your version of cuda.

If you are using it with docker you should create an image from nvidia/cuda:12.2.2-devel-ubuntu22.04 for example.

In my case it works only with devel docker image Install on your host https://docs.nvidia.com/datacenter/cloud-native/container-toolkit/latest/install-guide.html You can run it with nvidia support by using this cmd: docker run --runtime=nvidia -p 8001:8001

Dockerfile example:

FROM nvidia/cuda:12.2.2-devel-ubuntu22.04

RUN apt update && apt install -y git gcc

RUN apt-get update -y \ && apt-get upgrade -y \ && apt-get -y install build-essential \ zlib1g-dev \ libncurses5-dev \ libgdbm-dev \ libnss3-dev \ libssl-dev \ libreadline-dev \ libffi-dev \ libsqlite3-dev \ libbz2-dev \ wget \ && export DEBIAN_FRONTEND=noninteractive \ && apt-get purge -y imagemagick imagemagick-6-common

RUN cd /usr/src \ && wget https://www.python.org/ftp/python/3.11.0/Python-3.11.0.tgz \ && tar -xzf Python-3.11.0.tgz \ && cd Python-3.11.0 \ && ./configure --enable-optimizations \ && make altinstall

RUN update-alternatives --install /usr/bin/python python /usr/local/bin/python3.11 1

RUN apt install -y git python3-pip gcc

RUN git clone https://github.com/imartinez/privateGPT.git /app WORKDIR /app

RUN pip install poetry

RUN poetry env use 3.11.0

RUN poetry add sentence-transformers RUN poetry add huggingface_hub RUN poetry install --with ui,local && poetry run ./scripts/setup

ENV CMAKE_ARGS="-DLLAMA_CUBLAS=on -DCUDA_PATH=/usr/local/cuda-12.2 -DCUDAToolkit_ROOT=/usr/local/cuda-12.2 -DCUDAToolkit_INCLUDE_DIR=/usr/local/cuda-12/include -DCUDAToolkit_LIBRARY_DIR=/usr/local/cuda-12.2/lib64" ENV FORCE_CMAKE=1

RUN pip install llama-cpp-python --no-cache-dir

RUN poetry run pip install --force-reinstall --no-cache-dir llama-cpp-python

ENV LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-12.2/compat

EXPOSE 8001

ENTRYPOINT ["make", "run"]

docker-compose: version: '3.5'

services: privategpt: build: . image: privateGPT volumes:

dpenra commented 8 months ago

I found the solution. This is mainly because the system is unable to detect GPUs. Try to get info about your system gpu. By typing nvidia-smi and nvcc -V . If you cant access your gpu information you might have to install gpu driver in your system in order to use gpu accelerated privateGPT.

AIrabbit0 commented 8 months ago

ERROR: Option and is not recognized. Please run 'nvidia-smi -h'. and I runned that line and I got Supported products:

Please see the nvidia-smi documentation for more detailed information.

github-actions[bot] commented 8 months ago

Stale issue