Stata

Description

Integrated statistical package for data analysis, data management and graphics. Stata/MP takes advantage of multicore processors to perform its computations in parallel.

Home page

http://stata.com

Documentation

https://www.stata.com/features/documentation/

License

UiO has a license for Stata/MP for up to 32 cores. Access is granted on an individual basis. Request access if Stata does not open after loading the module.

Usage

Use

module avail Stata

to see which versions of Stata are available. Use

module load Stata/version

to get access to Stata. To run Stata in a job script, change to the directory containing the do-files

cd /path/to/your/do/files

and run Stata in batch mode (switch -b) as follows

stata-mp -b do stata-test.do

Multicore conciderations

If you are running multicore Stata you must concider the number of cores you want to allocate via SLURM (up to 32). This is done by --cpus-per-task=N. Stata-mp will per default use 8 cores. If you allocate less that 8 cores and start stata-mp with more than you have allocated, stata-mp will terminate. To set the number of cores in stata-mp put "set processors N" in the start of the .do file.

Assume you have requested SLURM to allocate only 4 cores using "--cpus-per-task=4" you must put "set processors 4" in the start of your .do file. Failing to do this will cause stata-mp to abort.

Example job script

Stata/MP job on eight cores.

#!/bin/bash

# SLURM resource management parameters
#
## job name (to identify your job)
#SBATCH --job-name=YourJob'sName
#
## project (for accounting)
#SBATCH --account=YourProject
#
## wall clock limit (job is terminated if limit exceeded)
#SBATCH --time=hh:mm:ss
#
## upper bound on memory (job is terminated if limit exceeded)
#SBATCH --mem-per-cpu=2G
#
## number of (parallel) tasks (e.g. 8 cores)
#SBATCH --nodes=1 --cpus-per-task=8

# initialize job environment
source /cluster/bin/jobsetup

# prepare job input data
#  - mostly, copy data to job directory on /work file system
#  - $SCRATCH is set to /work/${SLURM_JOBID}.d
cp __PathToYourInputData__ $SCRATCH


# load module for Stata
module load stata

# (optional) change directory to $SCRATCH or $TMPDIR
cd $SCRATCH

# run Stata
stata-mp -b __YourStataJob__.do  __YourStataJob__.log

# (recommended) create a directory for results in your HOME
mkdir -p $HOME/__DirectoryForResults__/$SLURM_JOBID

# copy results back to your HOME directory on /cluster file system
cp __RESULTS__ $HOME/__DirectoryForResults__/$SLURM_JOBID

# Note!
#  - If you want all results in one directory, remove
#    the part '/$SLURM_JOBID' in mkdir & cp
#  - Make sure that result files have different names for different
#    jobs or they will be overwritten by a next job.

 

Did you find what you were looking for?
Published June 21, 2021 10:35 AM - Last modified Mar. 29, 2022 3:18 PM