Skip to content

Setup

This page covers the BaseModel Python App delivered as a Docker container. Run Docker commands on the host machine; run Python commands in the container.

Before you start

  • Make sure your environment meets all requirements
  • Confirm the environment has access to CUDA and data
  • Prepare BaseModel access information received from your BaseModel contact:
    • registry name and credentials (username + token)
    • image name
  • If the image is already present locally, skip registry login and use that exact image name. Credentials are only needed to pull an unavailable image.

If you have no entitlement yet, request access. Your BaseModel contact supplies the registry URL, credentials, an entitled image and version, and the deployment requirements. An existing account alone does not supply image access.

1. Pull the image

The Python App image is named monad. Log in to the container registry and pull the version provided by your BaseModel contact:

bash
docker login -u USERNAME -p TOKEN_PASSWORD REGISTRY_URL
docker pull REGISTRY_URL/monad:VERSION

Replace USERNAME, TOKEN_PASSWORD, REGISTRY_URL, and VERSION with the values provided by your BaseModel contact.

Confirm the image is available:

bash
docker images | grep monad

2. Run the container

Prepare writable output directories on the host, then start a detached container. Replace the host paths below with your own paths. The Ray temporary directory must exist and be writable by the container user (uid=1000).

Working volume must be a real filesystem

Cache and checkpoints need a real local filesystem (for example, NVMe or EBS), with enough space for the workload. See Storage for sizing.

Variant A: default image user (uid 1000)

Host
mkdir -p /your/workspace/{configs,cache,data/hm,project,logs,model,runtime} /your/ray-tmp
mkdir -p /your/workspace/runtime/ray-auth
setfacl -m u:1000:rwx -m d:u:1000:rwx \
  /your/workspace /your/workspace/logs /your/workspace/model \
  /your/workspace/runtime /your/workspace/configs /your/workspace/cache \
  /your/workspace/data /your/workspace/data/hm /your/workspace/project \
  /your/workspace/runtime/ray-auth /your/ray-tmp

ray_token_directory=$(docker run --rm --entrypoint python REGISTRY_URL/monad:VERSION \
  -c "from pathlib import Path; print(Path.home() / '.ray')")

docker run -dit \
  --gpus '"device=<GPU_INDEX>"' \
  --shm-size 64gb \
  -w /workspace \
  -e MONAD_LOGGING_DIRECTORY=/workspace/logs \
  -v /your/workspace:/workspace:z \
  -v /your/data:/data/datasets:ro,z \
  -v /your/ray-tmp:/data/tmp:rw,z \
  -v "/your/workspace/runtime/ray-auth:${ray_token_directory}:z" \
  --name basemodel \
  REGISTRY_URL/monad:VERSION \
  tail -f /dev/null

tail -f /dev/null keeps this detached container running for subsequent docker exec commands.

  • --gpus '"device=<GPU_INDEX>"' — exposes only the assigned GPU; replace <GPU_INDEX> with its host index. Use all only when every GPU is assigned to this run, and select the devices to train on in your configuration.
  • --shm-size 64gb — shared memory for distributed processing and data loaders. Size it for your workload; insufficient shared memory can crash the node. 64gb is the reference setting used here.
  • -w /workspace — makes the mounted workspace the working directory for docker exec commands.
  • -e MONAD_LOGGING_DIRECTORY=/workspace/logs — keeps logs on the mounted workspace; optional when the image's default log location is already writable (see Logging).
  • -v /your/workspace:/workspace:z — working directory for configs, onboarding package, and all model artefacts. Split into multiple mounts if needed.
  • -v /your/data:/data/datasets:ro,z — optional local Parquet input, mounted read-only so training cannot alter source data.
  • -v /your/ray-tmp:/data/tmp:rw,z — writable Ray overlay. Monad uses /data/tmp even when TMPDIR or RAY_TMPDIR points elsewhere.
  • The ray-auth mount makes Ray's authentication-token directory writable and persistent. Its path is determined with the same image user as training; it is separate from Ray's temporary-processing directory.

The data mount is optional when all inputs come from a database. Keep the writable workspace and Ray mount in either case. The Python App may use /data/tmp/ray directly for temporary processing data, so setting TMPDIR alone does not replace this mount. Add your backend's environment settings when needed; see Connect Sources.

Host vs container paths

Paths in configs and scripts are always container-side paths (e.g., /workspace/..., /data/...). Files you write on the host at /your/workspace/ appear inside the container at /workspace/ via the volume mount. When reading outputs (reports, predictions), access them from the host-side mount path.

The default image user is uid 1000. The ACL example preserves the host owner's access while granting that user access to the workspace and output directories. Source data remains read-only; ensure the selected user can read it. If ACLs are unavailable, have the directory owner grant equivalent group access to the engine user.

