Skip to content

10 MB Allocation on GPU During VkInstance creation, not VkDevice creation #409

Description

@Prox501

So I have noticed an over-eager behavior in allocating 10 MB of memory on GPU. I was able to reproduce the behavior with the following code in C language:

#include <vulkan/vulkan.h>
#include <stdio.h>
#include <stdlib.h>

int main() {
    VkInstance instance;

    VkApplicationInfo appInfo = {
        .sType = VK_STRUCTURE_TYPE_APPLICATION_INFO,
        .pApplicationName = "VkInstanceTest",
        .applicationVersion = VK_MAKE_VERSION(1, 0, 0),
        .pEngineName = "NoEngine",
        .engineVersion = VK_MAKE_VERSION(1, 0, 0),
        .apiVersion = VK_API_VERSION_1_0
    };

    VkInstanceCreateInfo createInfo = {
        .sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO,
        .pApplicationInfo = &appInfo
    };

    VkResult result = vkCreateInstance(&createInfo, NULL, &instance);
    if (result != VK_SUCCESS) {
        fprintf(stderr, "Failed to create Vulkan instance! Error code: %d\n", result);
        return EXIT_FAILURE;
    }

    printf("VkInstance created successfully.\n");
    printf("Press Enter to exit...\n");
    getchar();  // Wait for user to press Enter

    vkDestroyInstance(instance, NULL);
    printf("VkInstance destroyed.\n");

    return EXIT_SUCCESS;
}

And you can build it by running clang -lvulkan demo.c -o demovulkan assuming that the c file is demo.c. When running with nvtop program which tracks real-time usage of GPU memory, on your AMDVLK, it over-eagerly allocate 10 MB on the GPU without a reason to when VkDevice have yet to be allocated or built when running above code. So if you instead point to using RADV driver, it reports either 0 mb allocation on GPU or not showing up at nvtop at all.

VK_ICD_FILENAMES=/usr/share/vulkan/icd.d/radeon_icd.x86_64.json ./demovulkan

Thanks.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions