diff --git a/BaiHu/Doc/Stable Diffusion占用运存太多怎么办 内存占用多解决方法.txt b/BaiHu/Doc/Stable Diffusion占用运存太多怎么办 内存占用多解决方法.txt new file mode 100644 index 00000000..2c29797c --- /dev/null +++ b/BaiHu/Doc/Stable Diffusion占用运存太多怎么办 内存占用多解决方法.txt @@ -0,0 +1 @@ +https://www.chinaz.com/2023/0519/1525978.shtml diff --git a/BaiHu/Temp/495ac512-b0c3-f7fb-e31a-1a99e7761451.png b/BaiHu/Temp/495ac512-b0c3-f7fb-e31a-1a99e7761451.png new file mode 100644 index 00000000..a537abe2 Binary files /dev/null and b/BaiHu/Temp/495ac512-b0c3-f7fb-e31a-1a99e7761451.png differ diff --git a/BaiHu/Test/TestGPU.py b/BaiHu/Test/TestGPU.py new file mode 100644 index 00000000..8a4d546e --- /dev/null +++ b/BaiHu/Test/TestGPU.py @@ -0,0 +1,33 @@ +# pip install pynvml +from pynvml import * +import torch +import gc + + +# 显示GPU显存使用情况 +def getVRam(): + # 初始化 + nvmlInit() + # GPU 0 ,一般都只有一张显卡 + h = nvmlDeviceGetHandleByIndex(0) + info = nvmlDeviceGetMemoryInfo(h) + print(f'total: {round(info.total / 1024 / 1024 / 1024, 1)} GB') + print(f'free : {round(info.free / 1024 / 1024 / 1024, 1)} GB') + print(f'used : {round(info.used / 1024 / 1024 / 1024, 1)} GB') + nvmlShutdown() + + +# 输出一下显存的占用 +getVRam() + +# 如果输出的结果是False,那么说明当前的Pytorch版本无法使用显卡。 +if torch.cuda.is_available(): + # GPU可用,启动显存清理 + gc.collect() + torch.cuda.empty_cache() + torch.cuda.ipc_collect() + gc.collect() + # 再显示一下显存的占用 + getVRam() +else: + print("当前机器不支持显卡清理!") diff --git a/BaiHu/doTask.py b/BaiHu/doTask.py index e670d7c8..8ab3183c 100644 --- a/BaiHu/doTask.py +++ b/BaiHu/doTask.py @@ -218,8 +218,7 @@ def get_task(): vjson_data = json.load(file) # 利用三元表达式输出 - printf("发现需要处理的" + ("WebUI" if model_type_id in [1, - 2] else "ComfyUI") + "任务,model_type_id=" + str( + printf("发现需要处理的" + ("WebUI" if model_type_id in [1, 2] else "ComfyUI") + "任务,model_type_id=" + str( model_type_id) + ",model_id=" + str( model_id) + ",prompt_id=" + str(prompt_id) + ",task_id=" + str(task_id))