mirror of
https://github.com/KoboldAI/KoboldAI-Client.git
synced 2025-03-12 09:30:05 +01:00
Merge branch 'united' into gui-and-scripting
This commit is contained in:
commit
8452940597
30
aiserver.py
30
aiserver.py
@ -82,6 +82,7 @@ class vars:
|
|||||||
submission = "" # Same as above, but after applying input formatting
|
submission = "" # Same as above, but after applying input formatting
|
||||||
lastctx = "" # The last context submitted to the generator
|
lastctx = "" # The last context submitted to the generator
|
||||||
model = "" # Model ID string chosen at startup
|
model = "" # Model ID string chosen at startup
|
||||||
|
model_type = "" # Model Type (Automatically taken from the model config)
|
||||||
noai = False # Runs the script without starting up the transformers pipeline
|
noai = False # Runs the script without starting up the transformers pipeline
|
||||||
aibusy = False # Stops submissions while the AI is working
|
aibusy = False # Stops submissions while the AI is working
|
||||||
max_length = 1024 # Maximum number of tokens to submit per action
|
max_length = 1024 # Maximum number of tokens to submit per action
|
||||||
@ -391,9 +392,29 @@ if(not vars.model in ["InferKit", "Colab", "OAI", "ReadOnly", "TPUMeshTransforme
|
|||||||
vars.allowsp = True
|
vars.allowsp = True
|
||||||
# Test for GPU support
|
# Test for GPU support
|
||||||
import torch
|
import torch
|
||||||
|
|
||||||
|
# Make model path the same as the model name to make this consistent with the other loading method if it isn't a known model type
|
||||||
|
# This code is not just a workaround for below, it is also used to make the behavior consistent with other loading methods - Henk717
|
||||||
|
if(not vars.model in ["NeoCustom", "GPT2Custom"]):
|
||||||
|
vars.custmodpth = vars.model
|
||||||
|
# Get the model_type from the config or assume a model type if it isn't present
|
||||||
|
from transformers import AutoConfig
|
||||||
|
try:
|
||||||
|
model_config = AutoConfig.from_pretrained(vars.custmodpth)
|
||||||
|
except ValueError as e:
|
||||||
|
vars.model_type = "not_found"
|
||||||
|
if(not vars.model_type == "not_found"):
|
||||||
|
vars.model_type = model_config.model_type
|
||||||
|
elif(vars.model == "NeoCustom"):
|
||||||
|
vars.model_type = "gpt_neo"
|
||||||
|
elif(vars.model == "GPT2Custom"):
|
||||||
|
vars.model_type = "gpt2"
|
||||||
|
else:
|
||||||
|
print("WARNING: No model type detected, assuming Neo (If this is a GPT2 model use the other menu option or --model GPT2Custom)")
|
||||||
|
vars.model_type = "gpt_neo"
|
||||||
print("{0}Looking for GPU support...{1}".format(colors.PURPLE, colors.END), end="")
|
print("{0}Looking for GPU support...{1}".format(colors.PURPLE, colors.END), end="")
|
||||||
vars.hascuda = torch.cuda.is_available()
|
vars.hascuda = torch.cuda.is_available()
|
||||||
vars.bmsupported = vars.model in ("EleutherAI/gpt-neo-1.3B", "EleutherAI/gpt-neo-2.7B", "EleutherAI/gpt-j-6B", "NeoCustom")
|
vars.bmsupported = vars.model_type in ("gpt_neo", "gptj")
|
||||||
if(args.breakmodel is not None and args.breakmodel):
|
if(args.breakmodel is not None and args.breakmodel):
|
||||||
print("WARNING: --breakmodel is no longer supported. Breakmodel mode is now automatically enabled when --layers is used (see --help for details).", file=sys.stderr)
|
print("WARNING: --breakmodel is no longer supported. Breakmodel mode is now automatically enabled when --layers is used (see --help for details).", file=sys.stderr)
|
||||||
if(args.breakmodel_layers is not None):
|
if(args.breakmodel_layers is not None):
|
||||||
@ -871,12 +892,13 @@ if(not vars.model in ["InferKit", "Colab", "OAI", "ReadOnly", "TPUMeshTransforme
|
|||||||
if("/" not in vars.model and vars.model.lower().startswith("gpt2")):
|
if("/" not in vars.model and vars.model.lower().startswith("gpt2")):
|
||||||
lowmem = {}
|
lowmem = {}
|
||||||
|
|
||||||
# Is CUDA available? If so, use GPU, otherwise fall back to CPU
|
# Download model from Huggingface if it does not exist, otherwise load locally
|
||||||
|
|
||||||
if(os.path.isdir(vars.model.replace('/', '_'))):
|
if(os.path.isdir(vars.model.replace('/', '_'))):
|
||||||
with(maybe_use_float16()):
|
with(maybe_use_float16()):
|
||||||
tokenizer = GPT2TokenizerFast.from_pretrained(vars.model.replace('/', '_'), cache_dir="cache/")
|
tokenizer = GPT2TokenizerFast.from_pretrained(vars.model.replace('/', '_'), cache_dir="cache/")
|
||||||
model = AutoModelForCausalLM.from_pretrained(vars.model.replace('/', '_'), cache_dir="cache/", **lowmem)
|
model = AutoModelForCausalLM.from_pretrained(vars.model.replace('/', '_'), cache_dir="cache/", **lowmem)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print("Model does not exist locally, attempting to download from Huggingface...")
|
print("Model does not exist locally, attempting to download from Huggingface...")
|
||||||
tokenizer = GPT2TokenizerFast.from_pretrained(vars.model, cache_dir="cache/")
|
tokenizer = GPT2TokenizerFast.from_pretrained(vars.model, cache_dir="cache/")
|
||||||
@ -1961,8 +1983,8 @@ def loadsettings():
|
|||||||
# Allow the models to override some settings
|
# Allow the models to override some settings
|
||||||
#==================================================================#
|
#==================================================================#
|
||||||
def loadmodelsettings():
|
def loadmodelsettings():
|
||||||
if(path.exists(vars.custmodpth + "/config.json")):
|
if(path.exists(vars.custmodpth.replace('/', '_') + "/config.json")):
|
||||||
model_config = open(vars.custmodpth + "/config.json", "r")
|
model_config = open(vars.custmodpth.replace('/', '_') + "/config.json", "r")
|
||||||
js = json.load(model_config)
|
js = json.load(model_config)
|
||||||
if("badwordsids" in js):
|
if("badwordsids" in js):
|
||||||
vars.badwordsids = js["badwordsids"]
|
vars.badwordsids = js["badwordsids"]
|
||||||
|
@ -1,15 +1,19 @@
|
|||||||
@echo off
|
@echo off
|
||||||
cd %~dp0
|
cd /D %~dp0
|
||||||
TITLE CMD for KoboldAI Runtime
|
TITLE CMD for KoboldAI Runtime
|
||||||
SET /P M=<loader.settings
|
SET /P M=<loader.settings
|
||||||
IF %M%==1 GOTO drivemap
|
IF %M%==1 GOTO drivemap
|
||||||
IF %M%==2 GOTO subfolder
|
IF %M%==2 GOTO subfolder
|
||||||
|
|
||||||
:subfolder
|
:subfolder
|
||||||
|
SET TEMP=%~DP0MINICONDA3
|
||||||
|
SET TMP=%~DP0MINICONDA3
|
||||||
call miniconda3\condabin\activate
|
call miniconda3\condabin\activate
|
||||||
cmd /k
|
cmd /k
|
||||||
|
|
||||||
:drivemap
|
:drivemap
|
||||||
subst K: miniconda3 >nul
|
subst K: miniconda3 >nul
|
||||||
|
SET TEMP=K:\
|
||||||
|
SET TMP=K:\
|
||||||
call K:\python\condabin\activate
|
call K:\python\condabin\activate
|
||||||
cmd /k
|
cmd /k
|
@ -12,8 +12,7 @@ echo.
|
|||||||
SET /P B=Type the number of the desired option and then press ENTER:
|
SET /P B=Type the number of the desired option and then press ENTER:
|
||||||
|
|
||||||
Reg add "HKLM\SYSTEM\CurrentControlSet\Control\FileSystem" /v "LongPathsEnabled" /t REG_DWORD /d "1" /f 2>nul
|
Reg add "HKLM\SYSTEM\CurrentControlSet\Control\FileSystem" /v "LongPathsEnabled" /t REG_DWORD /d "1" /f 2>nul
|
||||||
%~d0
|
cd /D %~dp0
|
||||||
cd %~dp0
|
|
||||||
|
|
||||||
if exist miniconda3\ (
|
if exist miniconda3\ (
|
||||||
echo Delete existing installation?
|
echo Delete existing installation?
|
||||||
@ -43,21 +42,27 @@ echo 1 > loader.settings
|
|||||||
subst K: /D >nul
|
subst K: /D >nul
|
||||||
mkdir miniconda3
|
mkdir miniconda3
|
||||||
subst K: miniconda3
|
subst K: miniconda3
|
||||||
|
SET TEMP=K:\
|
||||||
|
SET TMP=K:\
|
||||||
copy umamba.exe K:\umamba.exe
|
copy umamba.exe K:\umamba.exe
|
||||||
K:
|
K:
|
||||||
umamba.exe create -r K:\python\ -n base
|
umamba.exe create -r K:\python\ -n base
|
||||||
IF %B%==1 umamba.exe install --no-shortcuts -r K:\python\ -n base -f "%~dp0\environments\huggingface.yml" -y
|
IF %B%==1 umamba.exe install --no-shortcuts -r K:\python\ -n base -f "%~dp0\environments\huggingface.yml" -y --always-copy
|
||||||
IF %B%==2 umamba.exe install --no-shortcuts -r K:\python\ -n base -f "%~dp0\environments\finetuneanon.yml" -y
|
IF %B%==2 umamba.exe install --no-shortcuts -r K:\python\ -n base -f "%~dp0\environments\finetuneanon.yml" -y --always-copy
|
||||||
umamba.exe -r K:\ clean -a -y
|
umamba.exe -r K:\ clean -a -y
|
||||||
|
rd K:\Python\pkgs /S /Q
|
||||||
subst K: /d
|
subst K: /d
|
||||||
pause
|
pause
|
||||||
exit
|
exit
|
||||||
|
|
||||||
:subfolder
|
:subfolder
|
||||||
echo 2 > loader.settings
|
echo 2 > loader.settings
|
||||||
|
SET TEMP=%~DP0MINICONDA3
|
||||||
|
SET TMP=%~DP0MINICONDA3
|
||||||
umamba.exe create -r miniconda3\ -n base
|
umamba.exe create -r miniconda3\ -n base
|
||||||
IF %B%==1 umamba.exe install --no-shortcuts -r miniconda3 -n base -f environments\huggingface.yml -y
|
IF %B%==1 umamba.exe install --no-shortcuts -r miniconda3 -n base -f environments\huggingface.yml -y --always-copy
|
||||||
IF %B%==2 umamba.exe install --no-shortcuts -r miniconda3 -n base -f environments\finetuneanon.yml -y
|
IF %B%==2 umamba.exe install --no-shortcuts -r miniconda3 -n base -f environments\finetuneanon.yml -y --always-copy
|
||||||
umamba.exe clean -a -y
|
umamba.exe clean -a -y
|
||||||
|
rd miniconda3\Python\pkgs /S /Q
|
||||||
pause
|
pause
|
||||||
exit
|
exit
|
||||||
|
9
play.bat
9
play.bat
@ -1,18 +1,23 @@
|
|||||||
@echo off
|
@echo off
|
||||||
%~d0
|
cd /D %~dp0
|
||||||
cd %~dp0
|
|
||||||
TITLE KoboldAI - Server
|
TITLE KoboldAI - Server
|
||||||
SET /P M=<loader.settings
|
SET /P M=<loader.settings
|
||||||
IF %M%==1 GOTO drivemap
|
IF %M%==1 GOTO drivemap
|
||||||
IF %M%==2 GOTO subfolder
|
IF %M%==2 GOTO subfolder
|
||||||
|
|
||||||
:subfolder
|
:subfolder
|
||||||
|
ECHO Runtime launching in subfolder mode
|
||||||
|
SET TEMP=%~DP0MINICONDA3
|
||||||
|
SET TMP=%~DP0MINICONDA3
|
||||||
call miniconda3\condabin\activate
|
call miniconda3\condabin\activate
|
||||||
python aiserver.py %*
|
python aiserver.py %*
|
||||||
cmd /k
|
cmd /k
|
||||||
|
|
||||||
:drivemap
|
:drivemap
|
||||||
|
ECHO Runtime launching in K: drive mode
|
||||||
subst K: miniconda3 >nul
|
subst K: miniconda3 >nul
|
||||||
|
SET TEMP=K:\
|
||||||
|
SET TMP=K:\
|
||||||
call K:\python\condabin\activate
|
call K:\python\condabin\activate
|
||||||
python aiserver.py %*
|
python aiserver.py %*
|
||||||
subst K: /D
|
subst K: /D
|
||||||
|
@ -7,11 +7,15 @@ IF %M%==1 GOTO drivemap
|
|||||||
IF %M%==2 GOTO subfolder
|
IF %M%==2 GOTO subfolder
|
||||||
|
|
||||||
:subfolder
|
:subfolder
|
||||||
|
SET TEMP=%~DP0MINICONDA3
|
||||||
|
SET TMP=%~DP0MINICONDA3
|
||||||
call miniconda3\condabin\activate
|
call miniconda3\condabin\activate
|
||||||
GOTO GIT
|
GOTO GIT
|
||||||
|
|
||||||
:drivemap
|
:drivemap
|
||||||
subst K: miniconda3 >nul
|
subst K: miniconda3 >nul
|
||||||
|
SET TEMP=K:\
|
||||||
|
SET TMP=K:\
|
||||||
call K:\python\condabin\activate
|
call K:\python\condabin\activate
|
||||||
GOTO GIT
|
GOTO GIT
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user