Skip to content

Firestorm01X2/cuda-ssh

Repository files navigation

cuda-ssh

GPU-enabled SSH server in Docker (CUDA/OpenCL). Minimal, production-friendly setup to expose SSH on host port 2222 and persist user home data via a named volume.

Requirements

  • Docker (Windows: Docker Desktop with WSL2)
  • NVIDIA GPU + drivers
  • NVIDIA Container Toolkit
  • SSH client

Quick start (Windows)

  • Build and start everything:
.\restart.bat
  • Stop services:
.\stop.bat

Build image

docker build -t cuda-ssh .

Run with docker-compose (recommended)

docker-compose up -d

Run with Docker CLI

  • Basic:
docker run --gpus all -d -p 2222:22 cuda-ssh
  • With host volumes mapped to user homes:
docker run --gpus all -d -p 2222:22 \
  -v /path/on/host/user1:/home/user1 \
  -v /path/on/host/user2:/home/user2 \
  cuda-ssh

CUDA/OpenCL runtime flags

docker run -d --gpus all -p 2222:22 \
  -e NVIDIA_VISIBLE_DEVICES=all \
  -e NVIDIA_DRIVER_CAPABILITIES=compute,utility \
  cuda-ssh

SSH access

ssh user1@localhost -p 2222
ssh user2@localhost -p 2222

Add users in a running container (superusers only)

  • Enter the container with a sudo-capable account (one from superusers.txt):
    docker exec -it <container_id> bash
  • Add or update a user and optionally grant sudo:
    sudo /root/create_users.sh add alice 'Passw0rd!' --sudo
  • The script updates AllowUsers and sends a HUP to sshd, so SSH access for the new user becomes available immediately.

Sync local examples into the container (without recreating the /home volume)

This project uses a named volume for /home, so changes to examples/ copied into the image won't appear in an existing volume automatically.

To solve this, docker-compose.yml bind-mounts local ./examples read-only into the container at /mnt/examples-src, and the container runs /root/sync_examples.sh on startup to mirror them into /home/examples.

Notes:

  • Sync is mirror-like (uses --delete): files removed locally from ./examples are removed from /home/examples.
  • You can run it manually in a running container: docker exec -it <container_id_or_name> bash -lc "/root/sync_examples.sh"

Enter the container

docker exec -it <container_id> /bin/bash

Persisted data (named volume)

The named volume is fixed: cuda-ssh_home-data.

  • Create a backup (in the current directory), preserving permissions:
docker run --rm -v cuda-ssh_home-data:/from -v ${PWD}:/backup \
  alpine sh -c "cd /from && tar -czf /backup/home-data.tar.gz ."
  • Restore on another machine:
docker volume create cuda-ssh_home-data
docker run --rm -v cuda-ssh_home-data:/to -v ${PWD}:/backup \
  alpine sh -c "cd /to && tar -xzf /backup/home-data.tar.gz"
  • Inspect the volume mountpoint (optional):
docker volume inspect cuda-ssh_home-data --format "{{.Mountpoint}}"
  • Windows (Docker Desktop, WSL2) physical paths:
    • \\wsl$\docker-desktop-data\data\docker\volumes\cuda-ssh_home-data\_data
    • On some versions: \\wsl$\docker-desktop-data\version-pack-data\community\docker\volumes\cuda-ssh_home-data\_data

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •