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

本站现有博文333篇,共被浏览922296

本站已经建立2628天!

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