0

I am working on a Nvidia Jetson TX2 device that runs Ubuntu os. I want to build tensorflow c++ api and I need about 14GB memory available space. Is there some linux commands to check my available memory?

Fredi
  • 9
  • 2
  • There are many: `free, top, htop, cat /proc/meminfo, vmstat`. If you want GPU information you should use `nvidia-smi`. Sadly this question is not a real Stack Overflow questions and should be directed at [unix.se] or similar. – kvantour Aug 25 '21 at 06:23

1 Answers1

0

Disk Space

To get the free disk space memory in c++17 you could use the following way:

#include <iostream>  

#include <filesystem>
namespace fs = std::filesystem;

int main()
{
    fs::space_info tmp = fs::space("/tmp");

    std::cout << "Free space: " << tmp.free << '\n'
              << "Available space: " << tmp.available << '\n';
}

Memory

These both give information regarding memory in linux:

$ cat /proc/meminfo

OR

$ less /proc/meminfo

And then you could use grep to filter out the information that you need:

$ grep MemTotal /proc/meminfo

Or you could use c++ and the following function to get the total size (this is specific to linux though):

#include <unistd.h>

unsigned long long getTotalSystemMemory()
{
    long pages = sysconf(_SC_PHYS_PAGES);
    long page_size = sysconf(_SC_PAGE_SIZE);
    return pages * page_size;
}
Renis1235
  • 4,116
  • 3
  • 15
  • 27