mirror of
https://github.com/csunny/DB-GPT.git
synced 2025-08-30 23:56:25 +00:00
Merge remote-tracking branch 'origin/main' into dbgpt_api
This commit is contained in:
commit
2ae2e3c4a7
@ -2,26 +2,26 @@ Installation FAQ
|
||||
==================================
|
||||
|
||||
|
||||
##### Q1: execute `pip install -r requirements.txt` error, found some package cannot find correct version.
|
||||
##### Q1: execute `pip install -e .` error, found some package cannot find correct version.
|
||||
change the pip source.
|
||||
|
||||
```bash
|
||||
# pypi
|
||||
$ pip install -r requirements.txt -i https://pypi.python.org/simple
|
||||
$ pip install -e . -i https://pypi.python.org/simple
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
```bash
|
||||
# tsinghua
|
||||
$ pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple/
|
||||
$ pip install -e . -i https://pypi.tuna.tsinghua.edu.cn/simple/
|
||||
```
|
||||
|
||||
or
|
||||
|
||||
```bash
|
||||
# aliyun
|
||||
$ pip install -r requirements.txt -i http://mirrors.aliyun.com/pypi/simple/
|
||||
$ pip install -e . -i http://mirrors.aliyun.com/pypi/simple/
|
||||
```
|
||||
|
||||
##### Q2: sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) unable to open database file
|
||||
@ -29,5 +29,20 @@ $ pip install -r requirements.txt -i http://mirrors.aliyun.com/pypi/simple/
|
||||
make sure you pull latest code or create directory with mkdir pilot/data
|
||||
|
||||
##### Q3: The model keeps getting killed.
|
||||
|
||||
your GPU VRAM size is not enough, try replace your hardware or replace other llms.
|
||||
|
||||
##### Q4: How to access website on the public network
|
||||
|
||||
You can try to use gradio's [network](https://github.com/gradio-app/gradio/blob/main/gradio/networking.py) to achieve.
|
||||
```python
|
||||
import secrets
|
||||
from gradio import networking
|
||||
token=secrets.token_urlsafe(32)
|
||||
local_port=5000
|
||||
url = networking.setup_tunnel('0.0.0.0', local_port, token)
|
||||
print(f'Public url: {url}')
|
||||
time.sleep(60 * 60 * 24)
|
||||
```
|
||||
|
||||
Open `url` with your browser to see the website.
|
@ -49,7 +49,7 @@ For the entire installation process of DB-GPT, we use the miniconda3 virtual env
|
||||
python>=3.10
|
||||
conda create -n dbgpt_env python=3.10
|
||||
conda activate dbgpt_env
|
||||
pip install -r requirements.txt
|
||||
pip install -e .
|
||||
```
|
||||
Before use DB-GPT Knowledge
|
||||
```bash
|
||||
@ -97,15 +97,20 @@ You can configure basic parameters in the .env file, for example setting LLM_MOD
|
||||
|
||||
### 3. Run
|
||||
|
||||
**(Optional) load examples into SQLlite**
|
||||
```bash
|
||||
bash ./scripts/examples/load_examples.sh
|
||||
```
|
||||
|
||||
1.Run db-gpt server
|
||||
|
||||
```bash
|
||||
$ python pilot/server/dbgpt_server.py
|
||||
python pilot/server/dbgpt_server.py
|
||||
```
|
||||
|
||||
Open http://localhost:5000 with your browser to see the product.
|
||||
|
||||
```tip
|
||||
```{tip}
|
||||
If you want to access an external LLM service, you need to
|
||||
|
||||
1.set the variables LLM_MODEL=YOUR_MODEL_NAME, MODEL_SERVER=YOUR_MODEL_SERVER(eg:http://localhost:5000) in the .env file.
|
||||
@ -116,7 +121,7 @@ If you want to access an external LLM service, you need to
|
||||
If you want to learn about dbgpt-webui, read https://github./csunny/DB-GPT/tree/new-page-framework/datacenter
|
||||
|
||||
```bash
|
||||
$ python pilot/server/dbgpt_server.py --light
|
||||
python pilot/server/dbgpt_server.py --light
|
||||
```
|
||||
|
||||
### Multiple GPUs
|
||||
@ -141,6 +146,4 @@ DB-GPT supported 8-bit quantization and 4-bit quantization.
|
||||
|
||||
You can modify the setting `QUANTIZE_8bit=True` or `QUANTIZE_4bit=True` in `.env` file to use quantization(8-bit quantization is enabled by default).
|
||||
|
||||
Llama-2-70b with 8-bit quantization can run with 80 GB of VRAM, and 4-bit quantization can run with 48 GB of VRAM.
|
||||
|
||||
Note: you need to install the latest dependencies according to [requirements.txt](https://github.com/eosphoros-ai/DB-GPT/blob/main/requirements.txt).
|
||||
Llama-2-70b with 8-bit quantization can run with 80 GB of VRAM, and 4-bit quantization can run with 48 GB of VRAM.
|
@ -1,6 +1,8 @@
|
||||
### llama.cpp
|
||||
llama.cpp
|
||||
==================================
|
||||
|
||||
DB-GPT is now supported by [llama-cpp-python](https://github.com/abetlen/llama-cpp-python) through [llama.cpp](https://github.com/ggerganov/llama.cpp).
|
||||
|
||||
DB-GPT already supports [llama.cpp](https://github.com/ggerganov/llama.cpp) via [llama-cpp-python](https://github.com/abetlen/llama-cpp-python).
|
||||
|
||||
## Running llama.cpp
|
||||
|
||||
|
@ -1,6 +1,7 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
import os
|
||||
from typing import Optional, Any, Iterable
|
||||
from sqlalchemy import create_engine, text
|
||||
|
||||
@ -24,6 +25,9 @@ class SQLiteConnect(RDBMSDatabase):
|
||||
_engine_args = engine_args or {}
|
||||
_engine_args["connect_args"] = {"check_same_thread": False}
|
||||
# _engine_args["echo"] = True
|
||||
directory = os.path.dirname(file_path)
|
||||
if not os.path.exists(directory):
|
||||
os.makedirs(directory)
|
||||
return cls(create_engine("sqlite:///" + file_path, **_engine_args), **kwargs)
|
||||
|
||||
def get_indexes(self, table_name):
|
||||
|
@ -335,6 +335,20 @@ register_conv_template(
|
||||
)
|
||||
)
|
||||
|
||||
# Alpaca default template
|
||||
register_conv_template(
|
||||
Conversation(
|
||||
name="alpaca",
|
||||
system="Below is an instruction that describes a task. Write a response that appropriately completes the request.",
|
||||
roles=("### Instruction", "### Response"),
|
||||
messages=(),
|
||||
offset=0,
|
||||
sep_style=SeparatorStyle.ADD_COLON_TWO,
|
||||
sep="\n\n",
|
||||
sep2="</s>",
|
||||
)
|
||||
)
|
||||
|
||||
# Baichuan-13B-Chat template
|
||||
register_conv_template(
|
||||
# source: https://huggingface.co/baichuan-inc/Baichuan-13B-Chat/blob/f5f47be2adbbdceb784f334d6fa1ca2c73e65097/modeling_baichuan.py#L507
|
||||
|
68
scripts/examples/load_examples.bat
Normal file
68
scripts/examples/load_examples.bat
Normal file
@ -0,0 +1,68 @@
|
||||
@echo off
|
||||
setlocal
|
||||
|
||||
:: Get script location and set working directory
|
||||
for %%i in (%0) do set SCRIPT_LOCATION=%%~dpi
|
||||
cd %SCRIPT_LOCATION%
|
||||
cd ..
|
||||
cd ..
|
||||
set WORK_DIR=%CD%
|
||||
|
||||
:: Check if sqlite3 is installed
|
||||
where sqlite3 >nul 2>nul
|
||||
if %ERRORLEVEL% neq 0 (
|
||||
echo sqlite3 not found, please install sqlite3
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
:: Default file paths
|
||||
set DEFAULT_DB_FILE=DB-GPT\pilot\data\default_sqlite.db
|
||||
set DEFAULT_SQL_FILE=DB-GPT\docker\examples\sqls\*_sqlite.sql
|
||||
set DB_FILE=%WORK_DIR%\pilot\data\default_sqlite.db
|
||||
set SQL_FILE=
|
||||
|
||||
:argLoop
|
||||
if "%1"=="" goto argDone
|
||||
if "%1"=="-d" goto setDBFile
|
||||
if "%1"=="--db-file" goto setDBFile
|
||||
if "%1"=="-f" goto setSQLFile
|
||||
if "%1"=="--sql-file" goto setSQLFile
|
||||
if "%1"=="-h" goto printUsage
|
||||
if "%1"=="--help" goto printUsage
|
||||
goto argError
|
||||
|
||||
:setDBFile
|
||||
shift
|
||||
set DB_FILE=%1
|
||||
shift
|
||||
goto argLoop
|
||||
|
||||
:setSQLFile
|
||||
shift
|
||||
set SQL_FILE=%1
|
||||
shift
|
||||
goto argLoop
|
||||
|
||||
:argError
|
||||
echo Invalid argument: %1
|
||||
goto printUsage
|
||||
|
||||
:printUsage
|
||||
echo USAGE: %0 [--db-file sqlite db file] [--sql-file sql file path to run]
|
||||
echo [-d|--db-file sqlite db file path] default: %DEFAULT_DB_FILE%
|
||||
echo [-f|--sql-file sqlite file to run] default: %DEFAULT_SQL_FILE%
|
||||
echo [-h|--help] Usage message
|
||||
exit /b 0
|
||||
|
||||
:argDone
|
||||
|
||||
if "%SQL_FILE%"=="" (
|
||||
if not exist "%WORK_DIR%\pilot\data" mkdir "%WORK_DIR%\pilot\data"
|
||||
for %%f in (%WORK_DIR%\docker\examples\sqls\*_sqlite.sql) do (
|
||||
echo execute sql file: %%f
|
||||
sqlite3 "%DB_FILE%" < "%%f"
|
||||
)
|
||||
) else (
|
||||
echo Execute SQL file %SQL_FILE%
|
||||
sqlite3 "%DB_FILE%" < "%SQL_FILE%"
|
||||
)
|
69
scripts/examples/load_examples.sh
Executable file
69
scripts/examples/load_examples.sh
Executable file
@ -0,0 +1,69 @@
|
||||
#!/bin/bash
|
||||
# Only support SQLite now
|
||||
|
||||
SCRIPT_LOCATION=$0
|
||||
cd "$(dirname "$SCRIPT_LOCATION")"
|
||||
WORK_DIR=$(pwd)
|
||||
WORK_DIR="$WORK_DIR/../.."
|
||||
|
||||
if ! command -v sqlite3 > /dev/null 2>&1
|
||||
then
|
||||
echo "sqlite3 not found, please install sqlite3"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
DEFAULT_DB_FILE="DB-GPT/pilot/data/default_sqlite.db"
|
||||
DEFAULT_SQL_FILE="DB-GPT/docker/examples/sqls/*_sqlite.sql"
|
||||
DB_FILE="$WORK_DIR/pilot/data/default_sqlite.db"
|
||||
SQL_FILE=""
|
||||
|
||||
usage () {
|
||||
echo "USAGE: $0 [--db-file sqlite db file] [--sql-file sql file path to run]"
|
||||
echo " [-d|--db-file sqlite db file path] default: ${DEFAULT_DB_FILE}"
|
||||
echo " [-f|--sql-file sqlte file to run] default: ${DEFAULT_SQL_FILE}"
|
||||
echo " [-h|--help] Usage message"
|
||||
}
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
key="$1"
|
||||
case $key in
|
||||
-d|--db-file)
|
||||
DB_FILE="$2"
|
||||
shift # past argument
|
||||
shift # past value
|
||||
;;
|
||||
-f|--sql-file)
|
||||
SQL_FILE="$2"
|
||||
shift
|
||||
shift
|
||||
;;
|
||||
-h|--help)
|
||||
help="true"
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
usage
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [[ $help ]]; then
|
||||
usage
|
||||
exit 0
|
||||
fi
|
||||
|
||||
if [ -n $SQL_FILE ];then
|
||||
mkdir -p $WORK_DIR/pilot/data
|
||||
for file in $WORK_DIR/docker/examples/sqls/*_sqlite.sql
|
||||
do
|
||||
echo "execute sql file: $file"
|
||||
sqlite3 $DB_FILE < "$file"
|
||||
done
|
||||
|
||||
else
|
||||
echo "Execute SQL file ${SQL_FILE}"
|
||||
sqlite3 $DB_FILE < $SQL_FILE
|
||||
fi
|
||||
|
||||
|
47
scripts/llama_cpp_install.sh
Executable file
47
scripts/llama_cpp_install.sh
Executable file
@ -0,0 +1,47 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Get cuda version by torch
|
||||
CUDA_VERSION=`python -c "import torch;print(torch.version.cuda.replace('.', '') if torch.cuda.is_available() else '')"`
|
||||
|
||||
DEVICE="cpu"
|
||||
CPU_OPT="basic"
|
||||
|
||||
if [ "${CUDA_VERSION}" = "" ]; then
|
||||
echo "CUDA not support, use cpu version"
|
||||
else
|
||||
DEVICE="cu${CUDA_VERSION//./}"
|
||||
echo "CUDA version: $CUDA_VERSION, download path: $DEVICE"
|
||||
fi
|
||||
|
||||
echo "Checking CPU support:"
|
||||
CPU_SUPPORT=$(lscpu)
|
||||
|
||||
echo "$CPU_SUPPORT" | grep -q "avx "
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "CPU supports AVX."
|
||||
# CPU_OPT="AVX"
|
||||
# TODO AVX will failed on my cpu
|
||||
else
|
||||
echo "CPU does not support AVX."
|
||||
fi
|
||||
|
||||
echo "$CPU_SUPPORT" | grep -q "avx2"
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "CPU supports AVX2."
|
||||
CPU_OPT="AVX2"
|
||||
else
|
||||
echo "CPU does not support AVX2."
|
||||
fi
|
||||
|
||||
echo "$CPU_SUPPORT" | grep -q "avx512"
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "CPU supports AVX512."
|
||||
CPU_OPT="AVX512"
|
||||
else
|
||||
echo "CPU does not support AVX512."
|
||||
fi
|
||||
|
||||
EXTRA_INDEX_URL="https://jllllll.github.io/llama-cpp-python-cuBLAS-wheels/$CPU_OPT/$DEVICE"
|
||||
|
||||
echo "install llama-cpp-python from --extra-index-url ${EXTRA_INDEX_URL}"
|
||||
python -m pip install llama-cpp-python --force-reinstall --no-cache --prefer-binary --extra-index-url=$EXTRA_INDEX_URL
|
Loading…
Reference in New Issue
Block a user