• 文件 >
  • 如何在 TorchServe 中載入模型
快捷方式

⚠️ 注意:維護有限

本專案不再積極維護。現有版本仍然可用,但沒有計劃中的更新、錯誤修復、新功能或安全補丁。使用者應注意,潛在的安全漏洞可能不會得到處理。

如何在 TorchServe 中載入模型

在 TorchServe 中載入模型有多種方法。下面的流程圖試圖簡化這個過程並展示各種選項。

flowchart TD
    id1[[How to load a model in TorchServe?]] --> id13{Handler has an initialize method?}
    id13{Handler has an initialize method?} -- No, using BaseHandler initialize method --> id2{Model Type?} --> id3(PyTorch Eager)  & id4(TorchScripted) & id5(ONNX) & id6(TensorRT)
    id3(PyTorch Eager) --Required--> id7(Model File & weights file)
    id4(TorchScripted) --Required--> id8(TorchScripted weights ending in '.pt')
    id5(ONNX) --Required --> id9(Weights ending in '.onnx')
    id6(TensorRT) --Required--> id10(TensorRT weights ending in '.pt')
    id7(Model File & weights file) & id8(TorchScripted weights ending in '.pt') &  id9(Weights ending in '.onnx') & id10(TensorRT weights ending in '.pt') --> id11(Created a model archive .mar file)
    id13{Handler has an initialize method?} --Yes--> id21{"Does the initialize method inherit from BaseHandler?"}
    id21{"Does the initialize method inherit from BaseHandler?"} -- Yes --> id2{Model Type?}
    id21{Does the initialize method inherit from BaseHandler?} -- No --> id20("Create a custom method to
         load the model in the handler") --> id11(Create a model archive .mar file)
    id15["Create model archive by passing the
    weights with --serialized-file option"]
    id16["Specify path to the weights in model-config.yaml
    Create model archive by specifying yaml file with --config-file "]
	id11(Work on creating a model archive .mar file) --> id14{"Is your model large?"} --No--> id22{Do you want a self-contained model artifact}  --Yes--> id15
	id14{"Is your model large?"} --Yes--> id16
	id22{Do you want a self-contained model artifact} --No, I want model archieving & loading to be faster--> id16
	id15 & id16 --> id17["Start TorchServe.
	Two ways of starting torchserve
	- Pass the mar file with --models
	- Start TorchServe and call the register API with mar file"]




© 版權所有 2020, PyTorch Serve 貢獻者。

使用 Sphinx 構建,主題由 Read the Docs 提供(透過 theme)。

文件

訪問 PyTorch 的全面開發者文件

檢視文件

教程

獲取針對初學者和高階開發者的深度教程

檢視教程

資源

查詢開發資源並獲得問題解答

檢視資源