From a81dc690e51bb818165559d2315c8929ffbd5493 Mon Sep 17 00:00:00 2001 From: Florian Egger Date: Tue, 26 May 2026 15:49:13 +0200 Subject: [PATCH] Add Docker setup and build PyG extensions from source for ROCm - Install build tools (build-essential, cmake, ninja-build) in Dockerfile - Compile torch-scatter, torch-sparse, torch-cluster, torch-spline-conv from source since ROCm 5.6 lacks prebuilt wheels - Add Docker Compose usage instructions to README with build, run, and service management commands --- Dockerfile | 27 ++++++++++++++++++++------- README.md | 44 ++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 64 insertions(+), 7 deletions(-) diff --git a/Dockerfile b/Dockerfile index a9107a6..c9e0653 100644 --- a/Dockerfile +++ b/Dockerfile @@ -28,6 +28,10 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ libxrender-dev \ libgomp1 \ libnuma1 \ + # build tools required for compiling PyG extensions from source + build-essential \ + cmake \ + ninja-build \ && rm -rf /var/lib/apt/lists/* # Make python3.10 the default python3 @@ -47,15 +51,24 @@ RUN pip install --no-cache-dir \ --index-url https://download.pytorch.org/whl/rocm5.6 # --------------------------------------------------------------------------- -# Install PyTorch Geometric and extensions with ROCm 5.6 wheels +# Install PyTorch Geometric and extensions # --------------------------------------------------------------------------- +# ROCm 5.6 does not ship prebuilt PyG extension wheels, so we compile them +# from source. torch-geometric itself is pure-Python and installs from PyPI. +# The extensions (scatter, sparse, cluster, spline-conv) are built with +# torch.utils.cpp_extension which automatically picks up the ROCm toolchain +# shipped in the base image. +# --------------------------------------------------------------------------- +ENV ROCM_HOME=/opt/rocm +ENV HIP_HOME=/opt/rocm + +RUN pip install --no-cache-dir torch-geometric==2.4.0 + RUN pip install --no-cache-dir \ - torch-geometric==2.4.0 \ - torch-scatter==2.1.2+pt21rocm5.6 \ - torch-sparse==0.6.18+pt21rocm5.6 \ - torch-cluster==1.6.2+pt21rocm5.6 \ - torch-spline-conv==1.2.2+pt21rocm5.6 \ - -f https://data.pyg.org/whl/torch-2.1.0+rocm5.6.html + torch-scatter==2.1.2 \ + torch-sparse==0.6.18 \ + torch-cluster==1.6.2 \ + torch-spline-conv==1.2.2 # --------------------------------------------------------------------------- # Install remaining Python dependencies from PyPI diff --git a/README.md b/README.md index b982373..23445a9 100644 --- a/README.md +++ b/README.md @@ -210,6 +210,50 @@ pip install -r requirements.txt # pip install torch-geometric torch-scatter torch-sparse -f https://data.pyg.org/whl/torch-2.1.0+rocm5.6.html ``` +### Docker (Recommended) + +A pre-configured Docker image with ROCm 5.6 and all Python dependencies is provided for a reproducible, containerized environment. + +#### Prerequisites + +- Docker 20.10+ with Compose v2 (`docker compose`) +- AMD GPU with ROCm 5.6+ drivers installed on the host +- `video` and `render` group membership for GPU device access + +#### Build & Run + +```bash +# 1. Build the image +docker compose build + +# 2. Start the web dashboard (http://localhost:8000) +docker compose up -d dashboard + +# 3. Run model training (one-off) +docker compose run --rm train + +# 4. Start the live trading engine +docker compose --profile live up -d live-trading +``` + +#### Useful Commands + +```bash +# View dashboard logs +docker compose logs -f dashboard + +# Open an interactive shell inside the container +docker compose run --rm train bash + +# Stop all services +docker compose down + +# Stop and remove live-trading service +docker compose --profile live down +``` + +> **Note:** The container mounts `./data`, `./models`, and `./logs` as volumes so that datasets, trained models, and log files persist across restarts. + ### Run Training ```bash