### Create and Run MATLAB Script (Batch Mode) Source: https://github.com/hpcleuven/vscdocumentation/blob/master/source/compute/software/matlab_getting_started.md Example MATLAB script to perform calculations and save results, followed by a bash script to submit the MATLAB script to the PBS job system for execution on compute nodes. ```matlab ndim = 600; a = rand(600,1)*10; b = rand(1,600)*100; c = a * b; d = max(c); e = min(d); save('testmatlab', 'd', 'e'); exit; ``` ```bash #!/bin/bash -l #PBS -l walltime=01:00:00 #PBS -l pmem=950mb #PBS -N matlab_test_job module load matlab cd $PBS_O_WORKDIR matlab -nodisplay -r testmatlabscript ``` -------------------------------- ### Start MATLAB in Console Mode Source: https://github.com/hpcleuven/vscdocumentation/blob/master/source/compute/software/matlab_getting_started.md Initiates MATLAB without a graphical interface, providing a command prompt for executing m-files. Requires no X-Window server but lacks graphical facilities. Subject to CPU time limitations. ```bash $ matlab -nodisplay ``` -------------------------------- ### Load MATLAB Module Source: https://github.com/hpcleuven/vscdocumentation/blob/master/source/compute/software/matlab_getting_started.md Commands to check available MATLAB versions and load a specific version using the module utility. This ensures the correct environment is set up for MATLAB execution. ```bash $ module avail matlab $ module avail MATLAB $ module load matlab/R2014a $ module load MATLAB/2014a ``` -------------------------------- ### Submit MATLAB Job with qsub Source: https://github.com/hpcleuven/vscdocumentation/blob/master/source/compute/software/matlab_getting_started.md Submits a shell script containing MATLAB commands to a job scheduler. The command returns a job ID for monitoring. ```bash $ qsub testmatlabscript.sh ``` -------------------------------- ### Start MATLAB Script Execution Source: https://github.com/hpcleuven/vscdocumentation/blob/master/source/compute/software/matlab_getting_started.md Initiates a MATLAB script without a graphical user interface. It's commonly used for batch processing or automated tasks. ```bash matlab -nojvm -nodisplay -r test ``` -------------------------------- ### Build and Install Software with Intel Compiler on wICE Source: https://github.com/hpcleuven/vscdocumentation/blob/master/source/leuven/wice_advanced_guide.md Bash script template for building and installing software on wICE cluster using Intel 2022b compiler. Sets up the installation directory structure based on VSC environment variables and updates the PATH to include the newly installed binaries. Requires SLURM job submission parameters and a loaded Intel module. ```bash #!/bin/bash -l #SBATCH --clusters=... #SBATCH --partition=... #SBATCH ... module load intel/2022b installdir=${VSC_DATA}/your_software/${VSC_ARCH_LOCAL}${VSC_ARCH_SUFFIX}/intel-2022b export PATH=${installdir}/bin:${PATH} # run the software ``` -------------------------------- ### Submitting MapReduce Jobs with Prologue and Epilogue Source: https://github.com/hpcleuven/vscdocumentation/blob/master/source/compute/jobs/worker_framework.md This example demonstrates how to submit a MapReduce-style job using the 'wsub' command. It specifies pre-processing and post-processing scripts to be executed before and after the main job, respectively. The '-t' flag indicates the range of work items to be processed. ```bash $ wsub -prolog split-data.sh -batch run.pbs -epilog distr.sh -t 1-100 ``` -------------------------------- ### Basic Apptainer Definition File Example Source: https://github.com/hpcleuven/vscdocumentation/blob/master/source/compute/software/containers.md A minimal Apptainer definition file that bootstraps an Ubuntu 22.04 image, installs the 'grace' package, and sets a runscript to execute xmgrace. This demonstrates basic image creation and software installation within a container. ```default Bootstrap: docker From: ubuntu:22.04 %post apt-get update apt-get install -y grace %runscript /usr/bin/xmgrace ``` -------------------------------- ### Submit job to H100 GPU node with AMD Genoa CPU Source: https://github.com/hpcleuven/vscdocumentation/blob/master/source/leuven/wice_quick_start.md Submits a SLURM batch job to the gpu_h100 partition targeting nodes with H100 GPUs and AMD Genoa CPUs (4 GPUs and 64 cores per node). This example requests one H100 GPU with 16 cores on a single node. ```bash sbatch --account=lp_myproject --clusters=wice --partition=gpu_h100 \ --nodes=1 --ntasks=16 --gpus-per-node=1 myjobscript.slurm ``` -------------------------------- ### Set Installation Directory and Create Directory (Bash) Source: https://github.com/hpcleuven/vscdocumentation/blob/master/source/leuven/wice_advanced_guide.md This bash script snippet demonstrates how to define an installation directory using environment variables like ${VSC_DATA}, ${VSC_ARCH_LOCAL}, and ${VSC_ARCH_SUFFIX}, and then creates the directory if it doesn't exist. This is crucial for organizing software installations based on system architecture. ```bash #!/bin/bash -l #SBATCH --clusters=... #SBATCH --partition=... #SBATCH ... module load intel/2022b # just an example installdir=${VSC_DATA}/your_software/${VSC_ARCH_LOCAL}${VSC_ARCH_SUFFIX}/intel-2022b mkdir -p ${installdir} ``` -------------------------------- ### Submit Regular Compute Job to Genius Cluster Source: https://github.com/hpcleuven/vscdocumentation/blob/master/source/leuven/genius_quick_start.md Submit a batch job to the default 'batch' partition on the Genius cluster. This example requests two full compute nodes for 2 hours, specifying the account, cluster, time, and number of tasks per node. Adjust parameters like --time, --nodes, and --ntasks_per_node based on your job's requirements. ```bash $ sbatch --account=lp_myproject --clusters=genius --time=2:00:00 --nodes=2 \ --ntasks-per-node=36 myjobscript.slurm ``` -------------------------------- ### Submit Multi-Core Interactive Job with GPU and X11 on wICE Source: https://github.com/hpcleuven/vscdocumentation/blob/master/source/leuven/wice_quick_start.md Command to submit a longer interactive job on wICE interactive partition with 8 cores, 1 A100 GPU instance, X11 forwarding, and 8-hour walltime. Suitable for visualization and interactive GPU development. Replace 'lp_myproject' with your actual account name. ```bash $ srun --account=lp_myproject --clusters=wice --partition=interactive \ --ntasks-per-node=8 --gpus-per-node=1 --time=08:00:00 --x11 --pty bash -l ``` -------------------------------- ### Submit Single-Core Interactive Job on wICE Source: https://github.com/hpcleuven/vscdocumentation/blob/master/source/leuven/wice_quick_start.md Command to submit a short single-core interactive job on wICE interactive partition with 1-hour walltime. Provides a bash shell for interactive work like compiling, debugging, or post-processing. Replace 'lp_myproject' with your actual account name. ```bash $ srun --account=lp_myproject --clusters=wice --partition=interactive \ --ntasks=1 --time=01:00:00 --pty bash -l ``` -------------------------------- ### Include custom MATLAB script directories during compilation Source: https://github.com/hpcleuven/vscdocumentation/blob/master/source/compute/software/matlab_getting_started.md This example shows how to use the `-I` flag with the MATLAB Compiler (`mcc`) to include directories containing custom MATLAB scripts or compiled MEX files. This is essential when your main script depends on functions located in separate directories. ```bash $ mcc -m -I /path/to/MyMatlabScripts1/ -I /path/to/MyMatlabScripts2 .... \ -I /path/to/MyMatlabScriptsN multi_fibo ``` -------------------------------- ### Compile and run a MATLAB script with file dependencies Source: https://github.com/hpcleuven/vscdocumentation/blob/master/source/compute/software/matlab_getting_started.md This example shows how to compile a MATLAB script (`multi_fibo.m`) that depends on another MATLAB function (`fibonacci.m`). The MATLAB Compiler automatically detects and includes dependencies. The compilation command is shown, along with the execution of the generated shell script and its output. ```matlab function multi_fibo() %MULTIFIBO Calls FIBONACCI multiple times in a loop % Function calculates Fibonacci number for a matrix by calling the % fibonacci function in a loop. Compiling this file would automatically % compile the fibonacci function also because dependencies are % automatically checked. n=10:20 if max(n)<0 f = NaN; else [r c] = size(n); for i = 1:r %#ok for j = 1:c %#ok try f(i,j) = fibonacci(n(i,j)); catch f(i,j) = NaN; end end end end ``` ```bash $ mcc -m multi_fibo ./run_multi_fibo.sh $EBROOTMATLAB n = 10 11 12 13 14 15 16 17 18 19 20 Fibonacci 10 -> 34 Fibonacci 11 -> 55 Fibonacci 12 -> 89 Fibonacci 13 -> 144 Fibonacci 14 -> 233 Fibonacci 15 -> 377 Fibonacci 16 -> 610 Fibonacci 17 -> 987 Fibonacci 18 -> 1597 Fibonacci 19 -> 2584 Fibonacci 20 -> 4181 f = 34 55 89 144 233 377 610 987 1597 2584 4181 ``` -------------------------------- ### Setting Time Limits for Work Items Source: https://github.com/hpcleuven/vscdocumentation/blob/master/source/compute/jobs/worker_framework.md This example illustrates how to enforce a time limit for individual work item execution within a 'worker' job. It utilizes the 'timedrun' command, loaded via a module, to limit the execution of a specific command ('cfd-test') to a maximum of 20 minutes. This prevents work items from getting stuck in infinite loops. ```bash #!/bin/bash -l #PBS -l nodes=1:ppn=8 #PBS -l walltime=04:00:00 module load timedrun/1.0.1 cd $PBS_O_WORKDIR timedrun -t 00:20:00 cfd-test -t $temperature -p $pressure -v $volume ``` -------------------------------- ### Submit 2-Node Job to wICE IceLake Compute Nodes Source: https://github.com/hpcleuven/vscdocumentation/blob/master/source/leuven/wice_quick_start.md Command to submit a 2-node batch job to the default IceLake compute nodes (72 cores each) with 2-hour walltime. The batch and batch_icelake partitions are equivalent. Replace 'lp_myproject' with your actual project account and 'myjobscript.slurm' with your script file. ```bash $ sbatch --account=lp_myproject --clusters=wice \ --nodes=2 --ntasks-per-node=72 --time=2:00:00 myjobscript.slurm ``` -------------------------------- ### Check Job Status with qstat Source: https://github.com/hpcleuven/vscdocumentation/blob/master/source/compute/software/matlab_getting_started.md Displays the status of submitted jobs in the job scheduler. This helps in monitoring the progress of MATLAB scripts. ```bash $ qstat ``` -------------------------------- ### Basic Slurm Job Script Template for wICE Source: https://github.com/hpcleuven/vscdocumentation/blob/master/source/leuven/wice_quick_start.md Template for creating a Slurm job script on wICE cluster. Includes essential directives for specifying cluster, partition, time, nodes, tasks, and account information. Users should customize partition, time, nodes, ntasks-per-node, and account values based on their specific computational requirements. ```bash #!/bin/bash -l #SBATCH --clusters=wice #SBATCH --partition=... #SBATCH --time=... #SBATCH --nodes=... #SBATCH --ntasks-per-node=... #SBATCH --account=... module load ... ... ``` -------------------------------- ### Run MATLAB Function with Parameters Source: https://github.com/hpcleuven/vscdocumentation/blob/master/source/compute/software/matlab_getting_started.md Executes a MATLAB function, passing specific numerical values as arguments. The function processes these inputs and saves the results. ```bash $ matlab -nodisplay -r "testmatlabfunction 3 6" ``` -------------------------------- ### Submit job to GPU node with single A100 GPU Source: https://github.com/hpcleuven/vscdocumentation/blob/master/source/leuven/wice_quick_start.md Submits a SLURM batch job to the gpu_a100 partition requesting one A100 GPU with 18 cores. This demonstrates the recommended core-to-GPU ratio for optimal performance on WICE GPU nodes where each job has exclusive access to allocated cores and GPUs. ```bash sbatch --account=lp_myproject --clusters=wice --partition=gpu_a100 \ --nodes=1 --ntasks=18 --gpus-per-node=1 myjobscript.slurm ``` -------------------------------- ### Activate Conda Environment Source: https://github.com/hpcleuven/vscdocumentation/blob/master/source/compute/software/r_package_management.md Activate a Conda environment, named 'science' in this example, to start working with the packages installed within it. This command modifies your shell session to use the environment's settings. ```bash $ source activate science ``` -------------------------------- ### Submit debug job to A100 GPU partition with limited walltime Source: https://github.com/hpcleuven/vscdocumentation/blob/master/source/leuven/wice_quick_start.md Submits a SLURM batch job to the gpu_a100_debug partition for development and testing with a 10-minute walltime limit (maximum 1 hour allowed). Only one debug job can be queued at a time, and the A100 GPU is not divided into smaller instances in this partition. ```bash sbatch --account=lp_myproject --clusters=wice --partition=gpu_a100_debug \ --nodes=1 --ntasks=64 --gpus-per-node=1 --time=00:10:00 \ myjobscript.slurm ``` -------------------------------- ### MATLAB Function Definition with Input Handling Source: https://github.com/hpcleuven/vscdocumentation/blob/master/source/compute/software/matlab_getting_started.md Defines a MATLAB function that accepts two input parameters, converts them to numerics if they are strings, calculates their sum, and saves the results to a file. The function then exits. ```matlab function testmatlabfunction(input1,input2) % source: https://wiki.inf.ed.ac.uk/ANC/MatlabComputing % change arguments to numerics if necessary - only when compiling code if ~isnumeric(input1) input1n = str2num(input1); input2n = str2num(input2); else input1n = input1; input2n = input2; end sumofinputs = input1n + input2n; outputfilename = ['testfunction_' num2str(input1n) '_' num2str(input2n)]; save(outputfilename, 'input1n', 'input2n', 'sumofinputs'); exit; end ``` -------------------------------- ### Submit Job to wICE Sapphire Rapids Partition Source: https://github.com/hpcleuven/vscdocumentation/blob/master/source/leuven/wice_quick_start.md Command to submit a 2-node batch job to Sapphire Rapids compute nodes (96 cores each) instead of IceLake nodes. For jobs requiring longer walltime (up to 7 days), use batch_sapphirerapids_long partition. Replace account and script name with your values. ```bash $ sbatch --account=lp_myproject --clusters=wice --partition=batch_sapphirerapids \ --nodes=2 --ntasks-per-node=96 --time=2:00:00 myjobscript.slurm ``` -------------------------------- ### Copy VM Configuration Example to main.tf Source: https://github.com/hpcleuven/vscdocumentation/blob/master/source/cloud/terraform.md This command copies the example Terraform configuration for a single VM (`single.tf.example`) into the `main.tf` file. This initializes the VM definition for customization. ```shell cat examples/single.tf.example >> main.tf ```