Skip to content

tuanlda78202/cuda-docker

Repository files navigation

CUDA Docker for Server

Installation | Container Access | Features | Customization

image

Installation Steps

First, clone the repository:

git clone https://github.com/tuanlda78202/cuda-docker.git
cd cuda-docker

Build using Docker Directly

  1. Build the Docker image:
docker build -t cuda-dev-env -f cuda.Dockerfile .
  1. Running the container from image:
docker run -d \
  --name cuda-dev-container \
  --gpus all \
  -p 2222:2222 \
  -p 8888:8888 \
  -v /dev/shm:/dev/shm \
  -v "$(pwd)/workspace:/root/workspace" \
  -v "$HOME/.ssh:/root/.ssh" \
  -v "$HOME/.gitconfig:/root/.gitconfig" \
  -v "$(pwd)/data:/root/data" \
  -v "$(pwd)/models:/root/models" \
  cuda-dev-env

Build using Docker Compose

  1. Build the container (only):
# without cache
docker compose build --no-cache
# with cache
docker compose build
  1. Build and run on detach mode:
docker compose up -d
  1. Pause the container:
docker compose stop
  1. Stop the container:
docker compose down

Accessing the Container

SSH Access

  1. Default credentials:
username: root
password: helloworld
  1. Connect via SSH:
ssh -p 2222 root@localhost

Direct Container Access

Access the container's shell directly:

docker exec -it cuda-dev-container zsh

Development Environment Features

Included Tools

  • CUDA 12.4.1 with cuDNN
  • Python 3.11
  • Neovim
  • JupyterHub/JupyterLab
  • tmux
  • zsh with Oh My Zsh
  • Various development tools (git, conda, etc.)

Resource Monitoring

Monitor CPU/GPU usage using either:

nvitop     # GPU-specific monitoring
btop       # System-wide monitoring

Jupyter Services

  1. Start JupyterHub:
jupyterhub -f /root/jupyterhub_config.py
  1. Access Jupyter in your browser:
http://localhost:8888

Customization

Adding New Users

  1. Execute the user creation script:
docker exec -it cuda-dev-container /start-scripts/create-user.sh <username>
  1. Follow the prompts to set up the new user's password

Updating CUDA Configurations

The clangd configuration for CUDA is located at /root/.config/clangd/config.yaml. Modify the GPU architecture as needed:

CompileFlags:
  Add:
    - --cuda-gpu-arch=sm_86

Install extensions locally

chmod +x install.sh
./install.sh

Restart terminal and setup p10k configure

Troubleshooting

  1. If you can't connect via SSH, ensure:

    • The container is running (docker ps)
    • Port 2222 is not being used by another service
    • Your firewall allows connections to port 2222
  2. For GPU issues:

    • Verify GPU is visible: nvidia-smi
    • Check NVIDIA Container Toolkit installation: nvidia-container-cli info
  3. For Jupyter access issues:

    • Check if the service is running: ps aux | grep jupyter
    • Verify port 8888 is not blocked
    • Check logs: docker logs cuda-dev-container
  4. Cannot apt install new packages:

    • Update apt-get: apt-get update

About

cuda docker for server

Topics

Resources

Stars

Watchers

Forks

Contributors