|
|
|
@ -85,7 +85,7 @@ def get_images(ws, server_address, client_id, prompt):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 获取显卡使用率
|
|
|
|
|
def getUse(server_address):
|
|
|
|
|
def get_comfyui_used(server_address):
|
|
|
|
|
req = urllib.request.Request("http://{}/system_stats".format(server_address))
|
|
|
|
|
res = json.loads(urllib.request.urlopen(req).read())
|
|
|
|
|
|
|
|
|
@ -101,9 +101,9 @@ def getUse(server_address):
|
|
|
|
|
# 参考文档:如何清空Comfyui的gpu缓存
|
|
|
|
|
# https://wailikeji.blog.csdn.net/article/details/140035515
|
|
|
|
|
# 清理GPU显存
|
|
|
|
|
def clear_cache(server_address):
|
|
|
|
|
def clear_comfyui_cache(server_address):
|
|
|
|
|
# 显示显卡使用率
|
|
|
|
|
print('清理显存前:' + getUse(server_address))
|
|
|
|
|
print('清理显存前:' + get_comfyui_used(server_address))
|
|
|
|
|
# 打开文件并读取内容
|
|
|
|
|
file_path = r'../JSON/clearGPU.json'
|
|
|
|
|
if not os.path.exists(file_path):
|
|
|
|
@ -115,7 +115,7 @@ def clear_cache(server_address):
|
|
|
|
|
|
|
|
|
|
# 显示显卡使用率
|
|
|
|
|
time.sleep(2)
|
|
|
|
|
print('清理显存后:' + getUse(server_address))
|
|
|
|
|
print('清理显存后:' + get_comfyui_used(server_address))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 生成图像
|
|
|
|
@ -140,7 +140,7 @@ def generate_clip(server_address, prompt_data, client_id, output_path, myfilter)
|
|
|
|
|
binary_file.write(image_data)
|
|
|
|
|
ws.close()
|
|
|
|
|
# 清理GPU缓存
|
|
|
|
|
clear_cache(server_address)
|
|
|
|
|
clear_comfyui_cache(server_address)
|
|
|
|
|
return files
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|