ABP 检测示例使用 Morpheus
环境 |
支持 |
注释 |
---|---|---|
Conda | ✔ | |
Morpheus Docker 容器 | ✔ | 需要在主机上启动 Triton |
Morpheus 发布容器 | ✔ | 需要在主机上启动 Triton |
开发容器 | ✔ | 需要使用 dev-triton-start 脚本。如果使用 run.py 脚本,则需要添加 --server_url=triton:8000 标志。如果使用 CLI 示例,则需要将 --server_url=localhost:8000 替换为 --server_url=triton:8000 |
要运行此示例,需要 Triton Inference Server 的实例和示例数据集。以下步骤将概述如何使用提供的 FIL 模型构建和运行 Triton。
Triton Inference Server
docker pull nvcr.io/nvidia/morpheus/morpheus-tritonserver-models:24.10
部署 Triton Inference Server
运行以下命令以启动 Triton 并加载 abp-pcap-xgb
模型
docker run --rm --gpus=all -p 8000:8000 -p 8001:8001 -p 8002:8002 --name tritonserver nvcr.io/nvidia/morpheus/morpheus-tritonserver-models:24.10 tritonserver --model-repository=/models/triton-model-repo --exit-on-error=false --model-control-mode=explicit --load-model abp-pcap-xgb
验证模型部署
一旦 Triton 服务器完成启动,它将显示所有已加载模型的状态。成功部署模型将显示以下内容
+-----------------------------+---------+--------+
| Model | Version | Status |
+-----------------------------+---------+--------+
| abp-pcap-xgb | 1 | READY |
+-----------------------------+---------+--------+
使用 Morpheus 运行带有 PCAP 数据的异常行为分析检测管线。管线已在 run.py
中配置,并带有多个命令行选项
从 Morpheus 仓库的根目录运行
python examples/abp_pcap_detection/run.py --help
输出
Usage: run.py [OPTIONS]
Options:
--num_threads INTEGER RANGE Number of internal pipeline threads to use.
[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. [x>=1]
--model_max_batch_size INTEGER RANGE
Max batch size to use for the model. [x>=1]
--input_file PATH Input filepath. [required]
--output_file TEXT The path to the file where the inference
output will be saved.
--model_fea_length INTEGER RANGE
Features length to use for the model.
[x>=1]
--model_name TEXT The name of the model that is deployed on
Tritonserver.
--iterative Iterative mode will emit DataFrames one at a
time. Otherwise a list of DataFrames is
emitted. Iterative mode is good for
interleaving source stages.
--server_url TEXT Tritonserver url. [required]
--file_type [auto|csv|json] Indicates what type of file to read.
Specifying 'auto' will determine the file
type from the extension.
--help Show this message and exit.
要使用 examples/data
中提供的示例数据启动配置的 Morpheus 管线,请运行以下命令
python examples/abp_pcap_detection/run.py
注意:Morpheus 和 Triton Inference Server 容器必须有权访问相同的 GPU,此示例才能正常工作。
该管线将处理输入 abp_pcap_dump.jsonlines
示例数据,并将其写入 pcap_out.jsonlines
。
CLI 示例
以上示例说明了如何使用 Python API 构建自定义 Morpheus 管线。或者,可以使用 Morpheus 命令行通过注册 abp_pcap_preprocessing.py
模块作为插件来实现相同的目标。
从 Morpheus 仓库的根目录运行
morpheus --log_level INFO --plugin "examples/abp_pcap_detection/abp_pcap_preprocessing.py" \
run --pipeline_batch_size 100000 --model_max_batch_size 100000 \
pipeline-fil --model_fea_length 13 --label=probs \
from-file --filename examples/data/abp_pcap_dump.jsonlines --filter_null False \
deserialize \
pcap-preprocess \
monitor --description "Preprocessing rate" \
inf-triton --model_name "abp-pcap-xgb" --server_url "localhost:8000" \
monitor --description "Inference rate" --unit inf \
add-class --label=probs \
monitor --description "Add classification rate" --unit "add-class" \
serialize \
monitor --description "Serialize rate" --unit ser \
to-file --filename "pcap_out.jsonlines" --overwrite \
monitor --description "Write to file rate" --unit "to-file"