加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
docker_run.sh 2.49 KB
一键复制 编辑 原始数据 按行查看 历史
Hanxue 提交于 2021-03-04 23:45 . Vitis-AI 1.3.1 Release (#318)
#!/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
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化