main
黄海 1 year ago
parent eb2d6dde36
commit 04076f9a25

@ -120,7 +120,7 @@ def get_comfyui_used(server_address):
# 清理GPU显存
def clear_comfyui_cache(server_address):
# 显示显卡使用率
print('清理显存前:' + get_comfyui_used(server_address))
#print('清理显存前:' + get_comfyui_used(server_address))
# 打开文件并读取内容
file_path = r'../JSON/clearGPU.json'
if not os.path.exists(file_path):
@ -131,8 +131,8 @@ def clear_comfyui_cache(server_address):
queue_prompt(server_address, "cleanGpuRam", prompt_data)
# 显示显卡使用率
time.sleep(2)
print('清理显存后:' + get_comfyui_used(server_address))
#time.sleep(2)
#print('清理显存后:' + get_comfyui_used(server_address))
# 生成图像
@ -190,12 +190,8 @@ def get_webui_used(webui_server):
if res.status_code == 200:
jo = json.loads(res.text)
total = jo[0].replace('total', '').replace(' ', '').replace(':', '').replace('GB', '')
# free = jo[1].replace('free', '').replace(' ', '').replace(':', '').replace('GB', '')
used = jo[2].replace('used', '').replace(' ', '').replace(':', '').replace('GB', '')
used_lv = round(1.0 * (float(used)) / float(total) * 100, 2)
# print("显存:" + total + "GB,已使用:" + used + "GB,使用率:" + str(used_lv) + '%')
else:
# print("调用集成的获取显卡显存代码失败!")
pass
return total, used
@ -208,7 +204,8 @@ def clear_webui_cache(webui_address):
if res.status_code == 200:
jo = json.loads(res.text)
if jo['success']:
print("显存清理成功!")
#print("显存清理成功!")
pass
else:
print("显存清理失败!")
else:

Loading…
Cancel
Save