Skip to content

Commit

Permalink
Merge branch 'david-cpu-only-docs' into david-contrib-conda-yaml-1660
Browse files Browse the repository at this point in the history
  • Loading branch information
dagardner-nv committed Oct 7, 2024
2 parents 79fbc88 + c08b7d3 commit b4698bd
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 80 deletions.
57 changes: 57 additions & 0 deletions docker/run_container.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
#!/bin/bash
# SPDX-FileCopyrightText: Copyright (c) 2021-2024, 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.

# Color variables
b="\033[0;36m"
g="\033[0;32m"
r="\033[0;31m"
e="\033[0;90m"
y="\033[0;33m"
x="\033[0m"

_UNDEF_VAR_ERROR_MSG="Use the dev/release scripts to set these automatically"

DOCKER_IMAGE_NAME=${DOCKER_IMAGE_NAME:?"Must set \$DOCKER_IMAGE_NAME. ${_UNDEF_VAR_ERROR_MSG}"}
DOCKER_IMAGE_TAG=${DOCKER_IMAGE_TAG:?"Must set \$DOCKER_IMAGE_TAG. ${_UNDEF_VAR_ERROR_MSG}"}

# DOCKER_ARGS are set by the dev/release scripts
# DOCKER_EXTRA_ARGS are optionally set by the user
DOCKER_ARGS=${DOCKER_ARGS:-""}
DOCKER_ARGS="${DOCKER_ARGS} --net=host --cap-add=sys_nice ${DOCKER_EXTRA_ARGS}"
DOCKER_EXTRA_ARGS=${DOCKER_EXTRA_ARGS:-""}

if [[ -n "${CPU_ONLY}" ]]; then
echo -e "${b}Executing in CPU only mode${x}"
DOCKER_ARGS="${DOCKER_ARGS} --runtime=runc"
else
echo -e "${b}Executing in GPU mode${x}"
DOCKER_ARGS="${DOCKER_ARGS} --runtime=nvidia --gpus=all"
fi

if [[ -n "${SSH_AUTH_SOCK}" ]]; then
echo -e "${b}Setting up ssh-agent auth socket${x}"
DOCKER_ARGS="${DOCKER_ARGS} -v $(readlink -f $SSH_AUTH_SOCK):/ssh-agent:ro -e SSH_AUTH_SOCK=/ssh-agent"
fi

echo -e "${g}Launching ${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_TAG}...${x}"

# Enable command logging to show what is being executed
set -x
docker run ${DOCA_EXTRA_ARGS} --rm -ti ${DOCKER_ARGS} ${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_TAG} "${@:-bash}"

{ EXIT_CODE=$?; set +x; } 2>/dev/null

exit $EXIT_CODE
46 changes: 6 additions & 40 deletions docker/run_container_dev.sh
Original file line number Diff line number Diff line change
Expand Up @@ -14,46 +14,12 @@
# See the License for the specific language governing permissions and
# limitations under the License.

# set -x
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"

# Color variables
b="\033[0;36m"
g="\033[0;32m"
r="\033[0;31m"
e="\033[0;90m"
y="\033[0;33m"
x="\033[0m"
export DOCKER_IMAGE_NAME=${DOCKER_IMAGE_NAME:-"morpheus"}
export DOCKER_IMAGE_TAG=${DOCKER_IMAGE_TAG:-"dev-$(date +'%y%m%d')"}

DOCKER_IMAGE_NAME=${DOCKER_IMAGE_NAME:-"morpheus"}
DOCKER_IMAGE_TAG=${DOCKER_IMAGE_TAG:-"dev-$(date +'%y%m%d')"}
DOCKER_EXTRA_ARGS=${DOCKER_EXTRA_ARGS:-""}
export DOCKER_ARGS="-v $PWD:/workspace -v /dev/hugepages:/dev/hugepages --privileged"

DOCKER_ARGS=" --env WORKSPACE_VOLUME=${PWD} -v $PWD:/workspace --net=host --cap-add=sys_nice"

if [[ -n "${CPU_ONLY}" ]]; then
echo -e "${b}Executing in CPU only mode${x}"
DOCKER_ARGS="${DOCKER_ARGS} --runtime=runc"
else
echo -e "${b}Executing in GPU mode${x}"
DOCKER_ARGS="${DOCKER_ARGS} --runtime=nvidia --gpus=all"
fi

