Docker¶
Docker runs the MPM3S container image on a workstation running Windows, macOS or Linux. The image holds Julia, MPM3S, its GPU libraries and the tutorial files, so nothing else needs installing. On an HPC, where Docker is rarely available, use Singularity / Apptainer.
Add your GitHub account to your computer or HPC (while MPM3S.jl is private)
MPM3S.jl is private for now, so downloading it needs a GitHub account with access to MPM3S.jl, and a token to use in place of your GitHub password. This note disappears when MPM3S.jl is made public. To make the token:
- Open github.com/settings/tokens (on GitHub: Settings → Developer settings → Personal access tokens → Tokens (classic)) and click Generate new token (classic).
- Tick
repoandread:packages, choose an expiry date and generate the token. - Copy the token and keep it as safe as a password: GitHub shows it only once.
On your computer or HPC, downloading the image uses the token: section 2 logs it in with the token.
Command/terminal window¶
Julia, MPM3S and the containers are all operated through the terminal (macOS/Linux) or command (Windows) window. To open one:
Press the Windows key, type PowerShell and select Windows PowerShell.
- To open it in a particular folder, open the folder in File Explorer, right-click an empty space and choose Open in Terminal (Windows 11), or hold
Shiftwhile right-clicking and choose Open PowerShell window here (Windows 10).
Press Ctrl + Alt + T, or search for Terminal in your applications menu.
- To open it in a particular folder, right-click an empty space in the folder in your file manager and choose Open in Terminal.
Press Cmd + Space, type Terminal and press Return. Terminal is also in Applications → Utilities.
- To open it in a particular folder, right-click the folder in Finder and choose Services → New Terminal at Folder.
Code snippets are provided throughout the documentation, these can be copied and pasted into the Terminal/Command window.
1. Install Docker¶
Install Docker Desktop on Windows or macOS, or Docker Engine on Linux. Check it is installed by typing into your command/terminal window:
- On Linux, add yourself to the
dockergroup (Docker's post-installation steps), or putsudoin front of everydockercommand on this page. - For GPU runs you need an NVIDIA GPU and its driver, and on Linux the NVIDIA Container Toolkit; on Windows, Docker Desktop's WSL 2 engine (the default) is enough. Macs have no NVIDIA GPU, so they run on the CPU only.
- The image is built for Intel and AMD (x86-64) processors. On an Apple-silicon Mac, Docker runs it through emulation, which is slower.
2. Log in to the GitHub container registry¶
Log in with the command below, giving your GitHub username, and paste the token from the note at the top of this page when asked for the password. The login is remembered, so you only log in again when the token expires.
3. Make a working folder¶
Create a working folder, which we have called my_work, on a drive with plenty of space, as the results can run to
many GB. Put the drive's path in place of <path to large drive>. This is where the problem folders (containing the
json files and result folders) will be. First we must make the working directory and cd into it:
4. Download the image¶
Docker keeps the image itself rather than as a file, so the working folder stays empty; docker images lists it. Run
the same command again to update it to a new release.
latest is the newest release; its images are published the night after the release. For work you need to reproduce
later, name a release instead, e.g. ghcr.io/mpm3s/mpm3s:v0.3.0, here and in the commands below, so the image cannot
change underneath you.
5. Run a problem¶
Make a problem folder¶
From your working folder, make a folder for the problem, go into it and put the problem's files in it:
This example uses a premade problem, the self-weight column (Tutorial 1), whose
input files are inside the image. To copy them into the column folder, use:
$PWD (${PWD} in PowerShell) is the folder you are in, and -v "$PWD":/work -w /work makes it the container's
working folder, so the files are copied into your current directory, here column. --entrypoint cp runs cp in the
image in place of MPM3S.
<path to large drive>/my_work/
└── column/
├── input_data_gravity_column.json ← copied from the image
└── input_data_gravity_column_gpu.json ← copied from the image
- A problem folder holds everything its problem needs: the input file and, for each rigid body, its
.stland its mesh cache (the_mesh.txtfile named by"mesh cache"). The image cannot create a mesh cache, so it must be there. - Run from inside the problem folder. The container sees that folder, and the results are written into it, to the
folders the input file names in
"vtk directory"and"csv directory". - Keep the paths in the input file relative and inside the problem folder, so the container can see them.
Run it¶
From inside the problem folder (in this example you should be in column), give the image the input file and run it.
As in the copy, $PWD (${PWD} in PowerShell) is the folder you are in, so the results are written into your current
directory. On the CPU, MPM3S uses the number of cores minus 2 as threads (at least 1): set MPM3S_CORES to the cores to use, or
leave it out to use every core the container sees. An input file with "GPU": "on" needs the GPU passed in with
--gpus all.
docker run --rm --user "$(id -u):$(id -g)" -e MPM3S_CORES=8 -v "$PWD":/work -w /work ghcr.io/mpm3s/mpm3s:latest input_data_gravity_column.json
docker run --rm --gpus all --user "$(id -u):$(id -g)" -v "$PWD":/work -w /work ghcr.io/mpm3s/mpm3s:latest input_data_gravity_column_gpu.json
--user makes the results yours rather than root's.
The first line of the output shows how the run uses the machine, e.g. MPM3S 0.3.0 · CPU znver2 · 6 threads, with the
GPU added on a GPU run. The results are written into the problem folder:
<path to large drive>/my_work/
└── column/
├── input_data_gravity_column.json
├── input_data_gravity_column_gpu.json
├── vtk_column/ ← created by the run
└── csv_column/ ← created by the run
6. Practise on the tutorials¶
The tutorials' files are inside the image, in
/opt/MPM3S/validation_data_and_jsons, so a tutorial runs from an empty problem folder with nothing to download: give
the image the input file's path there. For example, the self-weight column
(Tutorial 1), from your working folder:
The results appear in column/vtk_column and column/csv_column; open them as described in
Viewing the output. The other tutorials run the same way, with the GPU passed in for those on the
GPU:
| Tutorial | Runs on | Input file | Its rigid bodies' files |
|---|---|---|---|
| 1 Self-weight column | CPU, or GPU | input_data_gravity_column.json, or input_data_gravity_column_gpu.json |
none |
| 2 Compaction via a rigid body | CPU | input_data_compress.json |
cube.stl, cube_mesh.txt |
| 3 Vertical penetration | GPU | input_data_CPT_dr32.json |
CPT.stl, CPT_mesh.txt |
| 4 Rolling sphere | CPU | input_data_sphere.json |
sphere.stl, sphere_mesh.txt |
| 5 Cable burial plough | GPU | input_data_plough_dr44.json |
plough.stl, plough_mesh.txt |
| 6 Drag anchor | GPU | input_data_AC14_dr32.json |
AC14_fluke_rot20.stl, AC14_fluke_rot20_mesh.txt, AC14_shank.stl, AC14_shank_mesh.txt |
To change a tutorial, or start a problem of your own from one, copy its files out of the image into a problem folder and run it as in section 5. For Tutorial 2, from inside its problem folder:
<path to large drive>/my_work/
├── column/
│ ├── input_data_gravity_column.json
│ ├── input_data_gravity_column_gpu.json
│ ├── vtk_column/
│ └── csv_column/
└── compaction/
├── input_data_compress.json ← copied from the image
├── cube.stl ← copied from the image
└── cube_mesh.txt ← copied from the image
Troubleshooting¶
| Message | Fix |
|---|---|
permission denied on /var/run/docker.sock |
On Linux, add yourself to the docker group, or put sudo in front of docker (section 1). |
unauthorized or denied when downloading |
Log in first (section 2), with a token that has repo and read:packages ticked. |
could not select device driver "" with capabilities: [[gpu]] |
On Linux, install the NVIDIA Container Toolkit (section 1) and restart Docker. |
… says "GPU": "on", but no GPU is visible |
Add --gpus all, on a machine with an NVIDIA GPU. |
the output folder … is not in a mounted host folder |
Run from inside the problem folder with -v … -w /work, and keep the output paths in the input file relative. |
usage: mpm3s input.json |
Give exactly one input file, and check it is in the folder you run from. |
| An error about meshing or Gmsh | A rigid body's mesh cache (_mesh.txt) is missing from the problem folder. |