First, clone the repository:
git clone https://github.com/tuanlda78202/cuda-docker.git
cd cuda-docker- Build the Docker image:
docker build -t cuda-dev-env -f cuda.Dockerfile .- 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 the container (only):
# without cache
docker compose build --no-cache
# with cache
docker compose build- Build and run on detach mode:
docker compose up -d- Pause the container:
docker compose stop- Stop the container:
docker compose down- Default credentials:
username: root
password: helloworld- Connect via SSH:
ssh -p 2222 root@localhostAccess the container's shell directly:
docker exec -it cuda-dev-container zsh- CUDA 12.4.1 with cuDNN
- Python 3.11
- Neovim
- JupyterHub/JupyterLab
- tmux
- zsh with Oh My Zsh
- Various development tools (git, conda, etc.)
Monitor CPU/GPU usage using either:
nvitop # GPU-specific monitoring
btop # System-wide monitoring- Start JupyterHub:
jupyterhub -f /root/jupyterhub_config.py- Access Jupyter in your browser:
http://localhost:8888
- Execute the user creation script:
docker exec -it cuda-dev-container /start-scripts/create-user.sh <username>- Follow the prompts to set up the new user's password
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_86chmod +x install.sh
./install.shRestart terminal and setup p10k configure
-
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
- The container is running (
-
For GPU issues:
- Verify GPU is visible:
nvidia-smi - Check NVIDIA Container Toolkit installation:
nvidia-container-cli info
- Verify GPU is visible:
-
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
- Check if the service is running:
-
Cannot
apt installnew packages:- Update
apt-get:apt-get update
- Update
