How to launch research software applications (Matlab, Stata, R, Mathematica) on Andes and Polaris high-performance linux machines (HPC's)

Launching software from Andes, Polaris:  

See https://services.dartmouth.edu/TDClient/KB/ArticleDet?ID=64641  for more details on running research software on our Linux HPC's such as Andes and Polaris. 

Begin by ensuring that you have FastX installed on your Mac/Win system: https://services.dartmouth.edu/TDClient/KB/ArticleDet?ID=81595
and that you are able to open an Xterm session on andes.dartmouth.edu or polaris.dartmouth.edu.  These can be done using an ssh connection with the -Y option, for example ssh -Y netid@polaris.dartmouth.edu 

Once you get the Xterm window open and the '$' prompt, do a quick test to make sure your terminal command line can also open up an external X window by typing xclock& at the command line: 

       $ xclock&

In a few seconds, you should see a new window open with a small clock in it.    

Close the clock window when it appears.  If not, re-install your X Window software (FastX, MobaXterm, XQuartz)

Click back inside the terminal window, and press the Enter/Return key to get a new command prompt ($).  Then, type the following command below to load the software you'd like to use (matlab, stata, R, etc) at the "$" prompt in your terminal window: 

       $ module load matlab

And then the software name to launch the interactive software in a new terminal X Window. 

       $ matlab ​​​​ 

Some software packages have more than one version installed.  Stata is one example.  Type module avail stata to see available versions

       $ module avail stata

       $ module load stata/15 ​​​​ 

       $ xstata 

       $ spss

       $ sas

Note: to use the "Discovery" HPC, there are extra steps involved to create a "batch submission" script.  See https://services.dartmouth.edu/TDClient/1806/Portal/KB/?CategoryID=21754 and https://services.dartmouth.edu/TDClient/1806/Portal/KB/ArticleDet?ID=132372)

Your DartFS file storage system is available at this same command prompt.  You can drag and drop files in, or use a Unix cp or mv command.  Type  ls to view files:
       $    ls

       mydata_on_dartfs_netid.csv
       myRscript.R
       myMatlabMfiles.M  

You can run R script files using the Rscript command.
       $    Rscript myRscript.R

Note: MATLAB .m files can be run using MATLAB without the graphical interface (the MATLAB GUI does not run on Discovery with srun)

Matlab can be run without the graphical interface
       $    matlab -nodisplay -nojvm -nosplash -nodesktop 

                      <  M A T L A B >  

       >>>  

 

Matlab scripts can be run at the prompt without the graphical interface

          Author a script on your desktop installation of Matlab, and save it to DartFS.  Samlpe script titled "testmfile.m", which contains the following code: 

                       

This script can then be run by logging with your DartFS account and navigating to the directory 
         $ module load matlab       

         $ matlab -nodisplay -nodesktop -nosplash -nojvm -r "run testmfile.m"

Scripts can be written to accept parameters and write to files  

                        
         $  matlab -nodisplay -nodesktop -nosplash -nojvm -r "matlabfunctionwritefile(25)" 

Scripts can also be written to export data out to your DartFS file storage: 

Example:  a script called "script.m" containing the following:
A = magic(5);
outputfile1 = 'output1.xlsx';
writematrix(A,outputfile1,'Sheet',1,'Range','E1:I5');
outputfile2 = '//dartfs-hpc/rc/home/2/username2/output2.xlsx';
writematrix(A,outputfile2,'Sheet',1,'Range','E1:I5');

Then run on Polaris at the command line like this:
[usrname@polaris ~]$ module load matlab
[usrname@polaris ~]$ matlab -nodisplay -nodesktop -nosplash -nojvm -r "run script.m"

This will output files "output1.xlsx" and "output2.xlsx" to the user's home directory.  Note the use of the full file path in the second file - this method could be used to write to subfolders on your DartFS file system.

Syntax examples for submitting a regular job: 
$ matlab -nodisplay -nodesktop -nosplash -nojvm -r "run jobname.m"

Syntax example with Try-Catch-End statement:
$ matlab -nodisplay -nodesktop -nosplash -nojvm -r "try; run('YourScriptName.m'); catch; end; exit";

Mathematica

[usrname@polaris ~]$ module load mathematica
[usrname@polaris ~]$ module avail mathematica

SSH Terminal and X Window Clients

     Windows / Mac / Linux "FastX" https://services.dartmouth.edu/TDClient/KB/ArticleDet?ID=81595

     Windows:  Gitbash  https://git-scm.com/downloads 

     Mac:  use built-in 'Terminal' Unix Shell 

     See this link for more help with the Andes Polaris Linux HPC machines:  https://services.dartmouth.edu/TDClient/KB/ArticleDet?ID=64641 

RStudio

Create a FastX connection to andes.dartmouth.edu on the Open Connections page, using the + button, Port 22 and your Dartmouth NetID

Uploaded Image (Thumbnail)

Double-click the connection and when prompted, enter your NetID password. 

After logging in, click the large + button ('Start a new Session')

Uploaded Image (Thumbnail)

Click the xterm button 

At the prompt, (username@andes$) type rstudio

R Studio will launch in a new window 

Uploaded Image (Thumbnail)

 

Details

Article ID: 78493
Created
Fri 5/17/19 12:34 PM
Modified
Thu 1/18/24 11:38 AM