From 11a8fd1eb9f98489cbf111601b3bf317f8f79322 Mon Sep 17 00:00:00 2001 From: jllllll <3887729+jllllll@users.noreply.github.com> Date: Sat, 15 Jul 2023 23:31:33 -0500 Subject: [PATCH] Add cuBLAS llama-cpp-python wheel installation (#102) Parses requirements.txt using regex to determine required version. --- webui.py | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/webui.py b/webui.py index 25c2d367..5049f700 100644 --- a/webui.py +++ b/webui.py @@ -1,5 +1,6 @@ import argparse import glob +import re import os import site import subprocess @@ -110,10 +111,10 @@ def update_dependencies(): os.chdir("text-generation-webui") run_cmd("git pull", assert_success=True, environment=True) - # Workaround for git+ packages not updating properly + # Workaround for git+ packages not updating properly Also store requirements.txt for later use with open("requirements.txt") as f: - requirements = f.read().splitlines() - git_requirements = [req for req in requirements if req.startswith("git+")] + textgen_requirements = f.read() + git_requirements = [req for req in textgen_requirements.splitlines() if req.startswith("git+")] # Loop through each "git+" requirement and uninstall it for req in git_requirements: @@ -161,6 +162,12 @@ def update_dependencies(): if '+cu' not in torver and run_cmd("conda list -f pytorch-cuda | grep pytorch-cuda", environment=True, capture_output=True).returncode == 1: return + # Install llama-cpp-python built with cuBLAS support for NVIDIA GPU acceleration + if '+cu' in torver: + llama_cpp = re.search('(?<=llama-cpp-python==)\d+(?:\.\d+)*', textgen_requirements) + if llama_cpp is not None: + run_cmd(f'python -m pip install llama-cpp-python=={llama_cpp[0]} --force-reinstall --no-deps --index-url=https://jllllll.github.io/llama-cpp-python-cuBLAS-wheels/AVX2/cu117', environment=True) + # Finds the path to your dependencies for sitedir in site.getsitepackages(): if "site-packages" in sitedir: