Skip to content

Commit

Permalink
Update base. Add helper scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
robballantyne committed Sep 2, 2023
1 parent b774ce6 commit cec3831
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 13 deletions.
2 changes: 1 addition & 1 deletion .env
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
### Build Vars ###

IMAGE_BASE="ghcr.io/ai-dock/pytorch:2.0.1-py3.10-cuda-11.8.0-base-22.04"
IMAGE_BASE="ghcr.io/ai-dock/jupyter-pytorch:2.0.1-py3.10-cuda-11.8.0-base-22.04"
IMAGE_TAG="latest"

### Horde Vars ###
Expand Down
4 changes: 2 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
workspace
config/
.env
config/authorized_keya
config/rclone
2 changes: 2 additions & 0 deletions build/COPY_ROOT/opt/ai-dock/bin/build/layer0/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ create_env() {
exported_env=/tmp/${MAMBA_DEFAULT_ENV}.yaml
micromamba env export -n ${MAMBA_DEFAULT_ENV} > "${exported_env}"
$MAMBA_CREATE -n horde --file "${exported_env}"
$MAMBA_INSTALL -n horde -c conda-forge -y \
gperftools
}

install_jupyter_kernels() {
Expand Down
28 changes: 28 additions & 0 deletions build/COPY_ROOT/opt/ai-dock/bin/get-cfqt-horde.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/bash

service="horde-webui"
port=7860

if [[ -z $CF_QUICK_TUNNELS ]]; then
printf "\n** You have not enabled Cloudflare quick tunnels **\n\n"
printf "To enable, you can do the following:\n\n"
printf "1. export CF_QUICK_TUNNELS=true\n"
printf "2. supervisorctl restart %s\n\n" $service
exit 1
fi

if [[ -f /var/log/supervisor/quicktunnel-${service}.log ]]; then
grep -b0 -a0 'trycloudflare.com' /var/log/supervisor/quicktunnel-${service}.log
if [[ $? -gt 0 ]]; then
printf "\n** Something may have gone wrong setting up the %s tunnel **\n\n" $service
printf "To set up manually you can run the following command:\n\n"
printf "cloudflared tunnel --url localhost:%s > /var/log/supervisor/quicktunnel-%s.log 2>&1 &\n\n" $port $service
fi
else
printf "** The %s tunnel has not yet started **\n\n"
if [[ -f /run/provisioning_script ]]; then
printf "The container is still being provisioned. Check the logs for progress (logtail.sh)\n\n"
else
printf "Please wait a moment and try again.\n\n"
fi
fi
43 changes: 39 additions & 4 deletions build/COPY_ROOT/opt/ai-dock/bin/preflight.sh
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,47 @@ function preflight_main() {
}

function preflight_move_to_workspace() {
dir="AI-Horde-Worker"
ws_dir=${WORKSPACE}${dir}
opt_dir="/opt/${dir}"

if [[ $WORKSPACE_MOUNTED = "true" ]]; then
if [[ ! -d ${WORKSPACE}AI-Horde-Worker ]]; then
mv /opt/AI-Horde-Worker ${WORKSPACE}
if [[ -d $ws_dir && -L $opt_dir ]]; then
printf "%s already symlinked to %s\n" $opt_dir $ws_dir
else
if [[ -L $ws_dir ]]; then
rm $ws_dir
fi
if [[ -d $ws_dir ]]; then
if [[ -d $opt_dir && ! -L $opt_dir ]]; then
printf "Backing up %s to %s_bak\n" $opt_dir $opt_dir
rm -rf ${opt_dir}_bak
mv $opt_dir ${opt_dir}_bak
fi
else
if [[ -d $opt_dir && ! -L $opt_dir ]]; then
rm -rf ${opt_dir}_bak
cp -rf $opt_dir ${opt_dir}_bak
else
rm $opt_dir
cp -rf ${opt_dir}_bak $opt_dir
fi
printf "Moving %s to %s\n" $opt_dir $ws_dir
mv $opt_dir $ws_dir
fi
printf "Creating symlink from %s to %s\n" $ws_dir $opt_dir
ln -s $ws_dir $opt_dir
fi
else
# Should not happen
if [[ ! -d $opt_dir ]]; then
cp -rf ${opt_dir}_bak $opt_dir
fi
# Should be a symlink unless user has moved things - We can't handle that
if [[ ! -e $ws_dir ]]; then
printf "Creating symlink from %s to %s\n" $opt_dir $ws_dir
ln -s $opt_dir $ws_dir
fi
rm -rf /opt/AI-Horde-Worker
ln -s ${WORKSPACE}AI-Horde-Worker /opt/AI-Horde-Worker
fi
}

Expand Down
16 changes: 10 additions & 6 deletions build/COPY_ROOT/usr/local/share/ai-dock/dreamer.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"metadata": {},
"outputs": [],
"source": [
"# Stop the dreamer service\n",
"# Stop the Dreamer service(s)\n",
"\n",
"!supervisorctl stop dreamer:*"
]
Expand All @@ -19,9 +19,9 @@
"metadata": {},
"outputs": [],
"source": [
"# Start the dreamer service\n",
"# Start the Dreamer service(s)\n",
"\n",
"!supervisorctl start dreamer:*"
"!jupyter-start-service.sh dreamer:*"
]
},
{
Expand All @@ -43,9 +43,9 @@
"metadata": {},
"outputs": [],
"source": [
"# Get secure web UI link\n",
"# Get secure Web UI link\n",
"\n",
"!grep -b0 -a0 'trycloudflare.com' /var/log/supervisor/quicktunnel-horde-webui.log"
"!get-cfqt-horde.sh"
]
},
{
Expand All @@ -54,7 +54,11 @@
"id": "08cbd5a5-0d3f-44d0-a952-cc0d0dd35a2a",
"metadata": {},
"outputs": [],
"source": []
"source": [
"# Get secure Jupyter link\n",
"\n",
"!get-cfqt-jupyter.sh"
]
}
],
"metadata": {
Expand Down

0 comments on commit cec3831

Please sign in to comment.