Problem of plotting picture and video in Linux HPC

In summary, the conversation discusses a Matlab program that runs without problems in a Windows OS but encounters warnings and errors when run in a Linux high performance computer. The program is used to create AVI files and TIFF pictures from a data file. It is mentioned that the program cannot be run in a system without display and that modifications may be needed for it to work in the HPC. The code for the program is also provided for reference. Possible solutions involving setting the DISPLAY environment variable and using X-forwarding are suggested.
  • #1
kelvin490
Gold Member
228
3
I have a Matlab program that reads data file and then create avi. files and tiff pictures. It runs without problem in window OS using R2014a but cannot run in a Linux high performance computer(HPC).

When the Matlab in Linux is started there are two warnings:
Warning: No display specified. You will not be able to display graphics on the screen.
Warning: No window system found. Java option 'Desktop' ignored.

When I run my program there are two error messages:
Error using getframe (line 53)
getframe requires a valid figure window.

Error in Density_3Dplot (line 93)
writeVideo(vid, getframe(gcf)); %get the picture and put in the avi file with
the handle "vid"

When I run the program in window, pictures are displayed one by one and the command getframe and writeVideo are used to put the pictures into the avi file. However when I run it in a node in HPC nothing can be displayed. How can I modify my program so that it can be run in a system without display? Thanks a lot.

I put my code here for your reference:
clear; close all; clc;%clear all previous data
fig = figure(1);%These two lines maximize the figure dialogue
set(fig,'Units','normalized','outerPosition',[0,0,1,1]);
fig_color='w'; fig_colordef='white';
cMap=jet(256);%set the colomap using the "jet" scale
%The following defines an alternative colormap called cMap2 (from white to red)Nmap=64;
cMin2 =[111];
cMax2 =[100];
cMap2 = zeros(Nmap,3);for i =1:Nmap;
cMap2(i,:)= cMin2*(Nmap- i)/(Nmap-1)+ cMax2*(i -1)/(Nmap-1);end

% cMap(1,:)=[111];
faceAlpha1=1;
faceAlpha2=0.65;
edgeColor1='none';
edgeColor2='none';NumBoxX=100;%box number in x direction
NumBoxY=100;%box number in y directionNumBoxZ=5;%box number in z directionFirstFile=0;%the number of the first file to be readFileInterval=400;%the number of intervals between filesLastFile=2000;%the number of the last file to be read34010ValCol=4;%indicate which column is used as value for plotting e.g. the 4th column is dis. density

[MinDis,MaxDis]=Find_MaxMin(FirstFile,FileInterval,LastFile,ValCol);%Call the function to find min and max density,used to define the range of colorbar

set(gcf,'Renderer','zbuffer');%eliminate unnecessary background and prevent stationary video -Important!
vid =VideoWriter('Evolution.avi');%Create a avi file
vid.Quality=100;
vid.FrameRate=15;
open(vid);%Open the avi file so that films can be put into it later on

for ii=FirstFile:FileInterval:LastFile%Thisfor loop controls the sequential reading of data files
ns = numel(num2str(ii));%Findout the number of digits of the number of file
switch ns %The following converts the file name so that they can be used in fopen belowcase1%it's for one digit, 1,2 etc.
filename = ['rho ' num2str(ii) '.dat'];
case 2 %it's for two digits,10,20 etc.
filename =['rho ' num2str(ii)'.dat'];case3%it's for three digits, 100,110 etc.
filename = ['rho ' num2str(ii) '.dat'];
case 4 %it's for4 digits
filename =['rho ' num2str(ii)'.dat'];case5%it's for 5 digits
filename = ['rho ' num2str(ii) '.dat'];
end

fid = fopen(filename,'r');
datacell = textscan(fid, '%f%f%f%f%f%f%f%f'); %There are 8 columns to be read so there are 8 %f
fclose(fid);

all_data = cell2mat(datacell); %converted into a matrix containing all the dis. density info. for every simulation cell

M=zeros(NumBoxX,NumBoxY,1); %create a matrix of 50x50x1,representing array of simulation cells M=zeros(NumBoxX,NumBoxY,NumBoxZ);
% % the following loops assign the dislocation density from all_data to M
for i=1:NumBoxX
for j=1:NumBoxY
for k=1:1 %for k=1:NumBoxZ Only the middle plate is shown
num=3+NumBoxZ*(j-1)+NumBoxZ*NumBoxY*(i-1);%num=k+NumBoxZ*(j-1)+NumBoxZ*NumBoxY*(i-1);
% if all_data(num,ValCol)<1e13
% all_data(num,ValCol)=0;
% end
M(i,j,k)=all_data(num,ValCol); %the ValCol column of all_data is dislocation density
end
end
end

