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

本站现有博文320篇,共被浏览756682

本站已经建立2421天!

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