forked from Xilinx/Vitis-AI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
docker_run.sh
executable file
·115 lines (92 loc) · 2.49 KB
/
docker_run.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
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
#!/bin/bash
# Copyright 2020 Xilinx Inc.
sed -n '1, 5p' ./setup/docker/docker/PROMPT.txt
read -n 1 -s -r -p "Press any key to continue..." key
sed -n '5, 15p' ./setup/docker/docker/PROMPT.txt
read -n 1 -s -r -p "Press any key to continue..." key
sed -n '15, 28p' ./setup/docker/docker/PROMPT.txt
read -n 1 -s -r -p "Press any key to continue..." key
sed -n '28, 61p' ./setup/docker/docker/PROMPT.txt
read -n 1 -s -r -p "Press any key to continue..." key
sed -n '62, 224p' ./setup/docker/docker/PROMPT.txt
read -n 1 -s -r -p "Press any key to continue..." key
sed -n '224, 308p' ./setup/docker/docker/PROMPT.txt
read -n 1 -s -r -p "Press any key to continue..." key
confirm() {
echo -en "\n\nDo you agree to the terms and wish to proceed [y/n]? "
read REPLY
case $REPLY in
[Yy]) ;;
[Nn]) exit 0 ;;
*) confirm ;;
esac
REPLY=''
}
confirm
if [[ "$1" == "-h" || "$1" == "--help" ]]; then
echo "Usage: $0 <image>"
exit 2
fi
HERE=$(pwd -P) # Absolute path of current directory
user=`whoami`
uid=`id -u`
gid=`id -g`
DOCKER_REPO="xilinx/"
BRAND=vitis-ai
VERSION=latest
CPU_IMAGE_TAG=${DOCKER_REPO}${BRAND}-cpu:${VERSION}
GPU_IMAGE_TAG=${DOCKER_REPO}${BRAND}-gpu:${VERSION}
IMAGE_NAME="${1:-$CPU_IMAGE_TAG}"
DEFAULT_COMMAND="bash"
if [[ $# -gt 0 ]]; then
shift 1;
DEFAULT_COMMAND="$@"
if [[ -z "$1" ]]; then
DEFAULT_COMMAND="bash"
fi
fi
DETACHED="-it"
xclmgmt_driver="$(find /dev -name xclmgmt\*)"
docker_devices=""
for i in ${xclmgmt_driver} ;
do
docker_devices+="--device=$i "
done
render_driver="$(find /dev/dri -name renderD\*)"
for i in ${render_driver} ;
do
docker_devices+="--device=$i "
done
DOCKER_RUN_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
if [ "$PWD" != "$DOCKER_RUN_DIR" ]; then
echo "WARNING: Please start 'docker_run.sh' from the Vitis-AI/ source directory";
fi
docker_run_params=$(cat <<-END
-v /dev/shm:/dev/shm \
-v /opt/xilinx/dsa:/opt/xilinx/dsa \
-v /opt/xilinx/overlaybins:/opt/xilinx/overlaybins \
-v /etc/xbutler:/etc/xbutler \
-e USER=$user -e UID=$uid -e GID=$gid \
-e VERSION=$VERSION \
-v $DOCKER_RUN_DIR:/vitis_ai_home \
-v $HERE:/workspace \
-w /workspace \
--rm \
--network=host \
${DETACHED} \
${RUN_MODE} \
$IMAGE_NAME \
$DEFAULT_COMMAND
END
)
##############################
if [[ $IMAGE_NAME == *"gpu"* ]]; then
docker run \
$docker_devices \
--gpus all \
$docker_run_params
else
docker run \
$docker_devices \
$docker_run_params
fi