CommunityData:Hyak Ikt (Deprecreated): Difference between revisions

From CommunityData
Line 200: Line 200:
# Don't panic. Everyone has done this at least once. It is spammy and a little bit difficult to deal with but can be solved. You are not in trouble.
# Don't panic. Everyone has done this at least once. It is spammy and a little bit difficult to deal with but can be solved. You are not in trouble.
# The usual reason for this to happen is because you've accidentally run something on a login node that ought to be run on a compute node. The solution is to find the badly behaved process and then use kill to kill the process.
# The usual reason for this to happen is because you've accidentally run something on a login node that ought to be run on a compute node. The solution is to find the badly behaved process and then use kill to kill the process.
# If it's a script or command on your commandline, control-c to kill it. But if you ran parallel, you'll need to kill parallel itself.
# If it's a script or command on your commandline, control-c to kill it -- if you backgrounded it, type fg to foreground it and then control-c. But if you ran parallel, you'll need to kill parallel itself.
# ps -faux | grep <your username> will show you all the things you are running (or have someone else run it for you if the spam is so terrible you can't get a command to run). The first column has the usernames, the second column has the process IDs, the last column has the things you're running. In the screenshot, the red smudge is the (obscured) user name, followed by the process ID. At the end of the line the last three entries are the time (in hyak time, type date if you want to compare hyak time to your time), then how much CPU time something has consumed, then a little diagram of parent and child processes. You want parallel (in the example, 9977). Killing the child process (in the example, 9992) won't likely help because parallel will just go on to the next task you queued up for it.
# ps -faux | grep <your username> will show you all the things you are running (or have someone else run it for you if the spam is so terrible you can't get a command to run). The first column has the usernames, the second column has the process IDs, the last column has the things you're running. In the screenshot, the red smudge is the (obscured) user name, followed by the process ID. At the end of the line the last three entries are the time (in hyak time, type date if you want to compare hyak time to your time), then how much CPU time something has consumed, then a little diagram of parent and child processes. You want parallel (in the example, 9977). Killing the child process (in the example, 9992) won't likely help because parallel will just go on to the next task you queued up for it.
# kill <process id>
# kill <process id>
[[File:faux.jpg]]
[[File:faux.jpg]]

Revision as of 20:01, 12 December 2019

To use Hyak, you must first have a UW NetID, access to Hyak, and a two factor authentication token. Details on getting set up with all three are available at CommunityData:Hyak setup.

There are a number of other sources of documentation:

Setting up SSH

When you connect to SSH, it will ask you for a key from your token. Typing this in every time you start a connection be a pain. One approach is to create an .ssh config file that will create a "tunnel" the first time you connect and send all subsequent connections to Hyak over that tunnel. Some details in the Hyak documentation.

I've added the following config to the file ~/.ssh/config on my laptop (you will want to change the username):

Host ikt hyak
   User makohill
   HostName login2.hyak.washington.edu
   ControlPath ~/.ssh/master-%r@%h:%p
   ControlMaster auto
   ControlPersist yes
   ForwardX11 yes
   ForwardX11Trusted yes
   Compression yes

ONE WARNING: If your SSH connection becomes stale or disconnected (e.g., if you change networks) it may take some time for the connection to time out. Until that happens, any connections you make to hyak will silently hang. If your connections to ssh hyak are silently hanging but your Internet connection seems good, look for ssh processes running on your local machine with:

ps ax|grep hyak

If you find any, kill them with kill <PROCESSID>. Once that is done, you should have no problem connecting to Hyak.

Connecting to Hyak

To connect to Hyak, you now only need to do:

ssh hyak

It will prompt you for your UWNetID's password and your PRN which is the little number that comes from your token.

Setting up your user's Hyak environment with CDSC tools

When setting up Hyak, you must first add these two stanzas to very top and the very bottom of your ~/.bashrc file. Generally, you can simply edit the following file on Hyak: ~/.bashrc

##  hyak-cdsc specific options -- TOP OF FILE
source /com/gentoo/etc/profile
##  end hyak-cdsc specific options -- TOP OF FILE
## BEGIN hyak-cdsc specific options -- BOTTOM OF FILE
source /etc/profile.d/modules.sh
module load parallel_sql

