包含: - hair_service_sd: 换发型/换发色算法服务 (端口 8801) - photo_service: LoRA 训练调度服务 (端口 32678) - stable-diffusion-webui: SD WebUI 推理服务 (端口 57860) - kohya_ss_home: 训练环境代码 - meidaojia: 监控测试脚本 - setup.sh: 一键部署脚本 (conda环境恢复 + 配置生成 + 完整性检查) - start_all_services.sh: 启动3个服务 - configure.ini.template: 路径模板化 (BASE_DIR自动推导) - conda_envs/py310.yml: py310 环境定义 大文件 (weights/, models/, data/, conda_envs/*.tar.gz 等) 通过 .gitignore 排除, 由网盘单独上传。
47 lines
1.3 KiB
Python
Executable File
47 lines
1.3 KiB
Python
Executable File
import torch
|
|
|
|
from modules import shared, ui_gradio_extensions
|
|
|
|
|
|
class Profiler:
|
|
def __init__(self):
|
|
if not shared.opts.profiling_enable:
|
|
self.profiler = None
|
|
return
|
|
|
|
activities = []
|
|
if "CPU" in shared.opts.profiling_activities:
|
|
activities.append(torch.profiler.ProfilerActivity.CPU)
|
|
if "CUDA" in shared.opts.profiling_activities:
|
|
activities.append(torch.profiler.ProfilerActivity.CUDA)
|
|
|
|
if not activities:
|
|
self.profiler = None
|
|
return
|
|
|
|
self.profiler = torch.profiler.profile(
|
|
activities=activities,
|
|
record_shapes=shared.opts.profiling_record_shapes,
|
|
profile_memory=shared.opts.profiling_profile_memory,
|
|
with_stack=shared.opts.profiling_with_stack
|
|
)
|
|
|
|
def __enter__(self):
|
|
if self.profiler:
|
|
self.profiler.__enter__()
|
|
|
|
return self
|
|
|
|
def __exit__(self, exc_type, exc, exc_tb):
|
|
if self.profiler:
|
|
shared.state.textinfo = "Finishing profile..."
|
|
|
|
self.profiler.__exit__(exc_type, exc, exc_tb)
|
|
|
|
self.profiler.export_chrome_trace(shared.opts.profiling_filename)
|
|
|
|
|
|
def webpath():
|
|
return ui_gradio_extensions.webpath(shared.opts.profiling_filename)
|
|
|