iotdb icon indicating copy to clipboard operation
iotdb copied to clipboard

AINODE 模型部署

Open YWzzq opened this issue 1 year ago • 1 comments

ainode部署模型需要model.pt与config.yaml文件, 1.model.pt文件就是直接torch.save()生成的吗? 2.我使用了dlnear生成了model.pt文件来测试是否生成正确model.pt,报错: IoTDB> call inference(dlinear_example, "select s0,s1,s2,s3,s4,s5,s6 from root.eg.etth", window=head(96)) Msg: org.apache.iotdb.jdbc.IoTDBSQLException: 301: Error occurred while executing inference:[PytorchStreamReader failed locating file constants.pkl: file not found]

YWzzq avatar Oct 12 '24 06:10 YWzzq

是否满足一下几点呢

AINode 支持的PyTorch 2.1.0、 2.2.0版本训练的模型,需避免使用2.2.0版本以上的特性。 AINode支持使用PyTorch JIT存储的模型,模型文件需要包含模型的参数和结构。 模型输入序列可以包含一列或多列,若有多列,需要和模型能力、模型配置文件对应。 模型的输入输出维度必须在config.yaml配置文件中明确定义。使用模型时,必须严格按照config.yaml配置文件中定义的输入输出维度。如果输入输出列数不匹配配置文件,将会导致错误。

CritasWang avatar Oct 12 '24 07:10 CritasWang

这个报错是模型保存方式不对,可以参考下面的保存方式

        sample_input = (
            _pack_input_dict(
                torch.randn(1, model_config[OptionsKey.INPUT_LENGTH.name()], model_config[OptionsKey.INPUT_VARS.name()])
            )
        )
        torch.jit.save(torch.jit.trace(model, sample_input),
                       model_file_path,
                       _extra_files={'model_config': json.dumps(model_config)})

ycycse avatar Nov 27 '24 09:11 ycycse