Initial RPS CUDA implementation

This commit is contained in:
Skeleton bootstrap 2026-11-26 09:07:21 +03:00
commit 8d583036d0
33 changed files with 2968 additions and 0 deletions

18
scripts/benchmark.py Normal file
View file

@ -0,0 +1,18 @@
"""Measure all six configurations specified in §8.5 on the GPU host."""
import json
import subprocess
import sys
import tempfile
from pathlib import Path
root = Path(__file__).resolve().parent.parent
config = json.loads((root / "config.example.json").read_bytes())
binary = Path(sys.argv[1]).resolve() if len(sys.argv) > 1 else root / "build/rps-server"
for width, height in ((1024, 48), (4096, 3072), (8192, 6144)):
for n in (4, 8):
config["simulation"].update(width=width, height=height, neighbors=n)
config["view"]["roi"].update(width=width, height=height)
with tempfile.NamedTemporaryFile(mode="w", suffix=".json") as f:
json.dump(config, f)
f.flush()
subprocess.run([binary, "--benchmark", f.name], check=True)

11
scripts/install-debian.sh Normal file
View file

@ -0,0 +1,11 @@
#!/bin/sh
set -eu
export DEBIAN_FRONTEND=noninteractive
# Add the Debian components containing the packaged NVIDIA driver and toolkit.
if ! grep -Eq '^Components: .*non-free([[:space:]]|$)' /etc/apt/sources.list.d/debian.sources; then
sed -i.rps-original '/^Components: main$/s/$/ contrib non-free non-free-firmware/' /etc/apt/sources.list.d/debian.sources
fi
apt-get update
apt-get install -y --no-install-recommends "linux-headers-$(uname -r)" nvidia-driver nvidia-smi nvidia-cuda-toolkit build-essential cmake libssl-dev nlohmann-json3-dev openssl
modprobe nvidia
nvidia-smi -L

12
scripts/start-server.sh Normal file
View file

@ -0,0 +1,12 @@
#!/bin/sh
# Run in the source directory on infra-gpu.
set -eu
umask 077
certdir="${XDG_CONFIG_HOME:-$HOME/.config}/rps-cuda"
mkdir -p "$certdir"
if [ ! -e "$certdir/server.key" ] && [ ! -e "$certdir/server.crt" ]; then
openssl req -x509 -newkey ec -pkeyopt ec_paramgen_curve:P-256 -nodes -days 365 -subj /CN=infra-gpu \
-addext subjectAltName=DNS:infra-gpu -addext extendedKeyUsage=serverAuth \
-keyout "$certdir/server.key" -out "$certdir/server.crt"
fi
exec ./build/rps-server --listen 127.0.0.1:7443 --tls-key "$certdir/server.key" --tls-cert "$certdir/server.crt"

28
scripts/tunnel.sh Normal file
View file

@ -0,0 +1,28 @@
#!/bin/sh
# ./scripts/tunnel.sh [ssh-alias] [local-port]
set -eu
alias_name=${1:-infra-gpu}
port=${2:-${RPS_SOCKS_PORT:-11080}}
case "$alias_name" in ""|-*|*[!A-Za-z0-9_.-]*) echo "Invalid SSH alias" >&2; exit 2;; esac
case "$port" in ""|*[!0-9]*) echo "Invalid local port" >&2; exit 2;; esac
if [ "$#" -gt 2 ] || [ "$port" -lt 1 ] || [ "$port" -gt 65535 ]; then
echo "Usage: tunnel.sh [ssh-alias] [port 1..65535]" >&2
exit 2
fi
dir="${XDG_CACHE_HOME:-$HOME/Library/Caches}/rps-cuda"
umask 077
mkdir -p "$dir"
socket_name=$alias_name
if [ "$port" != 11080 ]; then socket_name="$alias_name-$port"; fi
sock="${RPS_CONTROL_PATH:-$dir/$socket_name.sock}"
set --
if [ -n "${RPS_SSH_CONFIG:-}" ]; then
set -- -F "$RPS_SSH_CONFIG"
elif [ -f "$dir/reinstalled.conf" ]; then
set -- -F "$dir/reinstalled.conf"
fi
if ! ssh "$@" -S "$sock" -O check "$alias_name" 2>/dev/null; then
ssh "$@" -o ClearAllForwardings=no -o ExitOnForwardFailure=yes \
-o ServerAliveInterval=30 -MNf -S "$sock" -D "127.0.0.1:$port" "$alias_name"
fi
printf 'SOCKS5 127.0.0.1:%s via %s\nControl socket: %s\n' "$port" "$alias_name" "$sock"