Virtulisation.oci-container to setup rocm-torch-jupiter docker environment

I am using the following configuration to create a container with rocm and torch enabled but I cant see the container in the docker list of containers, dont know whats wrong. sudo nixos-rebuild switch build without issues:

{config, lib, pkgs, ...}:

let
    notebooksDir = "/home/notebooks";
in
{
    virtualisation.oci-containers = {
        backend = "docker";
        containers = {
            pytorchRocm = {
                image = "rocm/pytorch:latest";
                autoStart = true;
                cmd = [
                    "/bin/bash"
                    "-c"
                    ''
                    pip install -U elasticsearch langchain transformers huggingface_hub torch jupyter
                    tail -f /dev/null
                    ''
                ];
                environment = {
                     # ROCm Configuration
                    "HSA_OVERRIDE_GFX_VERSION" = "11.0.0";
                    "ROCR_VISIBLE_DEVICES" = "0";
                    "HIP_VISIBLE_DEVICES" = "0";
                    "PYTORCH_HIP_ALLOC_CONF" = "max_split_size_mb:512";
                };
                volumes = [
                     "${notebooksDir}:/workspace/notebooks"
                ];
                extraOptions = [
                     "--device=/dev/kfd"
                     "--device=/dev/dri"
                     "--group-add=video"
                     "--security-opt=seccomp=unconfined"
                ];
            };
        };
    };
}

Logs:

sudo systemctl status docker-pytorchRocm.service                                                                                               
● docker-pytorchRocm.service
     Loaded: loaded (/etc/systemd/system/docker-pytorchRocm.service; enabled; preset: ignored)
     Active: active (running) since Sun 2025-02-23 03:00:43 +08; 5min ago
 Invocation: a572ec516a7941d2930a133d1abe7312
    Process: 221569 ExecStartPre=/nix/store/l6zxl57yb0gdfsy5ql8nzxy2z9qn5ylk-pre-start/bin/pre-start (code=exited, status=0/SUCCESS)
   Main PID: 221583 (docker)
         IP: 0B in, 0B out
         IO: 0B read, 0B written
      Tasks: 13 (limit: 76325)
     Memory: 10.6M (peak: 11.1M)
        CPU: 936ms
     CGroup: /system.slice/docker-pytorchRocm.service
             └─221583 /nix/store/x59g9vvh2w1z2naw0ylds20j86zc26pd-docker-27.3.1/libexec/docker/docker run --rm --name=pytorchRocm --log-driver=journald -e HIP_VISIBLE_DEVICES=0 -e HSA_OVERRIDE_GFX_VERSIO>

Feb 23 03:02:44 latitude2 docker-pytorchRocm-start[221583]: 585ddfadb160: Download complete
Feb 23 03:02:44 latitude2 docker-pytorchRocm-start[221583]: b3fbe2871cb5: Verifying Checksum
Feb 23 03:02:44 latitude2 docker-pytorchRocm-start[221583]: b3fbe2871cb5: Download complete
Feb 23 03:02:46 latitude2 docker-pytorchRocm-start[221583]: dc127bd3c486: Verifying Checksum
Feb 23 03:02:46 latitude2 docker-pytorchRocm-start[221583]: dc127bd3c486: Download complete
Feb 23 03:02:47 latitude2 docker-pytorchRocm-start[221583]: d0e7c3820e54: Download complete
Feb 23 03:02:48 latitude2 docker-pytorchRocm-start[221583]: 49c1aac0f7e0: Verifying Checksum
Feb 23 03:02:48 latitude2 docker-pytorchRocm-start[221583]: 49c1aac0f7e0: Download complete
Feb 23 03:06:00 latitude2 docker-pytorchRocm-start[221583]: 17ddcce75bdb: Verifying Checksum
Feb 23 03:06:00 latitude2 docker-pytorchRocm-start[221583]: 17ddcce75bdb: Download complete
lines 11-24/24 (END)

 ~/etc/nixos  latitude2 !1  systemctl status container@pytorchRocm                                                                                                       
○ container@pytorchRocm.service - Container 'pytorchRocm'
     Loaded: loaded (/etc/systemd/system/container@.service; static)
     Active: inactive (dead)

Could it be that the container didn’t start for some reason? I would use docker logs to check for any errors.

So it turned out it had not fully pulled and downloaded all the resources for the image and hence not showing in the list of docker containers/image, one can monitor it via : journalctl -u docker-<name-of-the-container>.service -f :smiley: