From 5cb1f53c2fec4e1316e4f2ab331ff9ef7a31085a Mon Sep 17 00:00:00 2001 From: Dobromir Popov Date: Wed, 30 Aug 2023 21:21:27 +0000 Subject: [PATCH 1/5] added petals-ai dockerfile image source --- docker/images.petals-ai.dockerfile | 73 ++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 docker/images.petals-ai.dockerfile diff --git a/docker/images.petals-ai.dockerfile b/docker/images.petals-ai.dockerfile new file mode 100644 index 0000000..fd14a28 --- /dev/null +++ b/docker/images.petals-ai.dockerfile @@ -0,0 +1,73 @@ +# dobromirpopov/petals-ai :latest full +FROM python:slim + +# System dependencies +RUN apt-get update && apt-get install -y git && apt-get clean && rm -rf /var/lib/apt/lists/* + +# Upgrade pip +RUN pip install --upgrade pip + +# Add ENV for MODEL and HF_TOKEN +ENV MODEL_NAME=stabilityai/StableBeluga2 +ENV HF_TOKEN= +ENV DHT_PEERS= +ENV ENV_PARAMS= + +# pull petals and bake it into the image. comment for lite image +RUN git clone https://github.com/d-popov/health.petals.dev.git && cd /health.petals.dev && pip install -r requirements.txt + + +# Create the entrypoint script inside the Dockerfile +RUN echo '#!/bin/sh\n\ +INITIAL_PEERS=""\n\ +if [ -n "$DHT_PEERS" ]; then\n\ + INITIAL_PEERS="--initial_peers $DHT_PEERS"\n\ +fi\n\ +if [ ! -f "/initialized" ]; then\n\ + touch /initialized\n\ + pip install --upgrade petals\n\ + case "$MODE" in\n\ + "monitor")\n\ + git clone https://github.com/d-popov/health.petals.dev.git && \ + cd /health.petals.dev && pip install -r requirements.txt\n\ + ;;\n\ + "chat")\n\ + git clone https://github.com/petals-infra/chat.petals.dev.git && \ + cd /chat.petals.dev && pip install -r requirements.txt\n\ + ;;\n\ + "server" | "dht")\n\ + pip install git+https://github.com/bigscience-workshop/petals\n\ + ;;\n\ + esac\n\ +fi\n\ +if [ "$MODE" = "monitor" ] && [ -n "$DHT_PEERS" ]; then\n\ + echo "INITIAL_PEERS = ['$(echo $DHT_PEERS | sed "s/ /','/g")']" >> /health.petals.dev/config.py;\n\ + echo "setting initial peers to ['$(echo $DHT_PEERS | sed "s/ /','/g")']";\n\ +fi\n\ +if [ -n "$HF_TOKEN" ]; then\n\ + git config --global credential.helper store && \n\ + huggingface-cli login --token $HF_TOKEN --add-to-git-credential && \n\ + ENV_PARAMS="--use_auth_token $ENV_PARAMS"\n\ +fi\n\ +case "$MODE" in\n\ + "monitor")\n\ + cd /health.petals.dev\n\ + exec gunicorn app:app --bind 0.0.0.0:8484 --workers 4 --threads 10\n\ + ;;\n\ + "chat")\n\ + cd /chat.petals.dev\n\ + exec gunicorn app:app --bind 0.0.0.0:8484 --workers 4 --threads 10\n\ + ;;\n\ + "dht")\n\ + exec python -m petals.cli.run_dht --host_maddrs /ip4/0.0.0.0/tcp/31337 --identity_path bootstrap1.id $INITIAL_PEERS\n\ + ;;\n\ + "server" | *)\n\ + exec python -m petals.cli.run_server $ENV_PARAMS $MODEL_NAME $INITIAL_PEERS\n\ + ;;\n\ +esac' > /entrypoint.sh && chmod +x /entrypoint.sh + +# if using separate entrypoint file: +# COPY entrypoint.sh /entrypoint.sh +# RUN chmod +x /entrypoint.sh TEST + +ENTRYPOINT ["/entrypoint.sh"] From 7facee3e5605bf0f7c2ada2c419ac66e3acb9863 Mon Sep 17 00:00:00 2001 From: Dobromir Popov Date: Wed, 30 Aug 2023 22:47:15 +0000 Subject: [PATCH 2/5] trying to fix anoyying error with dht peers --- docker/images.petals-ai.dockerfile | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/docker/images.petals-ai.dockerfile b/docker/images.petals-ai.dockerfile index fd14a28..12de3fb 100644 --- a/docker/images.petals-ai.dockerfile +++ b/docker/images.petals-ai.dockerfile @@ -1,4 +1,6 @@ # dobromirpopov/petals-ai :latest full +# dobromirpopov/petals-ai:full +# FROM python:slim # System dependencies @@ -16,20 +18,18 @@ ENV ENV_PARAMS= # pull petals and bake it into the image. comment for lite image RUN git clone https://github.com/d-popov/health.petals.dev.git && cd /health.petals.dev && pip install -r requirements.txt - # Create the entrypoint script inside the Dockerfile RUN echo '#!/bin/sh\n\ -INITIAL_PEERS=""\n\ -if [ -n "$DHT_PEERS" ]; then\n\ - INITIAL_PEERS="--initial_peers $DHT_PEERS"\n\ -fi\n\ +echo "Script is starting..."\n\ +echo "MODE is set to: $MODE"\n\ +echo "DHT_PEERS is set to: $DHT_PEERS"\n\ if [ ! -f "/initialized" ]; then\n\ touch /initialized\n\ pip install --upgrade petals\n\ case "$MODE" in\n\ "monitor")\n\ - git clone https://github.com/d-popov/health.petals.dev.git && \ - cd /health.petals.dev && pip install -r requirements.txt\n\ + # git clone https://github.com/d-popov/health.petals.dev.git && \ + # cd /health.petals.dev && pip install -r requirements.txt\n\ ;;\n\ "chat")\n\ git clone https://github.com/petals-infra/chat.petals.dev.git && \ @@ -41,14 +41,25 @@ if [ ! -f "/initialized" ]; then\n\ esac\n\ fi\n\ if [ "$MODE" = "monitor" ] && [ -n "$DHT_PEERS" ]; then\n\ - echo "INITIAL_PEERS = ['$(echo $DHT_PEERS | sed "s/ /','/g")']" >> /health.petals.dev/config.py;\n\ - echo "setting initial peers to ['$(echo $DHT_PEERS | sed "s/ /','/g")']";\n\ + FORMATTED_PEERS=$(echo $DHT_PEERS | sed "s/ /','/g")\n\ + echo "Debug FORMATTED_PEERS: $FORMATTED_PEERS"\n\ + echo "INITIAL_PEERS = ['$FORMATTED_PEERS']" >> /health.petals.dev/config.py\n\ + #echo "INITIAL_PEERS = ['$(echo $DHT_PEERS | sed "s/ /','/g")']" >> /health.petals.dev/config.py;\n\ + echo "INITIAL_PEERS = ['"$FORMATTED_PEERS"']" >> /health.petals.dev/config.py\n\ + #echo "monitorring private swarm. Initial peers set to ['$(echo $DHT_PEERS | sed "s/ /','/g")']"\n\ + echo "monitoring private swarm. Initial peers set to ['"$FORMATTED_PEERS"']"\n\ +else \n\ + echo "monitor has no DHT peers. Monitoring public swarm."\n\ fi\n\ if [ -n "$HF_TOKEN" ]; then\n\ git config --global credential.helper store && \n\ huggingface-cli login --token $HF_TOKEN --add-to-git-credential && \n\ ENV_PARAMS="--use_auth_token $ENV_PARAMS"\n\ fi\n\ +INITIAL_PEERS=""\n\ +if [ -n "$DHT_PEERS" ]; then\n\ + INITIAL_PEERS="--initial_peers $DHT_PEERS"\n\ +fi\n\ case "$MODE" in\n\ "monitor")\n\ cd /health.petals.dev\n\ From 86598c59223c4135d4d7d4e0d13763f896ad9a98 Mon Sep 17 00:00:00 2001 From: Dobromir Popov Date: Wed, 30 Aug 2023 23:27:52 +0000 Subject: [PATCH 3/5] more tries to fix dht formatting --- docker/images.petals-ai.dockerfile | 47 +++++++++++++++++++----------- 1 file changed, 30 insertions(+), 17 deletions(-) diff --git a/docker/images.petals-ai.dockerfile b/docker/images.petals-ai.dockerfile index 12de3fb..48d4aa0 100644 --- a/docker/images.petals-ai.dockerfile +++ b/docker/images.petals-ai.dockerfile @@ -1,6 +1,6 @@ # dobromirpopov/petals-ai :latest full # dobromirpopov/petals-ai:full -# + FROM python:slim # System dependencies @@ -18,11 +18,34 @@ ENV ENV_PARAMS= # pull petals and bake it into the image. comment for lite image RUN git clone https://github.com/d-popov/health.petals.dev.git && cd /health.petals.dev && pip install -r requirements.txt +# FORMATTED_PEERS=$$(echo $$DHT_PEERS | sed "s/[^ ]\+/\'&\'/g")\n\ +# FORMATTED_PEERS=$$(echo $$DHT_PEERS | sed "s/[^ ]\\+/\\'&\\'/g")\n\ + # Create the entrypoint script inside the Dockerfile RUN echo '#!/bin/sh\n\ echo "Script is starting..."\n\ echo "MODE is set to: $MODE"\n\ -echo "DHT_PEERS is set to: $DHT_PEERS"\n\ +if [ "$MODE" = "monitor" ] && [ -n "$DHT_PEERS" ]; then\n\ + echo "DHT_PEERS is set to: $DHT_PEERS"\n\ + FORMATTED_PEERS=$DHT_PEERS\n\ + echo "Debug FORMATTED_PEERS: $FORMATTED_PEERS"\n\ +## +# # Convert space-separated string to comma-separated string\n\ +# TEMP_PEERS=$(echo $DHT_PEERS | tr " " ",")\n\ +# # Add single quotes around each element and make it Python list format\n\ +# FORMATTED_PEERS=$(echo $TEMP_PEERS | sed "s/\\([^,]*\\)/\'\\1\'/g")\n\ +# FORMATTED_PEERS="[$FORMATTED_PEERS]"\n\ +## + echo "monitoring PRIVATE swarm. Initial F peers set to $FORMATTED_PEERS"\n\ + echo "monitoring PRIVATE swarm. Initial peers set to $DHT_PEERS"\n\ + echo "monitoring PRIVATE swarm. Initial peers set to ['"$DHT_PEERS"']"\n\ + + echo "INITIAL_PEERS = ['$DHT_PEERS']" >> /health.petals.dev/config.py\n\ + echo "FORMATTED_PEERS = $FORMATTED_PEERS" >> /health.petals.dev/config.py\n\ +else \n\ + echo "monitor has no DHT peers. Monitoring public swarm."\n\ +fi\n\ + if [ ! -f "/initialized" ]; then\n\ touch /initialized\n\ pip install --upgrade petals\n\ @@ -40,25 +63,15 @@ if [ ! -f "/initialized" ]; then\n\ ;;\n\ esac\n\ fi\n\ -if [ "$MODE" = "monitor" ] && [ -n "$DHT_PEERS" ]; then\n\ - FORMATTED_PEERS=$(echo $DHT_PEERS | sed "s/ /','/g")\n\ - echo "Debug FORMATTED_PEERS: $FORMATTED_PEERS"\n\ - echo "INITIAL_PEERS = ['$FORMATTED_PEERS']" >> /health.petals.dev/config.py\n\ - #echo "INITIAL_PEERS = ['$(echo $DHT_PEERS | sed "s/ /','/g")']" >> /health.petals.dev/config.py;\n\ - echo "INITIAL_PEERS = ['"$FORMATTED_PEERS"']" >> /health.petals.dev/config.py\n\ - #echo "monitorring private swarm. Initial peers set to ['$(echo $DHT_PEERS | sed "s/ /','/g")']"\n\ - echo "monitoring private swarm. Initial peers set to ['"$FORMATTED_PEERS"']"\n\ -else \n\ - echo "monitor has no DHT peers. Monitoring public swarm."\n\ -fi\n\ + if [ -n "$HF_TOKEN" ]; then\n\ git config --global credential.helper store && \n\ huggingface-cli login --token $HF_TOKEN --add-to-git-credential && \n\ ENV_PARAMS="--use_auth_token $ENV_PARAMS"\n\ fi\n\ -INITIAL_PEERS=""\n\ +INITIAL_PEERS_ARG=""\n\ if [ -n "$DHT_PEERS" ]; then\n\ - INITIAL_PEERS="--initial_peers $DHT_PEERS"\n\ + INITIAL_PEERS_ARG="--initial_peers $DHT_PEERS"\n\ fi\n\ case "$MODE" in\n\ "monitor")\n\ @@ -70,10 +83,10 @@ case "$MODE" in\n\ exec gunicorn app:app --bind 0.0.0.0:8484 --workers 4 --threads 10\n\ ;;\n\ "dht")\n\ - exec python -m petals.cli.run_dht --host_maddrs /ip4/0.0.0.0/tcp/31337 --identity_path bootstrap1.id $INITIAL_PEERS\n\ + exec python -m petals.cli.run_dht --host_maddrs /ip4/0.0.0.0/tcp/31337 --identity_path bootstrap1.id $INITIAL_PEERS_ARG\n\ ;;\n\ "server" | *)\n\ - exec python -m petals.cli.run_server $ENV_PARAMS $MODEL_NAME $INITIAL_PEERS\n\ + exec python -m petals.cli.run_server $ENV_PARAMS $MODEL_NAME $INITIAL_PEERS_ARG\n\ ;;\n\ esac' > /entrypoint.sh && chmod +x /entrypoint.sh From 2bdf2946ab609d8fd250462e27fe32b797b4b7b5 Mon Sep 17 00:00:00 2001 From: Dobromir Popov Date: Wed, 30 Aug 2023 23:40:39 +0000 Subject: [PATCH 4/5] fixed DHT formatting !!!! --- docker/images.petals-ai.dockerfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/docker/images.petals-ai.dockerfile b/docker/images.petals-ai.dockerfile index 48d4aa0..dddfc9c 100644 --- a/docker/images.petals-ai.dockerfile +++ b/docker/images.petals-ai.dockerfile @@ -27,7 +27,7 @@ echo "Script is starting..."\n\ echo "MODE is set to: $MODE"\n\ if [ "$MODE" = "monitor" ] && [ -n "$DHT_PEERS" ]; then\n\ echo "DHT_PEERS is set to: $DHT_PEERS"\n\ - FORMATTED_PEERS=$DHT_PEERS\n\ + FORMATTED_PEERS=[$DHT_PEERS]\n\ echo "Debug FORMATTED_PEERS: $FORMATTED_PEERS"\n\ ## # # Convert space-separated string to comma-separated string\n\ @@ -38,9 +38,9 @@ if [ "$MODE" = "monitor" ] && [ -n "$DHT_PEERS" ]; then\n\ ## echo "monitoring PRIVATE swarm. Initial F peers set to $FORMATTED_PEERS"\n\ echo "monitoring PRIVATE swarm. Initial peers set to $DHT_PEERS"\n\ - echo "monitoring PRIVATE swarm. Initial peers set to ['"$DHT_PEERS"']"\n\ + echo "monitoring PRIVATE swarm. Initial peers array set to [$DHT_PEERS]"\n\ - echo "INITIAL_PEERS = ['$DHT_PEERS']" >> /health.petals.dev/config.py\n\ + echo "INITIAL_PEERS = [$DHT_PEERS]" >> /health.petals.dev/config.py\n\ echo "FORMATTED_PEERS = $FORMATTED_PEERS" >> /health.petals.dev/config.py\n\ else \n\ echo "monitor has no DHT peers. Monitoring public swarm."\n\ From 5c7af6ba15cf14f74e7fe6bf3c868cf62034d2e7 Mon Sep 17 00:00:00 2001 From: Dobromir Popov Date: Wed, 30 Aug 2023 23:40:59 +0000 Subject: [PATCH 5/5] more commands and scripts --- _CONFIGS/docker config.md | 27 +++++++++++++++++++++++++++ linux/tasks/rsync local folders.sh | 27 +++++++++++++++++++++++++++ linux/tasks/start_vnc.sh | 7 +++++++ 3 files changed, 61 insertions(+) create mode 100644 _CONFIGS/docker config.md create mode 100644 linux/tasks/rsync local folders.sh create mode 100644 linux/tasks/start_vnc.sh diff --git a/_CONFIGS/docker config.md b/_CONFIGS/docker config.md new file mode 100644 index 0000000..ed2d9fb --- /dev/null +++ b/_CONFIGS/docker config.md @@ -0,0 +1,27 @@ +# /etc/docker/daemon.json at .10 +{ + "runtimes": { + "nvidia": { + "args": [], + "path": "/usr/bin/nvidia-container-runtime" + } + }, + "storage-driver": "overlay2", + "data-root": "/mnt/appx/docker_host" +} + + +# /etc/docker/daemon.json at .11 + + "runtimes": { + "nvidia": { + "args": [], + "path": "nvidia-container-runtime" + } + }, + "data-root": "/mnt/apps/docker" +} + + + + diff --git a/linux/tasks/rsync local folders.sh b/linux/tasks/rsync local folders.sh new file mode 100644 index 0000000..7a9fe4f --- /dev/null +++ b/linux/tasks/rsync local folders.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +source_dir="/mnt/storage/nextcloud/popov/files/PORTABLE/" +destination_dir="/mnt/nas4T/DOBY/Portable/" + +# Check if the source directory exists +if [ ! -d "$source_dir" ]; then + echo "Source directory not found: $source_dir" + exit 1 +fi + +# Check if the destination directory exists +if [ ! -d "$destination_dir" ]; then + echo "Destination directory not found: $destination_dir" + exit 1 +fi + +# Loop through the subdirectories in the source directory +for subdir in "$source_dir"/*; do + if [ -d "$subdir" ]; then + subfolder=$(basename "$subdir") + echo "Syncing $subfolder..." + rsync -ah --info=progress2 --relative --rsync-path="mkdir -p '$destination_dir' && rsync" "$source_dir$subfolder/" "$destination_dir" + fi +done + +echo "All subfolders synced." diff --git a/linux/tasks/start_vnc.sh b/linux/tasks/start_vnc.sh new file mode 100644 index 0000000..680743e --- /dev/null +++ b/linux/tasks/start_vnc.sh @@ -0,0 +1,7 @@ +#!/bin/bash +vncserver :1 -geometry 1920x1080 + +#and novnc: +/usr/share/novnc/utils/launch.sh --vnc localhost:5901 + +