Variant B: host uid and gid

Run as the host user when outputs should retain that user's ownership. First create a logging configuration using the example configuration, saved as /your/workspace/logging.conf. Its configuration needs read access; the log directory needs write access. An image-owned configuration may be unreadable under the host uid, so mount the prepared configuration explicitly.

Host
mkdir -p /your/workspace/{configs,cache,data/hm,project,logs,model,runtime} /your/ray-tmp
mkdir -p /your/workspace/runtime/ray-auth
chmod u+r /your/workspace/logging.conf

ray_token_directory=$(docker run --rm --entrypoint python \
  --user "$(id -u):$(id -g)" REGISTRY_URL/monad:VERSION \
  -c "from pathlib import Path; print(Path.home() / '.ray')")

docker run -dit \
  --user "$(id -u):$(id -g)" \
  --gpus '"device=<GPU_INDEX>"' \
  --shm-size 64gb \
  -w /workspace \
  -e MONAD_LOGGING_CONFIG_PATH=/etc/monad/logging.conf \
  -e MONAD_LOGGING_DIRECTORY=/workspace/logs \
  -v /your/workspace:/workspace:z \
  -v /your/data:/data/datasets:ro,z \
  -v /your/ray-tmp:/data/tmp:rw,z \
  -v "/your/workspace/runtime/ray-auth:${ray_token_directory}:z" \
  -v /your/workspace/logging.conf:/etc/monad/logging.conf:ro,z \
  --name basemodel \
  REGISTRY_URL/monad:VERSION \
  tail -f /dev/null

Both variants require writable runtime/cache directories under the selected uid and a readable logging configuration. Before GPU work, check these in the engine container, with the same uid/gid that will run training:

Host: runtime preflight
docker exec basemodel id
docker exec basemodel test -r /etc/monad/logging.conf
docker exec basemodel python -c "import tempfile; f = tempfile.TemporaryFile(dir='/workspace/runtime'); f.write(b'preflight'); f.flush(); f.close()"
docker exec basemodel python -c "from pathlib import Path; import tempfile; f = tempfile.TemporaryFile(dir=Path.home() / '.ray'); f.close()"

Create the runtime directory as the project owner before the check. Repeat the write check for each configured cache, Ray temporary and log directory, replacing /workspace/runtime with that directory. Check the actual logging configuration path if it differs from the example. Resolve failed reads or writes before starting GPU work; a host-side check does not establish that the engine's uid can access the same mount.

To open a shell in the running container:

Host
docker exec -it basemodel bash

3. Verify the installation

Inside the container:

bash
python -c "import monad"

If this results with no error, your environment is ready.

If logging prevents startup

If an import or command fails with LoggingSetupError, choose a writable log directory using MONAD_LOGGING_DIRECTORY (available from version 1.11). See Log Output Directory for instructions. This setting is optional when the default log location is already writable.

4. Run a configured training job

For the complete first-run data conversion, training and prediction path, continue with the Tutorial. It writes configs, converted data, cache and outputs below /workspace, backed by /your/workspace on the host. The commands below are an alternative for an already prepared config.

Create /your/workspace/configs/fm_config.yaml using Basic Configuration. For the running container above, execute the documented CLI directly; no separate pretrain.py is required:

Host
docker exec -w /workspace basemodel python -m monad.run \
  --pretrain \
  --config-path /workspace/configs/fm_config.yaml \
  --output-path /workspace/project/model

Use a new output directory for a new run. See Key Flags before resuming or replacing existing results.

Alternatively, run the same job in a one-off container:

Host: alternative to docker exec
docker run --rm \
  --gpus all --shm-size 64gb \
  -w /workspace \
  -v /your/workspace:/workspace:z \
  -v /your/data:/data/datasets:ro,z \
  -v /your/ray-tmp:/data/tmp:rw,z \
  REGISTRY_URL/monad:VERSION \
  python -m monad.run --pretrain \
    --config-path /workspace/configs/fm_config.yaml \
    --output-path /workspace/project/model

Choose one execution method for a run; do not launch both commands against the same output directory.

Delivery as Python wheel

A Python wheel is also available on request but is not covered by this documentation — please contact your BaseModel representative if needed.

Optional workflow availability

The standard 1.17 image includes neither MLflow nor Plotly and has no pip, so the MLflow and treemap recipes do not run inside it. Run them in an environment where those packages are importable alongside BaseModel; BaseModel does not provide such an environment, so ask your BaseModel contact if you need one. The Python wheel available on request is not an installation procedure for these packages.

The standard image includes SHAP, Matplotlib and Seaborn, so missing MLflow and Plotly does not block native training, TSV exports or the native evaluation report. Classification and multi-target SHAP reports fail in 1.17.0 and 1.17.1; this is fixed in 1.17.2. See SHAP Report.