-
Notifications
You must be signed in to change notification settings - Fork 64
/
run-docker-example.sh
executable file
·74 lines (60 loc) · 2.79 KB
/
run-docker-example.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#!/usr/bin/env bash
# Copyright 2023 The DAPHNE Consortium
#
# 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.
echo "Use this as an example to start DAPHNE docker containers. Copy and customize for the various flavors."
echo "Add sudo to docker invocation if needed in your setup"
ARCH=X86-64
DOCKER_IMAGE=daphneeu/daphne-dev
DOCKER_TAG=latest_${ARCH}_BASE
#DOCKER_TAG=latest_${ARCH}_CUDA
if [[ "$(arch)" == arm* ]] || [ $(arch) == 'aarch64' ]; then
DOCKER_TAG=latest_ARMV8_BASE
fi
#on some installations docker can only be run with sudo
USE_SUDO=
#USE_SUDO=sudo
# run this script from the base path of your DAPHNE source tree
DAPHNE_ROOT=$PWD
# the directory used *inside* the container to bind-mount your source directory
DAPHNE_ROOT_CONTAINER=/daphne
# user info to set up your user inside the container (to avoid creating files that then belong to the root user)
USERNAME=$(id -n -u)
GID=$(id -g)
# some environment setup
CUDA_PATH=/usr/local/cuda
LD_LIBRARY_PATH=$CUDA_PATH/lib64:$DAPHNE_ROOT/lib:/usr/local/lib:$LD_LIBRARY_PATH
# temporarily adding this NSight Systems path
PATH=/opt/nvidia/nsight-compute/2023.2.2/host/target-linux-x64:$CUDA_PATH/bin:$DAPHNE_ROOT/bin:$PATH
# uncomment the appropriate to pass GPU devices to the container (goes hand in hand with DOCKER_TAG)
DEVICE_FLAGS=""
#DEVICE_FLAGS="--gpus all"
# this might be needed if a debugging session is run in the container
DEBUG_FLAGS=""
#DEBUG_FLAGS="--cap-add=SYS_PTRACE --security-opt seccomp=unconfined"
# set bash as the default command if none is provided
command=$*
if [ "$#" -eq 0 ]; then
command=bash
fi
# non-interactive: launch with PWD mounted
#docker run $DEVICE_FLAGS --user=$UID:$GID --rm -w "$DAPHNE_ROOT" -v "$DAPHNE_ROOT:$DAPHNE_ROOT" \
# -e TERM=screen-256color -e PATH="$PATH" -e LD_LIBRARY_PATH="$LD_LIBRARY_PATH" -e USER=$USERNAME -e UID=$UID \
# "$DOCKER_IMAGE:$DOCKER_TAG" $@
# for interactive use:
$USE_SUDO docker run $DEBUG_FLAGS $DEVICE_FLAGS -it --rm --hostname daphne-container -w $DAPHNE_ROOT_CONTAINER \
-v "$DAPHNE_ROOT:$DAPHNE_ROOT_CONTAINER" -e GID=$GID -e TERM=screen-256color -e PATH -e LD_LIBRARY_PATH \
-e USER=$USERNAME -e UID=$UID \
"$DOCKER_IMAGE:$DOCKER_TAG" $command
# move this up to above the DOCKER_IMAGE line to override the entrypoint:
# --entrypoint /daphne/containers/entrypoint-interactive.sh