Open qinhuangdaoStation opened 1 month ago
有两个方向可以排查下 1)静态图模型参数是否完整,如果不完整可能会出现上面的问题 2)静态图的模型的导出来自哪个版本的paddlepaddle,最好导出的静态图模型和推理静态图的paddlepaddle是一个版本
有两个方向可以排查下 1)静态图模型参数是否完整,如果不完整可能会出现上面的问题 2)静态图的模型的导出来自哪个版本的paddlepaddle,最好导出的静态图模型和推理静态图的paddlepaddle是一个版本
感谢,确实是版本不一致的问题
有两个方向可以排查下 1)静态图模型参数是否完整,如果不完整可能会出现上面的问题 2)静态图的模型的导出来自哪个版本的paddlepaddle,最好导出的静态图模型和推理静态图的paddlepaddle是一个版本
感谢,确实是版本不一致的问题
但是,又遇到一个新的问题。同样的模型,加载之后,相比于训练之前的base模型,训练之后的模型,在outpu_handle的时候,少了一个tensor,从base模型的2个tensor减少到了只有1个tensor,这个感觉很不理解。不知道能不能给一些建议,谢谢。
self.predictor = paddle.inference.create_predictor(_config) self.input_names = [name for name in self.predictor.get_input_names()] self.input_handles = [self.predictor.get_input_handle(name) for name in self.predictor.get_input_names()] self.output_handle = [self.predictor.get_output_handle(name) for name in self.predictor.get_output_names()]
软件环境
重复问题
错误描述
稳定复现步骤 & 代码
模型导出代码:
input_spec = [ InputSpec(shape=[None, None], dtype="int64", name="input_ids"), InputSpec(shape=[None, None], dtype="int64", name="token_type_ids"), InputSpec(shape=[None, None], dtype="int64", name="position_ids"), InputSpec(shape=[None, None, None, None], dtype="float32", name="attention_mask"), InputSpec(shape=[None, None], dtype="int64", name="omask_positions"), InputSpec(shape=[None], dtype="int64", name="cls_positions"), ] export_model(trainer.pretrained_model, input_spec, model_args.export_model_dir, model_args.export_type)
export_model代码: `def export_model( model: "PretrainedModel", input_spec=None, path: Optional[str] = None, model_format: Optional[str] = "paddle" ) -> Tuple[List[str], List[str]]: """ Export paddle inference model or onnx model.
`
模型加载代码: ` _static_model_file = os.path.join(model_dir, "inference.pdmodel") _static_params_file = os.path.join(model_dir, "inference.pdiparams") _config = paddle.inference.Config(_static_model_file, _static_params_file)
使用gpu
_config.enable_use_gpu(100, 0) _config.delete_pass("embedding_eltwise_layernorm_fuse_pass") _config.delete_pass("fused_multi_transformer_encoder_pass")
_config.set_cpu_math_library_num_threads(self._num_threads) _config.switch_use_feed_fetch_ops(False) _config.disable_glog_info() _config.enable_memory_optim() _config.switch_ir_optim(False)
self.predictor = paddle.inference.create_predictor(_config) `