训练步骤参考:
问题1:创建embedding 失败
日志:
File "/opt/conda/lib/python3.8/site-packages/torch/nn/modules/sparse.py", line 160, in forward
return F.embedding(
File "/opt/conda/lib/python3.8/site-packages/torch/nn/functional.py", line 2206, in embedding
return torch.embedding(weight, input, padding_idx, scale_grad_by_freq, sparse)
RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cpu and cuda:0! (when checking argument for argument index in method wrapper__index_select)
解决方法:
https://github.com/AUTOMATIC1111/stable-diffusion-webui/issues/2208
去掉命令行中的--medvram
问题2:创建的embeddings 训练之前时候加载失败
失败日志
Error verifying pickled file
Error verifying pickled file from /root/stable-diffusion-webui/embeddings/handanyang.pt:
Traceback (most recent call last):
File "/root/stable-diffusion-webui/modules/safe.py", line 97, in load
check_pt(filename)
File "/root/stable-diffusion-webui/modules/safe.py", line 77, in check_pt
check_zip_filenames(filename, z.namelist())
File "/root/stable-diffusion-webui/modules/safe.py", line 69, in check_zip_filenames
raise Exception(f"bad file inside {filename}: {name}")
Exception: bad file inside /root/stable-diffusion-webui/embeddings/handanyang.pt: handanyang/data.pkl
解决方法:
命令行中加上--disable-safe-unpickle
https://github.com/AUTOMATIC1111/stable-diffusion-webui/issues/2235
问题3:刚开始训练时候,失败
失败日志
return forward_call(*input, **kwargs)
File "/root/stable-diffusion-webui/repositories/stable-diffusion/ldm/models/diffusion/ddpm.py", line 879, in forward
return self.p_losses(x, c, t, *args, **kwargs)
File "/root/stable-diffusion-webui/repositories/stable-diffusion/ldm/models/diffusion/ddpm.py", line 1030, in p_losses
logvar_t = self.logvar[t].to(self.device)
RuntimeError: indices should be either on cpu or on the same device as the indexed tensor (cpu)
解决方法:
将出问题的变量t,存到CPU里面
编辑代码stable-diffusion/ldm/models/diffusion/ddpm.py第1030行上面,加上一行代码 t = t.to('cpu')
https://github.com/AUTOMATIC1111/stable-diffusion-webui/issues/2685
问题4:
训练了4%的时候失败;
失败日志
_imagingft C module is not installed
font = ImageFont.truetype(textfont, fontsize)
File "/opt/conda/lib/python3.8/site-packages/PIL/ImageFont.py", line 844, in truetype
return freetype(font)
File "/opt/conda/lib/python3.8/site-packages/PIL/ImageFont.py", line 841, in freetype
return FreeTypeFont(font, size, index, encoding, layout_engine)
File "/opt/conda/lib/python3.8/site-packages/PIL/ImageFont.py", line 169, in __init__
if core.HAVE_RAQM:
File "/opt/conda/lib/python3.8/site-packages/PIL/ImageFont.py", line 43, in __getattr__
raise ImportError("The _imagingft C module is not installed")
ImportError: The _imagingft C module is not installed
解决方法:
重新安装pillow
apt-get install libfreetype6-dev
====================
pip uninstall pillow
pip install --no-cache-dir pillow
https://stackoverflow.com/questions/4011705/python-the-imagingft-c-module-is-not-installed
这样就可以开始训练了;