alias int_machine='srun -p comdata-int --time=500:00:00 --mem=200G --pty /bin/bash'
alias big_machine='srun -p comdata --time=500:00:00 --mem=200G --pty /bin/bash'
alias any_machine='srun -p comdata --time=500:00:00 --mem=100G --pty /bin/bash'
alias build_machine='srun -p build --time=8:00:00 --mem=10G --pty /bin/bash'
alias rgrep='grep -r' 

MC_CORES=16
PATH="/com/local/bin:/sw/local/bin:$PATH"
R_LIBS_USER="~/R"

umask 007
## END hyak-cdsc specific options -- BOTTOM OF FILE


These are new as of November 30, 2017. As a result, you must completely remove the old environment variables, and such. They include material that will screw things up. The final line is particularly important. If you do not do this, the files you create on Hyak will be able to be read or written by others in the group!

Once you do this, you will need to restart bash. This can be done simply by logging out and then logging back in or by restarting bash with the command exec bash.

I also add these two lines to my Hyak .ssh/config:

ForwardX11 yes
ForwardX11Trusted yes

These lines will mean that if I have "checked out" an interactive machine, I can ssh from my computer to Hyak and then directly through an addition hop to the machine (like ssh n0652). Those ForwardX11 lines means if I graph things on this window, they will open on my local display.

Python Packages

If you need python libraries that are not installed in the shared environment:

$ pip3 install --user YOURLIBHERE

...replacing YOURLIBHERE with the name of the library you need, e.g. 'pandas'. The --user option will install it for just you.

If you have a lot of dependencies for a specific project, consider using Python Virtual Environments

Set up a password for Jupyter Notebook on Hyak

Once you have IPython/Jupyter up and running on Hyak and have set up all the port forwarding stuff described above, you might consider adding a password to secure your Jupyter session. Why bother? Anyone with access to Hyak can see that you're forwarding something via the login node. While unlikely, they may do something to interrupt or otherwise mess with your session. It should work. Keep in mind that anyone with access to your jupyter session can do anything you can do on the command line including access all your data, delete files, etc.

Instructions for setting up a password on your Jupyter sessions are available on the Hyak wiki (UW login required).

Note that you can/should skip the first command that loads the canopy module.

Running Jobs on Hyak

Cmbox notice.png This material is now out of date! It refers to the old version of the Hyak scheduler.

Screencast Examples (Sep, 2019):

  • Using parallel and batch jobs on ikt: Video

Screencast Examples (Feb, 2018, pre-SLURM):

When you first log in to Hyak, you will be on a "login node". These are nodes that have access to the Internet, and can be used to update code, move files around, etc. They should not be used for computationally intensive tasks. To actually run jobs, there are a few different options, described in detail in the itSigs documentation. Following are basic instructions for some common use cases.

Interactive nodes

For simple tasks, e.g. running R on a dataset, testing that code is working, etc. it is easiest to run it in an interactive node. This is a compute node that you interact with through the terminal. All of your disk storage is accessible just as though you were on the login node.

Parallel SQL

For big jobs you will want to use multiple nodes. Hyak has a very cool tool that makes this very easy, called Parallel SQL. Detailed instructions are in the itsigs parallel-sql documentation. There is also a full walkthrough example with instructions.

The basic workflow is:

1. Prepare the code, and test it with a single file (either on your computer, or on an interactive node). 2. Write a job_script file. This tells the node what job to run. There is an example on the Parallel SQL wiki page (linked above), and an example in the wikiresearch/hyak_example directory. 3. Create a task_list file. This is a list of commands that should be run, with one line per file that the command should operate on. An example file might look something like:

python analysis_script.py -i ./input/wiki_1.tsv -o ./output/wiki_1_analysis.tsv
python analysis_script.py -i ./input/wiki_2.tsv -o ./output/wiki_2_analysis.tsv
...

The README in the hyak_example directory has some example bash commands that you might use to generate this file.

