# Using a custom docker image

**URL:** <https://community.wandb.ai/t/using-a-custom-docker-image/5129>\
**Category:** W&B Help\
**Created:** [September 24, 2023, 3:04pm UTC](https://community.wandb.ai/t/using-a-custom-docker-image/5129 "2023-09-24T15:04:02Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![limitingfactor](https://sea2.discourse-cdn.com/flex020/user_avatar/community.wandb.ai/limitingfactor/32/1472_2.png) [@limitingfactor](https://community.wandb.ai/u/limitingfactor)\
**Post date:** [September 24, 2023, 3:04pm UTC](https://community.wandb.ai/t/using-a-custom-docker-image/5129/1 "2023-09-24T15:04:02Z")

</div>

Hello,

I am getting stuck trying to run a job using a custom docker image and would like some advice.

I am trying to use my own custom image based off the nvidia modulus image ([nvcr.io/nvidia/modulus/modulus](http://nvcr.io/nvidia/modulus/modulus)) as I need to newer code than in the base image.

This is my dockerfile to generate my image

```auto
ARG PYT_VER=23.08
FROM nvcr.io/nvidia/modulus/modulus:$PYT_VER as builder

RUN python -m pip install tensorflow
RUN python -m pip uninstall -y nvidia-modulus nvidia-modulus.sym nvidia-modulus.launch

ENV PYTHONPATH=/modulus/:/modulus-sym/:/modulus-launch/ 

WORKDIR /modulus-launch/examples/cfd/vortex_shedding_mgn

ENTRYPOINT ["sh", "launch.sh"]

```

It just uninstalls the existing modulus code and installs tensorflow.

The build isn’t fancy

```auto
docker build -t my_modulus:latest -f Dockerfile .

```

For reference my launch.sh

```auto
python -m pip uninstall nvidia-modulus nvidia-modulus.sym nvidia-modulus.launch -y

cd /modulus/
python -m pip install -e .

cd /modulus-sym/
python -m pip install -e .

cd /modulus-launch/
python -m pip install -e .

cd /modulus-launch/examples/cfd/vortex_shedding_mgn/
git config --global --add safe.directory /modulus-launch

pip install wandb --upgrade

python /modulus-launch/examples/cfd/vortex_shedding_mgn/wandb_train.py "$@"

```

This makes sure the container has modulus uninstalled and then installs a local version from the mounting points. Finally it run the training script.

To test my image I have used

```auto
docker run -e WANDB_API_KEY=<my api key> -e WANDB_DOCKER="my_modulus:latest" --shm-size=1g --ulimit memlock=-1 --ulimit stack=67108864 --runtime nvidia -v <my path to modulus-launch>:/modulus-launch -v <my path to modulus>:/modulus -v <my path to modulus-sym>:/modulus-sym -v <my path to my dataset>:/datasets/ -v <my path to my workspace>:/workspace/ -it --rm my_modulus:latest --project <project name> --entity <my entity>

```

This works fine and I get a job created on wandb.

I have setup a docker queue

```auto
env:
  - PYTHONPATH=/modulus/:/modulus-sym/:/modulus-launch/
gpus: all
volume:
  - <local path>:/modulus-launch
  - <local path>:/modulus
  - <local path>:/modulus-sym
  - <local path>:/datasets/
  - <local path>:/workspace/
builder:
  accelerator:
    base_image: my_modulus:latest

```

I have tried with and without the builder.

When launching the job from the website I use these options

```auto
{
    "args": [
        "--project",
        "<my project>",
        "--entity",
        "<my entitiy>"
    ],
    "run_config": {
        "epochs": 25,
        "ckpt_path": "/workspace/checkpoints_training_6"
    },
    "entry_point":
    [
    ]
}

```

This is to test changing the number of epoch and to save the checkpoints to a different folder.

The error I get is this

```auto
wandb: launch: Launching run in docker with command: docker run --rm -e WANDB_BASE_URL=https://api.wandb.ai -e WANDB_API_KEY -e WANDB_PROJECT=<project> -e WANDB_ENTITY=<my entity> -e WANDB_LAUNCH=True -e WANDB_RUN_ID=7dyx6mlk -e WANDB_USERNAME=<my username> -e WANDB_CONFIG='{"epochs": 25, "ckpt_path": "/workspace/checkpoints_training_6"}' -e WANDB_ARTIFACTS='{"_wandb_job": "<entity>/<project>/job-<job name>_wandb_train.py:latest"}' --env PYTHONPATH=/modulus/:/modulus-sym/:/modulus-launch/ --gpus all --volume <local path>:/modulus-launch --volume <local path>:/modulus --volume <local path>:/modulus-sym --volume <local path>:/datasets/ --volume <local path>:/workspace/ <>_wandb_train.py:7864ffe4
Traceback (most recent call last):
  File "<>/examples/cfd/vortex_shedding_mgn/wandb_train.py", line 20, in <module>
    import torch
ModuleNotFoundError: No module named 'torch'

```

Looking at the documentation it isn’t clear to me how to do this correctly. If anyone has some advice on how to use a docker image similar to what I have created above I would be grateful.

Thanks

LimitingFactor

---

<div class="post-metadata">

**Author:** ![uma-wandb](https://avatars.discourse-cdn.com/v4/letter/u/b77776/32.png) [@uma-wandb](https://community.wandb.ai/u/uma-wandb)\
**Post date:** [September 28, 2023, 6:39pm UTC](https://community.wandb.ai/t/using-a-custom-docker-image/5129/2 "2023-09-28T18:39:22Z")

</div>

Hey @limitingfactor - in your setup are you explicitly installing pytorch anywhere? We don’t automatically do this, so I just wanted to check on what happens if you explicitly download this beforehand or include it in your setup.

---

<div class="post-metadata">

**Author:** ![limitingfactor](https://sea2.discourse-cdn.com/flex020/user_avatar/community.wandb.ai/limitingfactor/32/1472_2.png) [@limitingfactor](https://community.wandb.ai/u/limitingfactor)\
**Post date:** [September 29, 2023, 10:52pm UTC](https://community.wandb.ai/t/using-a-custom-docker-image/5129/3 "2023-09-29T22:52:23Z")

</div>

Hi @uma-wandb, I am using the Nvidia modulus image as a starting point which already has pytorch installed in it.

---

<div class="post-metadata">

**Author:** ![uma-wandb](https://avatars.discourse-cdn.com/v4/letter/u/b77776/32.png) [@uma-wandb](https://community.wandb.ai/u/uma-wandb)\
**Post date:** [November 14, 2023, 6:13am UTC](https://community.wandb.ai/t/using-a-custom-docker-image/5129/4 "2023-11-14T06:13:55Z")

</div>

hey @limitingfactor - were you able to get this up and running? have you run into any further issues?

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex020/uploads/wandb/original/1X/366b649231631dbab896843020da0056074ac79d.png) [@system](https://community.wandb.ai/u/system)\
**Post date:** [January 13, 2024, 6:14am UTC](https://community.wandb.ai/t/using-a-custom-docker-image/5129/5 "2024-01-13T06:14:16Z")

</div>

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.