if [[ -n "${SSH_AUTH_SOCK}" ]]; then
echo -e "${b}Setting up ssh-agent auth socket${x}"
DOCKER_ARGS="${DOCKER_ARGS} -v $(readlink -f $SSH_AUTH_SOCK):/ssh-agent:ro -e SSH_AUTH_SOCK=/ssh-agent"
fi

echo -e "${g}Launching ${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_TAG}...${x}"

set -x
docker run \
-v /dev/hugepages:/dev/hugepages \
--privileged \
--rm \
-ti \
${DOCKER_ARGS} ${DOCKER_EXTRA_ARGS} \
${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_TAG} "${@:-bash}"

{ EXIT_CODE=$?; set +x; } 2>/dev/null

exit $EXIT_CODE
# Call the general run script
${SCRIPT_DIR}/run_container.sh
47 changes: 7 additions & 40 deletions docker/run_container_release.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,56 +16,23 @@

SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )"

# Color variables
b="\033[0;36m"
g="\033[0;32m"
r="\033[0;31m"
e="\033[0;90m"
y="\033[0;33m"
x="\033[0m"

# Change to the script file to ensure we are in the correct repo (in case were in a submodule)
pushd ${SCRIPT_DIR} &> /dev/null

MORPHEUS_SUPPORT_DOCA=${MORPHEUS_SUPPORT_DOCA:-OFF}
MORPHEUS_BUILD_MORPHEUS_LLM=${MORPHEUS_BUILD_MORPHEUS_LLM:-ON}
MORPHEUS_BUILD_MORPHEUS_DFP=${MORPHEUS_BUILD_MORPHEUS_DFP:-ON}

DOCKER_IMAGE_NAME=${DOCKER_IMAGE_NAME:-"nvcr.io/nvidia/morpheus/morpheus"}
DOCKER_IMAGE_TAG=${DOCKER_IMAGE_TAG:-"$(git describe --tags --abbrev=0)-runtime"}

# This variable is used for passing extra arguments to the docker run command. Do not use DOCKER_ARGS for this purpose.
DOCKER_EXTRA_ARGS=${DOCKER_EXTRA_ARGS:-""}
export DOCKER_IMAGE_NAME=${DOCKER_IMAGE_NAME:-"nvcr.io/nvidia/morpheus/morpheus"}
export DOCKER_IMAGE_TAG=${DOCKER_IMAGE_TAG:-"$(git describe --tags --abbrev=0)-runtime"}

popd &> /dev/null

DOCKER_ARGS="--env WORKSPACE_VOLUME=${PWD} --net=host --cap-add=sys_nice ${DOCKER_EXTRA_ARGS}"

if [[ -n "${CPU_ONLY}" ]]; then
echo -e "${b}Executing in CPU only mode${x}"
DOCKER_ARGS="${DOCKER_ARGS} --runtime=runc"
else
echo -e "${b}Executing in GPU mode${x}"
DOCKER_ARGS="${DOCKER_ARGS} --runtime=nvidia --gpus=all"
fi

if [[ -n "${SSH_AUTH_SOCK}" ]]; then
echo -e "${b}Setting up ssh-agent auth socket${x}"
DOCKER_ARGS="${DOCKER_ARGS} -v $(readlink -f $SSH_AUTH_SOCK):/ssh-agent:ro -e SSH_AUTH_SOCK=/ssh-agent"
fi

# DPDK requires hugepage and privileged container
DOCA_EXTRA_ARGS=""
# DPDK (and thus DOCA) requires hugepage and privileged container
export DOCKER_ARGS=""
if [[ ${MORPHEUS_SUPPORT_DOCA} == @(TRUE|ON) ]]; then
echo -e "${b}Enabling DOCA Support. Mounting /dev/hugepages and running in privileged mode${x}"
echo -e "Enabling DOCA Support. Mounting /dev/hugepages and running in privileged mode"

DOCKER_ARGS="${DOCKER_ARGS} -v /dev/hugepages:/dev/hugepages --privileged"
fi


echo -e "${g}Launching ${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_TAG}...${x}"

# Enable command logging to show what is being executed
set -x
docker run ${DOCA_EXTRA_ARGS} --rm -ti ${DOCKER_ARGS} ${DOCKER_IMAGE_NAME}:${DOCKER_IMAGE_TAG} "${@:-bash}"
set +x
# Call the general run script
${SCRIPT_DIR}/run_container.sh

0 comments on commit b4698bd

Please sign in to comment.