Updated 2021-05-17

Run Scala on the Cluster

Overview

  • This guide will focus on running Scala in batch mode. Additionally, Scala includes an interactive interpreter (like python).
  • If you wish to use Scala in interactive mode, follow these steps to set up a VNC session. In your VNC session, open a terminal, load Scala (module load scala) and run with the command scala

Tips

  • In the PBS script, load scala with module load scala.

Tip

you can use module avail scala to see what versions of scala are available.

  • The line to run a scala file is scala <filename>.scala. Add this to the computation part of your PBS script to run.

Walkthrough: Run Scala on the Cluster

  • This walkthrough will use a simple Scala program that prints "Hello World"
  • Scala Program: Hello.scala
  • PBS Script: scala.pbs
  • You can transfer the files to your account on the cluster to follow along. The file transfer guide may be helpful.

Part 1: The PBS Script

#PBS -N helloWorldScala
#PBS -A [Account]
#PBS -l nodes=1:ppn=2
#PBS -l pmem=2gb
#PBS -l walltime=1:00
#PBS -q inferno
#PBS -j oe
#PBS -o helloWorldScala.out

cd $PBS_O_WORKDIR
module load scala
scala Hello.scala
  • The #PBS directives are standard, requesting just 1 minute of walltime and 1 node with 2 cores. More on #PBS directives can be found in the PBS guide
  • $PBS_O_WORKDIR is simply a variable that represents the directory you submit the PBS script from.

Warning

Make sure the scala script you want to run (in this case, Hello.scala) is in the same directory you put the PBS script.

  • module load scala loads scala. To see what scala versions are available, run module avail scala, and load the one you want

Part 2: Submit Job and Check Status

  • Make sure you're in the dir that contains the PBS Script
  • Submit as normal, with qsub <pbs script name>. In this case qsub scala.pbs
  • Check job status with qstat -u <gtusername3> -n, replacing "gtusername3" with your gt username.
  • You can delete the job with qdel 22182721 , replacing the number with the jobid returned after running qsub

Part 3: Collecting Results

  • In the directory where you submitted the PBS script, you should see a helloWorldScala.out file, which contains the results of the job. Use cat helloWorldScala.out or open the file in a text editor to take a look.
  • helloWorldScala.out should look something like this:
Job name:   helloWorldScala
Queue:      inferno
End PBS Prologue Wed Oct  3 14:11:57 EDT 2018
---------------------------------------
Hello World!
---------------------------------------
Begin PBS Epilogue Wed Oct  3 14:12:25 EDT 2018
Job ID:     22604573.shared-sched.pace.gatech.edu
User ID:    shollister7
Job name:   helloWorldScala
Resources:  neednodes=1:ppn=2,nodes=1:ppn=2,pmem=2gb,walltime=00:01:00
Rsrc Used:  cput=00:00:19,energy_used=0,mem=159992kb,vmem=9238056kb,walltime=00:00:29

  • After the result files are produced, you can move the files off the cluster, refer to the file transfer guide for help.
  • Congratulations! You successfully ran a Scala program on the cluster.