Skip to content

Instantly share code, notes, and snippets.

@hitman99
Created August 8, 2017 10:35
Show Gist options
  • Save hitman99/92278269bd1cdd360be6f57feb27ba98 to your computer and use it in GitHub Desktop.
Save hitman99/92278269bd1cdd360be6f57feb27ba98 to your computer and use it in GitHub Desktop.
CloudWatch metrics for GPU on EC2 G3 instance
#!/bin/bash
IFS=', ' read -r -a STATS <<< `nvidia-smi --query-gpu=temperature.gpu,memory.used,memory.free,utilization.gpu,utilization.memory --format=csv,nounits,noheader`
#echo ${STATS[@]}
# Send values to CloudWatch
aws cloudwatch put-metric-data --metric-name Temperature --namespace GPUStats --value ${STATS[0]}
aws cloudwatch put-metric-data --metric-name MemoryUsed --namespace GPUStats --unit Megabytes --value ${STATS[1]}
aws cloudwatch put-metric-data --metric-name MemoryFree --namespace GPUStats --unit Megabytes --value ${STATS[2]}
aws cloudwatch put-metric-data --metric-name GPUUtilization --namespace GPUStats --value ${STATS[3]}
aws cloudwatch put-metric-data --metric-name MemoryUtilization --namespace GPUStats --value ${STATS[4]}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment