Morpheus CLI 概述
本节重点介绍 Morpheus CLI,并说明如何使用 CLI 来配置和运行 Morpheus 管道。
Morpheus CLI 构建于 Click Python 包之上,该包允许嵌套命令并将多个命令链接在一起。从高层次来看,CLI 分为两个主要部分:
-
-
run
-
用于运行 FIL、NLP 或 OTHER 管道。
-
-
-
tools
-
用于帮助设置、配置和运行管道及外部资源的工具/实用程序。
-
用户可以通过将 --help
传递给命令或子命令来获取任何命令的帮助。例如,要获取有关 run 的帮助
$ morpheus run --help
Usage: morpheus run [OPTIONS] COMMAND [ARGS]...
Run subcommand, used for running a pipeline
Options:
--num_threads INTEGER RANGE Number of internal pipeline threads to use [default: 64; x>=1]
--pipeline_batch_size INTEGER RANGE
Internal batch size for the pipeline. Can be much larger than the model batch size. Also used for Kafka consumers [default: 256; x>=1]
--model_max_batch_size INTEGER RANGE
Max batch size to use for the model [default: 8; x>=1]
--edge_buffer_size INTEGER RANGE
The size of buffered channels to use between nodes in a pipeline. Larger values reduce backpressure at the cost of memory. Smaller
values will push messages through the pipeline quicker. Must be greater than 1 and a power of 2 (i.e. 2, 4, 8, 16, etc.) [default:
128; x>=2]
--use_cpp BOOLEAN [Deprecated] Whether or not to use C++ node and message types or to prefer python. Only use as a last resort if bugs are encountered.
Cannot be used with --use_cpu_only [default: True]
--use_cpu_only Whether or not to run in CPU only mode, setting this to True will disable C++ mode. Cannot be used with --use_cpp
--manual_seed INTEGER RANGE Manually seed the random number generators used by Morpheus, useful for testing. [x>=1]
--help Show this message and exit.
Commands:
pipeline-fil Run the inference pipeline with a FIL model
pipeline-nlp Run the inference pipeline with a NLP model
pipeline-other Run a custom inference pipeline without a specific model type
目前,Morpheus 管道可以在四种不同的模式下运行。
-
-
pipeline-fil
-
此管道模式用于对 FIL(森林推理库)模型(如 XGBoost、RandomForestClassifier 等)运行推理。
-
-
-
pipeline-nlp
-
此管道模式用于对 NLP 模型运行推理,它提供在提交推理请求之前对输入数据进行分词的能力。
-
-
-
pipeline-other
-
运行自定义的推理管道,而无需使用特定的模型类型。
-
与 run 命令类似,我们可以获取有关 tools 的帮助
$ morpheus tools --help
Usage: morpheus tools [OPTIONS] COMMAND [ARGS]...
Tools subcommand
Options:
--help Show this message and exit.
Commands:
autocomplete Utility for installing/updating/removing shell completion for Morpheus
onnx-to-trt Converts an ONNX model to a TRT engine
帮助文本将显示参数、选项和所有可能的子命令。可以以相同的方式查询每个子命令的帮助
$ morpheus tools onnx-to-trt --help
Usage: morpheus tools onnx-to-trt [OPTIONS]
Converts an ONNX model to a TRT engine
Options:
--input_model PATH [required]
--output_model PATH [required]
--batches <INTEGER INTEGER>... [required]
--seq_length INTEGER [required]
--max_workspace_size INTEGER [default: 16000]
--help Show this message and exit.
Morpheus CLI 支持 bash、fish、zsh 和 PowerShell 自动补全。要设置自动补全,必须首先安装它。Morpheus 提供了一个工具来协助完成此操作
$ morpheus tools autocomplete install
bash completion installed in ~/.bash_completion
$ source ~/.bash_completion
安装自动补全后,当通过 CLI 构建管道时,可以使用 [TAB]
来显示所有命令、选项和参数
$ morpheus run pipeline- # [TAB][TAB]
pipeline-fil pipeline-nlp