PYTHONL Telegram 4906
🎯 Хочешь следить за загрузкой своей GPU прямо из Python?

Вот простой скрипт, который показывает текущую загрузку видеокарты NVIDIA (через `nvidia-smi`). Подходит для мониторинга в ML-задачах, инференсе и просто для интереса.

📦 Зависимости: установленный nvidia-smi и Python 3.6+

🧠 Код:


import subprocess

def get_gpu_utilization():
try:
result = subprocess.check_output(
['nvidia-smi', '--query-gpu=utilization.gpu,memory.used,memory.total',
'--format=csv,nounits,noheader'],
encoding='utf-8'
)
lines = result.strip().split('\n')
for idx, line in enumerate(lines):
gpu_util, mem_used, mem_total = map(str.strip, line.split(','))
print(f"🖥 GPU {idx}: {gpu_util}% load | {mem_used} MiB / {mem_total} MiB")
except FileNotFoundError:
print(" nvidia-smi not found. Make sure NVIDIA drivers are installed.")
except Exception as e:
print(f"⚠️ Error: {e}")

get_gpu_utilization()


📊 Вывод будет примерно такой:

GPU 0: 23% load | 412 MiB / 8192 MiB

🔥 Советы:
• Можно запускать в цикле для live-мониторинга
• Легко интегрировать в Telegram-бота или Slack-уведомления
• Работает на всех машинах с установленным NVIDIA драйвером и nvidia-smi

@pythonl



tgoop.com/pythonl/4906
Create:
Last Update:

🎯 Хочешь следить за загрузкой своей GPU прямо из Python?

Вот простой скрипт, который показывает текущую загрузку видеокарты NVIDIA (через `nvidia-smi`). Подходит для мониторинга в ML-задачах, инференсе и просто для интереса.

📦 Зависимости: установленный nvidia-smi и Python 3.6+

🧠 Код:


import subprocess

def get_gpu_utilization():
try:
result = subprocess.check_output(
['nvidia-smi', '--query-gpu=utilization.gpu,memory.used,memory.total',
'--format=csv,nounits,noheader'],
encoding='utf-8'
)
lines = result.strip().split('\n')
for idx, line in enumerate(lines):
gpu_util, mem_used, mem_total = map(str.strip, line.split(','))
print(f"🖥 GPU {idx}: {gpu_util}% load | {mem_used} MiB / {mem_total} MiB")
except FileNotFoundError:
print(" nvidia-smi not found. Make sure NVIDIA drivers are installed.")
except Exception as e:
print(f"⚠️ Error: {e}")

get_gpu_utilization()


📊 Вывод будет примерно такой:

GPU 0: 23% load | 412 MiB / 8192 MiB

🔥 Советы:
• Можно запускать в цикле для live-мониторинга
• Легко интегрировать в Telegram-бота или Slack-уведомления
• Работает на всех машинах с установленным NVIDIA драйвером и nvidia-smi

@pythonl

BY Python/ django


Share with your friend now:
tgoop.com/pythonl/4906

View MORE
Open in Telegram


Telegram News

Date: |

Commenting about the court's concerns about the spread of false information related to the elections, Minister Fachin noted Brazil is "facing circumstances that could put Brazil's democracy at risk." During the meeting, the information technology secretary at the TSE, Julio Valente, put forward a list of requests the court believes will disinformation. The visual aspect of channels is very critical. In fact, design is the first thing that a potential subscriber pays attention to, even though unconsciously. ZDNET RECOMMENDS With Bitcoin down 30% in the past week, some crypto traders have taken to Telegram to “voice” their feelings. Channel login must contain 5-32 characters
from us


Telegram Python/ django
FROM American