EADST

Jetson Check GPU Memory Usage with C++

Jetson Check GPU Memory Usage with C++

#include < iostream>
#include < unistd.h>
#include "cuda.h"

int main()
{
    // show memory usage of GPU
    size_t free_byte ;
    size_t total_byte ;

    while (true )
    {
        cudaError_t cuda_status = cudaMemGetInfo( &free_byte, &total_byte ) ;

        if ( cudaSuccess != cuda_status ){
            std::cout << "Error: cudaMemGetInfo fails, " << cudaGetErrorString(cuda_status) << std::endl;
            exit(1);
        }

        double free_db = (double)free_byte ;
        double total_db = (double)total_byte ;
        double used_db = total_db - free_db ;

        std::cout << "GPU memory usage: used = " << used_db/1024.0/1024.0 << ", free = "
                  << free_db/1024.0/1024.0 << " MB, total = " << total_db/1024.0/1024.0 << " MB" << std::endl;
        sleep(1);
    }

    return 0;
}

Reference

Nvidia Forums

相关标签
About Me
XD
Goals determine what you are going to be.
Category
标签云
FlashAttention UI Clash Docker Logo RAR PDB FP8 Bitcoin Markdown Numpy NLP Ubuntu VGG-16 Cloudreve GPT4 TensorRT UNIX LeetCode Mixtral SQLite 阿里云 Harness BeautifulSoup API Review PIP NLTK C++ Template InvalidArgumentError git 签证 GIT Plotly CUDA Sklearn 继承 LLAMA Tracking Hilton 域名 Crawler 多进程 XML ModelScope CAM LoRA Vim git-lfs JSON SVR mmap Streamlit 顶会 Hungarian FP32 HuggingFace Permission Jev TensorFlow ResNet-50 COCO Translation Website Breakpoint uwsgi FP16 uWSGI Color Statistics torchinfo Search printf Proxy Jetson Tensor Card 强化学习 证件照 云服务器 API网关 XGBoost ms-swift Data 递归学习法 hf 第一性原理 News Ptyhon Bert 报税 FP64 tqdm 飞书 NameSilo OCR Shortcut FastAPI icon CC 财报 Paper 多线程 Plate v2ray Conda Disk Magnet LaTeX TTS 图标 diffusers Safetensors 图形思考法 公式 Windows logger DeepSeek YOLO Attention GPTQ Knowledge Use Vmess Linux Gemma Agent SPIE Django LLM OpenAI llama.cpp Excel Domain Jupyter Video Food QWEN Rebuttal CEIR 音频 MD5 Anaconda CSV SAM CTC Paddle PDF v0.dev Llama WebCrawler RL Augmentation RGB BF16 腾讯云 Zip Qwen2.5 Password Pandas Michelin 关于博主 EXCEL HaggingFace Firewall VSCode IndexTTS2 Quantization transformers Hotel Tiktoken GoogLeNet PyCharm Google Qwen2 SQL Miniforge 论文 AI Distillation Pickle Pillow Animate Qwen OpenCV Pytorch Github Image2Text 论文速读 Math Python Dataset Bin Nginx Git Web GGML WAN Interview tar Random DeepStream BTC 净利润 VPN Quantize ONNX 算法题 ChatGPT PyTorch Transformers Diagram 搞笑 Baidu Datetime TSV Input Bipartite 版权 CLAP Algorithm Claude Base64 scipy Heatmap Land Freesound CV
站点统计

本站现有博文338篇,共被浏览973714次

本站已经建立2686天!

热门文章
文章归档
回到顶部