Skip to content

Instantly share code, notes, and snippets.

@juniorprincewang
Last active September 27, 2019 03:10
Show Gist options
  • Save juniorprincewang/f667b7922427645851dff92f0ce8f55d to your computer and use it in GitHub Desktop.
Save juniorprincewang/f667b7922427645851dff92f0ce8f55d to your computer and use it in GitHub Desktop.
CUDA MPS start and stop script
#!/bin/bash
# the following must be performed with root privilege
helpFuction()
{
echo ""
echo "Usage: $0 device_id"
echo -e "\t device_id is the id of nvidia device from what nvidia-smi displays"
exit 1
}
if [ -z $1 ];
then
helpFuction
fi
echo "Set Device $1"
export CUDA_VISIBLE_DEVICES="$1"
nvidia-smi -i "$1" -c EXCLUSIVE_PROCESS
nvidia-cuda-mps-control -d
#!/bin/bash
# the following must be performed with root privilege
helpFuction()
{
echo ""
echo "Usage: $0 device_id"
echo -e "\t device_id is the id of nvidia device from what nvidia-smi displays"
exit 1
}
if [ -z $1 ];
then
helpFuction
fi
echo "Set Device $1"
echo quit | nvidia-cuda-mps-control
nvidia-smi -i "$1" -c DEFAULT
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment