What does that mean? The user can submit a job to run on a compute node of the HPC, instead of submitting to the cluster (which we’ll cover in the next section). Ideal for longer-duration jobs that may require interaction somewhere in the middle.
It’s somewhat like when you go to the library and check out a book for a few hours. During that time, no one else is using that book. You can’t keep the book forever, so we’ll also teach you how to end your session so that that node is available to other users again.
This is quite easy to start:
[[email protected] ~]$ qloginYour job 448655 ("QLOGIN") has been submittedwaiting for interactive job to be scheduled ...Your interactive job 448655 has been successfully scheduled.Establishing /opt/gridengine/bin/rocks-qlogin.sh session to host compute-0-5.local ...Warning: Permanently added 'compute-0-5.local' (RSA) to the list of known hosts.Rocks Compute NodeRocks 5.0 (V)Profile built 11:57 17-Aug-2016Kickstarted 12:13 17-Aug-2016
The information given is a job number and an assigned compute node. You should see now that your prompt has changed and that you are now logged directly into a node. Even though we are logged into a node, we still have access to our directory contents.
[[email protected] ~]$ pwd/home/Joseph.Madison[[email protected] ~]$ lsdemo_files dissertation_research exp1 install_files[[email protected] ~]$
Let’s make another directory for this section.
Just for fun, we are going to use Python while we are playing around in our session.
Python is a programming language that is popular with scientists who need to crunch data and is recommended for those who are beginners. This document is not meant to teach you how to program in Python, just that you can access your folders and use the software in an interactive session.
[[email protected] scripts]$ pythonPython 2.4.3 (#1, Mar 14 2007, 19:01:42)[GCC 4.1.1 20070105 (Red Hat 4.1.1-52)] on linux2Type "help", "copyright", "credits" or "license" for more information.>>>
There is some information that pops up on the screen, namely, the Python version. Just like software, it is common for languages to go through versions. This is an older version, but there is a way to switch to a newer version. We need to exit this Python command prompt. We accomplish this by typing:
If you aren’t sure which version of Python will open when you type the python command, you can check using the
which python command. We will see we are using the older version of python (newer version has a different name).
[[email protected] scripts]$ which python/usr/bin/python
To access a newer version we can tell the HPC where to find it and to use that version. We will access the newer version in the
/share/apps folder on the HPC (this folder contains all common programs and environments that are common to all users.
[[email protected] scripts]$[[email protected] scripts]$ cd ..[[email protected] ~]$ source /share/apps/python27/env.sh[[email protected] ~]$ which python/share/apps/python27/bin/python
We are in the newer version of Python. Now that we have set up the appropriate version of Python, we are going to finally open Python.
[[email protected] ~]$ pythonPython 2.7.9 (default, Mar 16 2015, 10:11:38)[GCC 4.4.7 20120313 (Red Hat 4.4.7-1)] on linux2Type "help", "copyright", "credits" or "license" for more information.>>>
We can use this to type commands just like we were doing in the shell, but instead you use the Python language. So in the shell, if we wanted to write hello world on the screen, we would have used an
>>>"Hello world!"'Hello world!'
You can also perform basic math functions:
You can do lots of things from this Python command prompt, but I want to show you how to make your own Python program. Let’s write a program that counts to 100. First, let’s exit Python so we can use the shell text editor.
[[email protected] ~]$[ctrl]+d[[email protected] ~]$ nano counting.pyfor n in range(0,100):print n[ctrl]O, [enter], [ctrl]X
Note: spaces and indentations are important.
Now we can use python to run our code.
[[email protected] ~]$ python counting.py
You will get an output of 0 to 99. What might be more useful is if that output ended up in a file. We can do that.
[[email protected] ~]$ python counting.py > numberList.txt
In the above command, the greater-than symbol is used to funnel the output of the program into a text file. We can use ls to check and see if the file was generated.
[[email protected] ~]$ lscounting.py dissertation_research install_files scriptsdemo_files exp1 numberList.txt
You should see the file
numberList.txt, and we can check the contents using the
[[email protected] ~]$ more numberList.txt
A subset of the file will be displayed. You can use the space bar to progress through the file contents. Hooray! You wrote a program in Python.
Recall that we’ve done all of this from our interactive session. Now we are done, we need to close the connection.
[[email protected] ~]$ exitlogoutConnection to compute-0-5.local closed./opt/gridengine/bin/rocks-qlogin.sh exited with exit code 0
This may seem trivial, but recall that your node is unavailable for use by others. What if you forget to logout? Does the world end? No, but you should clean up your interactive session. So, you forgot to close your session with the exit command, and you realized the next day that you may have left your qlogin open. First we can check that by checking the status of the queue.
[[email protected] ~]$ qstatjob-ID prior name user state submit/start at queue slots ja-task-ID-----------------------------------------------------------------------------------------------------------------448656 0.50219 QLOGIN Joseph.Madis r 11/12/2016 18:00:45 [email protected] 1
You can then use the
qdel command for ending an interactive login and your job number.
[[email protected] ~]$ qdel 448656
Now we have ended our qlogin session. Please remember to exit your qlogin session when you are done so that those resources are available for others.