Memory allocation method, device, electronic device and storage medium

By allocating memory from video memory and system memory in the virtual GPU and dynamically adjusting the memory page location, the problem of low virtual GPU storage resource utilization is solved and higher resource utilization and cost-effectiveness are achieved.

CN117742957BActive Publication Date: 2024-08-27MOORE THREADS TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202311764609.1
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2023-12-20
Publication Date
2024-08-27
Estimated Expiration
2043-12-20

AI Technical Summary

Technical Problem

The storage resource allocation of virtual GPU in the existing technology has low resource utilization and cannot effectively utilize system memory. As a result, more virtual GPU instances cannot be created under the same hardware conditions, which increases the total cost of ownership.

Method used

By obtaining the remaining video memory capacity and the remaining allocable system memory capacity, and allocating memory from the video memory and/or system memory according to the target memory capacity requested by the virtual GPU creation, the memory overscore of the virtual GPU can be achieved, and the memory page position can be dynamically adjusted to improve resources. Utilization.

Benefits of technology

Under the same hardware conditions, more virtual GPU instances can be created to improve resource utilization, reduce the total cost of ownership, and improve virtual GPU performance and video memory resource utilization.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN117742957B
    Figure CN117742957B
Patent Text Reader

Abstract

The present disclosure relates to a memory allocation method, device, electronic device and storage medium. The method comprises: in response to a virtual GPU creation request, obtaining at least one of the remaining video memory capacity and the remaining allocatable system memory capacity, and the target memory capacity corresponding to the virtual GPU creation request, wherein the remaining allocatable system memory capacity represents the remaining capacity of the system memory allowed to be allocated to the virtual GPU; in response to the sum of the remaining video memory capacity and the remaining allocatable system memory capacity being greater than or equal to the target memory capacity, creating a virtual GPU, and allocating memory to the virtual GPU from the video memory and / or the system memory according to the target memory capacity.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure relates to the field of computer technology, and in particular to a memory allocation method, device, electronic device and storage medium. Background Art

[0002] GPU (Graphics Processing Unit) is a processor with computing capabilities, including a computing unit and a storage unit. Among them, the computing unit completes various computing tasks sent to the GPU. In the process of the computing unit completing the computing task, the computing unit needs to access data, and needs to save the calculation results of the computing unit and the temporary data generated by the calculation process. Therefore, the storage unit is also an important part of the GPU. In a typical computer system, the GPU is usually a PCI (Peripheral Component Interconnect) device, and there is GPU-specific memory (i.e., video memory) on the graphics card.

[0003] Currently, the storage resource allocation of virtual GPU (vGPU) all uses video memory, and the resource utilization rate is low. Summary of the invention

[0004] The present invention provides a memory allocation technology solution.

[0005] According to one aspect of the present disclosure, a memory allocation method is provided, comprising:

[0006] In response to the virtual GPU creation request, obtaining at least one of a remaining video memory capacity and an allocatable system memory remaining capacity, and a target memory capacity corresponding to the virtual GPU creation request, wherein the allocatable system memory remaining capacity indicates a remaining capacity of the system memory allowed to be allocated to the virtual GPU;

[0007] In response to the sum of the remaining video memory capacity and the allocatable system memory remaining capacity being greater than or equal to the target memory capacity, a virtual GPU is created, and memory is allocated to the virtual GPU from the video memory and / or the system memory according to the target memory capacity.

[0008] In one possible implementation,

[0009] The step of obtaining, in response to the virtual GPU creation request, at least one of the remaining video memory capacity and the remaining system memory capacity that can be allocated, and the target memory capacity corresponding to the virtual GPU creation request comprises: obtaining, in response to the virtual GPU creation request, the remaining video memory capacity and the target memory capacity corresponding to the virtual GPU creation request; and obtaining, in response to the target memory capacity being greater than the remaining video memory capacity, the remaining system memory capacity that can be allocated;

[0010] In response to the sum of the remaining video memory capacity and the remaining capacity of the allocatable system memory being greater than or equal to the target memory capacity, creating a virtual GPU, and allocating memory to the virtual GPU from the video memory and / or the system memory according to the target memory capacity, includes: in response to the sum of the remaining video memory capacity and the remaining capacity of the allocatable system memory being greater than or equal to the target memory capacity, creating a virtual GPU, and allocating memory to the virtual GPU from the video memory and the system memory, or only from the system memory, according to the target memory capacity.

[0011] In one possible implementation,

[0012] The step of obtaining, in response to the virtual GPU creation request, at least one of the remaining video memory capacity and the remaining allocatable system memory capacity, and the target memory capacity corresponding to the virtual GPU creation request comprises: obtaining, in response to the virtual GPU creation request, the remaining video memory capacity and the target memory capacity corresponding to the virtual GPU creation request;

[0013] In response to the sum of the remaining video memory capacity and the remaining capacity of the allocatable system memory being greater than or equal to the target memory capacity, creating a virtual GPU, and allocating memory to the virtual GPU from the video memory and / or the system memory according to the target memory capacity, includes: in response to the remaining video memory capacity being greater than or equal to the target memory capacity, creating a virtual GPU, and allocating memory to the virtual GPU from the video memory according to the target memory capacity.

[0014] In a possible implementation, the method further includes:

[0015] In response to the remaining video memory capacity being less than the size of a single memory page, and a first memory page of the first virtual GPU in the system memory and a second memory page of the second virtual GPU in the video memory satisfying a first preset memory location exchange condition, the second memory page is exchanged to the system memory, and the first memory page is exchanged to the video memory.

[0016] In a possible implementation manner, the first preset memory location exchange condition includes:

[0017] The priority of the first virtual GPU is higher than the priority of the second virtual GPU.

[0018] In a possible implementation manner, the first preset memory location exchange condition further includes:

[0019] The first virtual GPU is a virtual GPU with the highest priority among the virtual GPUs occupying the system memory.

[0020] In a possible implementation manner, the first preset memory location exchange condition further includes:

[0021] The first memory page is a memory page with the highest usage rate among the memory pages of the system memory of the first virtual GPU.

[0022] In a possible implementation manner, the first preset memory location exchange condition further includes:

[0023] The second virtual GPU is a virtual GPU with the lowest priority among the virtual GPUs whose video memory occupancy ratio is greater than or equal to a preset ratio, wherein the video memory occupancy ratio of any virtual GPU represents a ratio of the video memory capacity occupied by the virtual GPU to the total memory capacity occupied by the virtual GPU, and the total memory capacity occupied by the virtual GPU is the sum of the video memory capacity occupied by the virtual GPU and the system memory capacity;

[0024] or,

[0025] The second virtual GPU is a virtual GPU with the lowest priority among the virtual GPUs occupying the video memory.

[0026] In a possible implementation manner, the first preset memory location exchange condition further includes:

[0027] The second memory page is a memory page with the lowest usage rate among the memory pages of the video memory of the second virtual GPU.

[0028] In a possible implementation, in response to the remaining video memory capacity being less than the size of a single memory page, and a first memory page of a first virtual GPU in the system memory and a second memory page of a second virtual GPU in the video memory satisfying a first preset memory location exchange condition, exchanging the second memory page to the system memory, and exchanging the first memory page to the video memory, includes:

[0029] In response to the remaining video memory capacity being less than the size of a single memory page, and a first memory page of the first virtual GPU in the system memory and a second memory page of the second virtual GPU in the video memory satisfying a first preset memory location exchange condition, the second memory page is exchanged to the system memory, and the first memory page is exchanged to the video memory, in response to the virtual machine monitor in the host machine.

[0030] In a possible implementation, the method further includes:

[0031] In response to the remaining video memory capacity being greater than or equal to the size of a single memory page and the third memory page of the third virtual GPU in the system memory satisfying a second preset memory location swap condition, the third memory page is swapped to the video memory.

[0032] In a possible implementation, the second preset memory location exchange condition includes:

[0033] The third virtual GPU is a virtual GPU with the highest priority among the virtual GPUs occupying the system memory.

[0034] In a possible implementation manner, the second preset memory location exchange condition further includes:

[0035] The third memory page is a memory page with the highest usage rate among the memory pages of the system memory of the third virtual GPU.

[0036] In a possible implementation, the second preset memory location exchange condition includes:

[0037] The third memory page is a memory page with the highest usage rate among the memory pages of the system memory of each virtual GPU.

[0038] In a possible implementation, the method further includes:

[0039] Obtaining a super-resolution ratio, wherein the super-resolution ratio indicates a ratio of a maximum capacity of a system memory that can be used by the virtual GPU to a video memory capacity;

[0040] Determining the total capacity of the allocatable system memory according to the super-resolution ratio and the video memory capacity;

[0041] Apply for system memory according to the total capacity of the allocatable system memory.

[0042] In a possible implementation, after obtaining the remaining capacity of the allocatable system memory, the method further includes:

[0043] In response to the sum of the remaining video memory capacity and the remaining allocatable system memory capacity being less than the target memory capacity, a message indicating that the virtual GPU creation fails is returned.

[0044] According to one aspect of the present disclosure, a memory allocation device is provided, comprising:

[0045] A first acquisition module, configured to acquire, in response to a virtual GPU creation request, at least one of a remaining video memory capacity and an allocatable system memory remaining capacity, and a target memory capacity corresponding to the virtual GPU creation request, wherein the allocatable system memory remaining capacity indicates a remaining capacity of a system memory that is allowed to be allocated to the virtual GPU;

[0046] A memory allocation module is used to create a virtual GPU in response to the sum of the remaining video memory capacity and the remaining allocatable system memory capacity being greater than or equal to the target memory capacity, and to allocate memory to the virtual GPU from the video memory and / or the system memory according to the target memory capacity.

[0047] In one possible implementation,

[0048] The first acquisition module is used to: in response to a virtual GPU creation request, acquire the remaining video memory capacity and the target memory capacity corresponding to the virtual GPU creation request; in response to the target memory capacity being greater than the remaining video memory capacity, acquire the remaining capacity of the allocatable system memory;

[0049] The memory allocation module is used to: in response to the sum of the remaining video memory capacity and the remaining allocatable system memory capacity being greater than or equal to the target memory capacity, create a virtual GPU, and allocate memory to the virtual GPU from the video memory and the system memory, or only from the system memory, according to the target memory capacity.

[0050] In one possible implementation,

[0051] The first acquisition module is used to: in response to a virtual GPU creation request, acquire a remaining video memory capacity and a target memory capacity corresponding to the virtual GPU creation request;

[0052] The memory allocation module is used to: in response to the remaining video memory capacity being greater than or equal to the target memory capacity, create a virtual GPU, and allocate memory to the virtual GPU from the video memory according to the target memory capacity.

[0053] In a possible implementation manner, the device further includes:

[0054] The first exchange module is used to exchange the second memory page to the system memory and the first memory page to the video memory in response to the remaining video memory capacity being less than the size of a single memory page and the first memory page of the first virtual GPU in the system memory and the second memory page of the second virtual GPU in the video memory satisfying a first preset memory position exchange condition.

[0055] In a possible implementation manner, the first preset memory location exchange condition includes:

[0056] The priority of the first virtual GPU is higher than the priority of the second virtual GPU.

[0057] In a possible implementation manner, the first preset memory location exchange condition further includes:

[0058] The first virtual GPU is a virtual GPU with the highest priority among the virtual GPUs occupying the system memory.

[0059] In a possible implementation manner, the first preset memory location exchange condition further includes:

[0060] The first memory page is a memory page with the highest usage rate among the memory pages of the system memory of the first virtual GPU.

[0061] In a possible implementation manner, the first preset memory location exchange condition further includes:

[0062] The second virtual GPU is a virtual GPU with the lowest priority among the virtual GPUs whose video memory occupancy ratio is greater than or equal to a preset ratio, wherein the video memory occupancy ratio of any virtual GPU represents a ratio of the video memory capacity occupied by the virtual GPU to the total memory capacity occupied by the virtual GPU, and the total memory capacity occupied by the virtual GPU is the sum of the video memory capacity occupied by the virtual GPU and the system memory capacity;

[0063] or,

[0064] The second virtual GPU is a virtual GPU with the lowest priority among the virtual GPUs occupying the video memory.

[0065] In a possible implementation manner, the first preset memory location exchange condition further includes:

[0066] The second memory page is a memory page with the lowest usage rate among the memory pages of the video memory of the second virtual GPU.

[0067] In a possible implementation manner, the first switching module is used to:

[0068] In response to the remaining video memory capacity being less than the size of a single memory page, and a first memory page of the first virtual GPU in the system memory and a second memory page of the second virtual GPU in the video memory satisfying a first preset memory location exchange condition, the second memory page is exchanged to the system memory, and the first memory page is exchanged to the video memory, in response to the virtual machine monitor in the host machine.

[0069] In a possible implementation manner, the device further includes:

[0070] The second exchange module is used to exchange the third memory page to the video memory in response to the remaining video memory capacity being greater than or equal to the size of a single memory page and the third memory page of the third virtual GPU in the system memory meeting the second preset memory location exchange condition.

[0071] In a possible implementation, the second preset memory location exchange condition includes:

[0072] The third virtual GPU is a virtual GPU with the highest priority among the virtual GPUs occupying the system memory.

[0073] In a possible implementation manner, the second preset memory location exchange condition further includes:

[0074] The third memory page is a memory page with the highest usage rate among the memory pages of the system memory of the third virtual GPU.

[0075] In a possible implementation, the second preset memory location exchange condition includes:

[0076] The third memory page is a memory page with the highest usage rate among the memory pages of the system memory of each virtual GPU.

[0077] In a possible implementation, the information further includes:

[0078] A second acquisition module is used to acquire a super-resolution ratio, wherein the super-resolution ratio indicates a ratio of a maximum capacity of a system memory that can be used by a virtual GPU to a video memory capacity;

[0079] A determination module, used to determine the total capacity of the allocatable system memory according to the super-resolution ratio and the video memory capacity;

[0080] The application module is used to apply for system memory according to the total capacity of the allocatable system memory.

[0081] In a possible implementation manner, the device further includes:

[0082] The return module is used to return a message indicating that the virtual GPU creation fails in response to the sum of the remaining video memory capacity and the remaining allocatable system memory capacity being less than the target memory capacity.

[0083] According to one aspect of the present disclosure, an electronic device is provided, comprising: one or more processors; a memory for storing executable instructions; wherein the one or more processors are configured to call the executable instructions stored in the memory to execute the above method.

[0084] According to one aspect of the present disclosure, a computer-readable storage medium is provided, on which computer program instructions are stored, and when the computer program instructions are executed by a processor, the above method is implemented.

[0085] According to one aspect of the present disclosure, a computer program product is provided, including a computer-readable code, or a non-volatile computer-readable storage medium carrying the computer-readable code. When the computer-readable code runs in an electronic device, a processor in the electronic device executes the above method.

[0086] In an embodiment of the present disclosure, by responding to a virtual GPU creation request, at least one of the remaining video memory capacity and the remaining allocatable system memory capacity, and the target memory capacity corresponding to the virtual GPU creation request are obtained, wherein the remaining allocatable system memory capacity represents the remaining capacity of the system memory allowed to be allocated to the virtual GPU, in response to the sum of the remaining video memory capacity and the remaining allocatable system memory capacity being greater than or equal to the target memory capacity, a virtual GPU is created, and according to the target memory capacity, memory is allocated to the virtual GPU from the video memory and / or the system memory, thereby implementing memory super-allocation of the virtual GPU based on the system memory, that is, not only allocating virtual video memory from the video memory to the virtual GPU, but also allowing allocation of virtual video memory from the system memory to the virtual GPU, thereby making full use of hardware resources, creating more virtual GPU instances under the same hardware conditions, improving resource utilization, and reducing total cost of ownership.

[0087] It is to be understood that both the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the disclosure.

[0088] Further features and aspects of the present disclosure will become apparent from the following detailed description of exemplary embodiments with reference to the attached drawings. BRIEF DESCRIPTION OF THE DRAWINGS

[0089] The drawings herein are incorporated into the specification and constitute a part of the specification. These drawings illustrate embodiments consistent with the present disclosure and are used to illustrate the technical solutions of the present disclosure together with the specification.

[0090] Figure 1 Schematic diagram showing GPU access to video memory and system memory.

[0091] Figure 2 A schematic diagram showing a memory allocation scheme for a virtual GPU in the related art.

[0092] Figure 3 A flowchart of a memory allocation method provided by an embodiment of the present disclosure is shown.

[0093] Figure 4 A schematic diagram of a memory allocation method provided by an embodiment of the present disclosure is shown.

[0094] Figure 5 Another schematic diagram of the memory allocation method provided by an embodiment of the present disclosure is shown.

[0095] Figure 6 Another schematic diagram of the memory allocation method provided by an embodiment of the present disclosure is shown.

[0096] Figure 7 A block diagram of a memory allocation device provided by an embodiment of the present disclosure is shown.

