Skip to content

Commit

Permalink
Merge pull request #646 from nv-morpheus/branch-23.01
Browse files Browse the repository at this point in the history
[RELEASE] Morpheus v23.01
  • Loading branch information
mdemoret-nv authored Jan 31, 2023
2 parents ba2b897 + dfdac4c commit a57f3a1
Show file tree
Hide file tree
Showing 610 changed files with 49,180 additions and 10,124 deletions.
5 changes: 2 additions & 3 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
# Refer to the following link for the explanation of each params:
# http://releases.llvm.org/8.0.0/tools/clang/docs/ClangFormatStyleOptions.html
# https://releases.llvm.org/14.0.0/tools/clang/docs/ClangFormatStyleOptions.html
Language: Cpp
# BasedOnStyle: Google
AccessModifierOffset: -2
Expand Down Expand Up @@ -58,7 +58,6 @@ ConstructorInitializerAllOnOneLineOrOnePerLine: true
ConstructorInitializerIndentWidth: 2
ContinuationIndentWidth: 4
Cpp11BracedListStyle: true
DerivePointerAlignment: true
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
FixNamespaceComments: true
Expand Down Expand Up @@ -158,7 +157,7 @@ SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: c++17
Standard: c++20
StatementMacros:
- Q_UNUSED
- QT_REQUIRE_VERSION
Expand Down
2 changes: 1 addition & 1 deletion .clang-tidy
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ CheckOptions:
- key: readability-identifier-naming.TypeTemplateParameterCase
value: CamelCase
- key: readability-identifier-naming.TypeTemplateParameterIgnoredRegexp
value: ^[A-Z]$
value: '^([A-Z]|expr-type)$'
- key: readability-identifier-naming.TypeTemplateParameterPrefix
value: ''
- key: readability-identifier-naming.TypeTemplateParameterSuffix
Expand Down
32 changes: 32 additions & 0 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# SPDX-FileCopyrightText: Copyright (c) 2022-2023, 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.

FROM nvidia/cuda:11.5.1-devel-ubuntu20.04 AS base

RUN apt-get update && \
apt-get install --no-install-recommends --yes \
wget git-lfs gdb iputils-ping

ENV CONDA_DIR=/opt/conda

RUN wget "https://github.com/conda-forge/miniforge/releases/latest/download/Mambaforge-$(uname)-$(uname -m).sh" && \
bash Mambaforge-$(uname)-$(uname -m).sh -b -p ${CONDA_DIR} && \
echo ". ${CONDA_DIR}/etc/profile.d/conda.sh && conda activate base" >> /etc/skel/.bashrc && \
echo ". ${CONDA_DIR}/etc/profile.d/conda.sh && conda activate base" >> ~/.bashrc

ENV PATH="${CONDA_DIR}/bin:${PATH}"

ENV MAMBA_NO_BANNER=1
ENV PATH="${PATH}:/workspaces/morpheus/.devcontainer/bin"
77 changes: 77 additions & 0 deletions .devcontainer/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
<!--
SPDX-FileCopyrightText: Copyright (c) 2022-2023, 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.
-->

# Morpheus Devcontainer

