<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="/assets/xslt/atom.xslt" ?>
<?xml-stylesheet type="text/css" href="/assets/css/atom.css" ?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<id>https://adambatten.com/</id>
	<title>Adam Batten</title>
	<updated>2025-11-25T02:03:00+00:00</updated>

	<subtitle>Adam Batten | Astronomer &amp; Data Analyst</subtitle>

	
		
		<author>
			
				<name>Adam Batten</name>
			
			
			
		</author>
	

	<link href="https://adambatten.com/atom.xml" rel="self" type="application/rss+xml" />
	<link href="https://adambatten.com/" rel="alternate" type="text/html" />

	<generator uri="http://jekyllrb.com" version="3.10.0">Jekyll</generator>

	
		<entry>
			<id>https://adambatten.com/tutorials/installing_anaconda/</id>
			<title>Installing Python with Anaconda</title>
			<link href="https://adambatten.com/tutorials/installing_anaconda/" rel="alternate" type="text/html" title="Installing Python with Anaconda" />
			<updated>2022-03-18T00:00:00+00:00</updated>

			
				
				<author>
					
						<name>Adam Batten</name>
					
					
					
				</author>
			
			<summary>A guide for installing Python for the first time.</summary>
			<content type="html" xml:base="https://adambatten.com/tutorials/installing_anaconda/">&lt;div class=&quot;row&quot;&gt;
&lt;div class=&quot;medium-4 medium-push-8 columns&quot;&gt;
    &lt;div class=&quot;panel radius&quot;&gt;
      &lt;p id=&quot;toc&quot;&gt;&lt;strong&gt;Table of Contents&lt;/strong&gt;&lt;/p&gt;
&lt;ul id=&quot;markdown-toc&quot;&gt;
  &lt;li&gt;&lt;a href=&quot;#a-guide-to-installing-python-with-anaconda&quot; id=&quot;markdown-toc-a-guide-to-installing-python-with-anaconda&quot;&gt;A Guide to Installing Python with Anaconda.&lt;/a&gt;    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#python&quot; id=&quot;markdown-toc-python&quot;&gt;Python&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#downloading-and-installing-anaconda&quot; id=&quot;markdown-toc-downloading-and-installing-anaconda&quot;&gt;Downloading and Installing Anaconda&lt;/a&gt;        &lt;ul&gt;
          &lt;li&gt;&lt;a href=&quot;#windows-10-installation&quot; id=&quot;markdown-toc-windows-10-installation&quot;&gt;Windows 10 Installation&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href=&quot;#macos-installation&quot; id=&quot;markdown-toc-macos-installation&quot;&gt;MacOS Installation&lt;/a&gt;&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#anaconda-navigator&quot; id=&quot;markdown-toc-anaconda-navigator&quot;&gt;Anaconda Navigator&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

    &lt;/div&gt;
  &lt;/div&gt;&lt;!-- /.medium-4.columns --&gt;

&lt;div class=&quot;medium-8 medium-pull-4 columns&quot;&gt;

    &lt;h1 id=&quot;a-guide-to-installing-python-with-anaconda&quot;&gt;A Guide to Installing Python with Anaconda.&lt;/h1&gt;

    &lt;p class=&quot;success&quot;&gt;This tutorial is a write up of the installation instructions used for my “Introduction to Python Workshops” that I ran at Swinburne University of Technology. 