[0097] Figure 8 A block diagram of an electronic device 1900 provided by an embodiment of the present disclosure is shown. DETAILED DESCRIPTION

[0098] Various exemplary embodiments, features and aspects of the present disclosure will be described in detail below with reference to the accompanying drawings. The same reference numerals in the accompanying drawings represent elements with the same or similar functions. Although various aspects of the embodiments are shown in the accompanying drawings, the drawings are not necessarily drawn to scale unless otherwise specified.

[0099] The word “exemplary” is used exclusively herein to mean “serving as an example, example, or illustration.” Any embodiment described herein as “exemplary” is not necessarily to be construed as preferred or advantageous over other embodiments.

[0100] The term "and / or" herein is only a description of the association relationship of the associated objects, indicating that there may be three relationships. For example, A and / or B can represent: A exists alone, A and B exist at the same time, and B exists alone. In addition, the term "at least one" herein represents any combination of at least two of any one or more of a plurality of. For example, including at least one of A, B, and C can represent including any one or more elements selected from the set consisting of A, B, and C.

[0101] In addition, in order to better illustrate the present disclosure, numerous specific details are given in the following specific embodiments. It should be understood by those skilled in the art that the present disclosure can also be implemented without certain specific details. In some examples, methods, means, components and circuits well known to those skilled in the art are not described in detail in order to highlight the subject matter of the present disclosure.

[0102] The graphics card has GPU-specific memory (i.e., video memory). In addition, the GPU can also access the memory on the CPU side (i.e., system memory). For the GPU, accessing video memory has a smaller latency and a larger bandwidth, so the GPU usually gives priority to using video memory. However, the size of video memory is limited. When the video memory is insufficient, the GPU will access the system memory to obtain a larger storage space. Figure 1 Figure 2 shows a schematic diagram of GPU accessing video memory and system memory. Figure 1As shown in the figure, the GPU can access both video memory and system memory. Since accessing system memory requires passing through the PCIe (Peripheral Component Interconnect express) bus, its performance is lower than that of video memory. However, in a virtualized scenario, system memory is often larger than video memory and its cost is lower than that of video memory.

[0103] In the related art, the computing resources of a virtual GPU (ie, vGPU) are shared, while the storage resources are exclusive. If the remaining video memory capacity is insufficient, a virtual GPU cannot be created. Figure 2 FIG. 1 is a schematic diagram showing a memory allocation scheme of a virtual GPU in the related art. Figure 2 As shown, in the related art, virtual video memory is allocated to a virtual GPU (vGPU) only from the video memory of the GPU.

[0104] The disclosed embodiment provides a memory allocation method, which obtains at least one of the remaining video memory capacity and the remaining system memory capacity that can be allocated, and the target memory capacity corresponding to the virtual GPU creation request in response to a virtual GPU creation request, wherein the remaining system memory capacity that can be allocated represents the remaining system memory capacity that is allowed to be allocated to the virtual GPU, and in response to the sum of the remaining video memory capacity and the remaining system memory capacity that can be allocated being greater than or equal to the target memory capacity, creates a virtual GPU, and allocates memory to the virtual GPU from the video memory and / or the system memory according to the target memory capacity, thereby implementing memory super-allocation of the virtual GPU based on the system memory, that is, not only allocating virtual video memory from the video memory to the virtual GPU, but also allowing allocation of virtual video memory from the system memory to the virtual GPU, so that hardware resources can be fully utilized, more virtual GPU instances can be created under the same hardware conditions, resource utilization can be improved, and total cost of ownership (TCO) can be reduced.

[0105] The memory allocation method provided by the embodiment of the present disclosure is described in detail below with reference to the accompanying drawings.

[0106] Figure 3A flowchart of a memory allocation method provided by an embodiment of the present disclosure is shown. In one possible implementation, the execution subject of the memory allocation method may be a memory allocation device. For example, the memory allocation method may be executed by a terminal device or a server or other electronic device. The terminal device may be a user equipment (UE), a mobile device, a user terminal, a terminal, a cellular phone, a cordless phone, a personal digital assistant (PDA), a handheld device, a computing device, a vehicle-mounted device or a wearable device, etc. In some possible implementations, the memory allocation method may be implemented by a processor calling computer-readable instructions stored in a memory. For example Figure 3 As shown, the memory allocation method includes steps S31 to S32.

[0107] In step S31, in response to a virtual GPU creation request, at least one of the remaining video memory capacity and the remaining allocatable system memory capacity, as well as the target memory capacity corresponding to the virtual GPU creation request, is obtained, wherein the remaining allocatable system memory capacity represents the remaining capacity of the system memory allowed to be allocated to the virtual GPU.

[0108] In step S32, in response to the sum of the remaining video memory capacity and the allocatable system memory remaining capacity being greater than or equal to the target memory capacity, a virtual GPU is created, and memory is allocated to the virtual GPU from the video memory and / or the system memory according to the target memory capacity.

[0109] In the embodiment of the present disclosure, memory may be allocated to the virtual GPU from the video memory and the system memory to be used as the virtual video memory of the virtual GPU. Figure 4 A schematic diagram of a memory allocation method provided by an embodiment of the present disclosure is shown. Figure 4 As shown, memory can be allocated to the virtual GPU from video memory and system memory.

[0110] For a single virtual GPU, the physical memory corresponding to its virtual video memory may be all video memory, or may be video memory and system memory, or may be all system memory. The types of physical memory corresponding to the virtual video memory of different virtual GPUs may be the same or different.

[0111] In a possible implementation, the physical memory corresponding to the virtual video memory of a part of virtual GPUs is only the video memory, and the physical memory corresponding to the virtual video memory of another part of virtual GPUs is the video memory and the system memory.

[0112] In another possible implementation, the physical memory corresponding to the virtual video memory of some virtual GPUs is only the video memory, the physical memory corresponding to the virtual video memory of some virtual GPUs is both the video memory and the system memory, and the physical memory corresponding to the virtual video memory of another part of the virtual GPUs is only the system memory.

[0113] In another possible implementation, when the video memory is sufficient, the physical memory corresponding to the virtual video memory of each virtual GPU may all be the video memory.

[0114] In a possible implementation, the memory allocation method may be executed by a host. In this implementation, the client may not distinguish between two types of virtual video memory (i.e., virtual video memory allocated from video memory and virtual video memory allocated from system memory), and the mapping relationship between the virtual video memory of the virtual GPU and the physical memory may be completed by the host. For example, the mapping relationship between the virtual video memory of the virtual GPU and the physical memory may be recorded by the host's driver, and the client's driver may not distinguish between the two types of virtual video memory. Among them, the physical memory includes video memory and system memory. In one example, the memory allocation method may be executed by a virtual machine monitor in the host. In some application scenarios, the virtual machine monitor (Hypervisor) may also be referred to as a virtual machine manager, a virtual machine monitor (Virtual Machine Monitor, VMM), etc., which are not limited here.

[0115] In one possible implementation, the method further includes: obtaining a super-resolution ratio, wherein the super-resolution ratio indicates the ratio of the maximum capacity of system memory that can be used by the virtual GPU to the video memory capacity; determining the total capacity of allocatable system memory based on the super-resolution ratio and the video memory capacity; and applying for system memory based on the total capacity of allocatable system memory.

[0116] In this implementation, the super-resolution ratio can be obtained, wherein the super-resolution ratio can represent the ratio of the maximum capacity of the system memory that can be used by the virtual GPU to the video memory capacity, that is, the super-resolution ratio can represent the ratio between the system memory capacity allowed to be allocated to the virtual GPU and the video memory capacity. The total capacity of the allocable system memory can be obtained by multiplying the video memory capacity by the super-resolution ratio. Among them, the total capacity of the allocable system memory can represent the total capacity of the system memory allowed to be allocated to the virtual GPU. After determining the total capacity of the allocable system memory, the system memory can be applied for.

[0117] As an example of this implementation, the super-resolution ratio can be flexibly set by the user according to the requirements of the actual application scenario.

[0118] As another example of this implementation, the super-resolution ratio may be a default value.

[0119] As an example of this implementation, the host machine driver can determine the total allocatable system memory capacity according to the super-resolution ratio and the video memory capacity, and can apply for system memory according to the total allocatable system memory capacity.

[0120] In the implementation method, by obtaining the super-resolution ratio, where the super-resolution ratio represents the ratio of the maximum capacity of the system memory that can be used by the virtual GPU to the video memory capacity, the total allocatable system memory capacity is determined according to the super-resolution ratio and the video memory capacity, and the system memory is applied for according to the total allocatable system memory capacity. This is conducive to applying for continuous system memory, thereby facilitating the allocation of continuous system memory to the virtual GPU, which in turn helps to improve the performance of the virtual GPU and improve the utilization of the system memory.

