Compiling and Running Dynare on a linux cluster running CentOS or RHEL

Recently, docker images have been available, and I could run dynare using Apptainer on an hpc with Cent OS. This is the first time I have used containers, so my solution might need improvements/corrections. But it seems to be working. Here is what I did:

1. mkdir dynare
2. cd dynare

3. mkdir examples

4. touch examples/example1.mod

5. module load Apptainer

6. apptainer build dynare.sif docker://dynare/dynare:latest

7. apptainer exec \
8.     --env MLM_LICENSE_FILE=27000@matlab-campus.uni-tuebingen.de \
9.     dynare.sif \
10.    matlab -batch \
11.    "addpath('/home/matlab/dynare/matlab'); cd examples; dynare example1"

12. module unload Apptainer

Explanation:
Line 1: Make a folder, named ‘dynare’

Line 2: Enter the folder

Line 3: Make a folder, named ‘examples’

Line 4: Make an empty model file inside the examples folder, names ‘example1.mod’

Line 5: Load the ‘Apptainer’ module

Line 6: Build .sif file pulling the docker images from docker hub

Line 7: exec subcommand lets us run a command within the container

Line 8: Pass your matlab license as an environmental variable with --env

Line 9: Give the container image to exec

Line 10: Matlab should run line 11

Line 11: Commands to be executed inside matlab

Line 12: Unload the Apptainer module

If dynare works, we should see some dynare errors printed out, as our example1.mod file is empty. We should also make sure to change 27000@matlab-campus.uni-tuebingen.de according to our own license.

1 Like