Get the id of a GPU with low memory usage

What do you usually do?

It is assumed that you are using a GPU driver made by NVIDIA.

It seems that it is implemented as part of some framework, but I can't find it, so I'll write down what I'm doing in my case. (If you actually have one, please tell me secretly ...)

First, get the used memory status for each id by entering the following as a shell command.

nvidia-smi --query-gpu=index,memory.used --format=csv,noheader

Extract the result you want to use the following regular expression in the returned result.

^([0-9]+),(\s+)?([0-9]+)(\s+)?MiB$

The above two-step process is described as python code.

Recommended Posts

Get the id of a GPU with low memory usage
Get UNIXTIME at the beginning of today with a command
GraalVM's memory usage can be very low. What a 1/16 of Java!
How to get the ID of Type2Tag NXP NTAG213 with nfcpy
Get the URL of a JIRA ticket created with the jira-python library
Get the filename of a directory (glob)
Get the number of searches with a regular expression. SeleniumBasic VBA Python
Get the average salary of a job with specified conditions from indeed.com
[Python] Get the files in a folder with Python
Get the caller of a function in Python
Get a list of IAM users with Boto3
Get the stock price of a Japanese company with Python and make a graph
How to get a list of files in the same directory with python
[Introduction to Python] How to get the index of data with a for statement
Get the sum of each of multiple columns with awk
Take a screenshot of the LCD with Python-LEGO Mindstorms
Make a note of the list of basic Pandas usage
Try to get the contents of Word with Golang
Visualize the characteristic vocabulary of a document with D3.js
Get the operation status of JR West with Python
Roughly estimate the total memory usage of an object
Calculate the product of matrices with a character expression?
Get the value of a specific key in a list from the dictionary type in the list with Python
A network diagram was created with the data of COVID-19.
Measure the importance of features with a random forest tool
Check the memory status of the server with the Linux free command
Get the number of digits
Get the number of specific elements in a python list
Get a list of purchased DMM eBooks with Python + Selenium
Get thread ID with python
Analyze the topic model of becoming a novelist with GensimPy3
Make a BLE thermometer and get the temperature with Pythonista3
Get the trading price of virtual currency and create a chart with API of Zaif exchange
The story of making a question box bot with discord.py
Get the host name of the host PC with Docker on Linux
Get the source of the page to load infinitely with python.
How to display the CPU usage, pod name, and IP address of a pod created with Kubernetes
Process the contents of the file in order with a shell script
A story stuck with the installation of the machine learning library JAX
Get the number of PVs of Qiita articles you posted with API
Save the result of the life game as a gif with python
Find the optimal value of a function with a genetic algorithm (Part 2)
[Statistics] Grasp the image of the central limit theorem with a graph
[python, ruby] fetch the contents of a web page with selenium-webdriver
How to check the memory size of a variable in Python
[Introduction to StyleGAN] I played with "The Life of a Man" ♬
If you give a list with the default argument of the function ...
The story of making a standard driver for db with python.
Here's a brief summary of how to get started with Django
How to check the memory size of a dictionary in Python
[Python] Get the update date of a news article from HTML
How to find the memory address of a Pandas dataframe value
Count the maximum concatenated part of a random graph with NetworkX
How to get the vertex coordinates of a feature in ArcPy
Check the memory protection of linux kerne with the code for ARM
The idea of feeding the config file with a python file instead of yaml
Create a function to get the contents of the database in Go
Get a list of files in a folder with python without a path
The story of making a module that skips mail with python
Get the number of readers of a treatise on Mendeley in Python
Create a compatibility judgment program with the random module of python.