[0121] In another possible implementation, the method further includes: obtaining the total capacity of allocatable system memory; and applying for system memory according to the total capacity of allocatable system memory. In this implementation, the user can directly set the total capacity of allocatable system memory.

[0122] In an embodiment of the present disclosure, at least one of remaining video memory capacity and remaining allocatable system memory capacity, and a target memory capacity corresponding to the virtual GPU creation request may be obtained in response to a virtual GPU creation request.

[0123] The remaining video memory capacity may represent the remaining capacity of the video memory that can be allocated to the virtual GPU.

[0124] The allocatable system memory remaining capacity indicates the remaining capacity of the system memory allowed to be allocated to the virtual GPU. In a possible implementation, the allocatable system memory remaining capacity can be determined based on the total allocatable system memory capacity and the system content capacity allocated to the virtual GPU.

[0125] The target memory capacity corresponding to the virtual GPU creation request may represent the memory capacity to be allocated to the virtual GPU corresponding to the virtual GPU creation request. In one possible implementation, the virtual GPU creation request may carry the target memory capacity. In another possible implementation, the target memory capacity may be a preset value.

[0126] In one possible implementation, in response to a virtual GPU creation request, the remaining video memory capacity and the target memory capacity corresponding to the virtual GPU creation request can be obtained, and in response to the target memory capacity being greater than the remaining video memory capacity, the remaining allocatable system memory capacity can be obtained.

[0127] In another possible implementation, the remaining video memory capacity, the remaining allocatable system memory capacity, and the target memory capacity corresponding to the virtual GPU creation request may be obtained in response to the virtual GPU creation request. In this implementation, the remaining video memory capacity and the remaining allocatable system memory capacity may be obtained in response to the virtual GPU creation request.

[0128] In one possible implementation, the step of obtaining, in response to a virtual GPU creation request, at least one of a remaining video memory capacity and an allocatable system memory remaining capacity, and a target memory capacity corresponding to the virtual GPU creation request, includes: obtaining, in response to a virtual GPU creation request, a remaining video memory capacity and a target memory capacity corresponding to the virtual GPU creation request; and in response to the sum of the remaining video memory capacity and the allocatable system memory remaining capacity being greater than or equal to the target memory capacity, creating a virtual GPU, and allocating memory to the virtual GPU from a video memory and / or the system memory according to the target memory capacity, includes: in response to the remaining video memory capacity being greater than or equal to the target memory capacity, creating a virtual GPU, and allocating memory to the virtual GPU from a video memory according to the target memory capacity.

[0129] In this implementation, in response to a virtual GPU creation request, the remaining video memory capacity and the target memory capacity corresponding to the virtual GPU creation request can be obtained. In the case where the remaining video memory capacity is greater than or equal to the target memory capacity, it is not necessary to obtain the remaining capacity of the allocatable system memory, and a virtual GPU can be created according to the virtual GPU creation request, and memory is allocated to the virtual GPU from the video memory according to the target memory capacity. Since the remaining capacity of the allocatable system memory is greater than or equal to 0, in the case where the remaining video memory capacity is greater than or equal to the target memory capacity, it can be determined that the sum of the remaining video memory capacity and the remaining capacity of the allocatable system memory is greater than or equal to the target memory capacity based only on the remaining video memory capacity.

[0130] Figure 5 Another schematic diagram of the memory allocation method provided by the embodiment of the present disclosure is shown. Figure 5 As shown, when the video memory is sufficient, the video memory can be allocated to the virtual GPU first.

[0131] In this implementation, by responding to a virtual GPU creation request, obtaining the remaining video memory capacity and the target memory capacity corresponding to the virtual GPU creation request, creating a virtual GPU in response to the remaining video memory capacity being greater than or equal to the target memory capacity, and allocating memory to the virtual GPU from the video memory according to the target memory capacity. In this way, when there is sufficient video memory, video memory can be allocated to the virtual GPU on a priority basis, thereby enabling the virtual GPU to obtain better performance.

[0132] In a possible implementation, the step of obtaining, in response to a virtual GPU creation request, at least one of a remaining video memory capacity and an allocatable system memory remaining capacity, and a target memory capacity corresponding to the virtual GPU creation request, includes: obtaining, in response to a virtual GPU creation request, the remaining video memory capacity and the target memory capacity corresponding to the virtual GPU creation request; obtaining, in response to the target memory capacity being greater than the remaining video memory capacity, the allocatable system memory remaining capacity; creating a virtual GPU in response to the sum of the remaining video memory capacity and the allocatable system memory remaining capacity being greater than or equal to the target memory capacity, and allocating memory to the virtual GPU from video memory and / or the system memory according to the target memory capacity, includes: creating a virtual GPU in response to the sum of the remaining video memory capacity and the allocatable system memory remaining capacity being greater than or equal to the target memory capacity, and allocating memory to the virtual GPU from video memory and the system memory, or only from the system memory, according to the target memory capacity.

[0133] In this implementation, in response to a virtual GPU creation request, the remaining video memory capacity and the target memory capacity corresponding to the virtual GPU creation request can be obtained. When the remaining video memory capacity is less than the target memory capacity, the remaining capacity of the allocatable system memory can be obtained. When the sum of the remaining video memory capacity and the remaining capacity of the allocatable system memory is greater than or equal to the target memory capacity, a virtual GPU is created, and according to the target memory capacity, memory is allocated to the virtual GPU from the video memory and the system memory, or only from the system memory. Wherein, when the remaining video memory capacity is not 0, memory can be allocated to the virtual GPU from the video memory and the system memory according to the target memory capacity; when the remaining video memory capacity is 0, memory can be allocated to the virtual GPU only from the system memory according to the target memory capacity.

[0134] In this implementation, by responding to a virtual GPU creation request, obtaining the remaining video memory capacity and the target memory capacity corresponding to the virtual GPU creation request, in response to the target memory capacity being greater than the remaining video memory capacity, obtaining the allocatable system memory remaining capacity, in response to the sum of the remaining video memory capacity and the allocatable system memory remaining capacity being greater than or equal to the target memory capacity, creating a virtual GPU, and according to the target memory capacity, allocating memory to the virtual GPU from the video memory and the system memory, or only from the system memory, thereby enabling the creation of more virtual GPU instances under the same video memory resource conditions.

[0135] In a possible implementation, after obtaining the remaining capacity of the allocatable system memory, the method further includes: in response to the sum of the remaining video memory capacity and the remaining capacity of the allocatable system memory being less than the target memory capacity, returning a message indicating that the virtual GPU creation failed.

[0136] In this implementation, when the sum of the remaining video memory capacity and the remaining allocatable system memory capacity is less than the target memory capacity, a message indicating that the virtual GPU creation failed may be returned to prompt the user that the virtual GPU cannot be created temporarily.

[0137] As an example of this implementation, the message of the virtual GPU creation failure may carry information that the remaining video memory capacity and the remaining capacity of the allocatable system memory are insufficient.

[0138] In one possible implementation, the method further includes: in response to the remaining video memory capacity being less than the size of a single memory page, and the first memory page of the first virtual GPU in the system memory and the second memory page of the second virtual GPU in the video memory satisfying a first preset memory location exchange condition, exchanging the second memory page to the system memory, and exchanging the first memory page to the video memory.

[0139] In this implementation, the first memory page is a memory page of the first virtual GPU in the system memory, and the second memory page is a memory page of the second virtual GPU in the video memory.

[0140] In scenarios such as virtualization and cloud computing, maximizing resource utilization is one of the core goals. In related technologies, since video memory is exclusive, resource utilization is low. For example, according to the solution in related technologies, after vGPU a applies for memory from the video memory when it is created, it does not use all the requested video memory because the load is not large. This part of the video memory that vGPU a does not use is also occupied by vGPU a, resulting in the inability to use this part of the video memory when vGPU b is created. In this way, even if vGPU b has a higher load, its computing performance will be affected due to insufficient video memory resources.

[0141] In this implementation, in response to the remaining video memory capacity being less than the size of a single memory page, and the first memory page of the first virtual GPU in the system memory and the second memory page of the second virtual GPU in the video memory satisfying a first preset memory position exchange condition, the second memory page is exchanged to the system memory, and the first memory page is exchanged to the video memory. In this way, when the remaining video memory capacity is insufficient, the position of the memory page of the virtual GPU can be dynamically adjusted, thereby improving the flexibility of virtual video memory allocation of the virtual GPU and improving the utilization of video memory resources.