The Morpheus devcontainer is provided as a quick-to-set-up development and exploration environment for use with [Visual Studio Code](https://code.visualstudio.com) (Code). The devcontainer is a lightweight container which mounts-in a conda environment with cached packages, alleviating long conda download times on subsequent launches. It provides a simple framework for adding developer-centric [scripts](#scripts), and incorperates some helpful Code plugins, such as clangd and cmake support.

More information about devcontainers can be found at [containers.dev](https://containers.dev/).

## Getting Started

To get started, simply open the morpheus repository root folder within Code. A window should appear at the bottom-right corner of the editor asking if you would like to reopen the workspace inside of the dev container. After clicking the confirmation dialog, the container will first build, then launch, then remote-attach.

If the window does not appear, or you would like to rebuild the container, click ctrl-shift-p and search for `Dev Containers: Rebuild and Reopen in Container`. Hit enter, and the container will first build, then launch, then remote-attach.

Once remoted in to the devcontainer within code, the `setup-morpheus-env` script will begin to run and solve a morpheus conda environment (this conda environment is local to the morpheus repository and dev container and will not override any host environments). You should see the script executing in one of Code's integrated terminal. Once the script has completed, we're ready to start development or exploration of Morpheus. By default, each _new_ integrated terminal will automatically conda activate the morpheus environment.

## Development Scripts
Several convienient scripts are available in the devcontainer's `PATH` (`.devcontainer/bin`) for starting, stopping, and interacting with Triton and Kafka. More scripts can be added as needed.

### Interacting with Triton
To start Triton and connect it to the devcontainer network, the `dev-triton-start` script can be used. The following example starts _or restarts_ Triton with the `abp-pcap-xgb` model loaded.
```
dev-triton-start abp-pcap-xgb
```
Triton should now be started and DNS resolvable as `triton`.
```
ping triton
```
To load a different model, simply call `dev-triton-start` with a different model name. Multiple models can be loaded simultaneously by adding more model names to the command.
```
dev-triton-start model-1 model-2 ... model-n
```
To stop Triton, call `dev-triton-stop`. This may take several seconds as the Triton server shuts down gracefully.
```
dev-triton-stop
```
### Interacting with Kafka
To start Kafka and connect it to the devcontainer network, the `dev-kafka-start` script can be used. The following example starts _or restarts_ Kafka and Zookeeper.
```
dev-kafka-start
```
Kafka should now be started and DNS resolveable as `kafka`.
```
ping kafka
```
It can be extremely useful to interact directly with Kafka to produce test data to a specific topic. To do this, the `dev-kafka-produce` script can be used. This script opens a connect to the Kafka server and starts `kafka-console-producer.sh`. In this case with a specific topic. Once started, a prompt will appear in which new-line delimited messages can be entered in to the console.
```
dev-kafka-produce test-topic
>
```
It can also be useful to produce messages from a file. For this, the `dev-kafka-produce` script can be used with two arguments. The first argument is the topic name, and the second argument is the file to be forwarded to the console producer.
```
dev-kafka-produce test-topic $MORPHEUS_ROOT/examples/data/pcap_dump.jsonlines
```
To retrieve the logs from Kafka and Zookeeper, use the `dev-kafka-logs` script.
```
dev-kafka-logs
```
To stop Kafka and Zookeeper, use the `dev-kafka-stop` script.
```
dev-kafka-stop
```
6 changes: 3 additions & 3 deletions cmake/run_iwyu.sh.in → .devcontainer/bin/dev-kafka-logs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# Allows running ccache with options inside of CMake. CMake does not work well
# with setting variables before calling a command
${MORPHEUS_IWYU_PROGRAM} ${MORPHEUS_IWYU_OPTIONS} "$@"
COMPOSE_FILE="${MORPHEUS_ROOT}/.devcontainer/docker-compose.yml"

docker compose -f $COMPOSE_FILE logs zookeeper kafka
15 changes: 7 additions & 8 deletions docker/install_docker.sh → .devcontainer/bin/dev-kafka-produce
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.

apt-get update
apt-get install -y lsb-release
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
echo \
"deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
$(lsb_release -cs) stable" | tee /etc/apt/sources.list.d/docker.list > /dev/null
COMPOSE_FILE="${MORPHEUS_ROOT}/.devcontainer/docker-compose.yml"

apt-get update
apt-get install -y docker-ce docker-ce-cli containerd.io
if [[ $# -eq 2 ]]; then
docker compose -f $COMPOSE_FILE cp $2 kafka:/tmp/kafka-topic-input
docker compose -f $COMPOSE_FILE exec kafka bash -c "cat /tmp/kafka-topic-input | kafka-console-producer.sh --bootstrap-server kafka:9092 --topic $1"
else
docker compose -f $COMPOSE_FILE exec -it kafka kafka-console-producer.sh --bootstrap-server kafka:9092 --topic $1
fi
21 changes: 21 additions & 0 deletions .devcontainer/bin/dev-kafka-start
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/bin/bash
# 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.

COMPOSE_FILE="${MORPHEUS_ROOT}/.devcontainer/docker-compose.yml"

docker compose -f $COMPOSE_FILE up -d zookeeper kafka
export ZOOKEEPER_HOST=$(docker compose -f $COMPOSE_FILE exec zookeper hostname -i)
export KAFKA_HOST=$(docker compose -f $COMPOSE_FILE exec kafka hostname -i)
12 changes: 3 additions & 9 deletions cmake/vcpkg_triplets/x64-linux-dynamic.cmake → .devcontainer/bin/dev-kafka-stop
100644 → 100755
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
# SPDX-FileCopyrightText: Copyright (c) 2021, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#!/bin/bash
# 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");
Expand All @@ -13,11 +14,4 @@
# See the License for the specific language governing permissions and
# limitations under the License.

set(VCPKG_TARGET_ARCHITECTURE x64)
set(VCPKG_CRT_LINKAGE dynamic)
set(VCPKG_LIBRARY_LINKAGE dynamic)

set(VCPKG_CMAKE_SYSTEM_NAME Linux)

# Set the RPATH to allow finding other libraries in the same folder
set(VCPKG_LINKER_FLAGS "-Wl,-rpath,'$ORIGIN':'$ORIGIN/../lib'")
docker compose -f ${MORPHEUS_ROOT}/.devcontainer/docker-compose.yml stop kafka zookeeper
34 changes: 34 additions & 0 deletions .devcontainer/bin/dev-triton-start
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash
# 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.

args=""

if [ $# -gt 0 ] ; then
args="$args --model-control-mode=explicit"
fi

for model in $@ ; do
args="$args --load-model=$model"
done

export TRITON_MODEL_ARGS="$args"

COMPOSE_FILE="${MORPHEUS_ROOT}/.devcontainer/docker-compose.yml"

docker compose -f $COMPOSE_FILE up -d triton
export TRITON_HOST=$(docker compose -f $COMPOSE_FILE exec triton hostname -i)
sleep 1 # wait for triton to load models
docker compose -f $COMPOSE_FILE logs triton
17 changes: 17 additions & 0 deletions .devcontainer/bin/dev-triton-stop
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/bin/bash
# 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.

docker compose -f ${MORPHEUS_ROOT}/.devcontainer/docker-compose.yml stop triton
34 changes: 34 additions & 0 deletions .devcontainer/bin/setup-morpheus-env
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
#!/bin/bash
# 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.

# Ensure our ~/.config directory has the correct permissions. If ~/.config did
# not exist, and you mount ~/.config/gh from the host, then ~/.config will be
# created with root permissions which can break things
sudo mkdir -p ~/.config
sudo chown ${USER}:${USER} ~/.config

conda_env_find(){
conda env list | grep "${@}" >/dev/null 2>/dev/null
}

ENV_NAME=${ENV_NAME:-morpheus}

sed -ri "s/conda activate base/conda activate $ENV_NAME/g" ~/.bashrc;

if conda_env_find "${ENV_NAME}" ; \
then mamba env update --name ${ENV_NAME} -f ${MORPHEUS_ROOT}/docker/conda/environments/cuda11.5_dev.yml; \
else mamba env create --name ${ENV_NAME} -f ${MORPHEUS_ROOT}/docker/conda/environments/cuda11.5_dev.yml; \
fi
84 changes: 84 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
// !/bin/bash
// 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.
{
"name": "Morpheus",
"build": {
"dockerfile": "Dockerfile"
},

"hostRequirements": {
"gpu": true
},

"capAdd":[
"SYS_NICE",
"SYS_PTRACE"
],

"securityOpt": [
"seccomp=unconfined"
],

"runArgs": [
"--network=morpheus"
],

"containerEnv": {
"HOST_MORPHEUS_ROOT": "${localWorkspaceFolder}",
"MORPHEUS_ROOT": "${containerWorkspaceFolder}"
},

"postStartCommand": "${containerWorkspaceFolder}/.devcontainer/bin/setup-morpheus-env",

"initializeCommand": [ "./.devcontainer/init.sh" ],

"remoteUser": "coder",

"mounts": [
{"type":"bind", "source": "/var/run/docker.sock", "target": "/var/run/docker.sock"},
{"type":"bind", "source": "${localWorkspaceFolder}/.cache/conda", "target": "/home/coder/.conda"},
{"type":"bind", "source": "${localEnv:HOME}/.config/gh", "target": "/home/coder/.config/gh"}
],

"features": {
"ghcr.io/devcontainers/features/common-utils:1": {
"uid": "1000",
"gid": "1000",
"username": "coder"
},
"ghcr.io/devcontainers/features/docker-from-docker": {},
"ghcr.io/devcontainers/features/github-cli": {}
},

"customizations": {
"vscode": {
"extensions": [
"eamodio.gitlens",
"llvm-vs-code-extensions.vscode-clangd",
"ms-python.python",
"ms-vscode.cpptools",
"ms-vscode.cmake-tools",
"nvidia.nsight-vscode-edition",
"twxs.cmake",
"xaver.clang-format"
]
}
},
"settings": {
"C_Cpp.intelliSenseEngine": "disabled",
"python.terminal.activateEnvironment": false
}
}
Loading

0 comments on commit a57f3a1

Please sign in to comment.