-
Notifications
You must be signed in to change notification settings - Fork 3
/
docker_run.sh
111 lines (89 loc) · 2.24 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
#!/bin/bash
sed -n '1, 5p' ./docker/PROMPT.txt
read -n 1 -s -r -p "Press any key to continue..." key
sed -n '5, 15p' ./docker/PROMPT.txt
read -n 1 -s -r -p "Press any key to continue..." key
sed -n '15, 24p' ./docker/PROMPT.txt
read -n 1 -s -r -p "Press any key to continue..." key
sed -n '24, 53p' ./docker/PROMPT.txt
read -n 1 -s -r -p "Press any key to continue..." key
sed -n '53, 224p' ./docker/PROMPT.txt
read -n 1 -s -r -p "Press any key to continue..." key
sed -n '224, 231p' ./docker/PROMPT.txt
read -n 1 -s -r -p "Press any key to continue..." key
confirm() {
echo -n "Do you agree to the terms and wish to proceed [y/n]? "
read REPLY
case $REPLY in
[Yy]) break ;;
[Nn]) exit 0 ;;
*) confirm ;;
esac
REPLY=''
}
confirm
if [[ $# -ne 1 ]]; then
echo "Usage: $0 <image>"
exit 2
fi
HERE=$(pwd) # Absolute path of current directory
user=`whoami`
uid=`id -u`
gid=`id -g`
#echo "$user $uid $gid"
DOCKER_REPO="xilinx/"
BRAND=vitis-ai
VERSION=latest
CPU_IMAGE_TAG=${DOCKER_REPO}$BRAND:${VERSION}-cpu
GPU_IMAGE_TAG=${DOCKER_REPO}$BRAND:${VERSION}-gpu
IMAGE_NAME="${1:-$CPU_IMAGE_TAG}"
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
##############################
if [[ $IMAGE_NAME == *"sdk"* ]]; then
docker run \
-e USER=$user -e UID=$uid -e GID=$gid \
-v $HERE:/workspace \
-w /workspace \
-it \
--rm \
--network=host \
$IMAGE_NAME \
bash
elif [[ $IMAGE_NAME == *"gpu"* ]]; then
docker run \
$docker_devices \
-v /opt/xilinx/dsa:/opt/xilinx/dsa \
-v /opt/xilinx/overlaybins:/opt/xilinx/overlaybins \
-e USER=$user -e UID=$uid -e GID=$gid \
-v $HERE:/workspace \
-w /workspace \
-it \
--rm \
--runtime=nvidia \
--network=host \
$IMAGE_NAME \
bash
else
docker run \
$docker_devices \
-v /opt/xilinx/dsa:/opt/xilinx/dsa \
-v /opt/xilinx/overlaybins:/opt/xilinx/overlaybins \
-e USER=$user -e UID=$uid -e GID=$gid \
-v $HERE:/workspace \
-w /workspace \
-it \
--rm \
--network=host \
$IMAGE_NAME \
bash
fi