ssube / onnx-web

web UI for GPU-accelerated ONNX pipelines like Stable Diffusion, even on Windows and AMD
https://discord.gg/7CdQmutGuw
MIT License
202 stars 26 forks source link

show a progress bar while exporting models #171

Closed ssube closed 10 months ago

ssube commented 1 year ago

While exporting a large model, it's not always obvious that anything is happening, and can look like the launch script is hanging. I'd like to add progress bars, if possible, but that's turning out to be tricky:

/home/ssube/onnx-web/api/onnx_env/lib/python3.10/site-packages/transformers/models/clip/feature_extraction_clip.py:28: FutureWarning: The class CLIPFeatureExtractor is deprecated and will be removed in version 5 of Transformers. Please use CLIPImageProcessor instead.                                                                                               warnings.warn(                                                                                                                                                                    ONNX file: 0it [00:00, ?it/s]/home/ssube/onnx-web/api/onnx_env/lib/python3.10/site-packages/transformers/models/clip/modeling_clip.py:759: TracerWarning: torch.tensor results are registered as constants in the trace. You can safely ignore this warning if you use this function to create tensors out of constant variables that would be the same every time you call this function. In any other case, this might cause the trace to be incorrect.                                                                                                     mask.fill_(torch.tensor(torch.finfo(dtype).min))                                                                                                                                  /home/ssube/onnx-web/api/onnx_env/lib/python3.10/site-packages/torch/onnx/symbolic_opset9.py:5408: UserWarning: Exporting aten::index operator of advanced indexing in opset 14 is achieved by combination of multiple ONNX operators, including Reshape, Transpose, Concat, and Gather. If indices include negative values, the exported graph will produce incorrect results.                                                                                                                                                                               warnings.warn(                                                                                                                                                                    ONNX file: 470MB [00:03, 137MB/s]                                                                                                                                                   
[2023-02-18 03:49:30,327] DEBUG: onnx_web.convert.diffusion_stable: UNET config: FrozenDict([('sample_size', 64), ('in_channels', 4), ('out_channels', 4), ('center_input_sample', F
alse), ('flip_sin_to_cos', True), ('freq_shift', 0), ('down_block_types', ['CrossAttnDownBlock2D', 'CrossAttnDownBlock2D', 'CrossAttnDownBlock2D', 'DownBlock2D']), ('mid_block_type
', 'UNetMidBlock2DCrossAttn'), ('up_block_types', ['UpBlock2D', 'CrossAttnUpBlock2D', 'CrossAttnUpBlock2D', 'CrossAttnUpBlock2D']), ('only_cross_attention', False), ('block_out_cha
nnels', [320, 640, 1280, 1280]), ('layers_per_block', 2), ('downsample_padding', 1), ('mid_block_scale_factor', 1), ('act_fn', 'silu'), ('norm_num_groups', 32), ('norm_eps', 1e-05)
, ('cross_attention_dim', 768), ('attention_head_dim', 8), ('dual_cross_attention', False), ('use_linear_projection', False), ('class_embed_type', None), ('num_class_embeds', None)
, ('upcast_attention', False), ('resnet_time_scale_shift', 'default'), ('_class_name', 'UNet2DConditionModel'), ('_diffusers_version', '0.6.0'), ('_name_or_path', '/home/ssube/.cac
he/huggingface/diffusers/models--runwayml--stable-diffusion-v1-5/snapshots/39593d5650112b4cc580433f6b0435385882d819/unet')])                                                        
ONNX file: 0.00B [00:25, ?B/s]                                                                                                                                                      
[2023-02-18 03:49:56,019] ERROR: __main__: error converting diffusion model stable-diffusion-onnx-v1-5: The serialized model is larger than the 2GiB limit imposed by the protobuf l
ibrary. Therefore the output file must be a file path, so that the ONNX external data can be written to the same directory. Please specify the output file name.                    
[2023-02-18 03:49:56,043] DEBUG: __main__: model already exists, skipping fetch

This works for some smaller models but there is a size limit, which is hard to predict, because the model hasn't been serialized yet when tqdm.wrapattr is called.

ssube commented 10 months ago

Progress information is shown during the optimum exporter, although it's not a progress bar exactly.