mlcommons / GaNDLF

A generalizable application framework for segmentation, regression, and classification using PyTorch
https://gandlf.org
Apache License 2.0
158 stars 79 forks source link

add docker compose file #940

Open benmalef opened 3 weeks ago

benmalef commented 3 weeks ago

Fixes #875

Proposed Changes

You can check ref

you can run

docker compose up

to build and run your container

Checklist

github-actions[bot] commented 3 weeks ago

MLCommons CLA bot All contributors have signed the MLCommons CLA ✍️ ✅

sarthakpati commented 3 weeks ago

Looks good, but should we not be using this for all Docker builds?

benmalef commented 2 weeks ago

Looks good, but should we not be using this for all Docker builds?

It's the same with this, IMO but in an easier way. You can modify the compose.yaml. You can choose the dockerfile, the volume, the commands that you want to execute.

sarthakpati commented 2 weeks ago

Looks good, but should we not be using this for all Docker builds?

It's the same with this, IMO but in an easier way. You can modify the compose.yaml. You can choose the dockerfile, the volume, the commands that you want to execute.

Okay, then please provide clear examples of how this improves the existing docker workflow.

benmalef commented 1 week ago

I have created an example to demonstrate how to use it, but I have noticed that extra effort is required from the user to modify the compose.yaml file.

Using the docker command line

docker run -it --rm --name dataprep \
  --volume /home/researcher/gandlf_input:/input:ro \ # input data is mounted as read-only
  --volume /home/researcher/gandlf_output:/output \ # output data is mounted as read-write
  cbica/gandlf:latest-cpu \ # change to appropriate docker image tag
  construct-csv \ # standard construct CSV API starts
  --input-dir /input/data \
  --output-file /output/data.csv \
  --channels-id _t1.nii.gz \
  --label-id _seg.nii.gz

Using the docker compose file.

version: '1'

services:
  gandlf:
    build:
      context: .
      dockerfile: Dockerfile-CPU #choose the dockerfile
#    volumes: 
#     - /home/researcher/gandlf_input:/input:to
       - /home/researcher/gandlf_output:/output
    entrypoint: ["gandlf"]
    command: ["construct-csv",
"--input-dir ","/input/data",
"--output-file ","/output/data.csv",
" --channels-id"," _t1.nii.gz ",
" --label-id", "_seg.nii.gz" ] 

You can run docker compose up to run the container and execute the command.

sarthakpati commented 1 week ago

@hasan7n since you are far more familiar with docker than I am, what are you views on this?