mirror of
https://github.com/oobabooga/text-generation-webui.git
synced 2024-10-01 01:26:03 -04:00
Install older bitsandbytes on older gpus + fix llama-cpp-python issue (#75)
This commit is contained in:
parent
b1b3bb6923
commit
be98e74337
21
webui.py
21
webui.py
@ -7,6 +7,7 @@ import subprocess
|
||||
import sys
|
||||
|
||||
script_dir = os.getcwd()
|
||||
conda_env_path = os.path.join(script_dir, "installer_files", "env")
|
||||
|
||||
# Use this to set your command-line flags. For the full list, see:
|
||||
# https://github.com/oobabooga/text-generation-webui/#starting-the-web-ui
|
||||
@ -16,7 +17,6 @@ CMD_FLAGS = '--chat --model-menu'
|
||||
def run_cmd(cmd, assert_success=False, environment=False, capture_output=False, env=None):
|
||||
# Use the conda environment
|
||||
if environment:
|
||||
conda_env_path = os.path.join(script_dir, "installer_files", "env")
|
||||
if sys.platform.startswith("win"):
|
||||
conda_bat_path = os.path.join(script_dir, "installer_files", "conda", "condabin", "conda.bat")
|
||||
cmd = "\"" + conda_bat_path + "\" activate \"" + conda_env_path + "\" >nul && " + cmd
|
||||
@ -98,6 +98,20 @@ def update_dependencies():
|
||||
if os.path.exists(extension_req_path):
|
||||
run_cmd("python -m pip install -r " + extension_req_path + " --upgrade", assert_success=True, environment=True)
|
||||
|
||||
# Latest bitsandbytes requires minimum compute 7.0
|
||||
nvcc_device_query = "__nvcc_device_query" if not sys.platform.startswith("win") else "__nvcc_device_query.exe"
|
||||
min_compute = 70
|
||||
compute_array = run_cmd(os.path.join(conda_env_path, "bin", nvcc_device_query), environment=True, capture_output=True)
|
||||
old_bnb = "bitsandbytes==0.38.1" if not sys.platform.startswith("win") else "https://github.com/jllllll/bitsandbytes-windows-webui/raw/main/bitsandbytes-0.38.1-py3-none-any.whl"
|
||||
if compute_array.returncode == 0 and not any(int(compute) >= min_compute for compute in compute_array.stdout.decode('utf-8').split(',')):
|
||||
old_bnb_install = run_cmd(f"python -m pip install {old_bnb} --force-reinstall --no-deps", environment=True).returncode == 0
|
||||
print("\n\nWARNING: GPU with compute < 7.0 detected!")
|
||||
if old_bnb_install:
|
||||
print("Older version of bitsandbytes has been installed to maintain compatibility.")
|
||||
print("You will be unable to use --load-in-4bit!\n\n")
|
||||
else:
|
||||
print("You will be unable to use --load-in-8bit until you install bitsandbytes 0.38.1!\n\n")
|
||||
|
||||
# The following dependencies are for CUDA, not CPU
|
||||
# Check if the package cpuonly exists to determine if torch uses CUDA or not
|
||||
cpuonly_exist = run_cmd("conda list cpuonly | grep cpuonly", environment=True, capture_output=True).returncode == 0
|
||||
@ -200,5 +214,10 @@ if __name__ == "__main__":
|
||||
download_model()
|
||||
os.chdir(script_dir)
|
||||
|
||||
# Workaround for llama-cpp-python loading paths in CUDA env vars even if they do not exist
|
||||
conda_path_bin = os.path.join(conda_env_path, "bin")
|
||||
if not os.path.exists(conda_path_bin):
|
||||
os.mkdir(conda_path_bin)
|
||||
|
||||
# Run the model with webui
|
||||
run_model()
|
||||
|
Loading…
Reference in New Issue
Block a user