Hi everyone !
I have spent a lot of time trying to install llama-cpp-python with GPU support.
I need your help. I'll keep monitoring the thread and if I need to try other options and provide info post and I'll send everything quickly.
I use:
Windows 10 Home
Intel Processor
GPU NVidia RTX 3060
I installed it on my computer:
Cuda_12.2.2_537.13_windows
Anaconda fully new enviroment with Python 3.10.12
Visual Stidio Community 2022
Visual Studio Build Tools 2022
Cmake-3.27.4-windows-x86_64
Path to Cuda I got a command:
echo %CUDA_PATH%
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.2
I use cmd.exe
To get the environment variables I use the command:
set
Try to install by that instruction:
Local Language Models with GPU Support
https://github.com/KillianLucas/open-interpreter/blob/main/docs/GPU.md
After entering the first line:
set FORCE_CMAKE=1 && set CMAKE_ARGS=-DLLAMA_CUBLAS=on
Got the following environment variables:
ALLUSERSPROFILE=C:\ProgramData
APPDATA=C:\Users\igorb\AppData\Roaming
CMAKE_ARGS=-DLLAMA_CUBLAS=on
COMMONPROGRAMFILES=C:\Program Files\Common Files
COMMONPROGRAMFILES(X86)=C:\Program Files (x86)\Common Files
COMMONPROGRAMW6432=C:\Program Files\Common Files
COMPUTERNAME=DESKTOP-K5FCPTT
COMSPEC=C:\Windows\system32\cmd.exe
CONDA_BAT=E:\miniconda3\condabin\conda.bat
CONDA_DEFAULT_ENV=llamanew
CONDA_EXE=C:\Users\igorb\anaconda3\Scripts\conda.exe
CONDA_PROMPT_MODIFIER=(llamanew)
CONDA_PYTHON_EXE=C:\Users\igorb\anaconda3\python.exe
CONDA_SHLVL=1
CUDA_PATH=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.2
CUDA_PATH_V12_2=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.2
DRIVERDATA=C:\Windows\System32\Drivers\DriverData
FORCE_CMAKE=1
HOMEDRIVE=C:
And others below.
After running this command:
pip install llama-cpp-python --force-reinstall --upgrade --no-cache-dir -vv
Got the following error in the listing:
Building wheels for collected packages: llama-cpp-python
Created temporary directory: C:\Users\igorb\AppData\Local\Temp\pip-wheel-glrwuh6k
Destination directory: C:\Users\igorb\AppData\Local\Temp\pip-wheel-glrwuh6k
Running command Building wheel for llama-cpp-python (pyproject.toml)
*** scikit-build-core 0.5.0 using CMake 3.27.4 (wheel)
*** Configuring CMake...
2023-09-15 18:22:31,570 - 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\igorb\AppData\Local\Temp\tmp8bwuhpey\build\CMakeInit.txt
-- Building for: Visual Studio 17 2022
-- Selecting Windows SDK version 10.0.22621.0 to target Windows 10.0.19045.
-- The C compiler identification is MSVC 19.37.32824.0
-- The CXX compiler identification is MSVC 19.37.32824.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.37.32822/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.37.32822/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.41.0.windows.1")
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
CMake Warning at vendor/llama.cpp/CMakeLists.txt:125 (message):
Git repository not found; to enable automatic generation of build info,
make sure Git is installed and the project is a Git repository.
-- 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.140")
-- cuBLAS found
CMake Error at C:/Program Files/CMake/share/cmake-3.27/Modules/CMakeDetermineCompilerId.cmake:503 (message):
No CUDA toolset found.
Call Stack (most recent call first):
C:/Program Files/CMake/share/cmake-3.27/Modules/CMakeDetermineCompilerId.cmake:8 (CMAKE_DETERMINE_COMPILER_ID_BUILD)
C:/Program Files/CMake/share/cmake-3.27/Modules/CMakeDetermineCompilerId.cmake:53 (__determine_compiler_id_test)
C:/Program Files/CMake/share/cmake-3.27/Modules/CMakeDetermineCUDACompiler.cmake:307 (CMAKE_DETERMINE_COMPILER_ID)
vendor/llama.cpp/CMakeLists.txt:286 (enable_language)
-- Configuring incomplete, errors occurred!
*** CMake configuration failed
error: subprocess-exited-with-error
× Building wheel for llama-cpp-python (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> See above for output.
note: This error originates from a subprocess, and is likely not a problem with pip.
full command: 'C:\Users\igorb\anaconda3\envs\llaman\python.exe' 'C:\Users\igorb\anaconda3\envs\llaman\lib\site-packages\pip_vendor\pyproject_hooks_in_process_in_process.py' build_wheel 'C:\Users\igorb\AppData\Local\Temp\tmpc963p54s'
cwd: C:\Users\igorb\AppData\Local\Temp\pip-install-1obq29et\llama-cpp-python_475e6a59f42648fab37fac85854af94a
Building wheel for llama-cpp-python (pyproject.toml) ... error
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
Exception information:
Traceback (most recent call last):
File "C:\Users\igorb\anaconda3\envs\llaman\lib\site-packages\pip_internal\cli\base_command.py", line 180, in exc_logging_wrapper
status = run_func(*args)
File "C:\Users\igorb\anaconda3\envs\llaman\lib\site-packages\pip_internal\cli\req_command.py", line 248, in wrapper
return func(self, options, args)
File "C:\Users\igorb\anaconda3\envs\llaman\lib\site-packages\pip_internal\commands\install.py", line 429, in run
raise InstallationError(
pip._internal.exceptions.InstallationError: Could not build wheels for llama-cpp-python, which is required to install pyproject.toml-based projects
In Windows, you can set environment variables via Control Panel --> System --> About --> Advanced system settings --> Anvanced --> Environment variables --> System variables --> New
If you add environment variables there, they will automatically appear in the list of environment variables on command when Anaconda is rebooted:
set
If you add environment variables via the set command, they disappear in the environment variables after exiting Anaconda and then starting it.
More info:
When I set two system variables:
FORCE_CMAKE=1
LLAMA_CUBLAS=1
The llama-cpp-python installation goes without error, but after running it with the commands in cmd:
python
from llama_cpp import Llama
model = Llama("E:\LLM\LLaMA2-Chat-7B\llama-2-7b.Q4_0.gguf", verbose=True, n_threads=8, n_gpu_layers=40)
I'm getting data on a running model with a parameter:
BLAS = 0
A more complete listing:
llama_new_context_with_model: kv self size = 256.00 MB
llama_new_context_with_model: compute buffer total size = 71.97 MB
AVX = 1 | AVX2 = 1 | AVX512 = 0 | AVX512_VBMI = 0 | AVX512_VNNI = 0 | FMA = 1 | NEON = 0 | ARM_FMA = 0 | F16C = 1 | FP16_VA = 0 | WASM_SIMD = 0 | BLAS = 0 | SSE3 = 1 | SSSE3 = 0 | VSX = 0 |
Try also:
python -c "from llama_cpp import GGML_USE_CUBLAS; print(GGML_USE_CUBLAS)"
And receive:
False
And another piece of information:
Если Cmake установлен на компьютере, то по нему можно получить помощь по командам:
cmake --help
Part of the listing:
cmake [options]
cmake [options]
cmake [options] -S -B
Specify a source directory to (re-)generate a build system for it in the
current working directory. Specify an existing build directory to
re-generate its build system.
Options
-S = Explicitly specify a source directory.
-B = Explicitly specify a build directory.
-C = Pre-load a script to populate the cache.
-D [:]= = Create or update a cmake cache entry.
I also tried installing with the following environment variables:
set FORCE_CMAKE=1 && set CMAKE_ARGS=LLAMA_CUBLAS=ON
Also, the llama-cpp-python installation goes through without error, but the result is the same:
BLAS = 0
If I use that instruction:
How To Install Llama-2 Locally On Windows Computer – llama.cpp, Exllama, KoboltCpp
https://www.hardware-corner.net/guides/install-llama-2-windows-pc/
from the point:
Installing cuBLAS version for NVIDIA GPU
File:
cudart-llama-bin-win-cu12.1.0-x64
Contains 3 dlls:
cublas64_12.dll
cublasLt64_12.dll
cudart64_12.dll
And start llama as main.exe by command:
main.exe -m E:\LLM\LLaMA2-Chat-7B\llama-2-7b-chat.ggmlv3.q4_0.bin --in-prefix " [INST] " --in-suffix " [/INST]" -i -p "[INST] <> You are a helpful, respectful, and honest assistant. <> [/INST]" --n-gpu-layers 40 -ins --color
It is start fine with BLAS = 1 (GPU Support) and at a faster rate.
But I need use it with Python.
Hi everyone !
I have spent a lot of time trying to install llama-cpp-python with GPU support.
I need your help. I'll keep monitoring the thread and if I need to try other options and provide info post and I'll send everything quickly.
I use:
Windows 10 Home
Intel Processor
GPU NVidia RTX 3060
I installed it on my computer:
Cuda_12.2.2_537.13_windows
Anaconda fully new enviroment with Python 3.10.12
Visual Stidio Community 2022
Visual Studio Build Tools 2022
Cmake-3.27.4-windows-x86_64
Path to Cuda I got a command:
echo %CUDA_PATH%
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.2
I use cmd.exe
To get the environment variables I use the command:
set
Try to install by that instruction:
Local Language Models with GPU Support
https://github.com/KillianLucas/open-interpreter/blob/main/docs/GPU.md
After entering the first line:
set FORCE_CMAKE=1 && set CMAKE_ARGS=-DLLAMA_CUBLAS=on
Got the following environment variables:
ALLUSERSPROFILE=C:\ProgramData
APPDATA=C:\Users\igorb\AppData\Roaming
CMAKE_ARGS=-DLLAMA_CUBLAS=on
COMMONPROGRAMFILES=C:\Program Files\Common Files
COMMONPROGRAMFILES(X86)=C:\Program Files (x86)\Common Files
COMMONPROGRAMW6432=C:\Program Files\Common Files
COMPUTERNAME=DESKTOP-K5FCPTT
COMSPEC=C:\Windows\system32\cmd.exe
CONDA_BAT=E:\miniconda3\condabin\conda.bat
CONDA_DEFAULT_ENV=llamanew
CONDA_EXE=C:\Users\igorb\anaconda3\Scripts\conda.exe
CONDA_PROMPT_MODIFIER=(llamanew)
CONDA_PYTHON_EXE=C:\Users\igorb\anaconda3\python.exe
CONDA_SHLVL=1
CUDA_PATH=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.2
CUDA_PATH_V12_2=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.2
DRIVERDATA=C:\Windows\System32\Drivers\DriverData
FORCE_CMAKE=1
HOMEDRIVE=C:
And others below.
After running this command:
pip install llama-cpp-python --force-reinstall --upgrade --no-cache-dir -vv
Got the following error in the listing:
Building wheels for collected packages: llama-cpp-python
Created temporary directory: C:\Users\igorb\AppData\Local\Temp\pip-wheel-glrwuh6k
Destination directory: C:\Users\igorb\AppData\Local\Temp\pip-wheel-glrwuh6k
Running command Building wheel for llama-cpp-python (pyproject.toml)
*** scikit-build-core 0.5.0 using CMake 3.27.4 (wheel)
*** Configuring CMake...
2023-09-15 18:22:31,570 - 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\igorb\AppData\Local\Temp\tmp8bwuhpey\build\CMakeInit.txt
-- Building for: Visual Studio 17 2022
-- Selecting Windows SDK version 10.0.22621.0 to target Windows 10.0.19045.
-- The C compiler identification is MSVC 19.37.32824.0
-- The CXX compiler identification is MSVC 19.37.32824.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.37.32822/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.37.32822/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.41.0.windows.1")
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
CMake Warning at vendor/llama.cpp/CMakeLists.txt:125 (message):
Git repository not found; to enable automatic generation of build info,
make sure Git is installed and the project is a Git repository.
-- 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.140")
-- cuBLAS found
CMake Error at C:/Program Files/CMake/share/cmake-3.27/Modules/CMakeDetermineCompilerId.cmake:503 (message):
No CUDA toolset found.
Call Stack (most recent call first):
C:/Program Files/CMake/share/cmake-3.27/Modules/CMakeDetermineCompilerId.cmake:8 (CMAKE_DETERMINE_COMPILER_ID_BUILD)
C:/Program Files/CMake/share/cmake-3.27/Modules/CMakeDetermineCompilerId.cmake:53 (__determine_compiler_id_test)
C:/Program Files/CMake/share/cmake-3.27/Modules/CMakeDetermineCUDACompiler.cmake:307 (CMAKE_DETERMINE_COMPILER_ID)
vendor/llama.cpp/CMakeLists.txt:286 (enable_language)
-- Configuring incomplete, errors occurred!
*** CMake configuration failed
error: subprocess-exited-with-error
× Building wheel for llama-cpp-python (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> See above for output.
note: This error originates from a subprocess, and is likely not a problem with pip.
full command: 'C:\Users\igorb\anaconda3\envs\llaman\python.exe' 'C:\Users\igorb\anaconda3\envs\llaman\lib\site-packages\pip_vendor\pyproject_hooks_in_process_in_process.py' build_wheel 'C:\Users\igorb\AppData\Local\Temp\tmpc963p54s'
cwd: C:\Users\igorb\AppData\Local\Temp\pip-install-1obq29et\llama-cpp-python_475e6a59f42648fab37fac85854af94a
Building wheel for llama-cpp-python (pyproject.toml) ... error
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
Exception information:
Traceback (most recent call last):
File "C:\Users\igorb\anaconda3\envs\llaman\lib\site-packages\pip_internal\cli\base_command.py", line 180, in exc_logging_wrapper
status = run_func(*args)
File "C:\Users\igorb\anaconda3\envs\llaman\lib\site-packages\pip_internal\cli\req_command.py", line 248, in wrapper
return func(self, options, args)
File "C:\Users\igorb\anaconda3\envs\llaman\lib\site-packages\pip_internal\commands\install.py", line 429, in run
raise InstallationError(
pip._internal.exceptions.InstallationError: Could not build wheels for llama-cpp-python, which is required to install pyproject.toml-based projects
In Windows, you can set environment variables via Control Panel --> System --> About --> Advanced system settings --> Anvanced --> Environment variables --> System variables --> New
If you add environment variables there, they will automatically appear in the list of environment variables on command when Anaconda is rebooted:
set
If you add environment variables via the set command, they disappear in the environment variables after exiting Anaconda and then starting it.
More info:
When I set two system variables:
FORCE_CMAKE=1
LLAMA_CUBLAS=1
The llama-cpp-python installation goes without error, but after running it with the commands in cmd:
python
I'm getting data on a running model with a parameter:
BLAS = 0
A more complete listing:
llama_new_context_with_model: kv self size = 256.00 MB
llama_new_context_with_model: compute buffer total size = 71.97 MB
AVX = 1 | AVX2 = 1 | AVX512 = 0 | AVX512_VBMI = 0 | AVX512_VNNI = 0 | FMA = 1 | NEON = 0 | ARM_FMA = 0 | F16C = 1 | FP16_VA = 0 | WASM_SIMD = 0 | BLAS = 0 | SSE3 = 1 | SSSE3 = 0 | VSX = 0 |
Try also:
python -c "from llama_cpp import GGML_USE_CUBLAS; print(GGML_USE_CUBLAS)"
And receive:
False
And another piece of information:
Если Cmake установлен на компьютере, то по нему можно получить помощь по командам:
cmake --help
Part of the listing:
cmake [options]
cmake [options]
cmake [options] -S -B
Specify a source directory to (re-)generate a build system for it in the
current working directory. Specify an existing build directory to
re-generate its build system.
Options
-S = Explicitly specify a source directory.
-B = Explicitly specify a build directory.
-C = Pre-load a script to populate the cache.
-D [:]= = Create or update a cmake cache entry.
I also tried installing with the following environment variables:
set FORCE_CMAKE=1 && set CMAKE_ARGS=LLAMA_CUBLAS=ON
Also, the llama-cpp-python installation goes through without error, but the result is the same:
BLAS = 0
If I use that instruction:
How To Install Llama-2 Locally On Windows Computer – llama.cpp, Exllama, KoboltCpp
https://www.hardware-corner.net/guides/install-llama-2-windows-pc/
from the point:
Installing cuBLAS version for NVIDIA GPU
File:
cudart-llama-bin-win-cu12.1.0-x64
Contains 3 dlls:
cublas64_12.dll
cublasLt64_12.dll
cudart64_12.dll
And start llama as main.exe by command:
main.exe -m E:\LLM\LLaMA2-Chat-7B\llama-2-7b-chat.ggmlv3.q4_0.bin --in-prefix " [INST] " --in-suffix " [/INST]" -i -p "[INST] <> You are a helpful, respectful, and honest assistant. <> [/INST]" --n-gpu-layers 40 -ins --color
It is start fine with BLAS = 1 (GPU Support) and at a faster rate.
But I need use it with Python.