These workshops were targeted at Year 10 work experience students to learn the basics of loading data nd plotting with Python.&lt;/p&gt;

    &lt;h2 id=&quot;python&quot;&gt;Python&lt;/h2&gt;
    &lt;p&gt;Python is a programming language that is very popular and is used by many astronomers to perform their research. Some of the uses of Python include reading telescope data, analysing simulations and making graphs/plots of results. If you were you were to google ‘Install Python’ you would see many different options and versions of Python to install and from dfferent locations. It isn’t particularly clear which one you should use, how to install it and how to use it one you have.&lt;/p&gt;

    &lt;p&gt;Additionally, if you are using MacOS or Linux your computer likely already has a version of Python already installed to run the operating system. So installing a new version may cause some conficting issues with your computer, particularly if when you want to install more ‘Python packages’ (we will get to this later).&lt;/p&gt;

    &lt;p&gt;However there is much easier and better way to install Python. This is through using Anaconda.&lt;/p&gt;

    &lt;h2 id=&quot;downloading-and-installing-anaconda&quot;&gt;Downloading and Installing Anaconda&lt;/h2&gt;
    &lt;p&gt;Anaconda is distribution of Python designed for scientific computing. By installing Python through Anaconda, it makes managing and installing Python packages/versions significantly easier&lt;/p&gt;

    &lt;p&gt;You should be able to follow these instructions to install Anaconda on your system:&lt;/p&gt;

    &lt;ul&gt;
      &lt;li&gt;Go to &lt;a href=&quot;https://www.anaconda.com/products/individual&quot;&gt;https://www.anaconda.com/products/individual&lt;/a&gt; and click on ‘Download’. It should take you to the bottom of the page to the different options (see Figure 1 below).&lt;/li&gt;
      &lt;li&gt;Choose the installer for your operating system. You will probably want to use the graphical installer since it is much easier. &lt;strong&gt;Windows users note:&lt;/strong&gt; You can only use a graphical installer, but you need to check if your system is 64-bit (most likely) vs 32-bit, then choose the appropriate one. You can check which type your computer is by &lt;a href=&quot;https://support.microsoft.com/en-us/windows/32-bit-and-64-bit-windows-frequently-asked-questions-c6ca9541-8dce-4d48-0415-94a3faa2e13d&quot;&gt;clicking here&lt;/a&gt; and following the instructions.&lt;/li&gt;
      &lt;li&gt;After the download completes, double click on the file to open the installer. It should like Figure 2 on Windows 10 or Figure 7 on MacOS Big Sur.&lt;/li&gt;
      &lt;li&gt;Then follow either the &lt;a href=&quot;#windows-10-installation&quot;&gt;Windows 10&lt;/a&gt; or &lt;a href=&quot;#macos-installation&quot;&gt;MacOS&lt;/a&gt; installation instructions that follows.&lt;/li&gt;
    &lt;/ul&gt;

    &lt;p&gt;&lt;img src=&quot;/images/tutorials/anaconda_install/anaconda_install_0.png&quot; /&gt;&lt;/p&gt;
    &lt;p&gt;&lt;small align=&quot;center&quot;&gt;Figure 1 - Anaconda installation options. Choose the one that is appropriate for your computer.&lt;/small&gt;&lt;/p&gt;

    &lt;h3 id=&quot;windows-10-installation&quot;&gt;Windows 10 Installation&lt;/h3&gt;
    &lt;ul&gt;
      &lt;li&gt;Click ‘I Agree’ to the licensing agreement (see Figure 3).&lt;/li&gt;
      &lt;li&gt;Select to install for ‘Just Me’ then click ‘Next’.&lt;/li&gt;
      &lt;li&gt;Choose location to install. The default location should be something &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;C:\\Users\&amp;lt;NAME&amp;gt;\anaconda3&lt;/code&gt;. This default location is normally recommended, but you can install it elsewhere.&lt;/li&gt;
      &lt;li&gt;Tick the boxes that say &lt;em&gt;‘Add Anaconda3 to my PATH environment variable’&lt;/em&gt; and &lt;em&gt;‘Register Anaconda3 as my default Python 3.8’&lt;/em&gt;. See Figure 4. It will likely have a red warning that says the first option is not recommended, because it ‘makes anaconda get found before previously installed software’, but that is actually what we want to happen. It might also say a different number to Python 3.8 (i.e Python 3.9, 3.10, etc..), this is also okay.&lt;/li&gt;
      &lt;li&gt;Continue to Section &lt;a href=&quot;#anaconda-navigator&quot;&gt;Anaconda Navigator&lt;/a&gt;.&lt;/li&gt;
    &lt;/ul&gt;

    &lt;p&gt;&lt;img src=&quot;/images/tutorials/anaconda_install/anaconda_install_1.png&quot; /&gt;&lt;/p&gt;
    &lt;p align=&quot;center&quot;&gt;&lt;small&gt;Figure 2 - Anaconda Installer (Windows 10)&lt;/small&gt;&lt;/p&gt;

    &lt;p&gt;&lt;img src=&quot;/images/tutorials/anaconda_install/anaconda_install_2_windows.png&quot; /&gt;&lt;/p&gt;
    &lt;p align=&quot;center&quot;&gt;&lt;small&gt;Figure 3 - Anaconda License Agreement (Windows 10)&lt;/small&gt;&lt;/p&gt;

    &lt;p&gt;&lt;img src=&quot;/images/tutorials/anaconda_install/anaconda_install_6_windows.png&quot; /&gt;&lt;/p&gt;
    &lt;p align=&quot;center&quot;&gt;&lt;small&gt;Figure 4 - Anaconda installation options on Windows 10. You want to tick both boxes.&lt;/small&gt;&lt;/p&gt;

    &lt;h3 id=&quot;macos-installation&quot;&gt;MacOS Installation&lt;/h3&gt;
    &lt;ul&gt;
      &lt;li&gt;Click ‘Continue’ on Read Me to get to the licensing agreement.&lt;/li&gt;
      &lt;li&gt;Click ‘Continue’ then ‘I Agree’ to the licensing agreement (see Figure 7).&lt;/li&gt;
      &lt;li&gt;Click ‘Install’ on installation type. This will install anaconda in the default location, this is usually &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/Users/&amp;lt;NAME&amp;gt;/opt/anaconda3&lt;/code&gt;.&lt;/li&gt;
      &lt;li&gt;Click ‘Continue’ after the installation is complete.&lt;/li&gt;
      &lt;li&gt;Continue to Section &lt;a href=&quot;#anaconda-navigator&quot;&gt;Anaconda Navigator&lt;/a&gt;.&lt;/li&gt;
    &lt;/ul&gt;

    &lt;p&gt;&lt;img src=&quot;/images/tutorials/anaconda_install/anaconda_install_1_mac.png&quot; /&gt;&lt;/p&gt;
    &lt;p align=&quot;center&quot;&gt;&lt;small&gt;Figure 6 - Anaconda Installer (MacOS)&lt;/small&gt;&lt;/p&gt;

    &lt;p&gt;&lt;img src=&quot;/images/tutorials/anaconda_install/anaconda_install_2_mac.png&quot; /&gt;&lt;/p&gt;
    &lt;p align=&quot;center&quot;&gt;&lt;small&gt;Figure 7 - Anaconda License Agreement (MacOS)&lt;/small&gt;&lt;/p&gt;

    &lt;h2 id=&quot;anaconda-navigator&quot;&gt;Anaconda Navigator&lt;/h2&gt;
    &lt;p&gt;To check that Anaconda has been correctly installed we will attempt to open the Anaconda Navigator. You can load this program by doing the folowwing:&lt;/p&gt;

    &lt;ul&gt;
      &lt;li&gt;&lt;strong&gt;Windows:&lt;/strong&gt; Click the home button and search for ‘anaconda navigator’, then click to open&lt;/li&gt;
      &lt;li&gt;&lt;strong&gt;MacOS:&lt;/strong&gt; Click ‘Launchpad’ and search ‘anaconda-Navigator’, then click to open.&lt;/li&gt;
    &lt;/ul&gt;

    &lt;p&gt;The program should look something similar to Figures 8 (Windows) and 9 (MacOS). Note that you may have different icons or tiles showing based on what is already installed on your computer. The important thing you should be able to see is something called ‘JupyterLab’ and ‘Jupyter Notebook’. If you can see both of these, then it has installed correctly and you are ready to start using Anaconda and Python.&lt;/p&gt;

    &lt;p&gt;&lt;img src=&quot;/images/tutorials/anaconda_install/anaconda_navigator_windows.png&quot; /&gt;&lt;/p&gt;
    &lt;p align=&quot;center&quot;&gt;&lt;small&gt;Figure 8 - Anaconda Navigator in Windows 10&lt;/small&gt;&lt;/p&gt;

    &lt;p&gt;&lt;img src=&quot;/images/tutorials/anaconda_install/anaconda_navigator_macos.png&quot; /&gt;&lt;/p&gt;
    &lt;p align=&quot;center&quot;&gt;&lt;small&gt;Figure 9 - Anaconda Navigator in MacOS&lt;/small&gt;&lt;/p&gt;
  &lt;/div&gt;&lt;/div&gt;
</content>

			
				<category term="tutorial" />
			
			

			<published>2022-03-18T00:00:00+00:00</published>
		</entry>
	
		<entry>
			<id>https://adambatten.com/tutorials/setting_up_python_on_ozstar/</id>
			<title>Setting up Python on OzSTAR</title>
			<link href="https://adambatten.com/tutorials/setting_up_python_on_ozstar/" rel="alternate" type="text/html" title="Setting up Python on OzSTAR" />
			<updated>2021-02-02T00:00:00+00:00</updated>

			
				
				<author>
					
						<name>Adam Batten</name>
					
					
					
				</author>
			
			<summary>This is a short guide on how to set up Python on OzSTAR, the supercomputer located at the Swinburne University of Technology. This will guide you through setting up Conda enviroments and some of the pitfalls you may encounter along the way.</summary>
			<content type="html" xml:base="https://adambatten.com/tutorials/setting_up_python_on_ozstar/">&lt;div class=&quot;row&quot;&gt;
&lt;div class=&quot;medium-4 medium-push-8 columns&quot;&gt;
    &lt;div class=&quot;panel radius&quot;&gt;
      &lt;p id=&quot;toc&quot;&gt;&lt;strong&gt;Table of Contents&lt;/strong&gt;&lt;/p&gt;
&lt;ul id=&quot;markdown-toc&quot;&gt;
  &lt;li&gt;&lt;a href=&quot;#getting-started-with-using-conda-environments-on-ozstar&quot; id=&quot;markdown-toc-getting-started-with-using-conda-environments-on-ozstar&quot;&gt;Getting Started with using Conda Environments on OzStar&lt;/a&gt;    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#this-tutorial-covers&quot; id=&quot;markdown-toc-this-tutorial-covers&quot;&gt;This Tutorial Covers:&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#this-tutorial-assumes-you-can&quot; id=&quot;markdown-toc-this-tutorial-assumes-you-can&quot;&gt;This Tutorial Assumes You Can:&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#some-key-definitions&quot; id=&quot;markdown-toc-some-key-definitions&quot;&gt;Some Key Definitions:&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#preparation&quot; id=&quot;markdown-toc-preparation&quot;&gt;Preparation&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#loading-anaconda&quot; id=&quot;markdown-toc-loading-anaconda&quot;&gt;Loading Anaconda&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#using-conda-environments&quot; id=&quot;markdown-toc-using-conda-environments&quot;&gt;Using Conda environments&lt;/a&gt;    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#why-use-a-conda-environment&quot; id=&quot;markdown-toc-why-use-a-conda-environment&quot;&gt;Why use a Conda Environment?&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#creating-a-conda-environment&quot; id=&quot;markdown-toc-creating-a-conda-environment&quot;&gt;Creating a Conda Environment&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#activate-a-conda-environment&quot; id=&quot;markdown-toc-activate-a-conda-environment&quot;&gt;Activate a Conda Environment&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#deactivate-a-conda-environment&quot; id=&quot;markdown-toc-deactivate-a-conda-environment&quot;&gt;Deactivate a Conda Environment&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#issues-with-home-directory-quota&quot; id=&quot;markdown-toc-issues-with-home-directory-quota&quot;&gt;Issues with Home Directory Quota&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#python-3-vs-python-2&quot; id=&quot;markdown-toc-python-3-vs-python-2&quot;&gt;Python 3 vs. Python 2&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#acknowledgements&quot; id=&quot;markdown-toc-acknowledgements&quot;&gt;Acknowledgements&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

    &lt;/div&gt;
  &lt;/div&gt;&lt;!-- /.medium-4.columns --&gt;