[0142] As an example of this implementation method, in response to the remaining video memory capacity being less than the size of a single memory page, and the first memory page of the first virtual GPU in the system memory and the second memory page of the second virtual GPU in the video memory satisfying a first preset memory location exchange condition, the second memory page is exchanged to the system memory, and the first memory page is exchanged to the video memory, including: through a virtual machine monitor in a host machine, in response to the remaining video memory capacity being less than the size of a single memory page, and the first memory page of the first virtual GPU in the system memory and the second memory page of the second virtual GPU in the video memory satisfying the first preset memory location exchange condition, the second memory page is exchanged to the system memory, and the first memory page is exchanged to the video memory.

[0143] In this example, in response to the remaining video memory capacity being less than the size of a single memory page, and the first memory page of the first virtual GPU in the system memory and the second memory page of the second virtual GPU in the video memory satisfying the first preset memory position exchange condition, the second memory page is exchanged to the system memory, and the first memory page is exchanged to the video memory, thereby dynamically adjusting the position of the memory page of the virtual GPU by the virtual machine monitor in the host machine, and the client is unaware, thereby reducing the adaptation cost between different guest operating systems (Guest OS). The guest operating system may refer to an operating system installed on the client.

[0144] As an example of this implementation, the first preset memory location exchange condition includes: a priority of the first virtual GPU is higher than a priority of the second virtual GPU.

[0145] In this example, by exchanging the locations of the memory pages of the virtual GPUs based on the priorities of the virtual GPUs, a virtual GPU with a lower priority is more inclined to use the system memory, and a virtual GPU with a higher priority is more inclined to use the video memory. Figure 6 Another schematic diagram of the memory allocation method provided by the embodiment of the present disclosure is shown. Figure 6 As shown in FIG. 1 , a virtual GPU with a higher priority is more inclined to use video memory than a virtual GPU with a lower priority; and a virtual GPU with a lower priority is more inclined to use system memory than a virtual GPU with a higher priority.

[0146] In this example, when video memory is insufficient, the memory pages of the virtual GPU with a lower priority can be swapped into the system memory, and the memory pages of the virtual GPU with a higher priority can be swapped into the video memory, thereby improving the performance of the virtual GPU with a higher priority and helping to improve the utilization of the video memory.

[0147] In one example, the first preset memory location exchange condition further includes: the first virtual GPU is a virtual GPU with the highest priority among the virtual GPUs occupying the system memory. In this example, when the video memory is insufficient, the performance of the virtual GPU with the highest priority can be guaranteed first.

[0148] In another example, the first virtual GPU may be any virtual GPU that occupies the system memory and has a higher priority than the second virtual GPU.

[0149] In an example, the first preset memory location exchange condition further includes: the first memory page is a memory page with the highest usage rate among the memory pages of the first virtual GPU in the system memory.

[0150] The usage rate may be determined by using an LRU (Least Recently Used) algorithm, an LFU (Least Frequently Used) algorithm, etc., which is not limited here.

[0151] In this example, by swapping the location of the virtual GPU's memory pages based on usage, the location of the virtual GPU's memory pages is dynamically adjusted according to the virtual GPU's load, which helps to swap memory pages with higher usage rates into the video memory, thereby improving the utilization of the video memory and improving the overall performance of the virtual GPU.

[0152] In one example, the first preset memory location exchange condition also includes: the second virtual GPU is the virtual GPU with the lowest priority among the virtual GPUs whose video memory occupancy ratio is greater than or equal to the preset ratio, wherein the video memory occupancy ratio of any virtual GPU represents the ratio of the video memory capacity occupied by the virtual GPU to the total memory capacity occupied by the virtual GPU, and the total memory capacity occupied by the virtual GPU is the sum of the video memory capacity occupied by the virtual GPU and the system memory capacity; or, the second virtual GPU is the virtual GPU with the lowest priority among the virtual GPUs occupying the video memory.

[0153] In an example, the second virtual GPU may be a virtual GPU with the lowest priority among the virtual GPUs whose video memory occupancy ratio is greater than or equal to a preset ratio.

[0154] For example, the preset ratios corresponding to the various virtual GPUs may be the same, such as 10% or 20%, etc., which are not limited here.

[0155] For another example, the preset ratios corresponding to virtual GPUs of the same priority may be the same, and the preset ratio corresponding to a virtual GPU of a higher priority may be higher than the preset ratio corresponding to a virtual GPU of a lower priority.

[0156] In another example, the second virtual GPU is a virtual GPU with the lowest priority among the virtual GPUs occupying the video memory. In this example, the video memory occupation ratio of the virtual GPU may not be considered.

[0157] In this example, when video memory is insufficient, the memory pages of the virtual GPU with a lower priority can be swapped into the system memory, and the memory pages of the virtual GPU with a higher priority can be swapped into the video memory, thereby improving the performance of the virtual GPU with a higher priority and helping to improve the utilization of the video memory.

[0158] In one example, the first preset memory location exchange condition further includes: the second memory page is a memory page with the lowest usage rate among the memory pages of the video memory of the second virtual GPU. By exchanging the memory page with the lowest usage rate among the memory pages of the video memory of the second virtual GPU to the system memory, the performance of the first virtual GPU can be improved without almost reducing the performance of the second virtual GPU.

[0159] In an example, the first preset memory location exchange condition may be: the first virtual GPU is the virtual GPU with the highest priority among the virtual GPUs occupying the system memory; the second virtual GPU is the virtual GPU with the lowest priority among the virtual GPUs whose video memory occupancy ratio is greater than or equal to the preset ratio; the first memory page is the memory page with the highest utilization rate among the memory pages of the first virtual GPU in the system memory; the second memory page is the memory page with the lowest utilization rate among the memory pages of the second virtual GPU in the video memory.

[0160] As another example of this implementation, the first preset memory location exchange condition includes: the first memory page is the memory page with the highest usage rate among the memory pages of the system memory of each virtual GPU, and the second memory page is the memory page with the lowest usage rate among the memory pages of the video memory of each virtual GPU. By adopting this example, a virtual GPU with a lower load can be more inclined to use the system memory, and a virtual GPU with a lower load can be more inclined to use the video memory. In this example, the priority of the virtual GPU may not be considered, that is, the priority of the virtual GPU may not be set.

[0161] As another example of this implementation, the first preset memory location exchange condition includes: the first memory page is the memory page with the highest weight among the memory pages of the system memory for each virtual GPU, and the second memory page is the memory page with the lowest weight among the memory pages of the video memory for each virtual GPU. In this example, the weight of any memory page can be determined based on the priority of the virtual GPU corresponding to the memory page and the usage rate of the memory page. The weight of the memory page is positively correlated with the priority of the virtual GPU corresponding to the memory page, and the weight of the memory page is positively correlated with the usage rate of the memory page. That is, the higher the priority of the virtual GPU corresponding to the memory page, the higher the weight of the memory page; the higher the usage rate of the memory page, the higher the weight of the memory page.

[0162] In one possible implementation, the method further includes: in response to the remaining video memory capacity being greater than or equal to the size of a single memory page, and the third memory page of the third virtual GPU in the system memory meets the second preset memory location swap condition, swapping the third memory page to the video memory.

[0163] In this implementation, when some virtual GPU instances are destroyed, the remaining video memory capacity may be greater than or equal to the size of a single memory page. In response to the remaining video memory capacity being greater than or equal to the size of a single memory page and the third memory page of the third virtual GPU in the system memory meeting the second preset memory location swap condition, the third memory page is swapped to the video memory, thereby improving the performance of the third virtual GPU and the utilization of the video memory.

[0164] As an example of this implementation, the second preset memory location exchange condition includes: the third virtual GPU is a virtual GPU with the highest priority among the virtual GPUs occupying the system memory.

[0165] In this example, when the video memory is free, the memory page of the virtual GPU with the highest priority among the virtual GPUs occupying the system memory may be swapped to the video memory, thereby preferentially ensuring the performance of the virtual GPU with the highest priority.

[0166] In one example, the second preset memory location exchange condition also includes: the third memory page is the memory page with the highest usage rate among the memory pages of the third virtual GPU in the system memory. In this example, by exchanging the location of the virtual GPU's memory page based on the usage rate, the location of the virtual GPU's memory page is dynamically adjusted according to the load of the virtual GPU, which helps to exchange the memory page with higher usage rate to the video memory, thereby improving the utilization rate of the video memory and improving the performance of the virtual GPU as a whole.

