Spaces:
Build error
Build error
Create new file
Browse files- utils/aws/userdata.sh +29 -0
utils/aws/userdata.sh
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
|
| 2 |
+
#!/bin/bash
|
| 3 |
+
# AWS EC2 instance startup script https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/user-data.html
|
| 4 |
+
# This script will run only once on first instance start (for a re-start script see mime.sh)
|
| 5 |
+
# /home/ubuntu (ubuntu) or /home/ec2-user (amazon-linux) is working dir
|
| 6 |
+
# Use >300 GB SSD
|
| 7 |
+
|
| 8 |
+
cd home/ubuntu
|
| 9 |
+
if [ ! -d yolor ]; then
|
| 10 |
+
echo "Running first-time script." # install dependencies, download COCO, pull Docker
|
| 11 |
+
git clone -b paper https://github.com/WongKinYiu/yolor && sudo chmod -R 777 yolor
|
| 12 |
+
cd yolor
|
| 13 |
+
bash data/scripts/get_coco.sh && echo "Data done." &
|
| 14 |
+
sudo docker pull nvcr.io/nvidia/pytorch:21.08-py3 && echo "Docker done." &
|
| 15 |
+
python -m pip install --upgrade pip && pip install -r requirements.txt && python detect.py && echo "Requirements done." &
|
| 16 |
+
wait && echo "All tasks done." # finish background tasks
|
| 17 |
+
else
|
| 18 |
+
echo "Running re-start script." # resume interrupted runs
|
| 19 |
+
i=0
|
| 20 |
+
list=$(sudo docker ps -qa) # container list i.e. $'one\ntwo\nthree\nfour'
|
| 21 |
+
while IFS= read -r id; do
|
| 22 |
+
((i++))
|
| 23 |
+
echo "restarting container $i: $id"
|
| 24 |
+
sudo docker start $id
|
| 25 |
+
# sudo docker exec -it $id python train.py --resume # single-GPU
|
| 26 |
+
sudo docker exec -d $id python utils/aws/resume.py # multi-scenario
|
| 27 |
+
done <<<"$list"
|
| 28 |
+
fi
|
| 29 |
+
|