ubuntu 24 使用OF4
-
最近开始用正经超算跑程序了,记录一下Singularity配置和运行OF4。
下面是为什么不能使用docker的原因Singularity or Docker Docker images provide a means to gain root access to the system they are running on. For this reason Docker is not available on the PC2 clusters. Singularity is compatible with all Docker images and it can be used with GPUs and MPI applications. Here is a comparision between virtual machines, Docker and Singularity. Singularity images are stored as a single file which makes them easily shareable. You can host your images on the Singularity Cloud Library for others to download. You could also make it available by putting it on a web server like any other file. Singularity can be used to run massively-parallel applications which leverage fast interconnects like InfiniBand and GPUs. These applications suffer minimal performance loss since Singularity was designed to run "close to the hardware".
根据说明,Singularity 可以无痛转换docker 镜像
因此,
OF4的原生docker地址
https://hub.docker.com/r/openfoam/openfoam4-paraview50执行下面命令即可,然后就是等待
singularity pull docker://openfoam/openfoam4-paraview50
然后就可以得到
openfoam4-paraview50_latest.sif
文件执行和测试运行下面命令即可。
singularity run ./openfoam4-paraview50_latest.sif
但是如果使用自己编译的程序的话,会有寻找不到路径的情况,就要根据自己的情况处理。
可以在.bashrc文件中添加下面的内容
# User specific aliases and functions export WM_PROJECT_USER_DIR="/xxxxx/xxx/path"
配合SLRUM的话,因为OF4版本太老,没有找到其他使用外部系统高版本的MPI的解决办法。所以只能使用自带的内部MPI运行。
#!/bin/bash #SBATCH ... 根据自己情况配置 module 自己配置 singularity exec ~/openfoam4-paraview50_latest.sif ./run_OF4.sh
下面的脚本内容
#!/bin/bash source /opt/openfoam4/etc/bashrc bash rm -rf processor* decomposePar mpirun -np 32 reactingParcelFoam -parallel