diff --git a/container-template/proxy/nginx.conf b/container-template/proxy/nginx.conf new file mode 100644 index 0000000..fa0760e --- /dev/null +++ b/container-template/proxy/nginx.conf @@ -0,0 +1,175 @@ +events { worker_connections 2048; } + +http { + client_max_body_size 1024M; + + + # invokeai + server { + listen 9091; + + location / { + add_header Cache-Control no-cache; + proxy_pass http://localhost:9090; + proxy_intercept_errors on; + error_page 502 =200 @502; + } + + location /README.md{ + root /usr/share/nginx/html; + } + + location @502 { + add_header Cache-Control no-cache; + root /usr/share/nginx/html; + rewrite ^(.*)$ /readme.html break; + } + } + + # Fast Stable Diffusion + web UI + Comfy UI + server { + listen 3001; + + location /ws { + proxy_http_version 1.1; + proxy_set_header Accept-Encoding gzip; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + add_header Cache-Control no-cache; + proxy_set_header Host $host; + + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Real-IP $remote_addr; + proxy_pass http://localhost:3000; + } + + location /queue/join { + proxy_http_version 1.1; + proxy_set_header Accept-Encoding gzip; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + add_header Cache-Control no-cache; + proxy_set_header Host $host; + + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Real-IP $remote_addr; + proxy_pass http://localhost:3000; + } + + location / { + add_header Cache-Control no-cache; + proxy_pass http://localhost:3000; + proxy_http_version 1.1; + proxy_set_header Accept-Encoding gzip; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Host $host; + + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header X-Forwarded-Proto $scheme; + + + proxy_intercept_errors on; + error_page 502 =200 @502; + } + + location /README.md{ + root /usr/share/nginx/html; + } + + location @502 { + add_header Cache-Control no-cache; + root /usr/share/nginx/html; + rewrite ^(.*)$ /readme.html break; + } + } + + # Oobabooga + server { + listen 7861; + + location / { + add_header Cache-Control no-cache; + proxy_pass http://localhost:7860; + proxy_intercept_errors on; + error_page 502 =200 @502; + } + + location /README.md{ + root /usr/share/nginx/html; + } + + location @502 { + add_header Cache-Control no-cache; + root /usr/share/nginx/html; + rewrite ^(.*)$ /readme.html break; + } + } + + # code-server + server { + listen 8081; + + location / { + add_header Cache-Control no-cache; + proxy_pass http://localhost:8080; + proxy_intercept_errors on; + error_page 502 =200 @502; + } + + location /README.md{ + root /usr/share/nginx/html; + } + + location @502 { + add_header Cache-Control no-cache; + root /usr/share/nginx/html; + rewrite ^(.*)$ /readme.html break; + } + } + + # vscode server + server { + listen 8001; + + location / { + add_header Cache-Control no-cache; + proxy_pass http://localhost:8000; + proxy_intercept_errors on; + error_page 502 =200 @502; + } + + location /README.md{ + root /usr/share/nginx/html; + } + + location @502 { + add_header Cache-Control no-cache; + root /usr/share/nginx/html; + rewrite ^(.*)$ /readme.html break; + } + } + + # Dockerless CLI FastAPI Server + server { + listen 7270; # "rp" in Hex ASCII + + location / { + add_header Cache-Control no-cache; + proxy_pass http://localhost:7271; + proxy_intercept_errors on; + error_page 502 =200 @502; + } + + location /README.md{ + root /usr/share/nginx/html; + } + + location @502 { + add_header Cache-Control no-cache; + root /usr/share/nginx/html; + rewrite ^(.*)$ /readme.html break; + } + } + +} diff --git a/container-template/proxy/readme.html b/container-template/proxy/readme.html new file mode 100644 index 0000000..47f2696 --- /dev/null +++ b/container-template/proxy/readme.html @@ -0,0 +1,59 @@ + + + + + 502 | README | RunPod + + + + + +
+ + + + + diff --git a/container-template/runpod.txt b/container-template/runpod.txt new file mode 100644 index 0000000..23627b7 --- /dev/null +++ b/container-template/runpod.txt @@ -0,0 +1,6 @@ + ______ ______ _ +(_____ \ (_____ \ | | + _____) ) _ _ ____ _____) )___ __| | +| __ / | | | || _ \ | ____// _ \ / _ | +| | \ \ | |_| || | | || | | |_| |( (_| | +|_| |_||____/ |_| |_||_| \___/ \____| diff --git a/container-template/start.sh b/container-template/start.sh new file mode 100644 index 0000000..837a0b3 --- /dev/null +++ b/container-template/start.sh @@ -0,0 +1,83 @@ +#!/bin/bash +set -e # Exit the script if any statement returns a non-true return value + +# ---------------------------------------------------------------------------- # +# Function Definitions # +# ---------------------------------------------------------------------------- # + +# Start nginx service +start_nginx() { + echo "Starting Nginx service..." + service nginx start +} + +# Execute script if exists +execute_script() { + local script_path=$1 + local script_msg=$2 + if [[ -f ${script_path} ]]; then + echo "${script_msg}" + bash ${script_path} + fi +} + +# Setup SSH +setup_ssh() { + if [[ $PUBLIC_KEY ]]; then + echo "Setting up SSH..." + mkdir -p ~/.ssh + echo "$PUBLIC_KEY" >> ~/.ssh/authorized_keys + chmod 700 -R ~/.ssh + + for key_type in rsa dsa ecdsa ed25519; do + key_path="/etc/ssh/ssh_host_${key_type}_key" + if [ ! -f ${key_path} ]; then + ssh-keygen -t ${key_type} -f ${key_path} -q -N '' + echo "${key_type^^} key fingerprint:" + ssh-keygen -lf ${key_path}.pub + fi + done + + service ssh start + + echo "SSH host keys:" + for key in /etc/ssh/*.pub; do + echo "Key: $key" + ssh-keygen -lf $key + done + fi +} + +# Export environment variables +export_env_vars() { + echo "Exporting environment variables..." + printenv | grep -E '^RUNPOD_|^PATH=|^_=' | awk -F = '{ print "export " $1 "=\"" $2 "\"" }' >> /etc/rp_environment + echo 'source /etc/rp_environment' >> ~/.bashrc +} + +# Start code-server +start_code_server() { + echo "Starting code-server..." + nohup code-server --bind-addr 0.0.0.0:7777 --auth none --disable-telemetry /workspace &> /code-server.log & + echo "code-server started" +} + +# ---------------------------------------------------------------------------- # +# Main Program # +# ---------------------------------------------------------------------------- # + +start_nginx + +execute_script "/pre_start.sh" "Running pre-start script..." + +echo "Pod Started" + +setup_ssh +start_code_server +export_env_vars + +execute_script "/post_start.sh" "Running post-start script..." + +echo "Start script(s) finished, pod is ready to use." + +sleep infinity diff --git a/helper-templates/verify-nccl/Dockerfile b/helper-templates/verify-nccl/Dockerfile new file mode 100644 index 0000000..c48b2d0 --- /dev/null +++ b/helper-templates/verify-nccl/Dockerfile @@ -0,0 +1,21 @@ +FROM runpod/pytorch:2.0.1-py3.10-cuda11.8.0-devel + +ENV NCCL_DEBUG=TRACE + +WORKDIR /verify-nccl + +# Install additional packages +RUN apt-get update && apt-get install -y --no-install-recommends \ + nano \ + pciutils \ + && rm -rf /var/lib/apt/lists/* + +RUN git clone https://github.com/NVIDIA/cuda-samples.git && \ + cd cuda-samples/Samples/0_Introduction/simpleP2P && \ + make + +COPY check_nccl.sh . +RUN chmod +x check_nccl.sh + +# Start Container +CMD tail -f /dev/null diff --git a/helper-templates/verify-nccl/README.md b/helper-templates/verify-nccl/README.md new file mode 100644 index 0000000..595cb08 --- /dev/null +++ b/helper-templates/verify-nccl/README.md @@ -0,0 +1,10 @@ +# Verify NCCL + + +## Running Test + +SSH into the pod and then run the following command: + +```bash +./check_nccl.sh +``` diff --git a/helper-templates/verify-nccl/check_nccl.sh b/helper-templates/verify-nccl/check_nccl.sh new file mode 100644 index 0000000..91519f2 --- /dev/null +++ b/helper-templates/verify-nccl/check_nccl.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +# Run Simple P2P +echo "Running Simple P2P" +/verify-nccl/cuda-samples/Samples/0_Introduction/simpleP2P/simpleP2P