[0167] In an example, the second preset memory location exchange condition may be: the third virtual GPU is the virtual GPU with the highest priority among the virtual GPUs occupying the system memory, and the third memory page is the memory page with the highest usage rate among the memory pages of the system memory of the third virtual GPU.

[0168] As an example of this implementation, the second preset memory location exchange condition includes: the third memory page is the memory page with the highest usage rate among the memory pages of the system memory of each virtual GPU. By adopting this example, a virtual GPU with a lower load can be more inclined to use the system memory, and a virtual GPU with a lower load can be more inclined to use the video memory. In this example, the priority of the virtual GPU may not be considered, that is, the priority of the virtual GPU may not be set.

[0169] The memory allocation method provided in the embodiments of the present disclosure can be applied to technical fields such as GPU, vGPU, virtualization, and super-resolution, and is not limited here.

[0170] The memory allocation method provided by the embodiment of the present disclosure is described below through a specific application scenario. In this application scenario, the memory allocation method can be executed by a virtual machine monitoring program in a host machine (Host).

[0171] In this application scenario, users can set the super-resolution ratio. The host can determine the total allocatable system memory capacity based on the super-resolution ratio and video memory capacity, and can apply for system memory based on the total allocatable system memory capacity.

[0172] The host machine may, in response to a virtual GPU creation request, obtain the remaining video memory capacity and the target memory capacity corresponding to the virtual GPU creation request. In response to the remaining video memory capacity being greater than or equal to the target memory capacity, the host machine may create a virtual GPU, and allocate memory to the virtual GPU from the video memory according to the target memory capacity; in response to the target memory capacity being greater than the remaining video memory capacity, the host machine may obtain the remaining allocatable system memory capacity, and in response to the sum of the remaining video memory capacity and the remaining allocatable system memory capacity being greater than or equal to the target memory capacity, create a virtual GPU, and allocate memory to the virtual GPU from the video memory and the system memory, or only from the system memory according to the target memory capacity; in response to the sum of the remaining video memory capacity and the remaining allocatable system memory capacity being less than the target memory capacity, the host machine may return a message indicating that the virtual GPU creation failed.

[0173] In response to the remaining video memory capacity being less than the size of a single memory page, and the first memory page of the first virtual GPU in the system memory and the second memory page of the second virtual GPU in the video memory satisfying the first preset memory position exchange condition, the host machine may exchange the second memory page to the system memory, and exchange the first memory page to the video memory. The first preset memory position exchange condition may be: the first virtual GPU is the virtual GPU with the highest priority among the virtual GPUs occupying the system memory; the second virtual GPU is the virtual GPU with the lowest priority among the virtual GPUs whose video memory occupancy ratio is greater than or equal to the preset ratio; the first memory page is the memory page with the highest utilization rate among the memory pages of the first virtual GPU in the system memory; the second memory page is the memory page with the lowest utilization rate among the memory pages of the second virtual GPU in the video memory.

[0174] It can be understood that the above-mentioned various method embodiments mentioned in the present disclosure can be combined with each other to form a combined embodiment without violating the principle logic. Due to space limitations, the present disclosure will not repeat them. It can be understood by those skilled in the art that in the above-mentioned method of the specific implementation method, the specific execution order of each step should be determined according to its function and possible internal logic.

[0175] In addition, the present disclosure also provides a memory allocation device, an electronic device, a computer-readable storage medium, and a computer program product, all of which can be used to implement any memory allocation method provided by the present disclosure. The corresponding technical solutions and technical effects can be found in the corresponding records in the method part and will not be repeated here.

[0176] Figure 7 FIG. 1 is a block diagram of a memory allocation device provided by an embodiment of the present disclosure. Figure 7 As shown, the memory allocation device includes:

[0177] A first acquisition module 71 is used to obtain, in response to a virtual GPU creation request, at least one of a remaining video memory capacity and an allocatable system memory remaining capacity, and a target memory capacity corresponding to the virtual GPU creation request, wherein the allocatable system memory remaining capacity indicates a remaining capacity of a system memory that is allowed to be allocated to the virtual GPU;

[0178] The memory allocation module 72 is used to create a virtual GPU in response to the sum of the remaining video memory capacity and the allocatable system memory remaining capacity being greater than or equal to the target memory capacity, and allocate memory to the virtual GPU from the video memory and / or the system memory according to the target memory capacity.

[0179] In one possible implementation,

[0180] The first acquisition module 71 is used to: in response to a virtual GPU creation request, acquire the remaining video memory capacity and the target memory capacity corresponding to the virtual GPU creation request; in response to the target memory capacity being greater than the remaining video memory capacity, acquire the remaining capacity of the allocatable system memory;

[0181] The memory allocation module 72 is used to: in response to the sum of the remaining video memory capacity and the remaining allocatable system memory capacity being greater than or equal to the target memory capacity, create a virtual GPU, and allocate memory to the virtual GPU from the video memory and the system memory, or only from the system memory, according to the target memory capacity.

[0182] In one possible implementation,

[0183] The first acquisition module 71 is used to: in response to a virtual GPU creation request, acquire a remaining video memory capacity and a target memory capacity corresponding to the virtual GPU creation request;

[0184] The memory allocation module 72 is used to: in response to the remaining video memory capacity being greater than or equal to the target memory capacity, create a virtual GPU, and allocate memory to the virtual GPU from the video memory according to the target memory capacity.

[0185] In a possible implementation manner, the device further includes:

[0186] The first exchange module is used to exchange the second memory page to the system memory and the first memory page to the video memory in response to the remaining video memory capacity being less than the size of a single memory page and the first memory page of the first virtual GPU in the system memory and the second memory page of the second virtual GPU in the video memory satisfying a first preset memory position exchange condition.

[0187] In a possible implementation manner, the first preset memory location exchange condition includes:

[0188] The priority of the first virtual GPU is higher than the priority of the second virtual GPU.

[0189] In a possible implementation manner, the first preset memory location exchange condition further includes:

[0190] The first virtual GPU is a virtual GPU with the highest priority among the virtual GPUs occupying the system memory.

[0191] In a possible implementation manner, the first preset memory location exchange condition further includes:

[0192] The first memory page is a memory page with the highest usage rate among the memory pages of the system memory of the first virtual GPU.

[0193] In a possible implementation manner, the first preset memory location exchange condition further includes:

[0194] The second virtual GPU is a virtual GPU with the lowest priority among the virtual GPUs whose video memory occupancy ratio is greater than or equal to a preset ratio, wherein the video memory occupancy ratio of any virtual GPU represents a ratio of the video memory capacity occupied by the virtual GPU to the total memory capacity occupied by the virtual GPU, and the total memory capacity occupied by the virtual GPU is the sum of the video memory capacity occupied by the virtual GPU and the system memory capacity;

[0195] or,

[0196] The second virtual GPU is a virtual GPU with the lowest priority among the virtual GPUs occupying the video memory.

[0197] In a possible implementation manner, the first preset memory location exchange condition further includes:

[0198] The second memory page is a memory page with the lowest usage rate among the memory pages of the video memory of the second virtual GPU.

[0199] In a possible implementation manner, the first switching module is used to:

[0200] In response to the remaining video memory capacity being less than the size of a single memory page, and a first memory page of the first virtual GPU in the system memory and a second memory page of the second virtual GPU in the video memory satisfying a first preset memory location exchange condition, the second memory page is exchanged to the system memory, and the first memory page is exchanged to the video memory, in response to the virtual machine monitor in the host machine.

[0201] In a possible implementation manner, the device further includes:

[0202] The second exchange module is used to exchange the third memory page to the video memory in response to the remaining video memory capacity being greater than or equal to the size of a single memory page and the third memory page of the third virtual GPU in the system memory meeting the second preset memory location exchange condition.

[0203] In a possible implementation, the second preset memory location exchange condition includes:

[0204] The third virtual GPU is a virtual GPU with the highest priority among the virtual GPUs occupying the system memory.

[0205] In a possible implementation manner, the second preset memory location exchange condition further includes:

[0206] The third memory page is a memory page with the highest usage rate among the memory pages of the system memory of the third virtual GPU.

[0207] In a possible implementation, the second preset memory location exchange condition includes:

[0208] The third memory page is a memory page with the highest usage rate among the memory pages of the system memory of each virtual GPU.

[0209] In a possible implementation, the information further includes:

[0210] A second acquisition module is used to acquire a super-resolution ratio, wherein the super-resolution ratio indicates a ratio of a maximum capacity of a system memory that can be used by a virtual GPU to a video memory capacity;

