'Can't get available GPU memory [closed]

I try to get gpu available memory with code

bool bMemInfo1 = GLEW_NVX_gpu_memory_info; // false
bool bMemInfo2 = glewIsSupported("GL_NVX_gpu_memory_info"); // false
bool bMemInfo3 = glewGetExtension("GL_NVX_gpu_memory_info"); // false

GLint info = 0;

glGetIntegerv(GPU_MEMORY_INFO_CURRENT_AVAILABLE_VIDMEM_NVX, @info);

GLenum err = glGetError(); // 1280
if (GLEW_OK != err)
{
    cout << glewGetErrorString(err) << endl; // Unknown error
}

And I can't do it in my case. Could you explain why, please? Is there a possibility to obtain available GPU memory?



Solution 1:[1]

OpenGL was invented long before 3D GPUs. These things you’re trying to use are GL extensions, not part of any OpenGL standard. They may or may not work depending on OS version and GPU model.

If you’re on Windows, see DedicatedVideoMemory field returned by IDXGIAdapter::GetDesc() method.

If you’re on OSX, there’s kIOFBMemorySizeKey value you can query.

On Linux you’re out of luck, the OS doesn’t expose a consistent API to query that information. There’re device-specific ways which depend on GPU model, and vary widely: lspci tool won't work on many embedded SOCs, nvidia-smi tool only works for nVidia, vkGetPhysicalDeviceMemoryProperties() function requires Vulkan-capable GPU and drivers…

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Soonts