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

本站现有博文321篇,共被浏览764705

本站已经建立2442天!

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