简体   繁体   English

使用 SLURM 设置 Matlab 的显示分辨率

[英]Set display resolution for Matlab with SLURM

I use to run some Matlab simulations on a HPC cluster.我曾经在 HPC 集群上运行一些 Matlab 模拟。

The cluster runs SLURM.集群运行 SLURM。

One of the outputs of my Matlab script is a GIF file which shows the time evolution of what I am simulating.我的 Matlab 脚本的输出之一是一个 GIF 文件,它显示了我正在模拟的时间演变。 Every frame of the GIF file is obtained by means of the command "getframe", which takes a snapshot of the display. GIF 文件的每一帧都是通过命令“getframe”获得的,该命令拍摄显示的快照。

When I run the Matlab script on my computer, the GIF file looks perfect, as the snapshot has the resolution of my computer.当我在我的电脑上运行 Matlab 脚本时,GIF 文件看起来很完美,因为快照具有我电脑的分辨率。 When I run the same Matlab script on the HPC cluster, submitting the job through SLURM, the GIF file looks bad, as it features a very low resolution.当我在 HPC 集群上运行相同的 Matlab 脚本并通过 SLURM 提交作业时,GIF 文件看起来很糟糕,因为它的分辨率非常低。 After all, the HPC cluster has not an actual display, maybe just a virtual display.毕竟,HPC 集群并没有实际的显示,也许只是一个虚拟的显示。

So, here is my question: can I change the resolution of the virtual display when I submit the job, so that the snapshots which Matlab takes during the simulation look high-resolution?所以,这是我的问题:我可以在提交作业时更改虚拟显示器的分辨率,以便 Matlab 在模拟期间拍摄的快照看起来很高分辨率吗?

Try adding the following before the call to getframe :尝试在调用getframe之前添加以下内容:

h = figure;
h.WindowState = 'maximized';

This will make sure the window is maximised before the snapshot is captured.这将确保 window 在捕获快照之前最大化。 You then should get a higher resolution image.然后你应该得到一个更高分辨率的图像。

If that does not work, another option is to save each image to disk with print , where you can specify the resolution explicitly:如果这不起作用,另一种选择是使用print将每个图像保存到磁盘,您可以在其中明确指定分辨率:

print('-dpng', '-r200', filename)

but then you will have to merge all the files in a movie in a subsequent step.但是随后您将不得不在后续步骤中合并电影中的所有文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM