You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
https://github.com/AUTOMATIC1111/stable-diffusion-webui/blob/master/modules/api/api.py
#秋叶整合包如何安装Python包
https://www.cnblogs.com/bossma/p/17593474.html
# 升级 pip
打开 D:\sd-webui-aki-v4.7\python\Scripts 然后在地址栏中输入cmd回车:
python -m pip install --upgrade pip
# 安装包
pip install pynvml
# 修改的文件
D:\sd-webui-aki-v4.7\modules\api\api.py
# 添加的内容一
from pynvml import *
import torch
import gc
# 添加的内容二
self.add_api_route("/sdapi/v1/empty_cache", self.empty_cache, methods=["POST"])
self.add_api_route("/sdapi/v1/get_vram", self.get_vram, methods=["POST"])
# 添加的
def empty_cache(self):
if torch.cuda.is_available():
gc.collect()
torch.cuda.empty_cache()
torch.cuda.ipc_collect()
gc.collect()
return {"success":True,"message":"GPU is cleared!"}
def getVRam(self):
nvmlInit()
h = nvmlDeviceGetHandleByIndex(0)
info = nvmlDeviceGetMemoryInfo(h)
res=[]
res.append(f'total: {round(info.total / 1024 / 1024 / 1024, 1)} GB')
res.append(f'free : {round(info.free / 1024 / 1024 / 1024, 1)} GB')
res.append(f'used : {round(info.used / 1024 / 1024 / 1024, 1)} GB')
nvmlShutdown()
return res