Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SID Visualization Example #354

Merged
4 commits merged into from
Sep 16, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[submodule "examples/sid_visualization/viz"]
path = examples/sid_visualization/viz
url = ../../nv-morpheus/morpheus-visualizations.git
branch = branch-22.09
Git LFS file not shown
Git LFS file not shown
Git LFS file not shown
3 changes: 3 additions & 0 deletions examples/data/sid_visualization/group3-si-50nodes.jsonlines
Git LFS file not shown
Git LFS file not shown
153 changes: 153 additions & 0 deletions examples/sid_visualization/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
# SID Visualization Example

## Prerequisites

To run the demo you will need the following:
- Docker
mdemoret-nv marked this conversation as resolved.
Show resolved Hide resolved
- `docker-compose` (Tested with version 1.29)

## Setup

To run this demo, ensure all submodules are checked out:
```bash
git submodule update --init --recursive
efajardo-nv marked this conversation as resolved.
Show resolved Hide resolved
```

### Build Morpheus Dev Container

Before launching the demo, we need the dev container for Morpheus to be created:
```bash
export DOCKER_IMAGE_TAG="sid-viz"
```

# Build the dev container
```bash
./docker/build_container_dev.sh
```

efajardo-nv marked this conversation as resolved.
Show resolved Hide resolved
### Launch User Interface

We will use docker-compose to build and run the entire demo. To launch everything, run the following from the repo root:

Save the Morpheus repo directory:
```bash
export MORPHEUS_HOME=$(git rev-parse --show-toplevel)
```

Ensure SID model is downloaded for deployment to Triton:
```bash
./scripts/fetch_data.py fetch models
```

Change to the example directory:
```bash
cd ${MORPHEUS_HOME}/examples/sid_visualization
```

Launch the containers:
```bash
DOCKER_BUILDKIT=1 docker-compose up --build -d
```

The following GUI should be displayed when all containers have completed launching:

<img src="./img/initial_win.png" width=75% height=75%>

### Build Morpheus

Once docker-compose command has completed and GUI is displayed, exec into the container to build and run Morpheus:

Exec into the morpheus container:
```bash
docker-compose exec morpheus bash
```

Inside the container, compile morpheus:
```bash
BUILD_DIR=build-docker ./scripts/compile.sh
```

Install morpheus with an extra dependency:
```bash
pip install -e . && pip install websockets
```

Verify Morpheus is installed:
```bash
morpheus --version
```

Ensure the data has been downloaded:
```bash
./scripts/fetch_data.py fetch examples
```

***Keep this shell in the Morpheus Dev container running. It will be used later to start Morpheus.***

## Running the Demo

### Running Morpheus

After the GUI has been launched, Morpheus now needs to be started. In the same shell used to build Morpheus (the one running the Morpheus Dev container), run the following:
```bash
python examples/sid_visualization/run.py \
--debug --use_cpp=False --num_threads=1 \
--triton_server_url=triton:8001 \
--input_file=./examples/data/sid_visualization/group1-benign-2nodes.jsonlines \
--input_file=./examples/data/sid_visualization/group2-benign-50nodes.jsonlines \
--input_file=./examples/data/sid_visualization/group3-si-50nodes.jsonlines \
--input_file=./examples/data/sid_visualization/group4-benign-49nodes.jsonlines
```

**Note:** The first run of this script will take a few minutes to allow Triton to convert the deployed ONNX model to TensorRT. Subsequent runs will not include this conversion step so will be much quicker.

This launch will use all of the available datasets. Each dataset will show up as one batch in the visualization. Here is a description of each dataset:
efajardo-nv marked this conversation as resolved.
Show resolved Hide resolved

- `examples/data/sid_visualization/group1-benign-2nodes.jsonlines`
- Small scale with 2 nodes, no SID
- `examples/data/sid_visualization/group2-benign-50nodes.jsonlines`
efajardo-nv marked this conversation as resolved.
Show resolved Hide resolved
- Scale up to 50 nodes, no SID
- `examples/data/sid_visualization/group3-si-50nodes.jsonlines`
- 50 nodes, with SID from a single node
- `examples/data/sid_visualization/group4-benign-49nodes.jsonlines`
- Isolate bad node leaving 49 nodes, no SID

The following is a screenshot after all four batches have been processed:
mdemoret-nv marked this conversation as resolved.
Show resolved Hide resolved

<img src="./img/full_win.png" width=75% height=75%>

Use the slider or the following buttons to step through the inferences batches in the visualization:
| | |
| ---------------------------- | ------------------------------------------------- |
| <img src="./img/left.png"> | Step to previous inference batch |
| <img src="./img/right.png"> | Step to next inference batch |
| <img src="./img/replay.png"> | Step through all inference batches from beginning |
efajardo-nv marked this conversation as resolved.
Show resolved Hide resolved
| <img src="./img/pause.png"> | Pause animation |

