App Shield 数据的示例勒索软件检测 Morpheus 管道
使用 Triton Inference Server 的 Morpheus 管道示例。
环境 |
支持 |
注释 |
---|---|---|
Conda | ✔ | |
Morpheus Docker 容器 | ✔ | 需要在主机上启动 Triton |
Morpheus 发布容器 | ✔ | 需要在主机上启动 Triton |
Dev 容器 | ✔ | 需要使用 dev-triton-start 脚本。如果使用 run.py 脚本,则需要添加 --server_url=triton:8000 标志。如果使用 CLI 示例,则需要将 --server_url=localhost:8000 替换为 --server_url=triton:8000 |
拉取 Triton Inference Server Docker 镜像
从 NGC (https://ngc.nvidia.com/catalog/containers/nvidia:tritonserver) 拉取适用于您环境的 Docker 镜像。
示例
docker pull nvcr.io/nvidia/morpheus/morpheus-tritonserver-models:24.10
启动 Triton Inference Server 容器
从 Morpheus repo 根目录,运行以下命令以启动 Triton 并加载 ransomw-model-short-rf
模型
# Run Triton in explicit mode
docker run --rm -ti --gpus=all -p8000:8000 -p8001:8001 -p8002:8002 \
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 ransomw-model-short-rf
验证模型部署
一旦 Triton 服务器完成启动,它将显示所有已加载模型的状态。成功部署模型将显示以下内容
+----------------------------+---------+--------+
| Model | Version | Status |
+----------------------------+---------+--------+
| ransomw-model-short-rf | 1 | READY |
+----------------------------+---------+--------+
注意:如果输出中未显示此内容,请检查 Triton 日志中是否有与加载模型相关的任何错误消息。
从 Morpheus repo 的根目录运行以下命令以启动勒索软件检测管道
python examples/ransomware_detection/run.py --server_url=localhost:8000 \
--sliding_window=3 \
--model_name=ransomw-model-short-rf \
--input_glob=./examples/data/appshield/*/snapshot-*/*.json \
--output_file=./ransomware_detection_output.jsonlines
短模型的输入特征可以从每三个快照序列中获取,例如 (1, 2, 3) 或 (2, 3, 4)。滑动窗口表示在为模型生成输入时需要考虑的后续快照的数量。中模型的滑动窗口为 5
,长模型的滑动窗口为 10
。
此示例的配置选项可以使用以下命令查询
python examples/ransomware_detection/run.py --help
Usage: run.py [OPTIONS]
Options:
--debug BOOLEAN
--num_threads INTEGER RANGE Number of internal pipeline threads to use
[x>=1]
--n_dask_workers INTEGER RANGE Number of dask workers [x>=2]
--threads_per_dask_worker INTEGER RANGE
Number of threads per each dask worker
[x>=2]
--model_max_batch_size INTEGER RANGE
Max batch size to use for the model [x>=1]
--model_fea_length INTEGER RANGE
Features length to use for the model [x>=1]
--features_file TEXT File path for ransomware detection features
--model_name TEXT The name of the model that is deployed on
Tritonserver
--server_url TEXT Tritonserver url [required]
--sliding_window INTEGER RANGE Sliding window to be used for model input
request [x>=1]
--input_glob TEXT Input glob pattern to match files to read.
For example,
'./input_dir/*/snapshot-*/*.json' would read
all files with the 'json' extension in the
directory 'input_dir'. [required]
--watch_directory BOOLEAN The watch directory option instructs this
stage to not close down once all files have
been read. Instead it will read all files
that match the 'input_glob' pattern, and
then continue to watch the directory for
additional files. Any new files that are
added that match the glob will then be
processed.
--output_file TEXT The path to the file where the inference
output will be saved.
--help Show this message and exit.
注意:dask.distributed
中存在已知的竞争条件,有时会导致在关闭期间引发 tornado.iostream.StreamClosedError
,但这不会影响管道的输出。如果在关闭期间看到此异常,通常可以忽略它,除非它对应于其他不良行为。有关更多信息,请参阅 (#2026)。