indPatch=1:numel(M);
[F,V,C]=ind2patch(indPatch,M,'v'); %Call the function ind2patch in order to plot 3D cube with color
title('adfdadasfdasf','fontsize',20);%set title \sigma_{xx}
xlabel('y','fontsize',15);ylabel('x','fontsize',15); zlabel('z','fontsize',20); hold on;
set(get(gca,'xlabel'),'Position',[50 -10 30]); %set position of axis label
set(get(gca,'ylabel'),'Position',[-3 50 -15]);
% set(get(gca,'zlabel'),'Position',[64 190 -60]);
patch('Faces',F,'Vertices',V,'FaceColor','flat','CData',C,'EdgeColor','k','FaceAlpha',0.5);
axis equal; view(90,-90); axis tight; axis vis3d; grid off;
colormap(cMap);
caxis([MinDis MaxDis]); %set the range of the colorbar MinDis MaxDis %caxis([min(M(:)) max(M(:))]); %range of the colorbar according to one file only
cb = colorbar; % create the colorbar
set(get(cb,'title'),'string','dfdfdfd(m^{-2})','fontsize',20); % label the colorbar Stress (MPa)

lbpos = get(cb,'title'); % get the handle of the colorbar title
set(lbpos,'units','normalized','position',[0,1.06]);
MyAxes=gca;
set(MyAxes,'Units','Normalized','position',[0.05,0.1,0.8,0.8]);

writeVideo(vid, getframe(gcf)); %get the picture and put in the avi file with the handle "vid"

title('aaaaa','fontsize',10);%set title \sigma_{xx}
set(get(cb,'title'),'string','aaaaa(m^{-2})','fontsize',10); % label the colorbar Stress (MPa)
picturename = ['aaaaa' num2str(ii) ]; % set the name of the picture with number
print(fig,picturename,'-dtiff');%save the picture in choosen format '-djpeg' | '-dpng' | '-dtiff' | '-dpdf' | '-deps' | ...end

close(vid); %close the avi file after putting all the films into it
 
Last edited:
Physics news on Phys.org
  • #2
It might be that you need to set your DISPLAY environment variable,

http://nl.mathworks.com/matlabcentral/newsreader/view_thread/165074

Basically you do something like:
export DISPLAY=192.168.1.1:0

where 192.168.1.1 is the ip-adress of the hpc machine.

If you log in remotely using ssh, you also need to use X-forwarding.
 

1. How can I plot pictures and videos in Linux HPC?

In order to plot pictures and videos in Linux HPC, you will need to use a software package specifically designed for this purpose. Some popular options include Gnuplot, Matplotlib, and ImageMagick. These packages offer a wide range of tools and features for creating and manipulating images and videos.

2. Can I use any plotting software on Linux HPC?

Yes, you can use most plotting software on Linux HPC as long as it is compatible with the operating system and has been properly installed. However, some software may run more efficiently on Linux HPC compared to others, so it is recommended to do some research and choose a package that is optimized for this environment.

3. What are some common challenges when plotting pictures and videos in Linux HPC?

One of the main challenges when plotting pictures and videos in Linux HPC is ensuring compatibility between the software, the operating system, and the hardware. This can require some technical knowledge and troubleshooting, especially when using more advanced features. Additionally, the large amount of data and processing power required for plotting high-resolution images and videos can also pose a challenge.

4. Are there any specific libraries or tools that can help with plotting pictures and videos in Linux HPC?

Yes, there are several libraries and tools that are specifically designed for plotting pictures and videos in Linux HPC. These include OpenCV, FFmpeg, and VTK. These libraries offer a wide range of features and functions for working with images and videos on a high-performance computing platform.

5. Can I create interactive plots and videos on Linux HPC?

Yes, it is possible to create interactive plots and videos on Linux HPC using tools like Bokeh, Plotly, and D3. These packages allow for the creation of dynamic and interactive visualizations that can be used for data analysis and presentation. However, these tools may require more resources and technical expertise to use effectively on a HPC system.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
5K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
3K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
1
Views
4K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
3K
  • Programming and Computer Science
Replies
4
Views
4K
Back
Top