This directory contains Docker configuration for running the DimWit project with NVIDIA GPU support, Python, and JAX.
-
NVIDIA GPU with CUDA support
-
NVIDIA Docker Runtime (nvidia-docker2):
# Install nvidia-docker2 distribution=$(. /etc/os-release;echo $ID$VERSION_ID) curl -s -L https://nvidia.github.io/nvidia-docker/gpgkey | sudo apt-key add - curl -s -L https://nvidia.github.io/nvidia-docker/$distribution/nvidia-docker.list | sudo tee /etc/apt/sources.list.d/nvidia-docker.list sudo apt-get update sudo apt-get install -y nvidia-docker2 sudo systemctl restart docker
-
Docker Compose (v1.28.0 or higher for GPU support)
-
Build and start the container:
docker-compose up -d
-
Access the container:
docker-compose exec dimwit bash -
Stop the container:
docker-compose down
-
Build the GPU image:
docker build -t dimwit:latest . -
Run the container:
docker run --gpus all -it \ -v $(pwd):/workspace \ -v sbt-cache:/root/.sbt \ -v ivy-cache:/root/.ivy2 \ -p 8888:8888 \ dimwit:latest
Once inside the container, verify GPU access:
# Check NVIDIA driver
nvidia-smi
# Test JAX GPU support
python3 -c "import jax; print(jax.devices())"# Compile the project
sbt compile
# Run tests
sbt test
# Run examples
sbt "examples/run"
# Start SBT console
sbt console# Run Python scripts
python3 src/python/jax_helper.py
# Start Jupyter notebook
jupyter notebook --ip=0.0.0.0 --port=8888 --no-browser --allow-rootThe project directory is mounted as a volume, so changes made on your host machine are immediately reflected in the container and vice versa.
The following directories are stored in Docker volumes for faster rebuilds:
/root/.sbt- SBT cache/root/.ivy2- Ivy dependencies cache
Edit docker-compose.yml to change which GPUs are visible:
environment:
- CUDA_VISIBLE_DEVICES=0,1 # Use GPUs 0 and 1Edit Dockerfile and add packages to the pip install command:
RUN pip install numpy scipy matplotlib pandas your-package-hereThen rebuild:
docker-compose build-
Verify nvidia-docker2 is installed:
docker run --rm --gpus all nvidia/cuda:12.2.0-base-ubuntu22.04 nvidia-smi
-
Check Docker daemon configuration (
/etc/docker/daemon.json):{ "runtimes": { "nvidia": { "path": "nvidia-container-runtime", "runtimeArgs": [] } } }
Ensure CUDA libraries are in the path:
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH8888: Jupyter notebook5000: Application port (modify as needed)
Add more ports in docker-compose.yml as required.
dimwit provides two separate Dockerfiles:
- Dockerfile - GPU development image with NVIDIA JAX (~8 GB)
- Dockerfile.ci - CPU-only CI/CD image with JAX CPU (~2-3 GB)
The CPU variant is optimized for CI/CD pipelines, eliminating GPU dependencies while maintaining full functionality for build and test workflows.
- Smaller size: ~1 GB vs ~8 GB (GPU image)
- Faster pulls: 6-8x faster download times
- No GPU required: Works on standard GitHub Actions runners
- Lower costs: Reduced registry storage and bandwidth
The CI image is automatically built and published to GitHub Container Registry:
ghcr.io/marcelluethi/dimwit-ci:latest
Available tags:
latest- Most recent build from main branchsha-<commit>- Specific commit SHA for reproducible builds
Pull and run the CI image for local testing:
# Pull the image
docker pull ghcr.io/marcelluethi/dimwit-ci:latest
# Run compilation
docker run --rm -v $(pwd):/workspace ghcr.io/marcelluethi/dimwit-ci:latest sbt compile
# Interactive shell
docker run --rm -it -v $(pwd):/workspace ghcr.io/marcelluethi/dimwit-ci:latest bash
# Or build locally
docker build -f Dockerfile.ci -t dimwit-ci .Two GitHub Actions workflows manage the CI infrastructure:
Builds and pushes the CI image to GHCR when:
Dockerfile.cichanges- Build configuration changes (
build.sbt,project/) - Manually triggered via workflow dispatch
Trigger manually:
gh workflow run build-ci-image.ymlRuns on every push and pull request:
- Compiles all three modules (core, nn, examples)
- Uses the CI Docker image as container
- Caches SBT dependencies between runs
- Checks code formatting (non-blocking)
CI image (Dockerfile.ci):
Base: SBT Scala (sbtscala/scala-sbt with OpenJDK 11)
System Packages:
- OpenJDK 11
- SBT (Scala Build Tool)
- Git, curl, wget
Python Packages:
- JAX (CPU version)
- NumPy
- Matplotlib, Pandas, Scikit-learn
- Jupyter
Pre-cached:
- SBT dependencies (from
build.sbt) - Coursier/Ivy cache
Dev image (Dockerfile):
- Base:
nvcr.io/nvidia/jax:24.04-py3 - Size: ~8 GB
- JAX Backend: CUDA GPU
- NVIDIA Runtime: Required
- Use Case: Development with GPU
| Variant | Command | Size | Use Case |
|---|---|---|---|
| GPU Dev | docker build -t dimwit . |
~8 GB | Local development with GPU |
| CPU CI | docker build -f Dockerfile.ci -t dimwit-ci . |
~2-3 GB | CI/CD pipelines |
When dependencies need updates (e.g., new JAX version, Python upgrade):
- Update
Dockerfile.ciwith new versions - Trigger the rebuild workflow:
gh workflow run build-ci-image.yml
- Wait for build completion (~10-15 minutes)
- Verify the update:
docker pull ghcr.io/marcelluethi/dimwit-ci:latest docker run --rm ghcr.io/marcelluethi/dimwit-ci:latest pip list | grep jax
Image pull authentication failed:
# Login to GHCR locally
echo $GITHUB_TOKEN | docker login ghcr.io -u USERNAME --password-stdinSBT compilation fails:
- Check that
PYTHONPATHincludes/workspace/src/python - Verify JAX CPU is installed:
docker run ... python -c "import jax; print(jax.devices())"
Out of disk space:
- Clean old images:
docker system prune -a - Use specific SHA tags instead of always pulling
latest