4. Load the task_list into Parallel SQL.

$ module load parallel_sql
$ cat task_list | psu --load

5. Run the job_script on as many nodes as you need. When each task is finished, the node will get the next task from Parallel SQL.

$ for job in $(seq 1 N); do qsub job_script; done 
# N is the number of nodes

You can also use the -t flag, which makes jobs using multiple nodes easier to kill, but is not recommended by "the HYAK people".

$ qsub job_script -t 0-N
# N is the number of nodes


For producing your task_list file, you might find it useful to make a python script that slurps up a list of files from a dir and then inserts those filenames into a command file to be run repeatedly:

#!/usr/bin/env python3
import glob
outfile = "many_Redir_Runs.txt"
infileDir = "/com/raw_data/complete_wmf_dumps-20180220/enwiki-20180301/"
fileList = glob.glob(infileDir + "enwiki-20180301-pages-meta-history*.7z") #get all the 7z metahistory files
with open(outfile, 'w') as outFileHandle:
   for file in fileList:
       cleanFile = file.split("/")[-1]
       commandString = "7za x -so " + file + "| python ./01-extract_redirects.py > output/redir/" + cleanFile + ".tsv \n"
       outFileHandle.write(commandString)

R Markdown

R markdown is a useful way of writing up your analysis as a mix of explanatory text and code. You can, for example, create fancy Tufte-style handouts with code and explanatory text in the same file! In order to use R markdown, in a compute node, run the following command

$ Rscript -e "rmarkdown::render('analysis.Rmd')"

Python Virtual Environments

Python virtual environments are a great way to manage project dependencies, and they seem to work on HYAK in the same way that they do on local machines. First install virtualenv using pip (this only needs to be done once).

$ pip install virtualenv --user

Initialize a new virtual environment in the current directory. Many people create a new virtual environment for each project.

$ # this virtual environment will use python 3
$ virtualenv venv -p python3

To activate the virtual environment from a login node or an interactive compute node

$ source <path_to_venv_parent_dir>/venv/bin/activate

To load a virtual environment in parallel sql, add the following to your PBS bash script

source <path_to_venv_parent_dir>/venv/bin/activate

Killing jobs on compute nodes

Torque documentation suggests that you should do this with qdel. That might work, but apparently our system runs moab on top of torque and the recommended (by Hyak admins) way to kill a job is to use the mjobctl command.

For example, you might run nodestate from a login node to figure out the ID number for your job (let's say it's 12345), then run mjobctl -c 12345 to send a SIGTERM signal or mjobctl -F 12345 to send a SIGKILL signal that will bring job 12345 to an end.

Note that only four user accounts at a time can have the bits necessary to kill other people's jobs, so while you can do this on your own jobs, you'll need to bother the IRC channel to find help cancelling other's jobs (we think that Jeremy, Nate, Aaron, and Mako currently have the bits). Also, check out the documentation for mjobctl for more info.


Common Troubles and How to Solve Them

Help! I'm over CPU Quota and Hyak is Angry!

  1. Don't panic. Everyone has done this at least once. It is spammy and a little bit difficult to deal with but can be solved. You are not in trouble.
  2. The usual reason for this to happen is because you've accidentally run something on a login node that ought to be run on a compute node. The solution is to find the badly behaved process and then use kill to kill the process.
  3. If it's a script or command on your commandline, control-c to kill it -- if you backgrounded it, type fg to foreground it and then control-c. But if you ran parallel, you'll need to kill parallel itself.
  4. ps -faux | grep <your username> will show you all the things you are running (or have someone else run it for you if the spam is so terrible you can't get a command to run). The first column has the usernames, the second column has the process IDs, the last column has the things you're running. In the screenshot, the red smudge is the (obscured) user name, followed by the process ID. At the end of the line the last three entries are the time (in hyak time, type date if you want to compare hyak time to your time), then how much CPU time something has consumed, then a little diagram of parent and child processes. You want parallel (in the example, 9977). Killing the child process (in the example, 9992) won't likely help because parallel will just go on to the next task you queued up for it.
  5. kill <process id>

Faux.jpg