Differences
This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision | ||
software:java:caviness [2018-08-10 16:51] – anita | software:java:caviness [2021-04-27 16:21] (current) – external edit 127.0.0.1 | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== Projects in Java on Caviness ====== | ====== Projects in Java on Caviness ====== | ||
- | Using the basic Java example | + | Below is a basic Java example |
<file java HelloWorld.java> | <file java HelloWorld.java> | ||
Line 13: | Line 13: | ||
</ | </ | ||
- | <note important> | + | Check the version of the java compiler and java available on Caviness by using |
- | Check the versions of java development available on your cluster by using | + | < |
- | + | $ javac -version | |
- | < | + | |
$ java -version | $ java -version | ||
</ | </ | ||
- | and determine if this is acceptable for your java application to compile and create the '' | + | and determine if this is acceptable for your java application to compile and create the '' |
- | < | + | < |
- | [farber | + | [traine@login00 |
- | [(it_css: | + | [(it_css: |
- | [(it_css: | + | javac 1.8.0_161 |
+ | [(it_css: | ||
+ | openjdk version " | ||
+ | OpenJDK Runtime Environment (build 1.8.0_161-b14) | ||
+ | OpenJDK 64-Bit Server VM (build 25.161-b14, mixed mode) | ||
+ | [(it_css: | ||
+ | [(it_css: | ||
public class HelloWorld | public class HelloWorld | ||
{ | { | ||
Line 34: | Line 39: | ||
} | } | ||
} | } | ||
- | [(it_css: | + | [(it_css: |
- | Your job 1392265 (" | + | [(it_css: |
- | waiting for interactive job to be scheduled ... | + | |
- | Your interactive job 1392265 has been successfully scheduled. | + | |
- | Establishing / | + | |
- | [(it_css: | + | |
- | Adding package `openjdk/ | + | |
- | [(it_css: | + | |
- | [(it_css: | + | |
HelloWorld.class | HelloWorld.class | ||
- | [(it_css: | + | [(it_css: |
Hello, World! | Hello, World! | ||
- | [(it_css: | + | [(it_css: |
- | [(it_css: | + | |
</ | </ | ||
- | Once we are back on the head node, you will need a job submission script | + | If you want to compile |
+ | |||
+ | <code bash> | ||
+ | [traine@login00 ~]$ workgroup -g it_css | ||
+ | [(it_css: | ||
+ | salloc: Pending job allocation 7299417 | ||
+ | salloc: job 7299417 queued and waiting for resources | ||
+ | salloc: job 7299417 has been allocated resources | ||
+ | salloc: Granted job allocation 7299417 | ||
+ | salloc: Waiting for resource configuration | ||
+ | salloc: Nodes r00n56 are ready for job | ||
+ | [traine@r00n56 ~]$ javac -version | ||
+ | javac 1.8.0_161 | ||
+ | [traine@r00n56 ~]$ java -version | ||
+ | openjdk version " | ||
+ | OpenJDK Runtime Environment (build 1.8.0_161-b14) | ||
+ | OpenJDK 64-Bit Server VM (build 25.161-b14, mixed mode) | ||
+ | [traine@r00n56 ~]$ cd $WORKDIR/ | ||
+ | [traine@r00n56 java]$ cat HelloWorld.java | ||
+ | public class HelloWorld | ||
+ | { | ||
+ | public static void main(String[] args) | ||
+ | { | ||
+ | System.out.println(" | ||
+ | } | ||
+ | } | ||
+ | [traine@r00n56 java]$ javac HelloWorld.java | ||
+ | [traine@r00n56 java]$ ls | ||
+ | HelloWorld.class | ||
+ | [traine@r00n56 java]$ java HelloWorld | ||
+ | Hello, World! | ||
+ | [traine@r00n56 java]$ exit | ||
+ | exit | ||
+ | salloc: Relinquishing job allocation 7299417 | ||
+ | [(it_css: | ||
+ | </ | ||
+ | |||
+ | If you want to run your java job in batch, then you will need a job submission script. For this simple example, copy '' | ||
<file bash submit.qs> | <file bash submit.qs> | ||
+ | #!/bin/bash -l | ||
# | # | ||
- | # Template: | + | # Sections of this script that can/should be edited are delimited by a |
- | # | + | # [EDIT] tag. All Slurm job options are denoted by a line that starts |
- | # Change the following to #$ and set the amount of memory you need | + | # with "#SBATCH " followed by flags that would otherwise be passed on |
- | # per-slot if you're getting out-of-memory errors using the | + | # the command line. Slurm job options can easily be disabled in a |
- | # default: | + | # script by inserting a space in the prefix, e.g. "# SLURM " and |
- | # -l m_mem_free=2G | + | # reenabled by deleting that space. |
# | # | ||
- | # If you want an email message | + | # This is a batch job template for a program using a single processor |
- | # finishes, edit the -M line to have your email address | + | # core/thread (a serial job). |
- | # next two lines to start with #$ instead of just # | + | # |
- | # -m eas | + | #SBATCH --ntasks=1 |
- | # -M my_address@mail.server.com | + | # |
+ | # [EDIT] All jobs have memory limits imposed. | ||
+ | # CPU allocated | ||
+ | # with a per-node value (--mem) or a per-CPU value (--mem-per-cpu) | ||
+ | # with unitless values in MB and the suffixes K|M|G|T denoting | ||
+ | # kibi, mebi, gibi, and tebibyte units. | ||
+ | # the "#" | ||
+ | # | ||
+ | # SBATCH --mem=8G | ||
+ | # SBATCH --mem-per-cpu=1024M | ||
+ | # | ||
+ | # [EDIT] Each node in the cluster has local scratch disk of some sort | ||
+ | # that is always mounted as /tmp. Per-job and per-step temporary | ||
+ | # directories are automatically created and destroyed by the | ||
+ | # auto_tmpdir plugin in the /tmp filesystem. | ||
+ | # amount of free space on /tmp when your job is scheduled, the | ||
+ | # --tmp option can be used; it has the same behavior unit-wise as | ||
+ | # --mem and --mem-per-cpu. | ||
+ | # word SBATCH to enable: | ||
+ | # | ||
+ | # SBATCH --tmp=1T | ||
+ | # | ||
+ | # [EDIT] It can be helpful to provide a descriptive (terse) name for | ||
+ | # the job: | ||
+ | # | ||
+ | #SBATCH --job-name=java_serial_job | ||
+ | # | ||
+ | # [EDIT] The partition determines which nodes can be used and with what | ||
+ | # maximum runtime limits, etc. Partition limits can be displayed | ||
+ | # with the " | ||
+ | # | ||
+ | #SBATCH --partition=devel | ||
+ | # | ||
+ | # [EDIT] The maximum runtime for the job; a single integer is interpreted | ||
+ | # as a number of seconds, otherwise use the format | ||
+ | # | ||
+ | # d-hh: | ||
+ | # | ||
+ | # Jobs default | ||
+ | # if this option is omitted. | ||
+ | # | ||
+ | #SBATCH --time=0-00: | ||
+ | # | ||
+ | # [EDIT] By default SLURM sends the job's stdout to the file " | ||
+ | # | ||
+ | # | ||
+ | # word SBATCH on the following | ||
+ | # special tokens that can be used in the filenames: | ||
+ | # | ||
+ | # SBATCH --output=%x-%j.out | ||
+ | # SBATCH --error=%x-%j.out | ||
+ | # | ||
+ | # [EDIT] Slurm can send emails | ||
+ | # | ||
+ | # | ||
+ | # of these flags (separated by commas) are permissible for the | ||
+ | # | ||
+ | # for messages to get off the cluster. | ||
+ | # | ||
+ | # SBATCH | ||
+ | # SBATCH --mail-type=END, | ||
+ | # | ||
+ | # [EDIT] By default we DO NOT want to send the job submission environment | ||
+ | # to the compute node when the job runs. | ||
+ | # | ||
+ | #SBATCH --export=NONE | ||
# | # | ||
- | # Add vpkg_require commands after this line: | + | # |
- | vpkg_require openjdk/1.8.0 | + | # Do general job environment setup: |
+ | # | ||
+ | . / | ||
- | # Now append all of your shell commands necessary to run your program | + | # |
- | # after this line: | + | # [EDIT] Add your script statements hereafter, or execute a script or program |
+ | # using the srun command. | ||
+ | # | ||
java HelloWorld | java HelloWorld | ||
</ | </ | ||
- | Now submit the job using '' | + | Now submit the job using '' |
- | + | ||
- | < | + | |
- | (it_css: | + | |
- | Your job 1392329 (" | + | |
- | [(it_css: | + | |
- | job-ID | + | |
- | ------------------------------------------------------------------------------------------------------------------------------------------------ | + | |
- | | + | |
- | [(it_css: | + | |
- | HelloWorld.class | + | |
- | [(it_css: | + | |
- | [(it_css: | + | |
- | + | ||
- | [CGROUPS] UD Grid Engine cgroup setup commencing | + | |
- | [CGROUPS] Setting 1073741824 bytes (vmem none bytes) on n038 (master) | + | |
- | [CGROUPS] | + | |
- | [CGROUPS] done. | + | |
- | Adding package `openjdk/1.8.0` to your environment | + | <code bash> |
+ | [traine@login00 ~]$ workgroup -g it_css | ||
+ | [(it_css: | ||
+ | Submitted batch job 1231 1 | ||
+ | [(it_css: | ||
+ | HelloWorld.class | ||
+ | [(it_css: | ||
Hello, World! | Hello, World! | ||
- | [(it_css: | + | [(it_css: |
</ | </ | ||
- | <note tip> | + | <note tip> |