[0211] A determination module, used to determine the total capacity of the allocatable system memory according to the super-resolution ratio and the video memory capacity;

[0212] The application module is used to apply for system memory according to the total capacity of the allocatable system memory.

[0213] In a possible implementation manner, the device further includes:

[0214] The return module is used to return a message indicating that the virtual GPU creation fails in response to the sum of the remaining video memory capacity and the remaining allocatable system memory capacity being less than the target memory capacity.

[0215] In some embodiments, the functions or modules included in the device provided by the embodiments of the present disclosure can be used to execute the method described in the above method embodiments. Its specific implementation and technical effects can refer to the description of the above method embodiments. For the sake of brevity, they will not be repeated here.

[0216] The present disclosure also provides a computer-readable storage medium having computer program instructions stored thereon, wherein the computer program instructions implement the above method when executed by a processor. The computer-readable storage medium may be a non-volatile computer-readable storage medium, or may be a volatile computer-readable storage medium.

[0217] The embodiment of the present disclosure further provides a computer program, including a computer-readable code. When the computer-readable code is executed in an electronic device, a processor in the electronic device executes the above method.

[0218] The embodiments of the present disclosure also provide a computer program product, including a computer-readable code, or a non-volatile computer-readable storage medium carrying the computer-readable code. When the computer-readable code runs in an electronic device, a processor in the electronic device executes the above method.

[0219] An embodiment of the present disclosure also provides an electronic device, comprising: one or more processors; and a memory for storing executable instructions; wherein the one or more processors are configured to call the executable instructions stored in the memory to execute the above method.

[0220] The electronic device may be provided as a terminal, a server, or a device in other forms.

[0221] Figure 8 1 is a block diagram of an electronic device 1900 provided in an embodiment of the present disclosure. For example, the electronic device 1900 may be provided as a server or a terminal. Figure 8 , the electronic device 1900 includes a processing component 1922, which further includes one or more processors, and a memory resource represented by a memory 1932 for storing instructions executable by the processing component 1922, such as an application. The application stored in the memory 1932 may include one or more modules, each corresponding to a set of instructions. In addition, the processing component 1922 is configured to execute instructions to perform the above method.

[0222] The electronic device 1900 may also include a power supply component 1926 configured to perform power management of the electronic device 1900, a wired or wireless network interface 1950 configured to connect the electronic device 1900 to a network, and an input / output interface 1958 (I / O interface). The electronic device 1900 may operate based on an operating system stored in the memory 1932, such as a Microsoft Server operating system (Windows Server 2003). TM ), a graphical user interface operating system launched by Apple (MacOS X TM ), a multi-user, multi-process computer operating system (Unix TM ), a free and open source Unix-like operating system (Linux TM ), an open source Unix-like operating system (FreeBSD TM ) or similar.

[0223] In an exemplary embodiment, a non-volatile computer-readable storage medium is also provided, such as a memory 1932 including computer program instructions, which can be executed by the processing component 1922 of the electronic device 1900 to perform the above method.

[0224] The present disclosure may be a system, a method and / or a computer program product. The computer program product may include a computer-readable storage medium carrying computer-readable program instructions for causing a processor to implement various aspects of the present disclosure.

[0225] A computer-readable storage medium may be a tangible device that can hold and store instructions used by an instruction execution device. A computer-readable storage medium may be, for example, but not limited to, an electrical storage device, a magnetic storage device, an optical storage device, an electromagnetic storage device, a semiconductor storage device, or any suitable combination of the foregoing. More specific examples of computer-readable storage media (a non-exhaustive list) include: a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), a static random access memory (SRAM), a portable compact disk read-only memory (CD-ROM), a digital versatile disk (DVD), a memory stick, a floppy disk, a mechanical encoding device, such as a punch card or a raised structure in a groove on which instructions are stored, and any suitable combination of the foregoing. As used herein, a computer-readable storage medium is not to be interpreted as a transient signal per se, such as a radio wave or other freely propagating electromagnetic wave, an electromagnetic wave propagating through a waveguide or other transmission medium (e.g., a light pulse through a fiber optic cable), or an electrical signal transmitted through a wire.

[0226] The computer-readable program instructions described herein can be downloaded from a computer-readable storage medium to each computing / processing device, or downloaded to an external computer or external storage device via a network, such as the Internet, a local area network, a wide area network, and / or a wireless network. The network can include copper transmission cables, optical fiber transmissions, wireless transmissions, routers, firewalls, switches, gateway computers, and / or edge servers. The network adapter card or network interface in each computing / processing device receives the computer-readable program instructions from the network and forwards the computer-readable program instructions for storage in the computer-readable storage medium in each computing / processing device.

[0227] The computer program instructions for performing the operation of the present disclosure may be assembly instructions, instruction set architecture (ISA) instructions, machine instructions, machine-related instructions, microcode, firmware instructions, state setting data, or source code or object code written in any combination of one or more programming languages, including object-oriented programming languages, such as Smalltalk, C++, etc., and conventional procedural programming languages, such as "C" language or similar programming languages. Computer-readable program instructions may be executed completely on a user's computer, partially on a user's computer, as an independent software package, partially on a user's computer, partially on a remote computer, or completely on a remote computer or server. In the case of a remote computer, the remote computer may be connected to the user's computer via any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., using an Internet service provider to connect via the Internet). In some embodiments, an electronic circuit, such as a programmable logic circuit, a field programmable gate array (FPGA), or a programmable logic array (PLA), may be customized by utilizing the state information of the computer-readable program instructions, and the electronic circuit may execute the computer-readable program instructions, thereby realizing various aspects of the present disclosure.

[0228] Various aspects of the present disclosure are described herein with reference to the flowcharts and / or block diagrams of the methods, devices (systems) and computer program products according to the embodiments of the present disclosure. It should be understood that each box in the flowchart and / or block diagram and the combination of each box in the flowchart and / or block diagram can be implemented by computer-readable program instructions.

[0229] These computer-readable program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, or other programmable data processing device, thereby producing a machine, so that when these instructions are executed by the processor of the computer or other programmable data processing device, a device that implements the functions / actions specified in one or more boxes in the flowchart and / or block diagram is generated. These computer-readable program instructions can also be stored in a computer-readable storage medium, and these instructions cause the computer, programmable data processing device, and / or other equipment to work in a specific manner, so that the computer-readable medium storing the instructions includes a manufactured product, which includes instructions for implementing various aspects of the functions / actions specified in one or more boxes in the flowchart and / or block diagram.

[0230] Computer-readable program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other device so that a series of operating steps are performed on the computer, other programmable data processing apparatus, or other device to produce a computer-implemented process, thereby causing the instructions executed on the computer, other programmable data processing apparatus, or other device to implement the functions / actions specified in one or more boxes in the flowchart and / or block diagram.

[0231] The flow chart and block diagram in the accompanying drawings show the possible architecture, function and operation of the system, method and computer program product according to multiple embodiments of the present disclosure. In this regard, each square box in the flow chart or block diagram can represent a part of a module, program segment or instruction, and a part of the module, program segment or instruction includes one or more executable instructions for realizing the specified logical function. In some alternative implementations, the function marked in the square box can also occur in a sequence different from that marked in the accompanying drawings. For example, two continuous square boxes can actually be executed substantially in parallel, and they can sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each square box in the block diagram and / or flow chart, and the combination of the square boxes in the block diagram and / or flow chart can be implemented with a dedicated hardware-based system that performs the specified function or action, or can be implemented with a combination of special hardware and computer instructions.

[0232] The computer program product may be implemented in hardware, software or a combination thereof. In one optional embodiment, the computer program product is embodied as a computer storage medium, and in another optional embodiment, the computer program product is embodied as a software product, such as a software development kit (SDK) and the like.

[0233] The above description of various embodiments tends to emphasize the differences between the various embodiments. The same or similar aspects can be referenced to each other, and for the sake of brevity, they will not be repeated herein.

[0234] If the technical solution of the embodiments of the present disclosure involves personal information, the product using the technical solution of the embodiments of the present disclosure has clearly informed the personal information processing rules and obtained the individual's voluntary consent before processing the personal information. If the technical solution of the embodiments of the present disclosure involves sensitive personal information, the product using the technical solution of the embodiments of the present disclosure has obtained the individual's separate consent before processing the sensitive personal information, and at the same time meets the requirement of "explicit consent". For example, at personal information collection devices such as cameras, clear and prominent signs are set to inform that the personal information collection scope has been entered and personal information will be collected. If the individual voluntarily enters the collection scope, it is deemed that he or she agrees to collect his or her personal information; or on the device for processing personal information, when the personal information processing rules are notified by obvious signs / information, the individual's authorization is obtained through pop-up information or by asking the individual to upload his or her personal information; the personal information processing rules may include information such as the personal information processor, the purpose of personal information processing, the processing method, and the type of personal information processed.

