Last active
June 4, 2020 07:33
-
-
Save kHarshit/1d249a12fb53e5766457d31d0dbc1fe2 to your computer and use it in GitHub Desktop.
Monitor colab gpu usage
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
# Step 1: Create a file to monitor gpu usage in a jupyter cell | |
%%writefile gpu_usage.sh | |
#! /bin/sh | |
#comment: run for 10 seconds, change it as per your use | |
end=$((SECONDS+10)) | |
while [ $SECONDS -lt $end ]; do | |
nvidia-smi --format=csv --query-gpu=power.draw,utilization.gpu,memory.used,memory.free,fan.speed,temperature.gpu >> gpu.log | |
#comment: or use below command and comment above using # | |
#nvidia-smi dmon -i 0 -s mu -d 1 -o TD >> gpu.log | |
done | |
# Step 2: Execute the above script in background in another cell | |
%%bash --bg | |
bash gpu_usage.sh | |
# Step 3: Run the inference | |
# note that the script will record gpu usage for first 10 seconds, change it as per your model running time. | |
# the gpu utilization results will be save in `gpu.log` file. | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment