1. Open the Terminal and use the following commands at the command line.
module load sage/8.7 to load Sage. This command should return the confirmation “module loaded”.
3. Load other dependent modules for Sage. These modules must be loaded in the specific order specified by the system when the Sage module is loaded. Loading them in a different order may cause Sage to throw errors.
module load gcc/8.3 sqlite/3.25.2 perl/5.24.1 libgd/2.2.5 mpfr/3.1.5 ffmpeg/4.0.1 imagemagick/7.0.7 texlive/2018
sage to launch the Sage console within your Terminal window.
The Sage install may not always work properly on Oscar's VNC nodes due to the VNC nodes running older chipsets. The easiest way to remedy this issue is to run sage in an interactive job via the terminal in your VNC session.
Use the interact command with parameters for your specific job to start the interactive session, then load your modules and run the sage binary (steps 2-4 above).
interact -n 2 -m 32g -t 04:00:00 -f 'haswell|broadwell|skylake'
It is possible to install most Sage packages locally to your home folder by passing the
–user parameter at the end of your install command. See below for example steps to install the Sage packages “surface_dynamics” and “sage-flatsurf”. In this example, we are loading both packages from git repositories, so we need to load the git module.
module load git
sage -pip install git+https://gitlab.com/videlec/surface_dynamics –user
sage -pip install git+https://github.com/videlec/sage-flatsurf –user
Thanks to Trevor Hyde from Summer@ICERM 2019 for these instructions.
One method for running computations with Sage on Oscar is to write a script and use the slurm batch scheduler to have Oscar run your script. This requires two pieces:
#!/bin/bash #SBATCH -J test_program #SBATCH --array=0-9 #SBATCH -t 1:00:00 #SBATCH --mem=8G #SBATCH -e data/<oscar-username>/test_output/test%a.err #SBATCH -o data/<oscar-username>/test_output/test%a.out module load sage/8.7 module load gcc/8.3 sqlite/3.25.2 perl/5.24.1 libgd/2.2.5 mpfr/3.1.5 ffmpeg/4.0. 1 imagemagick/7.0.7 texlive/2018 sage test_program.sage $SLURM_ARRAY_TASK_ID
#!/bin/bashtells the system this is a bash (shell) script.
#SBATCH -J test_programsets the name of the job which appears when you check the status of your jobs.
#SBATCH –array=0-9is an easy way of doing parallel computations. In this case it says our job will run on 10 different nodes, each node will be passed a parameter and we have specified that the parameters will take the values 0 through 9. You can specify several ranges or even list individual parameters if you prefer.
#SBATCH -t 1:00:00specifies a time limit in
HH:MM:SSfor each node. Once this time runs out your program will stop running on that node. Be careful setting the time limit too high as doing so may make it take a long time for your job to get scheduled to run. Before starting a big computation try to do some smaller tests to see how long you expect to need.
#SBATCH –mem=8Gspecifies how much memory each node gets. Standard exploratory accounts get 123GB total to use at any one time. So if you allocate too much per job, fewer jobs will run at once. On the other hand, if you allocate too little and a computation needs more than it has, then it will terminate. If this happens an “out of memory” error will show up in the
.errfile for that node.
#SBATCH -e data/<ccv-username>/test_output/test%a.errand
#SBATCH -o data/<ccv-username>/test_output/test%a.outspecify where the error messages and output for each computation should be sent. You should store these files in your user folder, not on the submit node. We each have a folder inside the
datadirectory which you can see from the submit node. In this example I have created a folder titled
test_outputwhere I’m putting both of these files. You need to make these folders before you run the computation otherwise the output will be dumped into the void! The
%awill get replaced with the array parameter. So for example, since we set our array parameters to be
0-9there will be 10 nodes running and each of them gets a number between 0 and 9; this node corresponding to the parameter 7 will create two files
module load sage/8.7loads the sage module into the node.
module load gcc/8.3 sqlite/3.25.2 perl/5.24.1 libgd/2.2.5 mpfr/3.1.5 ffmpeg/4.0.1 imagemagick/7.0.7 texlive/2018loads the dependency packages for the sage module.
Everything after this in the script happens as if you typed it yourself onto the command line.
sage test_program.sage $SLURM_ARRAY_TASK_IDruns our example sage program
$SLURM_ARRAY_TASK_IDwhich is the array parameter passed to each node. You can use this parameter to select which input parameters to run your program on.
import sys def fun_math(message): print message sys.stdout.flush() job_id = int(sys.argv) fun_math('hi this is a test') fun_math('my job id is' + str(job_id))
sysso you can access the array parameter passed to your function from the node. This is accessed in this case by
sys.argv. Make sure you explicitly coerce to be an integer if you want to use it as an integer; it's a string by default.
.outfile for this node as a new line.
sys.stdout.flush()included in the function. This makes the program immediately send whatever output it has to the output file when called. Otherwise the program won’t output anything until it has completely finished running. If each node is running 100 potentially long computations and it finishes the first 99 but then times out on the 100th computation, and you don’t include any
sys.stdout.flush()commands, everything will be lost when time runs out.
sbatch <NAME_OF_BATCH_FILE>. In our example here, our batch file is called
sage-batch.sh, so we simply type
sbatch sage-batch.shSlurm will return a line that tells you your job has been submitted together with a job id number.
myqfrom anywhere on Oscar. This will show you what jobs you have running, how much time they have left, and which jobs are still waiting to run. Be patient, sometimes it takes a minute for things to get started.
scancel <JOB_ID>. You can specify a single node or just put the general job id for the whole run and cancel everything.