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

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

本站已经建立2466天!

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