#!/bin/bash


download_all_dependency(){
   mkdir -p /root/wdd/install/ai-run/
   cd /root/wdd/install/ai-run/

   wget https://oss.demo.uavcmlc.com/cmlc-installation/ai/nvidia-docker-toolkit-ubuntu.zip
   wget https://oss.demo.uavcmlc.com/cmlc-installation/ai/cmlc-ai-operator_v5.4.0-v100-all.tar.gz
   wget https://oss.demo.uavcmlc.com/cmlc-installation/ai/config.yaml
   wget https://oss.demo.uavcmlc.com/cmlc-installation/ai/drone_detect_model_20240903.zip
}

install_nvidia_docker_runtime(){

   unzip nvidia-docker-toolkit-ubuntu.zip

   cd dev_files

   dpkg -i libnvidia-container1_1.12.0-1_amd64.deb
   dpkg -i libnvidia-container-tools_1.12.0-1_amd64.deb
   dpkg -i nvidia-container-toolkit-base_1.12.0-1_amd64.deb
   dpkg -i nvidia-container-toolkit_1.12.0-1_amd64.deb
   dpkg -i nvidia-container-runtime_3.12.0-1_all.deb
   dpkg -i nvidia-docker2_2.12.0-1_all.deb

   systemctl restart docker
}

start_ai_process(){

  docker stop cmlc-ai && docker rm cmlc-ai

  # a100 model
  docker run -itd -p2333:2333 \
    --name cmlc-ai --runtime=nvidia --shm-size=8g \
    --restart=always \
    -v /root/wdd/install/ai-run/config.yaml:/cmii/cmlc-project-ai-streaming-engine/src/config.yaml \
    harbor.cdcyy.com.cn/cmii/cmlc-ai/cmlc-ai-operator:v5.4.0-v100-all

 # t4-model
  docker run -itd -p2333:2333 \
  --name cmlc-ai --runtime=nvidia --shm-size=8g \
  --restart=always \
  -v /root/wdd/ai-run/config.yaml:/cmii/cmlc-project-ai-streaming-engine/src/config.yaml \
  -v /root/wdd/ai-run/drone-t4.engine:/cmii/cmlc-project-ai-streaming-engine/models/yolov8/drone.engine \
  harbor.cdcyy.com.cn/cmii/cmlc-ai/cmlc-ai-operator:v5.4.0-v100-all


}

download_all_dependency