&lt;div class=&quot;medium-8 medium-pull-4 columns&quot;&gt;

    &lt;h2 id=&quot;getting-started-with-using-conda-environments-on-ozstar&quot;&gt;Getting Started with using Conda Environments on OzStar&lt;/h2&gt;

    &lt;p&gt;This is a short guide on how to set up Python on &lt;a href=&quot;https://supercomputing.swin.edu.au/ozstar/&quot;&gt;OzSTAR&lt;/a&gt;, the supercomputer located at the &lt;a href=&quot;https://www.swinburne.edu.au/&quot;&gt;Swinburne University of Technology&lt;/a&gt;. This will guide you through setting up &lt;a href=&quot;https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html&quot;&gt;Conda enviroments&lt;/a&gt; and some of the pitfalls you may encounter along the way. Keep in mind this isn’t necessarily the ‘perfect’ way to use Python on OzSTAR (since it really depends on your use case), but this tutorial is a good recommendation to get started for most people.&lt;/p&gt;

    &lt;p&gt;If you are unfamiliar with &lt;a href=&quot;https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html&quot;&gt;Conda environments&lt;/a&gt; before this guide, they may feel a little different, but will make using Python on OzSTAR significantly easier in the long run.&lt;/p&gt;

    &lt;p&gt;&lt;mark&gt;
Note: This is primarily aimed at people that will be using OzSTAR, and may not be applicable in other circumstances. 
&lt;/mark&gt;&lt;/p&gt;

    &lt;h3 id=&quot;this-tutorial-covers&quot;&gt;This Tutorial Covers:&lt;/h3&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#preparation&quot;&gt;Preparation&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#loading-anaconda&quot;&gt;Loading Anaconda&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#using-conda-environments&quot;&gt;Using Conda Environments&lt;/a&gt;
        &lt;ul&gt;
          &lt;li&gt;&lt;a href=&quot;#why-use-a-conda-environment&quot;&gt;Why Use a Conda Environment?&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href=&quot;#creating-a-conda-environment&quot;&gt;Creating a Conda Environment&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href=&quot;#activate-a-conda-environment&quot;&gt;Activate a Conda Environment&lt;/a&gt;&lt;/li&gt;
          &lt;li&gt;&lt;a href=&quot;#deactivate-a-conda-environment&quot;&gt;Deactivate a Conda Environment&lt;/a&gt;&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#issues-with-home-directory-quota&quot;&gt;Issues With Home Directory Quota&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;

    &lt;h3 id=&quot;this-tutorial-assumes-you-can&quot;&gt;This Tutorial Assumes You Can:&lt;/h3&gt;
    &lt;ul&gt;
      &lt;li&gt;Log into OzSTAR&lt;/li&gt;
      &lt;li&gt;Can edit a text file (specifically your &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.bashrc&lt;/code&gt; or &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.bash_profile&lt;/code&gt;)&lt;/li&gt;
    &lt;/ul&gt;

    &lt;h3 id=&quot;some-key-definitions&quot;&gt;Some Key Definitions:&lt;/h3&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;https://www.anaconda.com/&quot;&gt;Anaconda&lt;/a&gt;: A distribution of Python designed for scientific computing. By installing Python through Anaconda, it makes managing and installing Python packages/versions much easier. In particular, Anaconda has a useful feature called ‘&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;conda&lt;/code&gt; environments’ which allows us to use different versions of Python or Python packages when we need to.&lt;/li&gt;
      &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;conda&lt;/code&gt;: A package and environment manger that is bundled with &lt;a href=&quot;https://www.anaconda.com/&quot;&gt;Anaconda&lt;/a&gt;. It can install packages similar to how &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pip&lt;/code&gt; can install Python packages from &lt;a href=&quot;https://pypi.org/&quot;&gt;PyPI&lt;/a&gt; using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;conda install&lt;/code&gt;. It can also create environments using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;conda create&lt;/code&gt;.&lt;/li&gt;
      &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.bashrc&lt;/code&gt;: This is a Bash shell script that runs whenever you launch an interactive shell. You can put any command(s) in a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.bashrc&lt;/code&gt; that you would write at the command prompt. Then every time you launch a new interactive shell all the commands in the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.bashrc&lt;/code&gt; will be executed. It is common practice to customise your &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.bashrc&lt;/code&gt; to include your own preferences (e.g. &lt;a href=&quot;https://en.wikipedia.org/wiki/Alias_(command)&quot;&gt;aliases&lt;/a&gt; for specific commands that you type often). You can find your &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.bashrc&lt;/code&gt; in your home directory (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;~/.bashrc&lt;/code&gt;).&lt;/li&gt;
      &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;PATH&lt;/code&gt;: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;PATH&lt;/code&gt; is an environment variable that specifies a collection of directories where programs are located. This list of directories are locations where programs can be started without having to type the entire path (e.g. &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/User/username/subfolder/otherfolder/program.exe&lt;/code&gt;). For example: to run Python you would normally just use the prefix &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;python&lt;/code&gt;, without specifying where Python is located. This is because &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;python&lt;/code&gt; is already the system &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;PATH&lt;/code&gt;. If there are multiple directories in &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;PATH&lt;/code&gt; that the required program can use, the one that will be used is the one that was added to the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;PATH&lt;/code&gt; the latest.&lt;/li&gt;
    &lt;/ul&gt;

    &lt;h2 id=&quot;preparation&quot;&gt;Preparation&lt;/h2&gt;

    &lt;p&gt;To get started, make sure that there is absolutely nothing related to Python environments currently found anywhere in your home directory or module lists.
This includes loading any of the OzSTAR Python modules (including Anaconda), like Python; &lt;a href=&quot;https://numpy.org/&quot;&gt;NumPy&lt;/a&gt;; &lt;a href=&quot;https://matplotlib.org/&quot;&gt;Matplotlib&lt;/a&gt;; etc, or having any &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;conda&lt;/code&gt; installation (like &lt;a href=&quot;https://www.anaconda.com/&quot;&gt;Anaconda&lt;/a&gt; and &lt;a href=&quot;https://docs.conda.io/en/latest/miniconda.html&quot;&gt;Miniconda&lt;/a&gt;). 
Loading modules or libraries that are required by Python packages is fine.&lt;/p&gt;

    &lt;p&gt;You can ensure that all modules have been unloaded from your session use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;module perge&lt;/code&gt;.&lt;/p&gt;

    &lt;p&gt;&lt;mark&gt;
In case you are unfamiliar, OzSTAR uses modules to manage the software it has installed. If you want to use a module you first have to load it. To load a module use the following command: `module load &lt;module_name&gt;/&lt;software_version&gt;`.
You can search for modules using `module spider &lt;module_name&gt;`. To view a list of all the modules you have loaded use `module ls`.
&amp;lt;/mark&amp;gt;&lt;/module_name&gt;&lt;/software_version&gt;&lt;/module_name&gt;&lt;/mark&gt;&lt;/p&gt;

    &lt;h2 id=&quot;loading-anaconda&quot;&gt;Loading Anaconda&lt;/h2&gt;
    &lt;p&gt;For managing Python on OzSTAR I suggest using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;anaconda3&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;conda&lt;/code&gt; environments.&lt;/p&gt;

    &lt;p&gt;Despite its name, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;anaconda3&lt;/code&gt; is can be used for both Python 3 and Python 2 (&lt;a href=&quot;#python-3-vs-python-2&quot;&gt;see warning about using Python 2&lt;/a&gt;).
However Anaconda3 has the tendency to overwrite the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;PATH&lt;/code&gt; to certain libraries that are used for Python packages. Examples of this include the HDF5-library &lt;a href=&quot;https://h5py.org/&quot;&gt;h5py&lt;/a&gt; and the MPI-library &lt;a href=&quot;https://mpi4py.readthedocs.io/en/stable/&quot;&gt;mpi4py&lt;/a&gt;. It is a good idea to use the system modules on OzSTAR (except for the system Python) as they are compiled and optimized for the OzStar architecture. Therefore if you have a list of system modules that need to be loaded, make sure to load &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;anaconda3&lt;/code&gt; first so that the other modules will override the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;anaconda3&lt;/code&gt; paths as they are loaded. Loading all modules after &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;anaconda3&lt;/code&gt; means that those corresponding libraries are found earlier in the system &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;PATH&lt;/code&gt; than &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;anaconda3&lt;/code&gt;’s libraries. This ensures that everything is found in the correct place. To do this you can execute the following:&lt;/p&gt;

    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;module purge
module load anaconda3/5.0.1
&amp;lt;load other modules&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
    &lt;p&gt;The reason for using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;module purge&lt;/code&gt; all loaded modules first is to make absolutely sure that no paths are being overridden by &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;anaconda3&lt;/code&gt;. I highly recommend using your &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.bashrc&lt;/code&gt; or &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.bash_profile&lt;/code&gt; for this, such that you don’t have to do it manually every time you login.&lt;/p&gt;

    &lt;p&gt;&lt;mark&gt;
The reason for using `anaconda3/5.0.1` rather than `anaconda3/5.1.0` (which is also available on OzSTAR), is because the latter version has a bug where OzSTAR will not correctly set the paths to Anaconda&apos;s commands (like `conda`; `activate`; `deactivate`). Instead, it attempts to use the ones from `anaconda3/5.0.1` whenever any environment besides the default is [activated](#activating-an-anaconda-environment). This means that it once an environment is [activated](#activating-an-anaconda-environment) using `anaconda3/5.1.0`, it becomes impossible to [deactivate](#deactivate-an-anaconda-environment) the environment again.
&lt;/mark&gt;&lt;/p&gt;

    &lt;p&gt;&lt;b&gt;Example:&lt;/b&gt;&lt;/p&gt;

    &lt;p&gt;If every time I want to log into OzSTAR I load the modules &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;anaconda3&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;openmpi&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;hdf5&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;git&lt;/code&gt;, to avoid having to type these out every single time I put this code into my &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.bashrc&lt;/code&gt; file. Note that the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;anaconda3/5.0.1&lt;/code&gt; comes directly after &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;module purge&lt;/code&gt;.&lt;/p&gt;
    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;module purge
module load anaconda3/5.0.1
module load openmpi/3.0.0
module load hdf5/1.10.1
module load git/2.16.0
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;

    &lt;h2 id=&quot;using-conda-environments&quot;&gt;Using Conda environments&lt;/h2&gt;
    &lt;p&gt;&lt;mark&gt;
TL;DR: Create custom environments using `conda create -n &lt;env_name&gt; python==&lt;python_version&gt;`, activate with `source activate &lt;environment_name&gt;` and deactivate with `source deactivate`.
&amp;lt;/mark&amp;gt;&lt;/environment_name&gt;&lt;/python_version&gt;&lt;/env_name&gt;&lt;/mark&gt;&lt;/p&gt;

    &lt;h3 id=&quot;why-use-a-conda-environment&quot;&gt;Why use a Conda Environment?&lt;/h3&gt;
    &lt;p&gt;The main purpose to using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;conda&lt;/code&gt; environments is to create an isolated environment for your project. This means you don’t have to worry about if different projects you are working on require different versions of software.&lt;/p&gt;

    &lt;p&gt;Say for example that you are writing some code for one of your projects. This project requires Python &amp;gt; 3.5. However, in a different project at the same time you are using someone else’s software that is only compatible with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Python 2.7&lt;/code&gt;, you really have five choices:&lt;/p&gt;

    &lt;ol&gt;
      &lt;li&gt;Uninstall and reinstall Python every single time you swap between the different software (&lt;strong&gt;tedious and not fun&lt;/strong&gt;).&lt;/li&gt;
      &lt;li&gt;Re-write the other software to be Python 3 compatible (&lt;strong&gt;also not fun&lt;/strong&gt;).&lt;/li&gt;
      &lt;li&gt;Re-write all your software to be compatible&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Python 2.7&lt;/code&gt;compatible (&lt;strong&gt;not fun and will be more limited in features and support&lt;/strong&gt;).&lt;/li&gt;
      &lt;li&gt;Give up entirely (&lt;strong&gt;really really not fun&lt;/strong&gt;).&lt;/li&gt;
      &lt;li&gt;Use different &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;conda&lt;/code&gt; environments to swap between&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Python 2.7&lt;/code&gt;and Python 3 easily.&lt;/li&gt;
    &lt;/ol&gt;

    &lt;h3 id=&quot;creating-a-conda-environment&quot;&gt;Creating a Conda Environment&lt;/h3&gt;

    &lt;p&gt;The first rule about using a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;conda&lt;/code&gt; environment is NEVER use the base/default &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;conda&lt;/code&gt; environment (i.e. the one that is activate with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;source activate&lt;/code&gt; with no additional arguments).
This environment is available to everyone that uses the same &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;anaconda3&lt;/code&gt; module, and therefore cannot be used in a personal manner.
It also does not allow for packages to be installed globally (within the environment), which certain Python packages cannot deal with.
This is generally a good idea to avoid as well on personal computers.&lt;/p&gt;

    &lt;p&gt;So for this reason you will have to first create an new custom environment. A new environment can be created as follows:&lt;/p&gt;
    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;conda create -n &amp;lt;environment_name&amp;gt; python==&amp;lt;python_version&amp;gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
    &lt;p&gt;This will create an environment with the name &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;environment_name&amp;gt;&lt;/code&gt; using Python version &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;python_version&amp;gt;&lt;/code&gt;. This environment will be stored in your &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;~/.conda/envs&lt;/code&gt; directory. You can create multiple environments for the different versions of Python required. I personally have a &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Python 3.8&lt;/code&gt; environment for 99.9% of my work and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Python 2.7&lt;/code&gt; environment to run software that hasn’t been update to &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Python 3&lt;/code&gt; yet.&lt;/p&gt;

    &lt;p&gt;If you don’t know what to name your environment, I would suggest naming your environment after the Python version. i.e If you are going to be using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Python 3.8&lt;/code&gt;, name the environment &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;py38&lt;/code&gt;, or you are using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Python 2.7&lt;/code&gt; name it &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;py27&lt;/code&gt;.&lt;/p&gt;

    &lt;h3 id=&quot;activate-a-conda-environment&quot;&gt;Activate a Conda Environment&lt;/h3&gt;
    &lt;p&gt;After the environment has been made, it can be activated with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;source activate &amp;lt;environment_name&amp;gt;&lt;/code&gt; (or &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;. activate &amp;lt;environment_name&amp;gt;&lt;/code&gt;, either one is fine). You will be able to see that your environment is activated because the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;&amp;lt;environment_name&amp;gt;&lt;/code&gt; will appear on the left hand side of your prompt as shown below.&lt;/p&gt;

    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;[~] conda activate py38
(py38) [~]
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;

    &lt;p&gt;After you activate your environment, packages can be installed using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;pip&lt;/code&gt; or &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;conda&lt;/code&gt; as normal without having to use the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;--user&lt;/code&gt; flag (which installs a package locally, but as environments are isolated, that is not necessary).&lt;/p&gt;

    &lt;p&gt;It’s also convenient to include the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;source activate &amp;lt;environment_name&amp;gt;&lt;/code&gt; in your &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.bashrc&lt;/code&gt; or &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.bash_profile&lt;/code&gt; so that your environment is automatically activated when you log into OzSTAR. For example, I have an environment called &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;py38&lt;/code&gt; and my &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.bashrc&lt;/code&gt; contains this:&lt;/p&gt;

    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;module purge
module load anaconda3/5.0.1
source activate py38

module load openmpi/3.0.0
module load hdf5/1.10.1
module load git/2.16.0
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;

    &lt;h3 id=&quot;deactivate-a-conda-environment&quot;&gt;Deactivate a Conda Environment&lt;/h3&gt;
    &lt;p&gt;To deactivate an active environment use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;source deactivate&lt;/code&gt; ( or &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;. deactivate&lt;/code&gt;).&lt;/p&gt;

    &lt;p&gt;Keep a note of the &lt;a href=&quot;#loading-anaconda&quot;&gt;issue with deactivating environments&lt;/a&gt; if you use &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;anaconda3/5.1.0&lt;/code&gt;.&lt;/p&gt;

    &lt;h2 id=&quot;issues-with-home-directory-quota&quot;&gt;Issues with Home Directory Quota&lt;/h2&gt;
    &lt;p&gt;&lt;mark&gt;
TL;DR: If you are running out of inode space in your home directory, you can move your `.conda` to Lustre with `mv /home/&lt;username&gt;/.conda /fred/oz&lt;group_number&gt;/&lt;username&gt;` and make a symbolic link with `ln -s /fred/oz&lt;group_number&gt;/&lt;username&gt;/.conda /home/&lt;username&gt;/.conda`
&amp;lt;/mark&amp;gt;&lt;/username&gt;&lt;/username&gt;&lt;/group_number&gt;&lt;/username&gt;&lt;/group_number&gt;&lt;/username&gt;&lt;/mark&gt;&lt;/p&gt;

    &lt;p&gt;The main downside with using this approach to use Python on OzSTAR is that &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;conda&lt;/code&gt; environments produce a large number of small files.
If you have many environments or large ones, it is possible that you will hit the file limit (aka inode limit) in your home directory (which is set to 100k).&lt;/p&gt;

    &lt;p&gt;A solution to this is to move the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;.conda&lt;/code&gt; folder to a project on Lustre (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;/fred/&lt;/code&gt;) and making a symbolic link between its location and your home directory.&lt;/p&gt;

    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;mv /home/&amp;lt;username&amp;gt;/.conda /fred/oz&amp;lt;group_number&amp;gt;/&amp;lt;username&amp;gt;
ln -s /fred/oz&amp;lt;group_number&amp;gt;/&amp;lt;username&amp;gt;/.conda /home/&amp;lt;username&amp;gt;/.conda
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;

    &lt;p&gt;This will allow you to use your environments anywhere as if they were still located in your home directory.
However keep in mind that Lustre is designed for long-term, big-file storage and therefore is not nearly as fast with reading as the home directories are.
This means that activating an environment or executing a script can take a while to start up (often about 30 seconds to 1 minute).
Once started, there are no speed differences as all required scripts and modules have now been loaded.
So in effect, the first Python script you run in your session will take about a minute longer to run, but the rest will be exactly the same.&lt;/p&gt;

    &lt;h2 id=&quot;python-3-vs-python-2&quot;&gt;Python 3 vs. Python 2&lt;/h2&gt;
    &lt;p class=&quot;warning&quot;&gt;It is advised that you should be using Python 3 for almost all of your projects. As of the 1st of January 2020, Python 2 is no longer supported. Meaning that packages like &lt;a href=&quot;https://numpy.org/&quot;&gt;NumPy&lt;/a&gt;, &lt;a href=&quot;https://matplotlib.org&quot;&gt;Matplotlib&lt;/a&gt;, &lt;a href=&quot;https://scipy.org&quot;&gt;SciPy&lt;/a&gt; and &lt;a href=&quot;https://astropy.org&quot;&gt;Astropy&lt;/a&gt; (plus more) will no longer update or fix issues with the Python 2 version of the software. If you absolutely need to use Python 2 for a specific project (e.g. legacy code that hasn’t been ported into Python 3 yet), you can set up a&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;Python 2.7&lt;/code&gt;environment to run that specific piece of software and a Python 3 environment for everything else.&lt;/p&gt;

    &lt;h2 id=&quot;acknowledgements&quot;&gt;Acknowledgements&lt;/h2&gt;
    &lt;p&gt;A big thank to &lt;a href=&quot;https://github.com/1313e/&quot;&gt;Ellert van der Velden (@1313e)&lt;/a&gt; who wrote the backbone of this tutorial in a text document one day on Slack and for useful feedback on my interpretation of the document that I have presented in this article.&lt;/p&gt;

  &lt;/div&gt;&lt;/div&gt;
</content>

			
				<category term="tutorial" />
			
			

			<published>2021-02-02T00:00:00+00:00</published>
		</entry>
	
		<entry>
			<id>https://adambatten.com/tutorials/submitting_jobs_on_ozstar/</id>
			<title>Submitting a Job on a Supercomputer</title>
			<link href="https://adambatten.com/tutorials/submitting_jobs_on_ozstar/" rel="alternate" type="text/html" title="Submitting a Job on a Supercomputer" />
			<updated>2020-09-08T00:00:00+00:00</updated>

			
				
				<author>
					
						<name>Adam Batten</name>
					
					
					
				</author>
			
			<summary>A beginners guide to writing and submitting Slurm jobs on the OzSTAR supercomputer.</summary>
			<content type="html" xml:base="https://adambatten.com/tutorials/submitting_jobs_on_ozstar/">&lt;div class=&quot;row&quot;&gt;
&lt;div class=&quot;medium-4 medium-push-8 columns&quot;&gt;
    &lt;div class=&quot;panel radius&quot;&gt;
      &lt;p id=&quot;toc&quot;&gt;&lt;strong&gt;Table of Contents&lt;/strong&gt;&lt;/p&gt;
&lt;ul id=&quot;markdown-toc&quot;&gt;
  &lt;li&gt;&lt;a href=&quot;#a-beginners-guide-to-writing-and-submitting-slurm-jobs-on-ozstar&quot; id=&quot;markdown-toc-a-beginners-guide-to-writing-and-submitting-slurm-jobs-on-ozstar&quot;&gt;A beginners guide to writing and submitting Slurm jobs on OzSTAR.&lt;/a&gt;    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#this-tutorial-covers&quot; id=&quot;markdown-toc-this-tutorial-covers&quot;&gt;This Tutorial Covers:&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#this-tutorial-assumes-you-can&quot; id=&quot;markdown-toc-this-tutorial-assumes-you-can&quot;&gt;This Tutorial Assumes You Can:&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#some-key-definitions&quot; id=&quot;markdown-toc-some-key-definitions&quot;&gt;Some Key Definitions:&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#writing-and-submitting-a-job&quot; id=&quot;markdown-toc-writing-and-submitting-a-job&quot;&gt;Writing and Submitting A Job&lt;/a&gt;    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#writing-a-job-submission-script&quot; id=&quot;markdown-toc-writing-a-job-submission-script&quot;&gt;Writing a Job Submission Script&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#the-shebang&quot; id=&quot;markdown-toc-the-shebang&quot;&gt;1 The Shebang&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#sbatch&quot; id=&quot;markdown-toc-sbatch&quot;&gt;2 #SBATCH&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#loading-modules&quot; id=&quot;markdown-toc-loading-modules&quot;&gt;3 Loading Modules&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#job-step&quot; id=&quot;markdown-toc-job-step&quot;&gt;4 Job Step&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#submitting-a-job-submission-script&quot; id=&quot;markdown-toc-submitting-a-job-submission-script&quot;&gt;Submitting a Job Submission Script&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#querying-the-state-of-a-job&quot; id=&quot;markdown-toc-querying-the-state-of-a-job&quot;&gt;Querying the State of a Job&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#canceling-a-job&quot; id=&quot;markdown-toc-canceling-a-job&quot;&gt;Canceling a Job&lt;/a&gt;&lt;/li&gt;
  &lt;li&gt;&lt;a href=&quot;#examples&quot; id=&quot;markdown-toc-examples&quot;&gt;Examples&lt;/a&gt;    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#example-0&quot; id=&quot;markdown-toc-example-0&quot;&gt;Example 0&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#example-1&quot; id=&quot;markdown-toc-example-1&quot;&gt;Example 1&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#summary&quot; id=&quot;markdown-toc-summary&quot;&gt;Summary&lt;/a&gt;&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#acknowledgements&quot; id=&quot;markdown-toc-acknowledgements&quot;&gt;Acknowledgements&lt;/a&gt;&lt;/li&gt;
    &lt;/ul&gt;
  &lt;/li&gt;
&lt;/ul&gt;

    &lt;/div&gt;
  &lt;/div&gt;&lt;!-- /.medium-4.columns --&gt;

&lt;div class=&quot;medium-8 medium-pull-4 columns&quot;&gt;

    &lt;h2 id=&quot;a-beginners-guide-to-writing-and-submitting-slurm-jobs-on-ozstar&quot;&gt;A beginners guide to writing and submitting Slurm jobs on OzSTAR.&lt;/h2&gt;

    &lt;p&gt;Many students in the &lt;a href=&quot;https://astronomy.swin.edu.au/&quot;&gt;Centre of Astrophysics and Supercomputing&lt;/a&gt; at the &lt;a href=&quot;https://www.swinburne.edu.au/&quot;&gt;Swinburne University of Technology&lt;/a&gt; have found it challenging to determine exactly what they need to do when they want to turn a program they have written into a job to OzSTAR. This tutorial aims to resolve this issue by giving detailed instructions so by the end, even complete OzSTAR beginners should understand how to write and submit their own jobs.&lt;/p&gt;

    &lt;p&gt;This tutorial for submitting jobs is primarily aimed at people who will be using the &lt;a href=&quot;https://supercomputing.swin.edu.au/ozstar/&quot;&gt;OzSTAR supercomputer&lt;/a&gt; located at Swinburne. So keep in mind that some of this tutorial may not be applicable to all systems that are using a &lt;a href=&quot;https://slurm.schedmd.com/overview.html&quot;&gt;Slurm&lt;/a&gt; based job scheduler. This tutorial is based on the OzSTAR/Slurm documentation found &lt;a href=&quot;https://supercomputing.swin.edu.au/docs/2-ozstar/oz-slurm-create.html&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;

    &lt;h3 id=&quot;this-tutorial-covers&quot;&gt;This Tutorial Covers:&lt;/h3&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;#writing-a-job-submission-script&quot;&gt;Writing a job submission script&lt;/a&gt;.
        &lt;ul&gt;
          &lt;li&gt;&lt;a href=&quot;#1-the-shebang&quot;&gt;The Shebang&lt;/a&gt;.&lt;/li&gt;
          &lt;li&gt;&lt;a href=&quot;#2-sbatch&quot;&gt;#SBATCH&lt;/a&gt;.&lt;/li&gt;
          &lt;li&gt;&lt;a href=&quot;#3-loading-modules&quot;&gt;Loading Modules&lt;/a&gt;.&lt;/li&gt;
          &lt;li&gt;&lt;a href=&quot;#4-job-step&quot;&gt;Job Step&lt;/a&gt;.&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#submitting-a-job-submission-script&quot;&gt;Submitting a job submission script&lt;/a&gt;.&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#querying-the-state-of-a-job&quot;&gt;Querying the state of a job&lt;/a&gt;.&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#canceling-a-job&quot;&gt;Canceling a job&lt;/a&gt;.&lt;/li&gt;
      &lt;li&gt;&lt;a href=&quot;#examples&quot;&gt;Example Job Submission Scripts&lt;/a&gt;.&lt;/li&gt;
    &lt;/ul&gt;

    &lt;h3 id=&quot;this-tutorial-assumes-you-can&quot;&gt;This Tutorial Assumes You Can:&lt;/h3&gt;
    &lt;ul&gt;
      &lt;li&gt;Log into OzSTAR&lt;/li&gt;
      &lt;li&gt;Write a shell script&lt;/li&gt;
    &lt;/ul&gt;

    &lt;h3 id=&quot;some-key-definitions&quot;&gt;Some Key Definitions:&lt;/h3&gt;
    &lt;ul&gt;
      &lt;li&gt;&lt;a href=&quot;https://slurm.schedmd.com/documentation.html&quot;&gt;Slurm&lt;/a&gt;: A job scheduler. When you submit a job, you are submitting it to Slurm. Slurm works to organise and schedule when all of the jobs will run after they have been submitted. Slurm determines the optimal way to allocate CPUs, time and memory to jobs based on what has been requested.&lt;/li&gt;
    &lt;/ul&gt;

    &lt;h2 id=&quot;writing-and-submitting-a-job&quot;&gt;Writing and Submitting A Job&lt;/h2&gt;
    &lt;p&gt;Submitting a job on OzSTAR is a two step process:&lt;/p&gt;

    &lt;p&gt;1) First you have to request resources from OzSTAR. This will normally include the amount of memory you need, the number of CPUs you want to use and how long you expect to be using the resources. This step is called a ‘‘resource request”. An example resource request using english could be: 
&lt;em&gt;&lt;center&gt;&quot;I want to use 200 MB of memory on 1 CPU core for 2 hours&quot;.&lt;/center&gt;&lt;/em&gt;&lt;/p&gt;

    &lt;p&gt;2) The second step is where you say what you want these resources to be doing. This includes specifying what software is needed, which scripts you want to run, and how to execute them. This step is called the ‘job step’. An example job step could be:&lt;/p&gt;

    &lt;p&gt;&lt;em&gt;&lt;center&gt;&quot;I want to load python and then execute a python script&quot;.&lt;/center&gt;&lt;/em&gt;&lt;/p&gt;

    &lt;p&gt;Luckily, you can do both of these steps at the same time using a “submission script”.&lt;/p&gt;

    &lt;h3 id=&quot;writing-a-job-submission-script&quot;&gt;Writing a Job Submission Script&lt;/h3&gt;
    &lt;p&gt;A submission script is just a shell script that is formatted in a specific way such that it contains both your resource request and your job step. 
Here is an example of a simple submission script called &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;my_slurm_job.sh&lt;/code&gt;. This submission script will run a python script called &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;example_python_job.py&lt;/code&gt;.&lt;/p&gt;

    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;#!/bin/bash

#SBATCH --ntasks=1
#SBATCH --mem=100MB
#SBATCH --time=00:30:00

module purge
module load anaconda3/5.0.1

source activate py3

python example_python_job.py
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;

    &lt;p&gt;There are four main components to a submission script: &lt;a href=&quot;#1-the-shebang&quot;&gt;The Shebang&lt;/a&gt;, &lt;a href=&quot;#2-sbatch&quot;&gt;#SBATCH&lt;/a&gt;, &lt;a href=&quot;#3-loading-modules&quot;&gt;Loading Modules&lt;/a&gt; and &lt;a href=&quot;#4-job-step&quot;&gt;The Job Step&lt;/a&gt;.&lt;/p&gt;
    &lt;h3 id=&quot;the-shebang&quot;&gt;1 The Shebang&lt;/h3&gt;
    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;#!/bin/bash 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;

    &lt;p&gt;The first component is the very first line: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;#!/bin/bash&lt;/code&gt;. This line has many names including: ‘shebang’, ‘shabang’, ‘hashbang’, ‘pound-bang’, ‘hash-pling’ and probably lots of other ridiculous sounding names. This line serves the purpose of defining which ‘interpreter’ to use when executing the script.&lt;/p&gt;

    &lt;p&gt;In this case we are effectively saying:  “This is a bash (Bourne-Again Shell) script, so execute this script with a bash shell”.&lt;/p&gt;

    &lt;p&gt;Since all of your submission scripts will be likely be a bash script, this line will be the same for every submission script you write.&lt;/p&gt;

    &lt;h3 id=&quot;sbatch&quot;&gt;2 #SBATCH&lt;/h3&gt;
    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;#SBATCH --ntasks=1
#SBATCH --mem=100MB
#SBATCH --time=00:30:00
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;

    &lt;p&gt;The second component is where you request resources and it includes all the lines that start with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;#SBATCH&lt;/code&gt;. Any line in your submission script that begins with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;#SBATCH&lt;/code&gt; is understood by Slurm to be a resource request or an additional option related to the job.&lt;/p&gt;

    &lt;p class=&quot;warning&quot;&gt;Notice the # in front. This can be easy to forget but is important.&lt;/p&gt;

    &lt;p&gt;In this example script we are requesting: 1 CPU (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;#SBATCH --ntasks=1&lt;/code&gt;) and 100 MB of RAM (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;#SBATCH --mem=100MB&lt;/code&gt;) for 30 minutes (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;#SBATCH --time=00:30:00&lt;/code&gt;).
Similarly if you wanted request 2 GB of RAM on a single CPU for 12 hours your resource request would look like this:&lt;/p&gt;

    &lt;p&gt;&lt;b&gt;Example&lt;/b&gt;&lt;/p&gt;
    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;#SBATCH --ntasks=1
#SBATCH --mem=2GB
#SBATCH --time=12:00:00
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;

    &lt;p&gt;There are lots of additional options that you include here, for instance you can include the option to have SLURM send you an email when your job starts and ends.&lt;/p&gt;

    &lt;p&gt;&lt;b&gt;Example:&lt;/b&gt;&lt;/p&gt;
    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;#SBATCH --mail-user=name@swin.edu.au
#SBATCH --mail-type=ALL
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
    &lt;p&gt;You can see a complete list of parameters using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;man sbatch&lt;/code&gt;. I have also listed more examples of options that may be useful at the end of this tutorial.&lt;/p&gt;

    &lt;p class=&quot;info&quot;&gt;A good rule of thumb is: The more resources you request, the longer it will take for your job to start. 
This means that asking for way more time and RAM than you actually need is not a good idea. 
Unfortunately, this tutorial can not tell you how much resources your job will require. 
You will have have to determine that for yourself. 
If you are using python, you can look into using packages such as &lt;a href=&quot;https://github.com/pythonprofilers/memory_profiler&quot;&gt;memory_profiler&lt;/a&gt; and &lt;a href=&quot;https://github.com/pyutils/line_profiler&quot;&gt;line_profiler&lt;/a&gt; to help estimate the memory usage and timing of a script.&lt;/p&gt;

    &lt;h3 id=&quot;loading-modules&quot;&gt;3 Loading Modules&lt;/h3&gt;
    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;module purge
module load anaconda3/5.0.1

source activate py3
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;

    &lt;p&gt;The third component is where you load all the modules that are necessary to run your script. OzSTAR uses modules to manage the software it has installed. If you want to use a module you first have to load it. To load a module use the following command: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;module load &amp;lt;module_name&amp;gt;/&amp;lt;software_version&amp;gt;&lt;/code&gt;. You can search for modules using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;module spider &amp;lt;module_name&amp;gt;&lt;/code&gt;. We will be executing a python script using the example submission script, hence we have to load the modules for anaconda and the Conda environment that all the packages are install in.&lt;/p&gt;

    &lt;ul&gt;
      &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;module purge&lt;/code&gt; unloads all loaded modules.&lt;/li&gt;
      &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;module load anaconda3/5.0.1&lt;/code&gt; loads Anaconda. I recommend using the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;anaconda3/5.0.1&lt;/code&gt; version of instead of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;anaconda3/5.1.0&lt;/code&gt; because there is a significant bug in the later version on OzSTAR related to Conda environments.&lt;/li&gt;
      &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;source activate py3&lt;/code&gt; loads a Conda environment that I have called &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;py3&lt;/code&gt;. In this environment I have installed all of the necessary packages required to execute &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;example_python_job.py&lt;/code&gt;.&lt;/li&gt;
    &lt;/ul&gt;

    &lt;p&gt;Here is a list of a few common modules that you might need to load: &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;gcc/7.3.0&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;hdf5/1.10.1&lt;/code&gt;, &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;openmpi/3.0.0&lt;/code&gt;.&lt;/p&gt;

    &lt;p class=&quot;info&quot;&gt;Loading modules is not necessary if they are already loaded in your session. 
You can load modules in the &lt;code&gt;.bashrc&lt;/code&gt; file in your home directory the same way you would load them in a bash script.
If you load modules in your &lt;code&gt;.bashrc&lt;/code&gt; those modules will automatically get loaded into your environment every time you log into Ozstar. This means you only have to write &lt;code&gt;load module anaconda3/5.0.1&lt;/code&gt; once in your &lt;code&gt;.bashrc&lt;/code&gt; and then forget about it.&lt;/p&gt;

    &lt;p class=&quot;info&quot;&gt;If you are using python I highly recommend that you use Conda environments when working on OzSTAR. Anaconda environments will save you lots of time, stress and effort in the long run. I have a tutorial for &lt;a href=&quot;https://adambatten.com/tutorials/setting_up_python_on_ozstar.html&quot;&gt;setting up python on OzSTAR&lt;/a&gt; that details how to set up Conda environments.&lt;/p&gt;

    &lt;h3 id=&quot;job-step&quot;&gt;4 Job Step&lt;/h3&gt;
    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;python example_python_job.py
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
    &lt;p&gt;This final component is where you say what you want to actually run on the requested resources. This is the job step. In the example, we have a single line &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;python example_python_job.py&lt;/code&gt; indicating that our job will run the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;example_python_job.py&lt;/code&gt; script. It is also possible to list multiple job steps in a submission script and they will be performed one after another.&lt;/p&gt;

    &lt;p&gt;&lt;b&gt;Example:&lt;/b&gt;&lt;/p&gt;
    &lt;div class=&quot;language-shell highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;python example_python_job.py
python example_python_job2.py
python_example_python_job3.py
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
    &lt;p&gt;In this case, after the first job step is completed the second job step (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;example_python_job2.py&lt;/code&gt;) will begin. In your resource request you will have to allow for the time and memory requirements for all of the job steps.&lt;/p&gt;

    &lt;h3 id=&quot;submitting-a-job-submission-script&quot;&gt;Submitting a Job Submission Script&lt;/h3&gt;

    &lt;p&gt;After you have finished writing a submission script, you can submit it to Slurm with the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sbatch&lt;/code&gt; command.&lt;/p&gt;

    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; sbatch my_slurm_job.sh
sbatch: Submitted batch job 99999999
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;

    &lt;p&gt;If the job is successfully submitted, it will respond with the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;jobid&lt;/code&gt; that was assigned to the job. In this example the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;jobid&lt;/code&gt; is 99999999.&lt;/p&gt;

    &lt;p class=&quot;info&quot;&gt;You can also submit a job to the queue from within a submission script. This can be useful for automating a pipeline of scripts that need to be completed in a sequence.&lt;/p&gt;

    &lt;p&gt;You can find more documentaion related to the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;sbatch&lt;/code&gt; command on the official Slurm website &lt;a href=&quot;https://slurm.schedmd.com/sbatch.html&quot;&gt;here&lt;/a&gt;.&lt;/p&gt;

    &lt;h2 id=&quot;querying-the-state-of-a-job&quot;&gt;Querying the State of a Job&lt;/h2&gt;

    &lt;p&gt;You can find out about the state of your job and all other jobs in the queue using the command &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;squeue&lt;/code&gt;.&lt;/p&gt;

    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; squeue --user=yourusername
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
    &lt;p&gt;This will give you the status of all your running and submitted jobs.
You can also neglect the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;--user=yourusername&lt;/code&gt; to view the entire job queue for all users.&lt;/p&gt;

    &lt;p&gt;If you are using OzSTAR then the output of &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;squeue --user=yourusername&lt;/code&gt; should look similar to the figure below.&lt;/p&gt;

    &lt;p&gt;&lt;img src=&quot;/assets/images/slurm_squeue.png&quot; alt=&quot;&amp;quot;An image of the output of squeue after using sbatch on my_slurm_job.sh&amp;quot;&quot; /&gt;&lt;/p&gt;

    &lt;p&gt;The columns of the output are as follows:&lt;/p&gt;

    &lt;ul&gt;
      &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;JOBID&lt;/code&gt;: The JOBID that is given to the job. This ID is unique amongst all jobs past, present and future.&lt;/li&gt;
      &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;PARTITION&lt;/code&gt;: The type of ‘queue’ that the job is in. This is usually given by the name of the type of CPU that will be running the job.&lt;/li&gt;
      &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;NAME&lt;/code&gt;: The name of the job.&lt;/li&gt;
      &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;USER&lt;/code&gt;: The username of the person that submitted the job.&lt;/li&gt;
      &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ST&lt;/code&gt;: The status of the job.
        &lt;ul&gt;
          &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;R&lt;/code&gt;: Currently Running&lt;/li&gt;
          &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;PD&lt;/code&gt;: Waiting for Resources (Pending)&lt;/li&gt;
        &lt;/ul&gt;
      &lt;/li&gt;
      &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;TIME&lt;/code&gt;: The length of time the job has been running. If the job is pending (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ST = PD&lt;/code&gt;) it will say &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;0:00&lt;/code&gt;.&lt;/li&gt;
      &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;NODES&lt;/code&gt;: The number of ‘nodes’ that the job has requested. A ‘node’ is a collection of many CPUs. OzSTAR has a few different types of nodes with different amounts of CPUs on each. For example the &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;john&lt;/code&gt; (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;PARTITION = skylake&lt;/code&gt;) nodes have 32 CPUs each.&lt;/li&gt;
      &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;NODELIST(REASON)&lt;/code&gt;: If the job is currently running (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ST = R&lt;/code&gt;) this is the list of nodes that the job is using. If the job is pending (&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;ST = PD&lt;/code&gt;) this is why the job is pending.&lt;/li&gt;
    &lt;/ul&gt;

    &lt;p&gt;You can also use the &lt;a href=&quot;https://supercomputing.swin.edu.au/monitor/&quot;&gt;OzSTAR Job Monitor Website&lt;/a&gt; for a graphical view of all the jobs that are running and in the queue.&lt;/p&gt;

    &lt;h2 id=&quot;canceling-a-job&quot;&gt;Canceling a Job&lt;/h2&gt;
    &lt;p&gt;Sometimes you will have a job that you need to cancel for some reason. You can cancel a running or submitted job at any time with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;scancel jobid&lt;/code&gt;.&lt;/p&gt;

    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;&amp;gt;&amp;gt;&amp;gt; scancel 99999999
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;

    &lt;p&gt;You can also cancel all of your jobs with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;scancel --user=yourusername&lt;/code&gt; or you can only cancel your “Pending” jobs with &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;scancel -t PD&lt;/code&gt;.&lt;/p&gt;

    &lt;h2 id=&quot;examples&quot;&gt;Examples&lt;/h2&gt;

    &lt;h4 id=&quot;example-0&quot;&gt;Example 0&lt;/h4&gt;
    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;#!/bin/bash

#SBATCH --ntasks=1
#SBATCH --mem=100MB
#SBATCH --time=00:30:00

module purge
module load anaconda3/5.0.1

source activate py3

python example_python_job.py
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
    &lt;p&gt;This is the same example as shown throughout this tutorial.&lt;/p&gt;

    &lt;h4 id=&quot;example-1&quot;&gt;Example 1&lt;/h4&gt;
    &lt;div class=&quot;language-plaintext highlighter-rouge&quot;&gt;&lt;div class=&quot;highlight&quot;&gt;&lt;pre class=&quot;highlight&quot;&gt;&lt;code&gt;#!/bin/bash

#SBATCH --ntasks=1
#SBATCH --mem=100MB
#SBATCH --time=00:30:00

#SBATCH --job-name=Calculate_Mean
#SBATCH --output=slurm_output.txt

#SBATCH --mail-user=name@swin.edu.au
#SBATCH --mail-type=ALL
#SBATCH --account=oz999

module purge
module load anaconda3/5.0.1

source activate py3

python example_python_job.py
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;    &lt;/div&gt;
    &lt;p&gt;This is essentially the same as &lt;a href=&quot;#example-0&quot;&gt;Example 0&lt;/a&gt; but with a few additional parameters.&lt;/p&gt;

    &lt;ul&gt;
      &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;--job-name&lt;/code&gt; is being used to give a more meaningful name to the job.
This is the name that will show up as &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;NAME&lt;/code&gt; when using &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;squeue&lt;/code&gt;.&lt;/li&gt;
      &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;--output&lt;/code&gt; is defining the file that all of the Slurm output (i.e. print statements) will be directed.&lt;/li&gt;
      &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;--mail-user&lt;/code&gt; and &lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;--main-type&lt;/code&gt; makes Slurm send an email when your job starts and completes.&lt;/li&gt;
      &lt;li&gt;&lt;code class=&quot;language-plaintext highlighter-rouge&quot;&gt;--account&lt;/code&gt; is setting which group account this job belongs is associated with.&lt;/li&gt;
    &lt;/ul&gt;

    &lt;h3 id=&quot;summary&quot;&gt;Summary&lt;/h3&gt;
    &lt;p&gt;This tutorial is not meant as a comprehensive article covering all there is to know about using Slurm. Still, hopefully by now you feel confident enough to be able to write you own bash scripts and get jobs running on OzSTAR.&lt;/p&gt;

    &lt;h3 id=&quot;acknowledgements&quot;&gt;Acknowledgements&lt;/h3&gt;
    &lt;p&gt;Thank you to &lt;a href=&quot;https://github.com/1313e/&quot;&gt;Ellert van der Velden (@1313e)&lt;/a&gt; for useful feedback on the draft of this article.&lt;/p&gt;

  &lt;/div&gt;&lt;/div&gt;
</content>

			
				<category term="tutorial" />
			
			

			<published>2020-09-08T00:00:00+00:00</published>
		</entry>
	
</feed>