[0235] The embodiments of the present disclosure have been described above, and the above description is exemplary, not exhaustive, and is not limited to the disclosed embodiments. Many modifications and changes will be apparent to those of ordinary skill in the art without departing from the scope and spirit of the described embodiments. The selection of terms used herein is intended to best explain the principles of the embodiments, practical applications, or improvements to the technology in the market, or to enable other persons of ordinary skill in the art to understand the embodiments disclosed herein.

Claims

1. A memory allocation method, characterized in that: include: In response to the virtual GPU creation request, obtaining at least one of a remaining video memory capacity and an allocatable system memory remaining capacity, and a target memory capacity corresponding to the virtual GPU creation request, wherein the allocatable system memory remaining capacity indicates a remaining capacity of the system memory allowed to be allocated to the virtual GPU; In response to the sum of the remaining video memory capacity and the allocatable system memory remaining capacity being greater than or equal to the target memory capacity, creating a virtual GPU, and allocating memory to the virtual GPU from the video memory and / or the system memory according to the target memory capacity; According to the remaining video memory capacity, adjust the position of the memory page of the virtual GPU; wherein, adjusting the position of the memory page of the virtual GPU includes: swapping the memory page of the virtual GPU from the system memory to the video memory, or swapping the memory page of the virtual GPU from the video memory to the system memory.

2. The method according to claim 1, characterized in that The step of obtaining, in response to the virtual GPU creation request, at least one of the remaining video memory capacity and the remaining system memory capacity that can be allocated, and the target memory capacity corresponding to the virtual GPU creation request comprises: obtaining, in response to the virtual GPU creation request, the remaining video memory capacity and the target memory capacity corresponding to the virtual GPU creation request; and obtaining, in response to the target memory capacity being greater than the remaining video memory capacity, the remaining system memory capacity that can be allocated; In response to the sum of the remaining video memory capacity and the remaining capacity of the allocatable system memory being greater than or equal to the target memory capacity, creating a virtual GPU, and allocating memory to the virtual GPU from the video memory and / or the system memory according to the target memory capacity, includes: in response to the sum of the remaining video memory capacity and the remaining capacity of the allocatable system memory being greater than or equal to the target memory capacity, creating a virtual GPU, and allocating memory to the virtual GPU from the video memory and the system memory, or only from the system memory, according to the target memory capacity.

3. The method according to claim 1, characterized in that: The step of obtaining, in response to the virtual GPU creation request, at least one of the remaining video memory capacity and the remaining allocatable system memory capacity, and the target memory capacity corresponding to the virtual GPU creation request comprises: obtaining, in response to the virtual GPU creation request, the remaining video memory capacity and the target memory capacity corresponding to the virtual GPU creation request; In response to the sum of the remaining video memory capacity and the remaining capacity of the allocatable system memory being greater than or equal to the target memory capacity, creating a virtual GPU, and allocating memory to the virtual GPU from the video memory and / or the system memory according to the target memory capacity, includes: in response to the remaining video memory capacity being greater than or equal to the target memory capacity, creating a virtual GPU, and allocating memory to the virtual GPU from the video memory according to the target memory capacity.

4. The method according to claim 1, characterized in that: The adjusting the position of the memory page of the virtual GPU according to the remaining video memory capacity includes: In response to the remaining video memory capacity being less than the size of a single memory page, and a first memory page of the first virtual GPU in the system memory and a second memory page of the second virtual GPU in the video memory satisfying a first preset memory location exchange condition, the second memory page is exchanged to the system memory, and the first memory page is exchanged to the video memory.

5. The method according to claim 4, characterized in that The first preset memory location exchange condition includes: The priority of the first virtual GPU is higher than the priority of the second virtual GPU.

6. The method according to claim 5, characterized in that The first preset memory location exchange condition also includes: The first virtual GPU is a virtual GPU with the highest priority among the virtual GPUs occupying the system memory.

7. The method according to claim 5 or 6, characterized in that: The first preset memory location exchange condition also includes: The first memory page is a memory page with the highest usage rate among the memory pages of the system memory of the first virtual GPU.

8. The method according to claim 5, characterized in that The first preset memory location exchange condition also includes: The second virtual GPU is a virtual GPU with the lowest priority among the virtual GPUs whose video memory occupancy ratio is greater than or equal to a preset ratio, wherein the video memory occupancy ratio of any virtual GPU represents a ratio of the video memory capacity occupied by the virtual GPU to the total memory capacity occupied by the virtual GPU, and the total memory capacity occupied by the virtual GPU is the sum of the video memory capacity occupied by the virtual GPU and the system memory capacity; or, The second virtual GPU is a virtual GPU with the lowest priority among the virtual GPUs occupying the video memory.

9. The method according to claim 5 or 8, characterized in that: The first preset memory location exchange condition also includes: The second memory page is a memory page with the lowest usage rate among the memory pages of the video memory of the second virtual GPU.

10. The method according to claim 4, characterized in that In response to the remaining video memory capacity being less than the size of a single memory page, and a first memory page of a first virtual GPU in the system memory and a second memory page of a second virtual GPU in the video memory satisfying a first preset memory position exchange condition, exchanging the second memory page to the system memory, and exchanging the first memory page to the video memory, comprising: In response to the remaining video memory capacity being less than the size of a single memory page, and a first memory page of the first virtual GPU in the system memory and a second memory page of the second virtual GPU in the video memory satisfying a first preset memory location exchange condition, the second memory page is exchanged to the system memory, and the first memory page is exchanged to the video memory, in response to the virtual machine monitor in the host machine.

11. The method according to claim 1, characterized in that: The adjusting the position of the memory page of the virtual GPU according to the remaining video memory capacity includes: In response to the remaining video memory capacity being greater than or equal to the size of a single memory page and the third memory page of the third virtual GPU in the system memory satisfying a second preset memory location swap condition, the third memory page is swapped to the video memory.

12. The method according to claim 11, characterized in that The second preset memory location exchange condition includes: The third virtual GPU is a virtual GPU with the highest priority among the virtual GPUs occupying the system memory.

13. The method according to claim 12, characterized in that The second preset memory location exchange condition also includes: The third memory page is a memory page with the highest usage rate among the memory pages of the system memory of the third virtual GPU.

14. The method according to claim 11, characterized in that The second preset memory location exchange condition includes: The third memory page is a memory page with the highest usage rate among the memory pages of the system memory of each virtual GPU.

15. The method according to claim 1, characterized in that The method further comprises: Obtaining a super-resolution ratio, wherein the super-resolution ratio indicates a ratio of a maximum capacity of a system memory that can be used by the virtual GPU to a video memory capacity; Determining the total capacity of the allocatable system memory according to the super-resolution ratio and the video memory capacity; Apply for system memory according to the total capacity of the allocatable system memory.

16. The method according to claim 1, characterized in that After obtaining the remaining capacity of the allocatable system memory, the method further includes: In response to the sum of the remaining video memory capacity and the remaining allocatable system memory capacity being less than the target memory capacity, a message indicating that the virtual GPU creation fails is returned.

17. A memory allocation device, characterized in that: include: A first acquisition module, configured to acquire, in response to a virtual GPU creation request, at least one of a remaining video memory capacity and an allocatable system memory remaining capacity, and a target memory capacity corresponding to the virtual GPU creation request, wherein the allocatable system memory remaining capacity indicates a remaining capacity of a system memory that is allowed to be allocated to the virtual GPU; a memory allocation module, configured to create a virtual GPU in response to the sum of the remaining video memory capacity and the remaining allocatable system memory capacity being greater than or equal to the target memory capacity, and to allocate memory to the virtual GPU from the video memory and / or the system memory according to the target memory capacity; A swap module is used to adjust the position of the memory page of the virtual GPU according to the remaining video memory capacity; wherein the adjusting the position of the memory page of the virtual GPU includes: swapping the memory page of the virtual GPU from the system memory to the video memory, or swapping the memory page of the virtual GPU from the video memory to the system memory.

18. An electronic device, characterized in that: include: one or more processors; a memory for storing executable instructions; The one or more processors are configured to call the executable instructions stored in the memory to execute the method according to any one of claims 1 to 16.

19. A computer-readable storage medium having computer program instructions stored thereon, characterized in that: When the computer program instructions are executed by a processor, the method according to any one of claims 1 to 16 is implemented.