训练 embeddings 数据集时,出现 CUDA out of memory 错误提示
torch.cuda.OutOfMemoryError: CUDA out of memory. Tried to allocate 512.00 MiB (GPU 0; 4.00 GiB total capacity; 2.45 GiB
already allocated; 0 bytes free; 3.12 GiB reserved in total by PyTorch) If reserved memory is >> allocated memory try se
tting max_split_size_mb to avoid fragmentation. See documentation for Memory Management and PYTORCH_CUDA_ALLOC_CONF
搜索和尝试
https://blog.csdn.net/MirageTanker/arti ... /127998036
https://blog.csdn.net/PromiseTo/article ... /127240779
Stable Diffusion 本地部署教程
https://stackoverflow.com/questions/591 ... in-pytorch
E:\Temp\stable-diffusion-webui\repositories\stable-diffusion-stability-ai\scripts\txt2img.py
代码: 全选
parser.add_argument(
"--n_samples",
type=int,
default=3,
help="how many samples to produce for each given prompt. A.k.a batch size",
)
将其中3改为1
2.
代码: 全选
config = OmegaConf.load(f"{opt.config}")
device = torch.device("cuda") if opt.device == "cuda" else torch.device("cpu")
model = load_model_from_config(config, f"{opt.ckpt}", device)
改为
代码: 全选
config = OmegaConf.load(f"{opt.config}")
device = torch.device("cuda") if opt.device == "cuda" else torch.device("cpu")
model = load_model_from_config(config, f"{opt.ckpt}", device).half()
最后,只出图还是没问题的。
但是如果要自己训练数据集,4G显存就不够用了.