728x90
https://huggingface.co/docs/transformers/perf_infer_gpu_one
from pynvml import *
def print_gpu_utilization():
nvmlInit()
handle = nvmlDeviceGetHandleByIndex(0)
info = nvmlDeviceGetMemoryInfo(handle)
print(f"GPU memory occupied: {info.used//1024**2} MB.")
def print_summary(result):
print(f"Time: {result.metrics['train_runtime']:.2f}")
print(f"Samples/second: {result.metrics['train_samples_per_second']:.2f}")
print_gpu_utilization()
print_gpu_utilization()
# GPU memory occupied: 4564 MB.
๋ฐ์ํ
'๐ Python' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[์ ๋ ฌ ์๊ณ ๋ฆฌ์ฆ] ํ์ํธ(Tim sort) (0) | 2023.03.03 |
---|---|
leetCode python code markdown ๋ณํ๊ธฐ (0) | 2023.02.27 |
[python 3.8-] Print Format (0) | 2022.06.13 |
[*args, **kwargs] ํจ์ ํ๋ผ๋ฏธํฐ ๊ตฌ๋ถ์ (0) | 2022.06.13 |
[Code-Server] ์ฝ๋ ์๋ฒ์์ ์ฃผํผํฐ ๋ ธํธ๋ถ ์ฌ์ฉํ๊ธฐ (0) | 2021.07.11 |