Open zhongxiaoyu opened 1 year ago
(bk-sdm) :~/pnnx/build/install/bin$ ./pnnx ~/diffusers-ncnn/model/unet-fp16.pt inputshape=[1,4,32,32],[1],[1,77,768] pnnxparam = ~/diffusers_ncnn/model/unet_fp16.pnnx.param pnnxbin = /diffusers_ncnn/model/unet_fp16.pnnx.bin pnnxpy =/diffusers_ncnn/model/unet_fp16_pnnx.py pnnxonnx = /diffusers_ncnn/model/unet_fp16.pnnx.onnx ncnnparam =/diffusers_ncnn/model/unet_fp16.ncnn.param ncnnbin = ~/diffusers_ncnn/model/unet_fp16.ncnn.bin ncnnpy = ~/diffusers_ncnn/model/unet_fp16_ncnn.py fp16 = 1 optlevel = 2 device = cpu inputshape = [1,4,32,32]f32,[1]f32,[1,77,768]f32 inputshape2 = customop = moduleop = ############# pass_level0 inline module = diffusers.models.attention.BasicTransformerBlock inline module = diffusers.models.attention.FeedForward inline module = diffusers.models.attention.GEGLU inline module = diffusers.models.attention_processor.Attention inline module = diffusers.models.embeddings.TimestepEmbedding inline module = diffusers.models.embeddings.Timesteps inline module = diffusers.models.resnet.Downsample2D inline module = diffusers.models.resnet.ResnetBlock2D inline module = diffusers.models.resnet.Upsample2D inline module = diffusers.models.transformer_2d.Transformer2DModel inline module = diffusers.models.unet_2d_blocks.CrossAttnDownBlock2D inline module = diffusers.models.unet_2d_blocks.CrossAttnUpBlock2D open failed inline module = diffusers.models.attention.BasicTransformerBlock inline module = diffusers.models.attention.FeedForward inline module = diffusers.models.attention.GEGLU inline module = diffusers.models.attention_processor.Attention inline module = diffusers.models.embeddings.TimestepEmbedding inline module = diffusers.models.embeddings.Timesteps inline module = diffusers.models.resnet.Downsample2D inline module = diffusers.models.resnet.ResnetBlock2D inline module = diffusers.models.resnet.Upsample2D inline module = diffusers.models.transformer_2d.Transformer2DModel inline module = diffusers.models.unet_2d_blocks.CrossAttnDownBlock2D inline module = diffusers.models.unet_2d_blocks.CrossAttnUpBlock2D
Segmentation fault (core dumped)
1.convert to .pt model import os import torch from diffusers import StableDiffusionPipeline
device = "cuda" from_model = "nota-ai/bk-sdm-tiny-2m" to_model = "model" height, width = 512, 512
assert height % 8 == 0 and width % 8 == 0 height, width = height // 8, width // 8 os.makedirs(to_model, exist_ok=True)
pipe = StableDiffusionPipeline.from_pretrained(from_model, torch_dtype=torch.float16) pipe = pipe.to(device)
unet = torch.jit.trace(pipe.unet, (torch.tensor(torch.rand(1,4,height,width).to(device), dtype=torch.float16),torch.tensor(torch.rand(1).to(device), dtype=torch.float16),torch.tensor(torch.rand(1,77,768).to(device), dtype=torch.float16)),strict=False) unet.save(os.path.join(to_model,"unet-fp16.pt"))
2.convert to ncnn ./pnnx ~/model/unet-fp16.pt inputshape=[1,4,32,32],[1],[1,77,768]
为什么会出现open failed,最后直接Segmentation fault (core dumped)了
找到原因了吗 @zhongxiaoyu
error log | 日志或报错信息 | ログ
(bk-sdm) :~/pnnx/build/install/bin$ ./pnnx ~/diffusers-ncnn/model/unet-fp16.pt inputshape=[1,4,32,32],[1],[1,77,768] pnnxparam = ~/diffusers_ncnn/model/unet_fp16.pnnx.param pnnxbin = /diffusers_ncnn/model/unet_fp16.pnnx.bin pnnxpy =/diffusers_ncnn/model/unet_fp16_pnnx.py pnnxonnx = /diffusers_ncnn/model/unet_fp16.pnnx.onnx ncnnparam =/diffusers_ncnn/model/unet_fp16.ncnn.param ncnnbin = ~/diffusers_ncnn/model/unet_fp16.ncnn.bin ncnnpy = ~/diffusers_ncnn/model/unet_fp16_ncnn.py fp16 = 1 optlevel = 2 device = cpu inputshape = [1,4,32,32]f32,[1]f32,[1,77,768]f32 inputshape2 = customop = moduleop = ############# pass_level0 inline module = diffusers.models.attention.BasicTransformerBlock inline module = diffusers.models.attention.FeedForward inline module = diffusers.models.attention.GEGLU inline module = diffusers.models.attention_processor.Attention inline module = diffusers.models.embeddings.TimestepEmbedding inline module = diffusers.models.embeddings.Timesteps inline module = diffusers.models.resnet.Downsample2D inline module = diffusers.models.resnet.ResnetBlock2D inline module = diffusers.models.resnet.Upsample2D inline module = diffusers.models.transformer_2d.Transformer2DModel inline module = diffusers.models.unet_2d_blocks.CrossAttnDownBlock2D inline module = diffusers.models.unet_2d_blocks.CrossAttnUpBlock2D open failed inline module = diffusers.models.attention.BasicTransformerBlock inline module = diffusers.models.attention.FeedForward inline module = diffusers.models.attention.GEGLU inline module = diffusers.models.attention_processor.Attention inline module = diffusers.models.embeddings.TimestepEmbedding inline module = diffusers.models.embeddings.Timesteps inline module = diffusers.models.resnet.Downsample2D inline module = diffusers.models.resnet.ResnetBlock2D inline module = diffusers.models.resnet.Upsample2D inline module = diffusers.models.transformer_2d.Transformer2DModel inline module = diffusers.models.unet_2d_blocks.CrossAttnDownBlock2D inline module = diffusers.models.unet_2d_blocks.CrossAttnUpBlock2D
Segmentation fault (core dumped)
model | 模型 | モデル
how to reproduce | 复现步骤 | 再現方法
1.convert to .pt model import os import torch from diffusers import StableDiffusionPipeline
config
device = "cuda" from_model = "nota-ai/bk-sdm-tiny-2m" to_model = "model" height, width = 512, 512
check
assert height % 8 == 0 and width % 8 == 0 height, width = height // 8, width // 8 os.makedirs(to_model, exist_ok=True)
load model
pipe = StableDiffusionPipeline.from_pretrained(from_model, torch_dtype=torch.float16) pipe = pipe.to(device)
jit unet
unet = torch.jit.trace(pipe.unet, (torch.tensor(torch.rand(1,4,height,width).to(device), dtype=torch.float16),torch.tensor(torch.rand(1).to(device), dtype=torch.float16),torch.tensor(torch.rand(1,77,768).to(device), dtype=torch.float16)),strict=False) unet.save(os.path.join(to_model,"unet-fp16.pt"))
2.convert to ncnn ./pnnx ~/model/unet-fp16.pt inputshape=[1,4,32,32],[1],[1,77,768]