-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
63 additions
and
53 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,6 @@ on: | |
inputs: | ||
runner: | ||
type: string | ||
default: self-hosted | ||
required: true | ||
description: 'Runner Name' | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,43 +2,54 @@ | |
# Author: Ryoichi Ando ([email protected]) | ||
# License: Apache v2.0 | ||
|
||
# Check if $1 is not set (empty) | ||
if [ -z "$1" ]; then | ||
echo "Error: Argument not provided" | ||
exit 1 | ||
fi | ||
# set working directory | ||
WORKDIR=/tmp/vast-ci | ||
|
||
# set api key | ||
VAST_API_KEY=$1 | ||
if [ -d "$WORKDIR" ]; then | ||
echo "$WORKDIR already exists." | ||
cd $WORKDIR | ||
source $WORKDIR/venv/bin/activate | ||
else | ||
echo "Setting up..." | ||
|
||
# create a working directory | ||
WORKDIR=/tmp/vast-ci | ||
rm -rf $WORKDIR | ||
mkdir -p $WORKDIR | ||
cd $WORKDIR | ||
# Check if $1 is not set (empty) | ||
if [ -z "$1" ]; then | ||
echo "Error: Argument not provided" | ||
exit 1 | ||
fi | ||
|
||
# set api key | ||
VAST_API_KEY=$1 | ||
|
||
# create virtual env | ||
echo "create virtual env" | ||
python3 -m venv $WORKDIR/venv | ||
# create a working directory | ||
rm -rf $WORKDIR | ||
mkdir -p $WORKDIR | ||
cd $WORKDIR | ||
|
||
# activate virtual env | ||
source $WORKDIR/venv/bin/activate | ||
# create virtual env | ||
echo "create virtual env" | ||
python3 -m venv $WORKDIR/venv | ||
|
||
# install requests | ||
echo "install requests" | ||
pip3 install requests | ||
# activate virtual env | ||
source $WORKDIR/venv/bin/activate | ||
|
||
# download the vast CLI | ||
echo "download vast CLI" | ||
wget https://raw.githubusercontent.com/vast-ai/vast-python/master/vast.py -O vast | ||
chmod +x vast | ||
# install requests | ||
echo "install requests" | ||
pip3 install requests | ||
|
||
# set api key | ||
./vast set api-key $VAST_API_KEY | ||
# download the vast CLI | ||
echo "download vast CLI" | ||
wget https://raw.githubusercontent.com/vast-ai/vast-python/master/vast.py -O vast | ||
chmod +x vast | ||
|
||
# generate a new SSH key | ||
echo "generate a new SSH key" | ||
ssh-keygen -q -t ed25519 -N '' -f $WORKDIR/id_ed25519 | ||
# set api key | ||
./vast set api-key $VAST_API_KEY | ||
|
||
# generate a new SSH key | ||
echo "generate a new SSH key" | ||
ssh-keygen -q -t ed25519 -N '' -f $WORKDIR/id_ed25519 | ||
|
||
fi | ||
|
||
# your local public ssh key | ||
SSH_PUB_KEY=$WORKDIR/id_ed25519.pub | ||
|
@@ -60,23 +71,23 @@ MAX_RETRIES=10 | |
|
||
# https://vast.ai/docs/cli/commands | ||
query="" | ||
query+="reliability > 0.99 " # high reliability | ||
query+="num_gpus=1 " # single gpu | ||
query+="gpu_name=$GPU_NAME " # GPU | ||
query+="reliability > 0.99 " # high reliability | ||
query+="num_gpus=1 " # single gpu | ||
query+="gpu_name=$GPU_NAME " # GPU | ||
query+="driver_version >= 535.154.05 " # driver version | ||
query+="cuda_vers >= 11.8 " # cuda version | ||
query+="compute_cap >= 750 " # compute capability | ||
query+="geolocation in [US] " # country US,CA,IS,TW,VN,GB,NO | ||
query+="rentable=True " # rentable only | ||
query+="verified=True " # verified by vast.ai | ||
query+="disk_space >= $DISK_SPACE " # available disk space | ||
query+="dph <= 1.0 " # less than $1 per hour | ||
query+="duration >= 2 " # at least 2 days online | ||
query+="inet_up >= 200 " # at least 200MB/s upload | ||
query+="inet_down >= 200 " # at least 200MB/s download | ||
query+="cpu_ram >= 32 " # at least 32GB ram | ||
query+="inet_up_cost <= 0.25 " # upload cheaper than $0.25/GB | ||
query+="inet_down_cost <= 0.25 " # download cheaper than $0.25/GB | ||
query+="cuda_vers >= 11.8 " # cuda version | ||
query+="compute_cap >= 750 " # compute capability | ||
query+="geolocation in [US] " # country US,CA,IS,TW,VN,GB,NO | ||
query+="rentable=True " # rentable only | ||
query+="verified=True " # verified by vast.ai | ||
query+="disk_space >= $DISK_SPACE " # available disk space | ||
query+="dph <= 1.0 " # less than $1 per hour | ||
query+="duration >= 2 " # at least 2 days online | ||
query+="inet_up >= 200 " # at least 200MB/s upload | ||
query+="inet_down >= 200 " # at least 200MB/s download | ||
query+="cpu_ram >= 32 " # at least 32GB ram | ||
query+="inet_up_cost <= 0.25 " # upload cheaper than $0.25/GB | ||
query+="inet_down_cost <= 0.25 " # download cheaper than $0.25/GB | ||
|
||
TRIED_LIST=() | ||
while true; do | ||
|
@@ -85,14 +96,14 @@ while true; do | |
if [ ${#TRIED_LIST[@]} -gt 0 ]; then | ||
condition="host_id not in [" | ||
for host_id in "${TRIED_LIST[@]}"; do | ||
condition+="$host_id," | ||
condition+="$host_id," | ||
done | ||
condition="${condition%,}" | ||
condition+="]" | ||
else | ||
condition="" | ||
fi | ||
|
||
OFFER_CMD="./vast search offers \"$query $condition\" -o 'dph' --raw" | ||
echo $OFFER_CMD | ||
OFFER=$(eval $OFFER_CMD) | ||
|
@@ -128,7 +139,7 @@ while true; do | |
fi | ||
|
||
# write down the delete command | ||
echo "source $WORKDIR/venv/bin/activate; $WORKDIR/vast destroy instance $INSTANCE_ID" > $WORKDIR/delete-instance.sh | ||
echo "source $WORKDIR/venv/bin/activate; $WORKDIR/vast destroy instance $INSTANCE_ID" >$WORKDIR/delete-instance.sh | ||
chmod +x $WORKDIR/delete-instance.sh | ||
|
||
# register ssh key | ||
|
@@ -137,13 +148,13 @@ while true; do | |
|
||
# write the ssh command to a file | ||
ssh_command="ssh -i $WORKDIR/id_ed25519 -o StrictHostKeyChecking=no -o ConnectTimeout=5 $(./vast ssh-url $INSTANCE_ID)" | ||
echo "$ssh_command \$@" > $WORKDIR/ssh-command.sh | ||
echo "$ssh_command \$@" >$WORKDIR/ssh-command.sh | ||
chmod +x $WORKDIR/ssh-command.sh | ||
|
||
# write the rsync command to a file | ||
port=$(echo $(./vast ssh-url $INSTANCE_ID) | sed -E 's/^.*:(.*)$/\1/') | ||
hostname=$(echo $(./vast ssh-url $INSTANCE_ID) | sed -E 's/^[a-zA-Z]+:\/\/[a-zA-Z0-9._-]+@([^:]+):.*/\1/') | ||
echo "rsync -avz --exclude='.git' --exclude='asset' -e \"ssh -i $WORKDIR/id_ed25519 -o StrictHostKeyChecking=no -p $port\" . root@${hostname}:/root/ppf-contact-solver" > $WORKDIR/rsync-command.sh | ||
echo "rsync -avz --exclude='.git' --exclude='asset' -e \"ssh -i $WORKDIR/id_ed25519 -o StrictHostKeyChecking=no -p $port\" . root@${hostname}:/root/ppf-contact-solver" >$WORKDIR/rsync-command.sh | ||
chmod +x $WORKDIR/rsync-command.sh | ||
|
||
# Loop until SSH connection is successful | ||
|
@@ -170,4 +181,5 @@ while true; do | |
if [ "$ssh_ready" = true ]; then | ||
break | ||
fi | ||
done | ||
done | ||
|