The visualization on the right shows nodes in the current inference batch represented as
green spheres. White (benign) and red (SI) packets are shown flowing between the node connections.
While the animation is running, you can click the pause button or toggle off `Simulating`. Once paused,
you will be able to hover over an individual packet to view its contents.

Changing the dataset does not require relaunching the GUI. Simply re-run Morpheus with the new dataset and the GUI will be updated.

It's also possible to launch the demo using the Morpheus CLI using the following:

```bash
DEMO_DATASET="examples/data/sid_visualization/group1-benign-2nodes.jsonlines"
```

```bash
morpheus --log_level=DEBUG \
run --num_threads=1 --pipeline_batch_size=1024 --model_max_batch_size=32 --edge_buffer_size=4 --use_cpp=False \
pipeline-nlp --model_seq_length=256 \
from-file --filename=${DEMO_DATASET} \
deserialize \
preprocess --vocab_hash_file=morpheus/data/bert-base-uncased-hash.txt --truncation=True --do_lower_case=True --add_special_tokens=False \
inf-triton --model_name=sid-minibert-onnx --server_url=triton:8001 --force_convert_inputs=True \
monitor --description Inference\ Rate --unit=inf \
add-class \
gen-viz
```

Note, this launch method is more useful for showing performance than showing capability.
93 changes: 93 additions & 0 deletions examples/sid_visualization/docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# SPDX-FileCopyrightText: Copyright (c) 2022 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

version: "3"

x-with-gpus: &with_gpus
deploy:
resources:
reservations:
devices:
- capabilities:
- gpu

services:
triton:
image: nvcr.io/nvidia/tritonserver:22.06-py3
<<: *with_gpus
command: "tritonserver --exit-on-error=false --model-control-mode=explicit --load-model sid-minibert-onnx --model-repository=/models/triton-model-repo"
environment:
NVIDIA_VISIBLE_DEVICES: "${NVIDIA_VISIBLE_DEVICES:-all}"
ports:
- "8000"
- "8001"
- "8002"
runtime: nvidia
volumes:
- "${MORPHEUS_HOME:-../..}/models:/models"

gui:
image: sid-viz:latest
<<: *with_gpus
build:
context: viz
args:
RAPIDSAI_GPU_ARCH: "${RAPIDSAI_GPU_ARCH:-}" # 60 | 70 | 75 | 80 | 86
cap_add:
- SYS_ADMIN
- SYS_PTRACE
security_opt:
- apparmor=unconfined
environment:
NVIDIA_DRIVER_CAPABILITIES: all
MORPHEUS_SOCKET_URL: "morpheus:8765"
# Colorize the terminal in the container if possible
TERM: "${TERM:-}"
# Use the host's X11 display
DISPLAY: "${DISPLAY:-}"
XAUTHORITY: "${XAUTHORITY:-}"
XDG_SESSION_TYPE: "${XDG_SESSION_TYPE:-}"
XDG_RUNTIME_DIR: "${XDG_RUNTIME_DIR:?XDG_RUNTIME_DIR must be set}"
DBUS_SESSION_BUS_ADDRESS: "${DBUS_SESSION_BUS_ADDRESS:?DBUS_SESSION_BUS_ADDRESS must be set}"
runtime: nvidia
volumes:
- "/etc/fonts:/etc/fonts:ro"
- "/etc/timezone:/etc/timezone:ro"
- "/etc/localtime:/etc/localtime:ro"
- "/tmp/.X11-unix:/tmp/.X11-unix:rw"
- "/usr/share/fonts:/usr/share/fonts:ro"
- "/usr/share/icons:/usr/share/icons:ro"
- "${XDG_RUNTIME_DIR}:${XDG_RUNTIME_DIR}"
- "/run/dbus/system_bus_socket:/run/dbus/system_bus_socket"

morpheus:
image: morpheus:sid-viz
<<: *with_gpus
command: bash
cap_add:
- SYS_NICE
depends_on:
- gui
- triton
environment:
BUILD_DIR: build-docker # Avoid conflicting with the host default build
NVIDIA_VISIBLE_DEVICES: "${NVIDIA_VISIBLE_DEVICES:-all}"
ports:
- "8765"
stdin_open: true
tty: true
runtime: nvidia
volumes:
- "${MORPHEUS_HOME:-../../}:/workspace"
Binary file added examples/sid_visualization/img/full_win.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/sid_visualization/img/initial_win.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/sid_visualization/img/left.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/sid_visualization/img/pause.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/sid_visualization/img/replay.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added examples/sid_visualization/img/right.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading