Skip to content

Getting started

ndawlab edited this page Nov 23, 2017 · 1 revision

Welcome to the clusters wiki!

Interacting with spock

To get on spock you'll need a PNI account which you can request from the PNI internal website. Once that's done you can get on spock via ssh, for example if my user name is yaraujjo then I'd do:

The -XY tells spock you want x-forwarding on the main node, which means you'll be able to open GUI windows and such. Once you're on spock there are a few locations on the file system that are good to keep in mind. The first one is /jukebox/daw/, where there's some amount of disk space dedicated to the lab. The second is /scratch/, this is a location where I'd recommend you put temporary files that aren't important (because they will at some point be automatically deleted, presumably).

Using python on spock

On the cluster you can type the command module avail to look at what applications the sys-admins have installed for everyone to use. One of these will be anaconda or miniconda. You'll want to use these to create your own python environments. Here's an example:

module add anacondapy/3.4
conda create -p ~/my_conda_env
source activate ~/my_conda_env
conda install numpy scipy pandas

Using julia on spock

Like above, if you do module avail you'll see there are a few versions of julia installed on the cluster. None of them are the latest versions. So you have some options, you can either use one of the older versions of julia through the module add process outlined above or you can use the newest version of julia through it's binaries that we've put in /jukebox/daw/yoel/julia/julia6.0. Below is an example of how you could go about using the latest version of julia. Alternatively it might be a good idea to request the latest version julia be installed on spock.

# first open your bashrc file
vi ~/.bashrc
# in here you'll want to add an alias that points to the julia binary
alias j6="/jukebox/daw/yoel/julia/julia6.0/bin/julia"
# now save the file and get out of vim, and source your bashrc
source ~/.bashrc
# now you should be able to start up julia by typing j6
j6 

Editing your bashrc file

The file ~/.bashrc is automatically "read" by the computer when you log onto spock. What this means is that it's a good place to put "commands" or "things" that you want to take into effect until your next source ~/.bashrc. This can be useful for example, by making it so that you don't need to type the command module add fsl/5.0.9 each time you log onto spock, or any command. So the plan is to add these exact commands to the file that will get sourced when you log in. Example:

# open up your bashrc file
vi ~/.bashrc
# now add some commands, like: 
module add anacondapy/3.4
# save the file and get out of vim and resource the file
source ~/.bashrc

Now you should be able to use anaconda without having to type module add anacondapy/3.4

Here is what a ~/.bashrc file might look like

# .bashrc

# Source global definitions
if [ -f /etc/bashrc ]; then
        . /etc/bashrc
fi

### modules on spock
module add fsl/5.0.9

# User specific aliases and functions
umask 002
alias j6="/jukebox/daw/yoel/julia/julia6.0/bin/julia"
alias py36="source activate py36"
alias jobs="squeue -u yaraujjo"
alias njobs="squeue -u yaraujjo | cat -n"

# added by Miniconda3 4.3.21 installer
export PATH="/usr/people/yaraujjo/miniconda3/bin:$PATH"

Using the SLURM manager to run jobs

Briefly though, if I had a file called test.py and it contents were:

print("silly test")

Then I can run it through on spock like so:

srun --time=0-00:05:00 --mem=2M python /path/to/test.py

The disadvantage of this approach is that now this job will essentially "take over" your terminal and you won't be able to do anything until it's done. Also, if your connection is lost to the cluster then your job is done for, so in general this is probably a bad use case.

A different approach could be to run a job via sbatch instead of srun. Here it does not matter what your connection is once you've sent the job off and you get to keep your terminal. Again, if I have an example bash script do_stuff.sh:

#!/bin/bash

#SBATCH --mem=2M
#SBATCH --time=0-00:05:00

echo "hello"

I would run this file by typing:

sbatch /path/to/do_stuff.sh

A few things to note about sbatch, the "commented" lines with #SBATCH are required resource parameters that tell slurm how much memory you want and in this case the upper limit of time for which your job is allowed to run. On spock these parameters are required, however you are not required to put them in the .sh file. You can exclude them and instead run the job as:

sbatch --mem=2M --time=0-00:05:00 /path/to/do_stuff.sh

In addition by default when you call sbatch an output file will be created in the directory where sbatch was called from. It's usually named slurm-[some_numbers_designating_your_job_ID].out this file may contain important information about your job. In the above example it would contain "hello".