Skip to main content
🎓 Claude Code Masterclass Learn AI-assisted development on Udemy — plus the companion book on Leanpub & Amazon. Start Learning
Fix Docker GPU Device Driver Error
DevOps

Fix Docker GPU Device Driver Error

Docker GPU passthrough failing? Install nvidia-container-toolkit, configure runtime, and set proper device capabilities.

LB
Luca Berton
· 1 min read

The Error

When working with Docker, you may encounter this error:

could not select device driver with capabilities gpu

This is one of the most common Docker issues. Here’s how to diagnose and fix it.

Common Causes

1. Configuration Issues

Most Docker errors stem from configuration problems:

  • Incorrect Dockerfile syntax or build context
  • Wrong docker-compose.yml settings
  • Missing environment variables or secrets

2. Resource Constraints

Docker containers share host resources:

# Check Docker disk usage
docker system df

# Check container resource usage
docker stats --no-stream

3. Networking Issues

Container networking can be tricky:

# List networks
docker network ls

# Inspect a network
docker network inspect bridge

# Check container connectivity
docker exec -it <container> ping <target>

Step-by-Step Fix

Step 1: Check Container Status

# List all containers (including stopped)
docker ps -a

# Check container logs
docker logs <container-name> --tail 50

# Inspect container details
docker inspect <container-name>

Step 2: Diagnose the Issue

# Check Docker daemon logs
journalctl -u docker.service --since "1 hour ago"

# Check Docker system info
docker info

# Check for resource issues
docker system df -v

Step 3: Apply the Fix

Based on your diagnosis:

# Restart Docker daemon
sudo systemctl restart docker

# Clean up unused resources
docker system prune -f

# Rebuild without cache if needed
docker build --no-cache -t myapp .

Step 4: Verify

# Start container and watch logs
docker compose up -d && docker compose logs -f

# Health check
docker inspect --format='{{.State.Health.Status}}' <container>

Prevention

  1. Use Docker Compose for multi-container setups
  2. Implement health checks in all containers
  3. Set resource limits (memory, CPU)
  4. Configure log rotation to prevent disk fill
  5. Use .dockerignore to keep builds fast

Want to level up your container skills? Check out Luca Berton’s courses for practical DevOps training.

Free 30-min AI & Cloud consultation

Book Now