docker_web_demo.sh
1 #!/usr/bin/env bash 2 # 3 # This script will automatically pull docker image from DockerHub, and start a daemon container to run the Qwen-Chat web-demo. 4 5 IMAGE_NAME=qwenllm/qwenvl:2-cu121 6 QWEN_CHECKPOINT_PATH=/path/to/Qwen2-VL-7B-Instruct 7 PORT=8901 8 CONTAINER_NAME=qwen2-vl 9 10 function usage() { 11 echo ' 12 Usage: bash docker/docker_web_demo.sh [-i IMAGE_NAME] -c [/path/to/Qwen-Instruct] [-n CONTAINER_NAME] [--port PORT] 13 ' 14 } 15 16 while [[ "$1" != "" ]]; do 17 case $1 in 18 -i | --image-name ) 19 shift 20 IMAGE_NAME=$1 21 ;; 22 -c | --checkpoint ) 23 shift 24 QWEN_CHECKPOINT_PATH=$1 25 ;; 26 -n | --container-name ) 27 shift 28 CONTAINER_NAME=$1 29 ;; 30 --port ) 31 shift 32 PORT=$1 33 ;; 34 -h | --help ) 35 usage 36 exit 0 37 ;; 38 * ) 39 echo "Unknown argument ${1}" 40 exit 1 41 ;; 42 esac 43 shift 44 done 45 46 if [ ! -e ${QWEN_CHECKPOINT_PATH}/config.json ]; then 47 echo "Checkpoint config.json file not found in ${QWEN_CHECKPOINT_PATH}, exit." 48 exit 1 49 fi 50 51 sudo docker pull ${IMAGE_NAME} || { 52 echo "Pulling image ${IMAGE_NAME} failed, exit." 53 exit 1 54 } 55 56 sudo docker run --gpus all -d --restart always --name ${CONTAINER_NAME} \ 57 -v /var/run/docker.sock:/var/run/docker.sock -p ${PORT}:80 \ 58 --mount type=bind,source=${QWEN_CHECKPOINT_PATH},target=/data/shared/Qwen/Qwen2-VL-Instruct \ 59 -it ${IMAGE_NAME} \ 60 python web_demo_mm.py --server-port 80 --server-name 0.0.0.0 -c /data/shared/Qwen/Qwen2-VL-Instruct/ && { 61 echo "Successfully started web demo. Open 'http://localhost:${PORT}' to try! 62 Run \`docker logs ${CONTAINER_NAME}\` to check demo status. 63 Run \`docker rm -f ${CONTAINER_NAME}\` to stop and remove the demo." 64 }