Skip to content

Commit

Permalink
scripts and info for /export/apps
Browse files Browse the repository at this point in the history
  • Loading branch information
nadyawilliams committed Feb 24, 2016
1 parent 589c854 commit 9f20898
Show file tree
Hide file tree
Showing 8 changed files with 213 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/nbcr-nfs/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
REDHAT.ROOT = $(CURDIR)/../../

-include $(ROCKSROOT)/etc/Rules.mk
include Rules.mk

build:

install::
mkdir -p -m 755 $(ROOT)/$(PKGROOT)/bin
install -m 755 bin/* $(ROOT)/$(PKGROOT)/bin
mkdir -p -m 755 $(ROOT)/$(PKGROOT)/info
install -m 644 info/* $(ROOT)/$(PKGROOT)/info

clean::
87 changes: 87 additions & 0 deletions src/nbcr-nfs/bin/showVisGpu
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
#!/opt/python/bin/python2.7

import os
import sys
import subprocess
from pprint import pprint

class GPUinfo:
""" base class """
def __init__(self, argv):
self.usage_command = os.path.basename(argv[0])
self.args = argv[1:]
self.space = ' '
self.specinfo = ''
self.nameinfo = 'checks for available GPU ids'
self.descinfo = 'outputs free GPU ids as a comma-separated string\n' + \
'%sNUM - number of GPUs to use for a job' % self.space
self.cmd = '/usr/bin/nvidia-smi'
self.utilization = 7 # utilization field in nvidia-smi output (without "| /" characters)
self.numgpu = 1
self.numgpuMax = 8 # max gpu count on a node
self.freeids = [] # list of free gpus
self.env = 'CUDA_VISIBLE_DEVICES' # environ variable to set

self.parseArgs()

def parseArgs(self):
""" check input arguments, and print usage"""
if len(self.args) == 0:
return
if self.args[0] in ('-h', '--help', 'help'):
self.help()
# first argument is number of desired gpus
numgpu = int(self.args[0])
if numgpu > 8 :
numgpu = 8
self.numgpu = numgpu

def help(self):
print "\nNAME\n%s%s - %s." % (self.space, self.usage_command, self.nameinfo)
print '\nSYNOPSIS\n', self.space + self.usage_command, "NUM", "[-h|--help|help]"
print '\nDESCRIPTION\n', self.space + self.descinfo
print self.specinfo
sys.exit(0)

def runTest(self):
""" test output """
pprint (self.__dict__)

def nvsmi(self):
"""find output of nvidia-smi"""
__name__ = "nvsmi"

cmd = "%s | grep %%" % self.cmd
info, err = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
if err:
print "%s returned error: %s" % (self.cmd,err)

info = info.translate(None, "|/") # remove | and /
lines = info.split('\n')[:-1] # split into lines, rm last new line

return lines

def findFree(self, lines):
""" find list of free GPU ids from a given output"""
for i in range (len(lines)):
parts = lines[i].split()
util = int(parts[self.utilization][:-1])
if util < 1:
self.freeids.append(i)
return

def setVisible(self):
strVis = str(self.freeids[0:self.numgpu]).strip('[]')
strVis = strVis.replace(' ','')
print strVis

#os.environ[self.env] = a

def run(self):
lines = self.nvsmi() # run nvidia-smi command
self.findFree(lines) # find free gpu ids
self.setVisible()

### Main ###
app = GPUinfo(sys.argv)
app.run()
15 changes: 15 additions & 0 deletions src/nbcr-nfs/bin/startVNC
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/bin/bash

acc=`whoami`
port=${acc:4:2}

if [ "$acc" == "npw" ]; then
port=25
fi
if [ "$acc" == "yin" ]; then
port=26
fi

echo "Using display :$port for vnc"
rocks run host compute-0-1 command="vncserver :$port"

14 changes: 14 additions & 0 deletions src/nbcr-nfs/bin/stopVNC
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/bin/bash

acc=`whoami`
port=${acc:4:2}

if [ "$acc" == "npw" ]; then
port=25
fi
if [ "$acc" == "yin" ]; then
port=26
fi

rocks run host compute-0-1 command="vncserver -kill :$port"

24 changes: 24 additions & 0 deletions src/nbcr-nfs/info/amber.sub
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/bin/bash
#$ -V
#$ -e amber-suit.e
#$ -o amber-suit.o
#$ -cwd
#$ -S /bin/bash
#$ -q gpu
#$ -l gpu=4
#$ -pe orte 4

# this example reqeusts 4 cpus and 4 gpus
# the required switches are above last 3 lines

# load the needed enviornment
module load amber14/gnu

# WORKAROUND to find free GPUs
# note number in the line below equals number of GPUs used in -l gpu line above
export CUDA_VISIBLE_DEVICES=`/share/apps/bin/showVisGpu 4`

# run your amber commands (cd to directory with input files)
cd $HOME/amber-run1
$AMBERHOME/bin/pmemd.cuda -O -i mdin.GPU -o mdout.1GPU -inf mdinfo.1GPU -x mdcrd.1GPU -r restrt.1GPU

25 changes: 25 additions & 0 deletions src/nbcr-nfs/info/amberGaMD.sub
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash
#$ -V
#$ -e amber-suit.e
#$ -o amber-suit.o
#$ -cwd
#$ -S /bin/bash
#$ -q gpu
#$ -l gpu=1
#$ -pe orte 4

# this example reqeusts 4 cpus and 1 gpu
# the request for GPU queue, number of CPUs, and number of GPUs are above last 3 lines

# load the needed enviornment
module load amberGaMD14/gnu

# WORKAROUND to find free GPUs
# note number in the line below equals number of GPUs used in -l gpu line above
export CUDA_VISIBLE_DEVICES=`/share/apps/bin/showVisGpu 1`

# run your amber commands (cd to directory with input files)
# YOURACCOUNT is your login name
cd /data/YOURACCOUNT/amber-run1
$AMBERHOME/bin/pmemd.cuda -O -i mdin.GPU -o mdout.1GPU -inf mdinfo.1GPU -x mdcrd.1GPU -r restrt.1GPU

30 changes: 30 additions & 0 deletions src/nbcr-nfs/info/modules
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

All applicaitons environment is set using modules.
From the list of available modules load modules needed by your application.

In general, modules that require other modules load them as a prerequisite
so that no extra loading will be implicitely needed. Applications modules
loading must be done in SGE submit script or on a command line.

To list available modules :
module avail

To load needed modules:
Example 1. load for amber14 compiled with gnu compiler:
module load amber14/gnu

Example 2. load for matlab
module load matlab

To list loaded modules:
module list

To unload a module:
module unload matlab

Unloading is only needed if switching for differently compiled versions of the same application
or if the previously loaded moduules conflict with a new needed.

For more info run:
man module

4 changes: 4 additions & 0 deletions src/nbcr-nfs/version.mk
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
NAME = nbcr-nfs
VERSION = 1
RELEASE = 0
PKGROOT = /export/apps/

0 comments on commit 9f20898

Please sign in to comment.