sparkleman commited on
Commit ·
aeaf225
1
Parent(s): 89db2d9
UPDATE: Change gpu state display
Browse files123423 unmodified lines28293031323322 unmodified lines565758596061629 unmodified lines72737475767731 unmodified lines109110111112113114528 unmodified lines643644645646647648649650651652653from config import CONFIG, ModelConfigimport os, copy, types, gc, sys, re, time, collections, asynciofrom huggingface_hub import hf_hub_download23 unmodified linesnvmlInit()gpu_h = nvmlDeviceGetHandleByIndex(0)torch.backends.cudnn.benchmark = Truetorch.backends.cudnn.allow_tf32 = Truetorch.backends.cuda.matmul.allow_tf32 = True22 unmodified linesChatCompletionChoice,ChatCompletionMessage,)from utils import cleanMessages, parse_think_response, remove_nested_think_tags_stackclass ModelStorage:9 unmodified lineslogger.info(f"STRATEGY - {CONFIG.STRATEGY}")for model_config in CONFIG.MODELS:logger.info(f"Load Model - {model_config.SERVICE_NAME}")31 unmodified linesMODEL_STORAGE[model_config.SERVICE_NAME].MODEL_CONFIG = model_configMODEL_STORAGE[model_config.SERVICE_NAME].model = tmp_modelMODEL_STORAGE[model_config.SERVICE_NAME].pipeline = tmp_pipelinelogger.info(f"Load Model - DEFALUT_MODEL_NAME is `{DEFALUT_MODEL_NAME}`")528 unmodified linesraise f"Can not find `{modelName}`"async def chatResponseStreamDisconnect():if "cuda" in CONFIG.STRATEGY:gpu_info = nvmlDeviceGetMemoryInfo(gpu_h)logger.info(f"[STATUS] vram {gpu_info.total} used {gpu_info.used} free {gpu_info.free}")model_state = Nonerequest_dict = request.model_dump()1234567891023 unmodified lines34353637383940414243444546474822 unmodified lines7172737475769 unmodified lines868788899091929331 unmodified lines125126127128129130131528 unmodified lines660661662663664665666from config import CONFIG, ModelConfigfrom utils import (cleanMessages,parse_think_response,remove_nested_think_tags_stack,format_bytes,)import os, copy, types, gc, sys, re, time, collections, asynciofrom huggingface_hub import hf_hub_download23 unmodified linesnvmlInit()gpu_h = nvmlDeviceGetHandleByIndex(0)def logGPUState():if "cuda" in CONFIG.STRATEGY:gpu_info = nvmlDeviceGetMemoryInfo(gpu_h)logger.info(f"[STATUS] vram {format_bytes(gpu_info.total)} used {format_bytes(gpu_info.used)} free {format_bytes(gpu_info.free)}")torch.backends.cudnn.benchmark = Truetorch.backends.cudnn.allow_tf32 = Truetorch.backends.cuda.matmul.allow_tf32 = True22 unmodified linesChatCompletionChoice,ChatCompletionMessage,)class ModelStorage:9 unmodified lineslogger.info(f"STRATEGY - {CONFIG.STRATEGY}")logGPUState()for model_config in CONFIG.MODELS:logger.info(f"Load Model - {model_config.SERVICE_NAME}")31 unmodified linesMODEL_STORAGE[model_config.SERVICE_NAME].MODEL_CONFIG = model_configMODEL_STORAGE[model_config.SERVICE_NAME].model = tmp_modelMODEL_STORAGE[model_config.SERVICE_NAME].pipeline = tmp_pipelinelogGPUState()logger.info(f"Load Model - DEFALUT_MODEL_NAME is `{DEFALUT_MODEL_NAME}`")528 unmodified linesraise f"Can not find `{modelName}`"async def chatResponseStreamDisconnect():logGPUState()model_state = Nonerequest_dict = request.model_dump()
57 unmodified lines58596057 unmodified lineselse:i += 1return result57 unmodified lines5859606162636465666768697057 unmodified lineselse:i += 1return resultdef format_bytes(size):power = 2**10n = 0power_labels = {0: "", 1: "K", 2: "M", 3: "G", 4: "T"}while size > power:size /= powern += 1return f"{size:.4f}{power_labels[n]+'B'}"
app.py+19-6
utils.py+10