Overseas access: www.kdjingpai.com
Bookmark Us
Current Position:fig. beginning " AI Answers

怎样优化InstantCharacter的显存占用以在24GB GPU上运行?

2025-08-24 1.1 K

降低显存占用的实践方法

针对中端显卡用户,可通过以下组合策略实现流畅运行:

  • 使用梯度检查点:在代码中设置pipe.enable_xformers_memory_efficient_attention()激活内存优化
  • Quantitative loading:修改模型加载语句为pipe = InstantCharacterFluxPipeline.from_pretrained(base_model, torch_dtype=torch.float16)
  • 分块渲染:将1024px图像拆分为两个512px区域分别生成后拼接
  • 限制并发: Setting Environment VariablesPYTORCH_CUDA_ALLOC_CONF=max_split_size_mb:128

进阶优化方案:

  • 使用–medvram参数启动Gradio界面
  • 替换VAE为tiny版:pipe.vae = AutoencoderTiny.from_pretrained("madebyollin/taesd")
  • 降低CLIP切词长度:修改nb_token=768(原1024)

Recommended

Can't find AI tools? Try here!

Just type in the keyword Accessibility Bing SearchYou can quickly find all the AI tools on this site.

Top

en_USEnglish