-
-
Save xihajun/a82789cbe9de021565ec9285e62e4280 to your computer and use it in GitHub Desktop.
update for chai
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Copyright (C) 2019 by Christian Goll <[email protected]> | |
# | |
# Permission to use, copy, modify, and/or distribute this software for any | |
# purpose with or without fee is hereby granted. | |
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH | |
# REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND | |
# FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, | |
# INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM | |
# LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR | |
# OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | |
# PERFORMANCE OF THIS SOFTWARE. | |
export SLURMD=/usr/local/sbin/slurmd | |
export SLURMCONF=/usr/local/etc/slurm.conf | |
export GRESCONF=/usr/local/etc/gres.conf | |
export NOW=$(date +%Y%m%d%H%M) | |
if [ -e $SLURMCONF ] ; then | |
cp $SLURMCONF $SLURMCONF.$NOW | |
fi | |
if [ -e $GRESCONF ] ; then | |
cp $GRESCONF $GRESCONF.$NOW | |
fi | |
cat > $SLURMCONF <<EOF | |
# instant slurm file, automatically generated | |
ClusterName=$(cat /etc/machine-id) | |
ControlMachine=localhost | |
SlurmdUser=root | |
SlurmctldPort=6817 | |
SlurmdPort=6818 | |
StateSaveLocation=/var/lib/slurm | |
SlurmdSpoolDir=/var/spool/slurmd | |
SwitchType=switch/none | |
MpiDefault=none | |
SlurmctldPidFile=/var/run/slurmctld.pid | |
SlurmdPidFile=/var/run/slurmd.pid | |
ProctrackType=proctrack/cgroup | |
ReturnToService=1 | |
SelectType=select/cons_res | |
SelectTypeParameters=CR_Core | |
TaskPlugin=task/affinity | |
SlurmctldTimeout=300 | |
SlurmdTimeout=300 | |
InactiveLimit=0 | |
MinJobAge=300 | |
KillWait=30 | |
Waittime=0 | |
SchedulerType=sched/builtin | |
FastSchedule=1 | |
SlurmctldDebug=3 | |
SlurmctldLogFile=/var/log/slurmctld.log | |
SlurmdDebug=3 | |
SlurmdLogFile=/var/log/slurmd.log | |
JobCompType=jobcomp/none | |
PropagateResourceLimitsExcept=MEMLOCK | |
PartitionName=normal Nodes=localhost Default=YES MaxTime=UNLIMITED State=UP | |
NodeName=localhost FOO $($SLURMD -C | grep -v UpTime | cut -f 2-32 -d ' ') | |
EOF | |
if [ -e /dev/nvidia0 ] ; then | |
gpucount=$(ls /dev/nvidia[0-9] | wc -l) | |
if [ $gpucount -eq 1 ] ; then | |
cat > $GRESCONF <<EOF | |
Name=gpu File=/dev/nvidia0 | |
EOF | |
cat >> $SLURMCONF <<EOF | |
GresTypes=gpu | |
EOF | |
sed -i 's/FOO/GresType=gpu/' $SLURMCONF | |
elif [ $gpucount -gt 1 ] ; then | |
cat > $GRESCONF <<EOF | |
Name=gpu File=/dev/nvidia[0-$(($gpucount-1))] | |
EOF | |
cat >> $SLURMCONF <<EOF | |
Gres=gpu | |
EOF | |
sed -i 's/FOO/GresType=gpu/' $SLURMCONF | |
fi | |
else | |
sed -i 's/FOO//' $SLURMCONF | |
fi | |
cat <<EOF | |
# Wrote minimal instant slurm configuration to $SLURMCONF | |
# Orginal $SLURMCONF can be found under $SLURMCONF.$NOW | |
EOF | |
if [ -e $GRESCONF ] ; then | |
cat <<EOF | |
# Wrote $GRESCONF | |
EOF | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment