PaddleSlim icon indicating copy to clipboard operation
PaddleSlim copied to clipboard

PaddleSlim静态离线量化模型大小不变,推理速度下降

Open zhouyuxixixi opened this issue 6 years ago • 2 comments

请问一个问题,为什么我使用paddleslim进行模型(模型使用resnet18_vd)的静态离线量化quntpost,模型大小一点都没改变,这是正常现象?而且我试了推理速度,量化后的还变慢了、

对训练的模型进行静态离线量化

不能使用CPU进行离线量化,否则内存溢出被kill

!cd /home/aistudio/work/PaddleSlim-release-1.1.1/demo/quant/quant_post
&& python quant_post.py --model_path /home/aistudio/work/PaddleClas-master/inference/ResNet18_vd
--save_path /home/aistudio/work/PaddleSlim-release-1.1.1/model/post_quant_model/ResNet18_vd
--model_filename model
--params_filename params
# --image_shape "3, 224, 224"
--batch_size 32
--batch_num 10
# --activation_quantize_type "range_abs_max"
# --train_list_name "eval.txt"
# --data_dir "/home/aistudio/work/dataset/PCB_DATASET"
--use_gpu true

----------- Configuration Arguments ----------- batch_num: 10 batch_size: 16 model_filename: model model_path: /home/aistudio/work/PaddleClas-master/inference/ResNet18_vd params_filename: params save_path: /home/aistudio/work/PaddleSlim-release-1.1.1/model/post_quant_model/ResNet18_vd use_gpu: True

2020-11-18 09:49:35,362-INFO: Load model and set data loader ... W1118 09:49:35.380448 1168 device_context.cc:252] Please NOTE: device: 0, CUDA Capability: 70, Driver API Version: 11.0, Runtime API Version: 9.0 W1118 09:49:35.385556 1168 device_context.cc:260] device: 0, cuDNN Version: 7.6. 2020-11-18 09:49:37,717-INFO: Collect quantized variable names ... 2020-11-18 09:49:41,997-INFO: Run batch: 0 2020-11-18 09:49:56,495-INFO: Run batch: 5 2020-11-18 09:50:04,377-INFO: Finish all batch: 10 2020-11-18 09:50:04,378-INFO: Calculate KL threshold ... 2020-11-18 09:51:04,922-INFO: Update the program ...

zhouyuxixixi avatar Nov 18 '20 02:11 zhouyuxixixi

您好,这两个问题与Paddle量化的特点有关,即量化后保存的是一个以float32格式保存的,但数值范围在int8的模型,所以会有体积不下降,速度没提高的效果。 实际发挥量化的效果需要用到预测引擎(PaddleLite, Paddle-TensorRT等),可以关注下https://github.com/PaddlePaddle/PaddleSlim/tree/develop/demo/quant/deploy/TensorRT , 和PaddleLite REPO的教程

baiyfbupt avatar Dec 07 '20 09:12 baiyfbupt

您好, 我想问一下, 我用paddleslim静态离线量化模型, 碰到这个问题: Exception: 'feed_targets' does not have inputs variable。 请问有朋友知道这是什么原因引起的吗?

Dora1483 avatar Apr 20 '22 16:04 Dora1483