Video memory management method and apparatus, and device, storage medium and program product

WO2026145346A9PCT designated stage Publication Date: 2026-08-13MOORE THREADS TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Authority / Receiving Office
WO · WO
Patent Type
Applications
Current Assignee / Owner
Filing Date
2025-12-26
Publication Date
2026-08-13

Smart Images

  • Figure CN2025146203_13082026_PF_FP_ABST
    Figure CN2025146203_13082026_PF_FP_ABST
Patent Text Reader

Abstract

A video memory management method and apparatus, and a device, a storage medium and a program product, which relate to the technical field of virtualization. The method is executed by means of a computer device, wherein one or more clients run in the computer device, and each client is allocated with a part of a video memory in a physical GPU of the computer device. The method comprises: acquiring a first remaining video memory of a first client (210); and on the basis of the capacity of the first remaining video memory and a video memory capacity threshold value, adjusting the capacity of a video memory of the first client (220). By means of the solution, the utilization rate of a video memory of a physical GPU can be improved.
Need to check novelty before this filing date? Find Prior Art

Description

Video memory management methods, devices, equipment, storage media and software products

[0001] This application claims priority to Chinese Patent Application No. 202411977270.8, filed on December 30, 2024, entitled “Method, Apparatus, Device, Storage Medium and Program Product for Video Memory Management”, the entire contents of which are incorporated herein by reference. Technical Field

[0002] This application relates to the field of virtualization technology, and in particular to a video memory management method, apparatus, device, storage medium, and program product. Background Technology

[0003] Graphics Processing Unit (GPU) virtualization is a technology that allows the computing and memory resources of a physical GPU to be shared across multiple virtual environments.

[0004] In related technologies, GPU virtualization can be controlled by a hypervisor. Specifically, the hypervisor can create virtual GPUs (vGPUs) on different guest machines, and each vGPU on a guest machine will exclusively occupy a fixed portion of the physical GPU's video memory.

[0005] However, in the above scheme, each part of the physical GPU's video memory can only be used by the vGPU that exclusively occupies that part of the video memory, resulting in low utilization of the physical GPU's video memory. Summary of the Invention

[0006] This application provides a memory management method, apparatus, device, storage medium, and program product that can improve the utilization rate of physical GPU memory. The technical solution is as follows.

[0007] On one hand, a video memory management method is provided, the method being executed by a computer device running one or more guest machines; each guest machine is allocated a portion of the video memory in the physical GPU of the computer device as the video memory of a virtual GPU in the guest machine; the method includes:

[0008] Obtain the first remaining video memory of a first client in a computer device; the first client is one of one or more clients; the first remaining video memory is the unused video memory allocated to the first client;

[0009] The capacity of the first client's video memory is adjusted based on the capacity of the first remaining video memory and the video memory capacity threshold.

[0010] On one hand, a video memory management device is provided, the device comprising:

[0011] A remaining video memory acquisition module is used to acquire the first remaining video memory of a first client in a computer device; the computer device is running one or more clients; each client is allocated a portion of the video memory in the physical GPU of the computer device as the video memory of the virtual GPU in the client; the first client is one of the one or more clients; the first remaining video memory is the unused video memory allocated to the first client;

[0012] The video memory allocation module is used to adjust the video memory capacity of the first client machine based on the capacity of the first remaining video memory and the video memory capacity threshold.

[0013] In one possible implementation, the video memory allocation module is used for...

[0014] If the capacity of the first remaining video memory is greater than the first video memory capacity threshold, a portion of the video memory is reclaimed from the video memory allocated to the first client.

[0015] If the capacity of the first remaining video memory is less than the second video memory capacity threshold, additional video memory is allocated to the first client machine.

[0016] Wherein, the first video memory capacity threshold is greater than the second video memory capacity threshold.

[0017] In one possible implementation, the computer device also runs a management program, and the video memory allocation module is used for...

[0018] When the capacity of the first remaining video memory is greater than the first video memory capacity threshold, the first client sends a first video memory management request to the management program. The first video memory management request contains a first video memory address. The first video memory address is all or part of the address of the first remaining video memory.

[0019] The management program adds the first video memory corresponding to the first video memory address to the video memory pool, which is used to store video memory that has not been allocated to the client.

[0020] In one possible implementation, the device further includes:

[0021] The address locking module is used to lock the first video memory address through the first client before the video memory allocation module sends the first video memory management request to the management program through the first client, when the capacity of the first remaining video memory is greater than the first video memory capacity threshold; the video memory address locked by the first client is a video memory address that is prohibited from being accessed by the program or process in the first client.

[0022] The video memory allocation module is used to send the first video memory management request to the management program through the first client when the first video memory address is successfully locked.

[0023] In one possible implementation, the video memory allocation module is used for:

[0024] The management program queries the second video memory address based on the first video memory address; the second video memory address is the address of the first video memory in the management program.

[0025] The management program adds the second video memory address to the video memory pool.

[0026] In one possible implementation, the management program maintains a mapping relationship between the client and the address assigned to the client that is explicitly stored in the management program; the apparatus further includes:

[0027] The mapping cancellation module is used to cancel the mapping relationship between the first client and the second video memory address through the management program.

[0028] In one possible implementation, the computer device also runs a management program, and the video memory allocation module is used for...

[0029] If the capacity of the first remaining video memory is less than the second video memory capacity threshold, the first client sends a second video memory management request to the management program.

[0030] The management program allocates a second memory from the memory pool to the first client machine according to the second memory management request. The memory pool is used to store memory that has not been allocated to the client machine.

[0031] In one possible implementation, the video memory allocation module is used to send a second video memory management request to the management program through the first client when the video memory allocated to the first client does not meet the swapping conditions.

[0032] The exchange conditions include the following:

[0033] The video memory allocated to the first client does not contain swappable video memory; the swappable video memory is already occupied and can be replaced via system memory; or,

[0034] The video memory allocated to the first client includes swappable video memory, and the sum of the capacity of the swappable video memory and the capacity of the first remaining video memory is less than the second video memory capacity threshold.

[0035] In one possible implementation, the video memory allocation module is used for:

[0036] When there is sufficient video memory in the video memory pool, the third video memory address is removed from the video memory pool by the management program; the third video memory address is the address of the second video memory in the management program.

[0037] The management program sends a video memory management response to the first client, the video memory management response being used to indicate that the first client has been allocated the second video memory;

[0038] The fourth video memory address is unlocked by the first client according to the video memory management response; the fourth video memory address is the address of the second video memory in the first client.

[0039] The fourth video memory address is sent to the management program through the first client.

[0040] The management program establishes a mapping relationship between the third video memory address and the fourth video memory address.

[0041] In one possible implementation, the management program maintains a mapping relationship between the client and the address assigned to the client that is explicitly stored in the management program; the apparatus further includes:

[0042] The mapping relationship establishment module is used to establish a mapping relationship between the first client and the third video memory address through the management program.

[0043] In one possible implementation, the device further includes:

[0044] The video memory reclamation module is used to send a video memory reclamation request to a second client through the management program when the video memory in the video memory pool is insufficient; the second client is another client running on the computer device besides the first client.

[0045] The video memory allocation module is further configured to send a third video memory management request to the management program through the second client according to the video memory reclamation request, wherein the third video memory management request contains a fifth video memory address; the fifth video memory address is all or part of the address of the second remaining video memory of the second client; and the management program adds the third video memory corresponding to the fifth video memory address to the video memory pool.

[0046] In one possible implementation, the video memory allocation module is configured to send a third video memory management request to the management program via the second client, based on the video memory reclamation request, when the capacity of the second remaining video memory is greater than the third video memory capacity threshold.

[0047] In one possible implementation, the video memory allocation module is further configured to:

[0048] If the capacity of the second remaining video memory is not greater than the third video memory capacity threshold, the second client queries the capacity of the swappable video memory in the video memory of the second client; the swappable video memory is video memory that has been occupied and can be replaced by system memory.

[0049] If the sum of the capacity of the swappable video memory in the second client's video memory and the capacity of the second remaining video memory is greater than the third video memory capacity threshold, the swappable video memory in the second client's video memory is replaced by system memory.

[0050] In one possible implementation, the video memory allocation module is configured to reclaim a portion of the video memory allocated to the first client when the capacity of the first remaining video memory is greater than the first video memory capacity threshold and the capacity of the video memory allocated to the first client is greater than the lower limit of the video memory capacity.

[0051] In one possible implementation, the video memory allocation module is configured to allocate additional video memory to the first client when the capacity of the first remaining video memory is less than the second video memory capacity threshold and the video memory capacity allocated to the first client is less than the upper limit of video memory capacity.

[0052] In another aspect, a computer device is provided, the computer device including a processor and a memory, the memory storing instructions, the instruction set being loaded and executed by the processor to implement the video memory management method as described above.

[0053] In another aspect, a computer-readable storage medium is provided, wherein instructions are stored therein, which are loaded and executed by a processor to implement the video memory management method described above.

[0054] In another aspect, a computer program product is provided, the computer program product including computer instructions stored in a computer-readable storage medium; the computer instructions are read and executed by a processor of a computer device to cause the computer device to implement the video memory management method described above.

[0055] In another aspect, a chip is provided, which includes programmable logic circuitry and / or program instructions, for implementing the video memory management method described above when the chip is running.

[0056] This application provides a scheme for dynamically managing the video memory of a vGPU based on the remaining video memory capacity of the guest machine where the vGPU resides. Specifically, for a guest machine, when the allocated video memory utilization rate of the guest machine is low (more video memory remaining), it indicates that the utilization rate of the video memory exclusively used by the vGPU of the guest machine is low. At this time, a portion of the video memory already allocated to the guest machine can be reclaimed. When the allocated video memory utilization rate of the guest machine is high (less video memory remaining), it indicates that the utilization rate of the video memory exclusively used by the vGPU of the guest machine is high. At this time, new video memory can be allocated to the guest machine. Through the above scheme, the remaining video memory capacity of each guest machine can be controlled within a certain capacity range. From the perspective of the entire virtual machine system, the above scheme can achieve the effect of transferring a portion of the video memory exclusively used by guest machines with insufficient video memory utilization to guest machines with higher video memory utilization, thereby improving the overall utilization rate of the physical GPU's video memory. Attached Figure Description

[0057] Figure 1 is an architecture diagram of a virtualization system involved in this application;

[0058] Figure 2 is a flowchart of a video memory management method according to this application;

[0059] Figure 3 is a flowchart of a video memory management method according to this application;

[0060] Figure 4 is a framework diagram of a video memory management system according to an embodiment of this application;

[0061] Figure 5 is a flowchart of a video memory management method according to this application;

[0062] Figure 6 is a framework diagram of a video memory management system according to an embodiment of this application;

[0063] Figure 7 is a flowchart of a video memory management method according to this application;

[0064] Figure 8 is a framework diagram of a video memory management system according to an embodiment of this application;

[0065] Figure 9 is a framework diagram of a video memory management system according to an embodiment of this application;

[0066] Figure 10 is a framework diagram of client-initiated request for video memory management involved in this application;

[0067] Figure 11 is a framework diagram of the management program for video memory management involved in this application;

[0068] Figure 12 is a framework diagram of the client releasing video memory according to the request of the management program involved in this application;

[0069] Figure 13 is a block diagram of a video memory management device provided in an exemplary embodiment of this application;

[0070] Figure 14 is a schematic diagram of the structure of a computer device provided in an exemplary embodiment of this application. Detailed Implementation

[0071] To make the objectives, technical solutions, and advantages of this application clearer, the embodiments of this application will be described in further detail below with reference to the accompanying drawings. First, some concepts involved in this application will be introduced:

[0072] 1) GPU

[0073] A GPU, also known as a graphics processing unit, visual processor, or display chip, is a microprocessor that performs graphics processing-related computations on computer devices (such as personal computers, workstations, game consoles, and mobile devices). In some scenarios, GPUs can also be used for computations other than graphics processing, such as computations related to artificial intelligence (AI) training and inference, and blockchain-related computations.

[0074] 2) Virtualization

[0075] In the field of computer science, virtualization is a resource management technology that abstracts and transforms various physical resources of a computer device, such as processors, networks, memory, and storage, breaking down barriers between physical structures and allowing users to use these resources in a better way than the original configuration. These virtualized portions of resources (also known as virtualized resources) are not limited by the existing resource deployment methods, geographical location, or physical configuration. Virtualized resources generally refer to both virtualized computing and storage resources.

[0076] GPU virtualization is a technology that shares the computing and memory resources of a physical GPU across multiple virtual environments. It features convenient resource sharing, high cost-effectiveness, good isolation, and flexible deployment.

[0077] Please refer to Figure 1, which shows an architecture diagram of a virtualization system related to this application. As shown in Figure 1, the virtualization system includes a host 100, on which a hypervisor 200 and one or more client machines 300 are running.

[0078] The host 100 may include computer hardware such as a physical central processing unit (CPU), physical memory, physical GPU, physical bus, etc. These computer hardware components constitute a physical computer system. The host 100 may run an operating system (OS), which can be called a Host OS.

[0079] The aforementioned management program 200 is also called a hypervisor. It can run on the operating system of the host 100, or it can run directly on the computer hardware of the host 100.

[0080] The hypervisor 200 is responsible for creating and managing the clients 300. The hypervisor 200 is a type of system software that acts as an intermediary between the computer hardware of the host 100 and the clients 300, and is responsible for effectively allocating and utilizing the hardware resources used by each client 300.

[0081] Guest 300 is a virtual machine that may contain a virtual GPU; optionally, guest 300 may also contain other virtual resources such as virtual CPU, virtual memory, and virtual bus; guest 300 may have an independently running operating system (which may be called Guest OS) to support guest 300 to work independently on host 100.

[0082] The virtualization system described above may also include one or more user terminals 400, with the host 100 connected to the user terminals 400 via wired or wireless networks. Different client machines 300 can be assigned to different user terminals 400, and multiple user terminals 400 can share the hardware resources of the host 100 through different client machines 300.

[0083] In a virtualization scheme based on the architecture shown in Figure 1, the computing resources of the vGPU are time-division shared, while the storage resources are exclusive. That is, when a portion of the video memory in the physical GPU is allocated to a vGPU, this portion of video memory cannot be used by other clients, regardless of whether the client corresponding to that vGPU uses it. As a result, the video memory resources of the physical GPU are not fully utilized.

[0084] Furthermore, video memory (VRAM) is a crucial resource for GPUs, and GPUs typically achieve higher performance and efficiency when using VRAM compared to system memory. In the virtualization scheme described above, the VRAM allocated to vGPUs cannot be shared between different vGPUs. When some vGPUs are idle while others are busy (using more VRAM), the busy vGPUs cannot effectively utilize the idle VRAM and must instead use the guest's system memory. This results in the vGPU needing to access the physical GPU frequently when it calls upon the physical GPU to execute tasks, even when some VRAM is not being used effectively. Since the performance of the physical GPU accessing system memory is lower than that accessing VRAM, the efficiency of the physical GPU will decrease in this scenario.

[0085] The solutions shown in the subsequent embodiments of this application provide a scheme for dynamically managing the video memory allocated to guest machines in a virtualization scenario, which can flexibly adjust the video memory allocated to each guest machine.

[0086] Please refer to Figure 2, which shows a flowchart of a video memory management method according to this application. This video memory management method can be executed by a computer device running a management program and one or more guest machines. Each guest machine is allocated a portion of the video memory in the physical GPU of the computer device as the video memory of a virtual GPU within the guest machine. For example, the computer device can be host 100 in the virtualization system shown in Figure 1, the management program can be management program 200 in the framework shown in Figure 1, and the guest machine can be guest machine 300 in the framework shown in Figure 1. As shown in Figure 2, the video memory management method may include the following steps:

[0087] Step 210: Obtain the first remaining video memory of the first client in the computer device; the first client is one of one or more clients; the first remaining video memory is the unused video memory allocated to the first client.

[0088] The aforementioned first remaining video memory refers to the video memory allocated to the first client that is not occupied by any program or process in the first client.

[0089] In this embodiment of the application, each client can work independently. The program or process running in the operating system (Guest OS) of each client can call the vGPU in the current client to perform tasks. During the process of the program or process calling the vGPU to perform tasks, it can occupy a portion of the video memory allocated to the current client to store the data read or output by the vGPU when performing tasks. Optionally, when the program or process finishes calling the vGPU to perform tasks, it can release the video memory previously occupied.

[0090] In one possible implementation, the aforementioned first remaining video memory refers to the portion of video memory allocated to the first client machine that meets the current application needs of the first client machine. Specifically, when a program or process in the first client machine calls the vGPU to execute a task, it requests the video memory required by the task from the first client machine. At some point during task execution, only a portion of the video memory requested by the program or process may be written with task data. However, in the above embodiment of this application, the video memory occupied by the program or process in the first client machine refers to the video memory requested by the program or process in the first client machine, which includes video memory with task data already written and a portion of video memory without task data yet written. Therefore, the capacity of the video memory occupied by the program or process in the first client machine is usually larger than the capacity of the video memory with task data already written.

[0091] For example, suppose the video memory allocated to the first client is 10Mb. At a certain moment, 6Mb of this 10Mb video memory is occupied by applications or processes, and 4Mb of this 6Mb video memory has been written with task data. At this time, the video memory allocated to the first client is 6Mb that has been occupied, not 4Mb.

[0092] The aforementioned acquisition of the first remaining video memory of the first client in the computer device may refer to the acquisition of the capacity of the first remaining video memory of the first client.

[0093] Alternatively, obtaining the first remaining video memory of the first client in the computer device may also refer to obtaining the video memory address corresponding to the first remaining video memory of the first client.

[0094] The first remaining video memory of the first client machine can be the remaining video memory of the first client machine at the current moment.

[0095] Alternatively, the first remaining video memory of the first client can be the average of the remaining video memory of the first client at various times within a specified time period before the current time.

[0096] Alternatively, the first remaining video memory of the first client can be the weighted average of the remaining video memory of the first client at various times within a specified time period before the current time.

[0097] Step 220: Adjust the capacity of the first client's video memory based on the capacity of the first remaining video memory and the video memory capacity threshold.

[0098] In this embodiment of the application, when the computer device adjusts the capacity of the video memory of the first client, it can control the remaining capacity of the video memory of the first client within a specified capacity range.

[0099] If the remaining video memory capacity of the first client is too large, it indicates that a significant amount of video memory in the first client is idle, affecting the utilization rate of the video memory. Conversely, if the remaining video memory capacity of the first client is too small, it indicates that the video memory of the first client is insufficient, affecting the performance of the first client. In this regard, the solution shown in the embodiment of this application controls the remaining video memory capacity of the first client within a specified capacity range, which can avoid the situation of low video memory utilization or insufficient video memory in the client (i.e., virtual machine), thereby balancing video memory utilization and virtual machine operating performance.

[0100] Specifically, in this embodiment, the video memory allocated to each client is not fixed, but dynamically adjusted. During the use of video memory by each client, if the remaining capacity of video memory of client 1 increases and the remaining capacity of video memory of client 2 decreases, it indicates that client 1 is currently relatively "idle" (video memory utilization is low, video memory is surplus), while client 2 is currently relatively "busy" (video memory utilization is high, video memory is insufficient). At this time, the computer device can adjust the capacity of video memory of client 1 and client 2 respectively, which is equivalent to "lending" part of the video memory of client 1 to client 2.

[0101] In this embodiment of the application, the computer device can determine whether to adjust the capacity of the first client's video memory based on the relationship between the capacity of the first remaining video memory and the video memory capacity threshold, and determine the method for adjusting the capacity of the first client's video memory.

[0102] If it is determined that the video memory capacity of the first client needs to be adjusted, the video memory capacity of the first client is increased or decreased according to the corresponding adjustment method. Specifically, for example, when the remaining video memory capacity of the first client is large, the video memory capacity of the first client can be decreased; when the remaining video memory capacity of the first client is small, the video memory capacity of the first client can be increased, thereby limiting the remaining video memory capacity of the first client to a suitable capacity range. By performing the corresponding processing on multiple clients using the above scheme, it is equivalent to dynamically transferring the video memory of the client with a larger remaining video memory capacity to the client with a smaller remaining video memory capacity.

[0103] The specified capacity range can be a capacity range preset by developers or administrators; or, the specified capacity range can be a capacity range dynamically set by the computer device. For example, the specified capacity range can be a capacity range set by the computer device based on the capacity of the physical GPU's video memory that has not yet been allocated to each client machine.

[0104] In summary, this application provides a scheme for dynamically managing the video memory of a vGPU based on the remaining video memory capacity of the guest machine where the vGPU resides. For a guest machine, when the allocated video memory utilization rate is low (more remaining video memory), it indicates that the utilization rate of the video memory exclusively used by the vGPU of that guest machine is low. In this case, a portion of the video memory already allocated to that guest machine can be reclaimed. When the allocated video memory utilization rate of that guest machine is high (less remaining video memory), it indicates that the utilization rate of the video memory exclusively used by the vGPU of that guest machine is high. In this case, new video memory can be allocated to that guest machine. Through the above scheme, the remaining video memory capacity of each guest machine can be controlled within a certain capacity range. From the perspective of the entire virtual machine system, the above scheme can achieve the effect of transferring a portion of the video memory exclusively used by guest machines with insufficient video memory utilization to guest machines with higher video memory utilization, thereby improving the overall utilization rate of the physical GPU's video memory.

[0105] Furthermore, since the solution provided in this application embodiment improves the overall utilization of the physical GPU's video memory, in scenarios where some vGPUs are idle and the rest are busy, the physical GPU can access more video memory rather than system memory, thereby improving the working efficiency of the physical GPU.

[0106] Based on the embodiment shown in Figure 2, please refer to Figure 3, which illustrates a flowchart of a video memory management method according to an embodiment of this application. As shown in Figure 3, step 220 above may include the following steps.

[0107] Step 220a: If the capacity of the first remaining video memory is greater than the first video memory capacity threshold, a portion of the video memory is reclaimed from the video memory allocated to the first client.

[0108] In this embodiment of the application, when the capacity of the first remaining video memory is greater than the first video memory capacity threshold, it can be considered that the utilization rate of the video memory allocated to the first client is insufficient and a large amount of video memory is idle. At this time, a portion of the video memory already allocated to the first client can be reclaimed to reduce the capacity of the video memory allocated to the first client, thereby releasing a portion of the video memory previously allocated to the first client and preventing the first client from occupying this portion of video memory for a long time.

[0109] The aforementioned "reclaiming a portion of the video memory from the video memory allocated to the first client" can refer to releasing a portion of the physical GPU's video memory that has been allocated to the first client, i.e., setting it as unallocated video memory.

[0110] In some embodiments, the capacity of the first remaining video memory being greater than the first video memory capacity threshold may mean that the capacity of the first remaining video memory obtained most recently is greater than the first video memory capacity threshold; or, the capacity of the first remaining video memory being greater than the first video memory capacity threshold may mean that the capacity of the first remaining video memory obtained most recently N times is greater than the first video memory capacity threshold, where N is an integer greater than or equal to 2.

[0111] Step 220b: If the capacity of the first remaining video memory is less than the second video memory capacity threshold, allocate new video memory to the first client machine; wherein the first video memory capacity threshold is greater than the second video memory capacity threshold.

[0112] Optionally, the capacity range between the first and second video memory capacity thresholds is the specified capacity range. Alternatively, the capacity range between the first and second video memory capacity thresholds can be a subset of the specified capacity range.

[0113] In this embodiment of the application, when the capacity of the first remaining video memory is less than the second video memory capacity threshold, it can be considered that the utilization rate of the video memory allocated to the first client is high, and the first client may have insufficient video memory. At this time, new video memory can be allocated to the first client to increase the capacity of the video memory allocated to the first client, so that the first client can use more video memory.

[0114] The above-mentioned additional allocation of new video memory to the first client machine can refer to the allocation of the unallocated portion of the physical GPU's video memory to the first client machine.

[0115] In some embodiments, the above-mentioned first remaining video memory capacity being less than the second video memory capacity threshold may mean that the most recently obtained first remaining video memory capacity is less than the second video memory capacity threshold; or, the above-mentioned first remaining video memory capacity being less than the second video memory capacity threshold may mean that the first remaining video memory capacity obtained in the most recent N times is less than the second video memory capacity threshold.

[0116] The first and second video memory capacity thresholds mentioned above can be thresholds preset by the developers.

[0117] Alternatively, the aforementioned first and second video memory capacity thresholds can also be thresholds set by the computer device. For example, the computer device can set the aforementioned first and second video memory capacity thresholds based on the capacity of unallocated video memory in the physical GPU's video memory; for example, the computer device can query the correspondence between the capacity of unallocated video memory in the physical GPU's video memory and the aforementioned first and second video memory capacity thresholds to determine the aforementioned first and second video memory capacity thresholds; or, for yet another example, the computer device can input the capacity of unallocated video memory in the physical GPU's video memory into a preset calculation formula to obtain the aforementioned first and second video memory capacity thresholds.

[0118] Based on the embodiment shown in Figure 3, please refer to Figure 4, which shows a framework diagram of a video memory management system according to an embodiment of this application. As shown in Figure 4, a management program, client 410, and client 420 are running in the computer device, and client 410 and client 420 have their own allocated video memory.

[0119] At time 1, the remaining video memory 410a in the video memory allocated to client 410 is less than the second video memory capacity threshold, and the remaining video memory 420a in the video memory allocated to client 420 is greater than the first video memory capacity threshold. At this time, the video memory allocated to client 410 and client 420 is adjusted. Specifically, the unallocated portion of video memory in video memory 430 is allocated to client 410, and a portion of the video memory allocated to client 420 is released.

[0120] At time 2, after the video memory adjustment, the video memory allocated to client 410 increased compared to time 1, while the video memory allocated to client 420 decreased compared to time 1.

[0121] In one possible implementation, step 220a can be implemented as follows: when the capacity of the first remaining video memory is greater than the first video memory capacity threshold and the capacity of the video memory allocated to the first client is greater than the lower limit of the video memory capacity, a portion of the video memory is reclaimed from the video memory allocated to the first client.

[0122] In this embodiment of the application, in order to avoid insufficient video memory after the first client releases its video memory, a lower limit for video memory capacity can be preset. If the video memory capacity of the first client is greater than the lower limit, a portion of the video memory allocated to the first client is released.

[0123] For example, assuming the minimum video memory capacity is 100MB, when the capacity of the first remaining video memory is greater than the first video memory capacity threshold, if the video memory capacity allocated to the first client is greater than 100MB (for example, the video memory capacity allocated to the first client is 150MB), then the computer device can release a portion of the video memory allocated to the first client (for example, release 50MB). Optionally, if the video memory capacity allocated to the first client is not greater than 100MB (for example, the video memory capacity allocated to the first client is equal to 100MB), then the computer device will not release the video memory allocated to the first client.

[0124] In one possible implementation, step 220b above can be implemented as follows: when the capacity of the first remaining video memory is less than the second video memory capacity threshold, and the video memory capacity allocated to the first client is less than the upper limit of the video memory capacity, additional video memory is allocated to the first client.

[0125] In this embodiment of the application, in order to prevent the first client from acquiring video memory without limit, thereby squeezing the video memory capacity of other clients, a video memory capacity limit can be preset. If the video memory capacity of the first client is less than the video memory capacity limit, a new portion of video memory can be allocated to the first client.

[0126] For example, assuming the maximum video memory capacity is 200MB, when the first remaining video memory capacity is less than the second video memory capacity threshold, if the video memory capacity allocated to the first client is less than 200MB (for example, the video memory capacity allocated to the first client is 150MB), the computer device can allocate a new portion of video memory to the first client (for example, allocate a new 50MB). Optionally, if the video memory capacity allocated to the first client is not less than 200MB (for example, the video memory capacity allocated to the first client is equal to 200MB), the computer device will not allocate any new video memory to the first client.

[0127] Based on the embodiment shown in Figure 3, please refer to Figure 5, which illustrates a flowchart of a video memory management method according to this application. As shown in Figure 5, step 220a may include steps 220a1 and 220a2.

[0128] Step 220a1: When the capacity of the first remaining video memory is greater than the first video memory capacity threshold, the first client sends a first video memory management request to the management program. The first video memory management request contains the first video memory address. The first video memory address is all or part of the address of the first remaining video memory.

[0129] Specifically, step 220a1 can be executed by the first client in the computer device; for example, step 220a1 can be executed by the client-side video memory management process running in the first client.

[0130] In this embodiment of the application, the dynamic management of video memory can be achieved through interaction between the client and the management program. Specifically, when the first client detects that the utilization rate of the video memory allocated to it is insufficient, it can actively request to release a portion of the video memory that it exclusively occupies. At this time, the first client can send a request (i.e. the first video memory management request mentioned above) to the management program, and notify the management program of the address of the video memory that needs to be released.

[0131] Step 220a2: Add the first video memory corresponding to the first video memory address to the video memory pool through the management program. The video memory pool is used to store video memory that has not been allocated to the client.

[0132] In this embodiment of the application, the aforementioned video memory pool is used to store video memory that has not been allocated to the client, which may refer to the video memory pool being used to store the identifier (such as the address) of the video memory that has not been allocated to the client.

[0133] Specifically, step 220a2 can be executed by a management program in a computer device; for example, step 220a1 can be executed by a memory management process running in the management program.

[0134] In this embodiment of the application, after the management program receives the first video memory management request sent by the first client, it can add the video memory corresponding to the video memory address carried by the first video memory management request to the video memory pool.

[0135] The above-mentioned addition of the first video memory to the video memory pool may refer to adding the identifier (such as the address) of the first video memory to the video memory pool.

[0136] Optionally, the capacity of the aforementioned first video memory can be a capacity preset by the developers or administrators.

[0137] Alternatively, the capacity of the first video memory can be determined by the first client based on the capacity of the first remaining video memory. For example, the first client can look up the correspondence between the remaining video memory capacity and the freed video memory capacity to obtain the capacity of the first video memory; or, the first client can input the capacity of the first remaining video memory into a pre-set calculation formula to obtain the capacity of the first video memory output by the calculation formula. Optionally, when the capacity of the first video memory is determined by the first client based on the capacity of the first remaining video memory, the capacity of the first video memory can be positively correlated with the capacity of the first remaining video memory, that is, the larger the capacity of the first remaining video memory, the larger the capacity of the first video memory.

[0138] The solution shown in the embodiments of this application can realize the dynamic release of video memory through the interaction between the first client and the management program. Specifically, when the first client detects that the utilization rate of its allocated video memory is insufficient, it notifies the management program to release a portion of the video memory of the first client. The management program does not need to obtain the information of the first remaining video memory from the first client. This simplifies the interaction between the management program and the first client in the dynamic management of video memory and simplifies the calculation process on the management program side, thereby improving the operating efficiency of the virtual machine system.

[0139] Based on the scheme shown in Figure 4 above, in one possible implementation, before sending the first video memory management request to the management program through the first client, the method further includes:

[0140] If the capacity of the first remaining video memory is greater than the first video memory capacity threshold, the first video memory address is locked by the first client machine; the video memory address locked by the first client machine is a video memory address that is prohibited from being accessed by the program or process in the first client machine.

[0141] In this embodiment of the application, the process of the first client locking the first video memory address can be as follows:

[0142] If the capacity of the first remaining video memory is greater than the first video memory capacity threshold, the first client / the client-side video memory management process running in the first client can request video memory from the first operating system; the first operating system is the operating system running in the first client; if the first capacity of video memory is obtained, the first client / the client-side video memory management process requests the first operating system to lock the first video memory address corresponding to the obtained video memory; wherein, the video memory address locked by the first operating system is a video memory address that is prohibited from being accessed by applications or processes in the first operating system.

[0143] Taking the above steps as an example executed by the client-side video memory management process in the first client, since multiple applications or processes can run simultaneously in the first client, and these applications or processes may occupy new video memory at any time, in order to prevent the first video memory from being occupied by other applications or processes in the first client while the client-side video memory management process requests the release of the first video memory, the following steps can be performed:

[0144] S1, before requesting the release of video memory, the client-side video memory management process can first apply to the first operating system for a certain amount of video memory (i.e., the aforementioned first capacity) as the first video memory to be released.

[0145] S2, the first operating system may simultaneously process multiple requests for video memory sent by different applications or processes. When processing the request from the client-side video memory management process, it can allocate the aforementioned first capacity of video memory from the unused video memory of the first client to the client-side video memory management process. If the current unused video memory capacity of the first client is greater than or equal to the first capacity, the allocation can be determined to be successful. For example, a mapping relationship is established between the address of the first capacity of video memory and the client-side video memory management process, and a successful request response is returned to the client-side video memory management process. If the current unused video memory capacity of the first client is less than the first capacity, the allocation can be determined to be unsuccessful, and a failed request response is returned to the client-side video memory management process.

[0146] Alternatively, if the amount of unused video memory currently held by the first client is less than the first capacity, the first operating system can allocate the unused video memory currently held by the first client to the client-side video memory management process. The client-side video memory management process can then request the remaining video memory as needed. For example, if the first capacity is 50MB, and the amount of unused video memory currently held by the first client is 30MB when the first operating system processes the request from the client-side video memory management process, the first operating system can first allocate 30MB of video memory to the client-side video memory management process. Afterward, the client-side video memory management process can request the remaining 20MB of video memory from the first operating system.

[0147] S3. If the client-side video memory management process obtains a sufficient amount of video memory, it can request the first operating system in the first client to lock the video memory address of the obtained portion of video memory.

[0148] S4. If the client-side video memory management process fails to allocate enough video memory, it can continue to allocate video memory until it does. If it fails to allocate enough video memory for an extended period of time, the client-side video memory management process can stop allocating video memory.

[0149] Accordingly, step 220a1 above can be implemented as follows: if the first video memory address is successfully locked, the first video memory management request is sent to the management program through the first client.

[0150] In this embodiment of the application, if the first operating system successfully locks the first video memory address, it means that the first video memory address will not be occupied by other applications or processes in the first client. At this time, the client-side video memory management process in the first client can send the first video memory management request to the management program.

[0151] Optionally, if the first video memory address is not successfully locked, the client-side video memory management process in the first client can release the previously allocated video memory and re-allocate video memory.

[0152] For example, when the first operating system locks the first video memory address, it can check whether there is data at that address, or whether the video memory corresponding to that address is occupied by other applications or processes. If so, it determines that locking the first video memory address has failed; otherwise, it locks the first video memory address. Afterward, the first operating system sends a success or failure response to the client-side video memory management process, so that the client-side video memory management process can send a first video memory management request to the management program based on a successful lock response, or release the previously allocated video memory based on a failed lock response.

[0153] Specifically, the first operating system locks the first video memory address by marking it as locked. Correspondingly, the first operating system can handle video memory requests from applications or processes in the first client machine based on the status of the local video memory address (locked / unlocked).

[0154] For example, when the first operating system receives a request for video memory from an application or process in the first client machine, it can query the unlocked video memory addresses to find those that are not currently occupied. Then, based on these unoccupied video memory addresses, it can allocate video memory to the application or process. For instance, it can establish a mapping relationship between all or part of the currently unoccupied video memory addresses and the application or process (indicating that the application or process has requested and occupied the video memory corresponding to these addresses), and indicate these video memory addresses to the application or process so that the application or process can access these video memory addresses (such as writing, modifying, or reading).

[0155] Based on the solutions shown in the above embodiments, please refer to Figure 6, which illustrates a framework diagram of video memory management according to an embodiment of this application. As shown in Figure 6, the first client 610 maintains a video memory address 610a. In this video memory address 610a, the unlocked portion of the address corresponds to the address of the video memory allocated to the first client 610. The management program maintains a video memory pool 620a, which stores the addresses of video memory not allocated to the client. When the video memory utilization rate of the first client 610 is low, the process of releasing video memory can be as follows:

[0156] S1, the client-side video memory management process in the first client 610 requests the video memory to be released from the first operating system and requests to lock the video memory address corresponding to the video memory to be released (i.e., the first video memory address).

[0157] S2, the first operating system locks the first video memory address in video memory address 610a.

[0158] S3, the client-side video memory management process sends a first video memory management request to the management program-side video memory management process in the management program 620, which contains the first video memory address to be released.

[0159] S4, the video memory management process on the management program side adds the corresponding video memory address to the video memory pool 620a according to the first video memory address.

[0160] With the solution shown in the embodiments of this application, the first client can lock the part of the video memory to be released in the operating system of the first client before requesting the release of video memory from the management program. This avoids errors caused by the first video memory being occupied by other applications or processes in the first client during the process of the video memory management process on the client side requesting the release of the first video memory, and ensures the accuracy of video memory release.

[0161] Based on the solutions shown in the above embodiments, in one possible implementation, the first video memory address is the address of the first video memory in the first client machine, and step 220a2 can be implemented as follows:

[0162] Step 220a2-1: Through the management program, query the second video memory address based on the first video memory address; the second video memory address is the address of the first video memory in the management program.

[0163] In this embodiment, the memory addresses corresponding to the same video memory may be different in the management program and the client. For example, in the client, video memory can be represented by a logical address (or linear address), allowing applications or processes to access video memory based on the logical address. However, in the management program, since it needs to access the actual video memory by calling the physical GPU, the management program needs to know the physical address corresponding to the video memory. To address this, the management program can pre-set a mapping relationship between the address (logical address) of the video memory in the client and the address (physical address) of the video memory in the management program. After obtaining the first video memory address, the management program can query the corresponding second video memory address through the mapping relationship.

[0164] Step 220a2-2: Add the second video memory address to the video memory pool through the management program.

[0165] After the management program finds the second video memory address, it can add the second video memory address to the video memory pool.

[0166] Optionally, the management program can also delete the mapping relationship between the first video memory address and the second video memory address.

[0167] With the solution shown in the embodiments of this application, when the same video memory has different addresses in the client machine and the management program, the management program can first convert the address of the video memory that the client machine indicates to be released into the address of the video memory in the management program, and put the converted address into the video memory pool. In this way, the management program can uniformly manage the addresses of the video memory of different clients, ensuring the accuracy and efficiency of dynamic video memory management.

[0168] In the above embodiments of this application, the management program queries the second video memory address corresponding to the first video memory address. Optionally, in other embodiments, the above-mentioned querying of the second video memory address corresponding to the first video memory address can also be performed by the first client. For example, the first client maintains a mapping relationship between the first video memory address and the second video memory address. Before sending the first video memory management request, the first client can query the mapping relationship between the first video memory address and the second video memory address to obtain the second video memory address, and send the second video memory address along with the first video memory management request to the management program. After receiving the first video memory management request, the management program adds the second video memory address carried in the first video memory management request to the video memory pool.

[0169] Based on the solutions shown in the above embodiments, in one possible implementation, the management program maintains a mapping relationship between the client and the address of the video memory allocated to the client in the management program; the above method may also include: canceling the mapping relationship between the first client and the second video memory address through the management program.

[0170] Since different clients operate independently, they may use the same address system. In other words, different video memory may correspond to the same address in different clients. If the management program only maintains the mapping relationship between the addresses of video memory in the client (such as logical addresses) and the addresses of video memory in the management program (such as physical addresses), the same logical address may correspond to multiple physical addresses, which may lead to subsequent business errors.

[0171] To address the aforementioned issues, in this embodiment, the management program maintains not only the mapping relationship between the logical address of the video memory in the client and the physical address of the video memory, but also the mapping relationship between the physical address of the video memory and the client corresponding to the video memory. Subsequently, when the client requests the management program to access a certain video memory A via the physical GPU, the request carries the client's identifier and the logical address of video memory A. The management program can first query the mapping relationship between the physical address of the video memory and the client corresponding to the video memory using the client's identifier (e.g., the client's ID) to obtain the physical address of the video memory corresponding to the client. Then, based on the mapping relationship between the logical address of the video memory in the client and the physical address of the video memory, and the logical address of video memory A, it queries the physical address of video memory A from the physical address of the corresponding video memory of the client.

[0172] Correspondingly, once the management program adds the second memory address to the memory pool, it means that the first client can no longer access the first memory via the physical GPU. At this point, the management program needs to cancel the mapping relationship between the first client and the second memory address (e.g., delete the mapping relationship) to prevent the first client from encountering errors in subsequent tasks that access memory via the physical GPU.

[0173] Based on the solutions shown in one or more of the above embodiments, please refer to Figure 7, which illustrates a flowchart of a video memory management method according to this application. As shown in Figure 7, step 220b may include steps 220b1 and 220b2.

[0174] Step 220b1: If the capacity of the first remaining video memory is less than the second video memory capacity threshold, send a second video memory management request to the management program through the first client.

[0175] Specifically, step 220b1 can be executed by the first client in the computer device; for example, step 220b1 can be executed by the client-side video memory management process running in the first client.

[0176] In this embodiment of the application, when the first client detects that the utilization rate of the video memory allocated to it is high and the video memory is insufficient, it can actively request to obtain more video memory. At this time, the first client can send a request (i.e. the above-mentioned second video memory management request) to the management program to request the management program to allocate more video memory to the first client.

[0177] Step 220b2: Through the management program, the second video memory in the video memory pool is added to the first client according to the second video memory management request. The video memory pool is used to store video memory that has not been allocated to the client.

[0178] Specifically, step 220b2 can be executed by a management program in a computer device; for example, step 220b2 can be executed by a memory management process running in the management program.

[0179] In this embodiment of the application, after the management program receives the second video memory management request sent by the first client, it can add a portion of the video memory in the video memory pool to the first client.

[0180] Optionally, the capacity of the aforementioned second video memory can be a capacity preset by the developers or administrators.

[0181] Alternatively, the capacity of the second video memory can be determined and requested by the first client based on the capacity of the first remaining video memory. For example, the first client can query the correspondence between the remaining video memory capacity and the newly requested video memory capacity based on the capacity of the first remaining video memory to obtain the capacity of the second video memory; or, the first client can input the capacity of the first remaining video memory into a pre-set calculation formula to obtain the capacity of the second video memory output by the calculation formula. Optionally, when the capacity of the second video memory is determined by the first client based on the capacity of the first remaining video memory, the capacity of the second video memory can be inversely correlated with the capacity of the first remaining video memory, that is, the smaller the capacity of the first remaining video memory, the larger the capacity of the second video memory.

[0182] Alternatively, the capacity of the second video memory can also be determined by the management program based on the available video memory in the video memory pool. For example, the management program can look up the correspondence between the available video memory capacity in the video memory pool and the capacity of the second video memory to obtain the capacity of the second video memory; or, the management program can input the available video memory capacity in the video memory pool into a pre-set calculation formula to obtain the capacity of the second video memory output by the calculation formula. Optionally, when the capacity of the second video memory is determined automatically by the management program based on the available video memory capacity in the video memory pool, the capacity of the second video memory can be positively correlated with the available video memory capacity in the video memory pool, that is, the larger the available video memory capacity in the video memory pool, the larger the capacity of the second video memory.

[0183] The solution shown in the embodiments of this application can realize dynamic allocation of video memory through the interaction between the first client and the management program. Specifically, when the first client detects that the utilization rate of its allocated video memory is high, it notifies the management program to allocate more video memory to the first client. The management program does not need to obtain the information of the first remaining video memory from the first client. This simplifies the interaction between the management program and the first client in dynamic video memory management and simplifies the calculation process on the management program side, thereby improving the operating efficiency of the virtual machine system.

[0184] Based on the solution provided by the embodiment shown in Figure 7 above, in one possible implementation, step 220b2 can be implemented as the following steps:

[0185] Step 220b2-1: If there is sufficient video memory in the video memory pool, remove the third video memory address from the video memory pool through the management program; the third video memory address is the address of the second video memory in the management program.

[0186] In this embodiment, after receiving the second video memory management request, the management program can first determine whether the video memory in the video memory pool is sufficient; for example, whether the capacity of the video memory in the video memory pool is greater than a certain threshold. Optionally, this threshold can be a pre-set threshold. If the management program determines that the video memory in the video memory pool is sufficient, it can append the second video memory corresponding to the third video memory address in the video memory pool to the first client. At this time, the third video memory address needs to be removed from the video memory pool to prevent the third video memory address from being reassigned to other clients.

[0187] Step 220b2-2: Send a video memory management response to the first client through the management program. The video memory management response is used to indicate that the first client has been allocated second video memory.

[0188] In this embodiment of the application, the management program can notify the first client of the newly allocated video memory through the video memory management response.

[0189] The aforementioned memory management response may carry one or more of the following information:

[0190] The video memory allocation success indicator is used to indicate that the first client has successfully requested new video memory; the capacity information of the second video memory; and the address of the third video memory of the second video memory.

[0191] Specifically, when the capacity of the second video memory is a preset capacity, and the video memory management response carries a video memory allocation success indication, the first client can determine that the video memory with the preset capacity has been allocated based on the video memory allocation success indication.

[0192] When the above video memory management response carries the capacity information of the second video memory, the first client can determine the video memory that has been allocated the capacity indicated by the capacity information based on the capacity information of the second video memory.

[0193] When the above video memory management response carries the address of the third video memory corresponding to the second video memory, the first client can determine that the video memory corresponding to the third video memory address has been allocated based on the third video memory address.

[0194] Step 220b2-3: Unlock the fourth video memory address through the first client according to the video memory management response; the fourth video memory address is the address of the second video memory in the first client.

[0195] In this embodiment, after receiving the aforementioned video memory management response, the first operating system in the first client can allocate the previously locked fourth video memory address to the second video memory and unlock the fourth video memory address, so that applications or processes in the first client can subsequently request to use the second video memory through the fourth video memory address. The video memory capacity corresponding to the fourth video memory address is the same as the video memory capacity corresponding to the third video memory address.

[0196] The aforementioned unlocking of the fourth video memory address can refer to marking the fourth video memory address as unlocked, or it can refer to deleting the lock flag of the fourth video memory address.

[0197] Optionally, if the above-mentioned video memory management response carries the third video memory address of the second video memory, the first client can also establish a mapping relationship between the third video memory address and the fourth video memory address in the first client.

[0198] Step 220b2-4: Send the fourth video memory address to the management program through the first client.

[0199] After the first client allocates the fourth video memory address to the second video memory, it also needs to notify the management program of the fourth video memory address so that the management program can use the fourth video memory address to determine the second video memory accessed by the physical GPU of the first client.

[0200] Step 220b2-5: Establish the mapping relationship between the third video memory address and the fourth video memory address through the management program.

[0201] After receiving the fourth video memory address sent by the first client, the management program can establish a mapping relationship between the third video memory address and the fourth video memory address. Subsequently, when the application or process in the first client uses the second video memory, the first client can send a call request containing the fourth video memory address to the management program. At this time, the management program can query the corresponding third video memory address based on the fourth video memory address and call the physical GPU to access the second video memory based on the third video memory address.

[0202] Based on the solutions shown in the above embodiments, please refer to Figure 8, which illustrates a framework diagram of video memory management according to an embodiment of this application. As shown in Figure 8, the first client 810 maintains a video memory address 810a. In this video memory address 810a, the unlocked portion of the address corresponds to the address of the video memory allocated to the first client 810. The management program maintains a video memory pool 820a, which stores the addresses of video memory not allocated to the client. When the video memory utilization rate is high, the process of the first client 810 requesting the allocation of new video memory can be as follows:

[0203] S1, the client-side video memory management process in the first client 810 sends a second video memory management request to the management program-side video memory management process in the management program 820.

[0204] S2, when there is sufficient video memory in the video memory pool, the video memory management process on the management program removes a certain amount of video memory from the video memory pool. The corresponding video memory address in the management process (i.e., the third video memory address, which may be a physical address) is the video memory address in the management process.

[0205] S3, the video memory management process on the management program side sends a video memory management response to the video memory management process on the client side, indicating that new video memory (i.e., second video memory) has been allocated for the first client 810.

[0206] S4, the client-side video memory management process instructs the first operating system to unlock a new video memory address (i.e., the fourth video memory address, which could be a logical address) in the first client 810 at video memory address 810a.

[0207] S5, the client-side video memory management process notifies the management program-side video memory management process of the new video memory address (fourth video memory address) in the first client 810.

[0208] S6, the video memory management process on the management program side establishes the mapping relationship between the third video memory address and the fourth video memory address 820b.

[0209] According to the scheme shown in the embodiments of this application, when the management program allocates new video memory to the first client, the management program and the first client can interact to unlock the address of the newly allocated video memory in the first client. Furthermore, a mapping relationship is established in the management program between the address of the newly allocated video memory in the first client and the address of the newly allocated video memory in the management program, so that the first client can accurately access this part of the newly allocated video memory through the management program, ensuring the accuracy of subsequent video memory access.

[0210] Based on the solutions shown in the above embodiments, in one possible implementation, the management program maintains a mapping relationship between the client and the address of the video memory allocated to the client in the management program; the above method further includes: establishing a mapping relationship between the first client and the third video memory address through the management program.

[0211] Regarding the issue that different video memory may correspond to the same address in different client machines, in this embodiment of the application, after the management program adds the second video memory in the video memory pool to the first client machine, it is necessary to establish a mapping relationship between the first client machine and the third video memory address to avoid errors in subsequent tasks of the first client machine calling the physical GPU to access video memory.

[0212] Based on the solutions shown in the above embodiments, in one possible implementation, step 220b1 can be implemented as follows: If the video memory allocated to the first client does not meet the swapping conditions, a second video memory management request is sent from the first client to the management program. The swapping conditions include the following:

[0213] The video memory allocated to the first client does not contain swappable video memory; swappable video memory is already occupied and can be replaced via system memory; or,

[0214] The video memory allocated to the first client includes swappable video memory, and the sum of the capacity of the swappable video memory and the capacity of the first remaining video memory is less than the second video memory capacity threshold.

[0215] In this embodiment, different applications or processes can run in the first client machine, and the requirements of different applications or processes for video memory and system memory may also be different. For example, some applications or processes can only use video memory, some applications or processes can use both video memory and system memory, and some applications or processes can only use system memory. When the video memory occupancy rate in the first client machine is high and the video memory is insufficient, the first client machine can first consider swapping the occupied video memory through the system memory managed by the first operating system, thereby releasing a portion of the video memory within the first client machine. Specifically, for some applications or processes that can use both video memory and system memory, when the application or process occupies video memory, if the remaining video memory of the first client machine is insufficient, and a large amount of video memory can be released after swapping out the video memory occupied by the application or process through system memory, then it is not necessary to request new video memory from the management program (that is, to send a second video memory management request to the management program), thus avoiding frequent requests for new video memory and ensuring the accuracy of video memory allocation. Conversely, if an application or process that can use both video memory and system memory is not currently using video memory, or is only using a small amount of video memory, it needs to request new video memory from the management program.

[0216] Based on the solutions shown in the above embodiments, in one possible implementation, the method further includes: when the video memory in the video memory pool is insufficient, sending a video memory reclamation request to a second client through a management program; the second client is any client running on the computer device other than the first client; through the second client, sending a third video memory management request to the management program according to the video memory reclamation request, the third video memory management request containing a fifth video memory address; the fifth video memory address is all or part of the address of the second remaining video memory of the second client; and adding the third video memory corresponding to the fifth video memory address to the video memory pool through the management program.

[0217] In one possible implementation, the second remaining video memory is the unused video memory allocated to the second client.

[0218] In this embodiment, when the video memory in the video memory pool is insufficient, the management program can also actively reclaim the video memory with low utilization rate from each client, thereby improving the success rate of allocating new video memory to the first client and ensuring the effect of dynamic video memory allocation.

[0219] For example, when the video memory pool is insufficient, the management program can send a video memory reclamation request to other clients besides the first client. This video memory reclamation request can trigger other clients to request the release of their unused video memory. The way other clients request the release of their unused video memory is similar to the way the first client actively requests the release of its unused first video memory, and will not be described in detail here.

[0220] Correspondingly, if the second client successfully releases its video memory to the management program and there is sufficient video memory in the video memory pool, the management program can allocate the second video memory to the first client.

[0221] The second client mentioned above refers to any client running on the computer device that, besides the first client, has a allocated video memory capacity greater than the third video memory capacity threshold. In other words, during the process of allocating video memory to the first client, if the video memory pool is insufficient, it can request the reclamation of video memory from other clients that have already been allocated a significant amount (also known as over-allocated video memory). Clients with over-allocated video memory have a higher probability of releasing their allocated video memory. Therefore, this scheme can improve the success rate of reclaiming video memory from other clients, thereby ensuring the efficiency of dynamic video memory management.

[0222] Optionally, the step of sending a video memory reclamation request to the second client through the management program when the video memory pool is insufficient can also be executed independently by the management program. That is, regardless of whether any client requests the allocation of new video memory, as long as the management program detects that the video memory pool is insufficient (the video memory capacity in the pool is below a certain threshold), the management program can send the aforementioned video memory reclamation request to each client separately. In this case, the aforementioned second client can be a client running in the computer device whose allocated video memory capacity is greater than the third video memory capacity threshold.

[0223] Based on the solutions shown in the above embodiments, in one possible implementation, the process of sending a third video memory management request to the management program through the second client according to the video memory reclamation request may include:

[0224] If the capacity of the second remaining video memory is greater than the third video memory capacity threshold, the second client sends a third video memory management request to the management program based on the video memory reclamation request.

[0225] In this embodiment of the application, after the second client receives the video memory reclamation request, if its remaining video memory capacity is sufficient, it can directly send a third video memory management request to the management program, thereby releasing the video memory while ensuring that its own video memory usage is not affected, thus achieving a balance between the dynamic allocation effect of the client's video memory and the client's operating efficiency.

[0226] Based on the solutions shown in the above embodiments, in one possible implementation, the method further includes: when the capacity of the second remaining video memory is not greater than the third video memory capacity threshold, querying the capacity of the swappable video memory in the video memory of the second client through the second client; the swappable video memory is video memory that has been occupied and can be replaced by system memory; when the sum of the capacity of the swappable video memory in the video memory of the second client and the capacity of the second remaining video memory is greater than the third video memory capacity threshold, replacing the swappable video memory in the video memory of the second client through system memory.

[0227] In this embodiment, after receiving a video memory reclamation request, if the second client has insufficient remaining video memory, it can attempt to replace the swappable cache locally using system memory. Optionally, if the second client has sufficient remaining video memory after replacing the swappable video memory, it can send a third video memory management request to the management program; conversely, if the second client still has insufficient remaining video memory after replacing the swappable video memory, it can send a reclamation failure response to the management program.

[0228] According to the scheme shown in the embodiments of this application, after the second client receives a video memory reclamation request, if its remaining video memory capacity is insufficient, it can attempt to perform memory swapping, that is, swap the occupied video memory with the system memory, thereby improving the success rate of video memory release while ensuring that its own video memory usage is not affected, and thus improving the effect of dynamic video memory management.

[0229] The solutions described in the above embodiments of this application provide a dynamic memory management scheme for GPU virtualization scenarios. For example, when some vGPUs are idle, these vGPUs (a) can "lend" their allocated memory back to the Hypervisor. The Hypervisor can then allocate this memory to the more heavily loaded vGPU (b). When the load on vGPU (a) increases and it requires more memory, the Hypervisor reclaims memory from vGPU (b) and "returns" it to vGPU (a) to meet its memory needs. This approach fully utilizes hardware resources while ensuring fairness in the use of vGPU resources.

[0230] Unlike methods that allocate and fix video memory during vGPU creation, the method described in this application allows vGPUs to dynamically adjust their video memory during runtime. When a vGPU is idle, unused video memory is "lent" to the hypervisor. When a vGPU is busy and the hypervisor has spare video memory, the vGPU can utilize more video memory than necessary. This fully utilizes hardware resources while preventing the computing units within the GPU from using system memory, thus avoiding impacting its computational performance.

[0231] For example, the above scheme may include the following steps:

[0232] Step 1: When creating a vGPU, you can specify three parameters: minimum video memory (SizeA), default video memory (SizeB), and maximum video memory (SizeC). These values ​​increase sequentially. By default, the vGPU can use only SizeB of video memory. When the vGPU is lightly loaded, try reducing its available video memory to SizeA. When the vGPU is heavily loaded, try increasing its available video memory to SizeC.

[0233] Step 2: When it is necessary to reduce the available video memory (SizeB->SizeA), the driver running in the Guest tries to request video memory (its size is SizeB-SizeA). If it can be requested, the driver will keep this part of the video memory to ensure that this part of the video memory will not be allocated to other applications. Then the driver notifies the Hypervisor of the address of this part of the video memory for it to reclaim.

[0234] Step 3: When more available video memory is needed (SizeB->SizeC), the driver running in the Guest (corresponding to the video memory management process on the client side mentioned above) sends a message to the Hypervisor to query the remaining video memory. If the Hypervisor has enough video memory, it informs the Guest driver of the address of this video memory for its use.

[0235] Step 4: The Hypervisor periodically checks the Guest's load. If it needs to forcibly reclaim video memory from the Guest (the Guest is using more video memory than SizeB), the Hypervisor sends a forced reclamation request to the Guest. The Guest driver will then attempt to allocate system memory and migrate / swap the excess video memory to system memory to free up video memory resources.

[0236] Based on the solutions shown in the above embodiments, please refer to Figure 9, which illustrates a framework diagram of video memory management according to an embodiment of this application. As shown in Figure 9, a management program 910, a client 920, and a client 930 run in the host. Clients 920 and 930 each have a vGPU, and both are allocated video memory. The video memory capacity has three types, from smallest to largest: SizeA, SizeB, and SizeC. Taking a client 920 initiating a video memory management request as an example, the video memory management process involved in this application can be as follows:

[0237] S1, the client 920 determines to initiate video memory management based on the relationship between the remaining video memory capacity and the video memory capacity threshold in the currently allocated video memory, and requests the management program 910 to release or allocate video memory.

[0238] For example, if the client 920 is allocated video memory of SizeB or SizeC, and the remaining video memory capacity is greater than the first video memory capacity threshold, the client 920 can request the hypervisor 910 to release the video memory.

[0239] For example, if the client 920 is allocated video memory of Size A or Size B, and the remaining video memory capacity is less than the second video memory capacity threshold, the client 920 can request video memory allocation from the management program 910.

[0240] S2, the management program 910, upon request from the client 920, releases a portion of the video memory allocated to the client 920, or allocates new video memory to the client 920.

[0241] For example, when client 920 requests the hypervisor 910 to release video memory, the hypervisor 910 releases a portion of the video memory of client 920 into video memory pool 910a.

[0242] For example, when client 920 requests video memory allocation from management program 910, management program 910 can allocate a portion of the video memory in video memory pool 910a to client 920.

[0243] S3, when the video memory in the video memory pool 910a is insufficient, the management program 910 sends a video memory reclamation request to the client 930 to request the client 930 to release the video memory.

[0244] S4, Client 930 determines whether to release video memory to the video memory pool based on the current usage of the allocated video memory.

[0245] For example, if the client 930 is allocated a video memory capacity of SizeB or SizeC, and there is sufficient remaining video memory, then the video memory can be directly released to the video memory pool.

[0246] For example, if the client 930 is allocated a video memory capacity of SizeB or SizeC, and the remaining video memory capacity is insufficient, it can try to swap out the video memory from the main memory. If the remaining video memory capacity is sufficient after the swap, it can be released to the video memory pool. If the remaining video memory capacity is still insufficient after the swap, it can refuse to release the video memory.

[0247] For example, if the client 930 is allocated a video memory capacity of SizeA, then the video memory can be refused to be released directly.

[0248] The execution processes of the aforementioned client and management program sides are shown in Figures 10 to 12, respectively.

[0249] Please refer to Figure 10, which shows the framework diagram of client-initiated request for video memory management involved in this application. As shown in Figure 10, the process of the client actively requesting the release or allocation of video memory can be as follows:

[0250] S1001, Statistics on client machine video memory usage.

[0251] For example, the client-side video memory management process in the client can obtain the remaining video memory capacity allocated to the client. When the remaining video memory capacity is greater than a certain threshold (the aforementioned first video memory capacity threshold), it proceeds to step S1002. When the remaining video memory capacity is less than a certain threshold (the aforementioned second video memory capacity threshold), it proceeds to step S1006.

[0252] S1002 requests video memory from the operating system in the client machine.

[0253] The client-side video memory management process can request video memory to be released from the operating system in the client. If not enough video memory is requested, proceed to step S1002; otherwise, proceed to step S1003.

[0254] S1003, request the operating system to lock the allocated video memory. If the lock is successful, proceed to step S1004; otherwise, proceed to step S1005.

[0255] S1004 sends the address information of the acquired video memory to the management program in the host.

[0256] For example, the client-side video memory management process can send a first video memory management request containing a first video memory address (logical address) to the management program to request the release of the video memory corresponding to the first video memory address, and return to step S1001.

[0257] S1005, release the allocated video memory and return to step S1001.

[0258] The client-side video memory management process can return previously allocated video memory to the primary operating system within the client machine.

[0259] S1006, determine whether the exchange condition is met.

[0260] The client-side video memory management process can determine whether the occupied video memory can be swapped out from system memory, and whether the remaining video memory after the swap is still less than the second video memory capacity threshold. If yes, proceed to step S1007; otherwise, return to step S1001.

[0261] S1007 requests new video memory from the management program in the host.

[0262] The client-side video memory management process can send a second video memory management request to the management program. If a response indicating successful allocation is received from the management program, proceed to step S1008; otherwise, return to step S1001.

[0263] S1008: Based on the information returned by the management program, locate the previously locked video memory address (logical address).

[0264] S1009 releases the locked video memory address to the operating system, allowing the operating system to allocate this part of the video memory address to applications or processes in the guest machine.

[0265] Optionally, the client-side video memory management process can also notify the management program of the released video memory addresses, so that the management program can establish a mapping relationship between the released video memory addresses and the physical addresses of the newly allocated video memory to the client.

[0266] Please refer to Figure 11, which shows a framework diagram of the management program performing video memory management according to this application. As shown in Figure 11, the process by which the management program releases or allocates video memory according to the client's request is as follows:

[0267] S1101 receives the client's video memory management request.

[0268] S1102, Upon receiving a request to release video memory, proceed to step S1103.

[0269] S1103, based on the address information (logical address) in the request, query the corresponding physical address.

[0270] S1104, cancel the mapping relationship between this part of the logical address and the physical address.

[0271] S1105 saves the queried physical address to the video memory pool.

[0272] S1106, complete the video memory release and return to step S1101.

[0273] S1107, A request to allocate video memory is received, proceed to step S1108.

[0274] S1108, determine if there is enough video memory in the video memory pool. If yes, proceed to step S1109; otherwise, proceed to step S1113.

[0275] S1109: Search for video memory in the video memory pool that meets the allocated capacity.

[0276] S1110 maps the video memory found in the video memory pool to the client machine.

[0277] For example, the management program in the host establishes a mapping relationship between the physical address of this part of the video memory and the client.

[0278] S1111 synchronizes the mapped information to the client.

[0279] For example, the management program in the host machine notifies the client machine of the allocation request for this part of the video memory so that the client machine knows that it has been allocated new video memory.

[0280] S1112, video memory allocation complete, return to step S1101.

[0281] S1113, Locate client machines on the host that are using excessive video memory.

[0282] For example, the management program can query the host for clients with allocated video memory of SizeC (e.g., client 930).

[0283] S1114, send a video memory reclamation request to the queried client and return to step S1101.

[0284] Please refer to Figure 12, which shows a framework diagram of the client releasing video memory according to the request of the management program, as described in this application. As shown in Figure 12, the process of the client releasing video memory according to the request of the management program can be as follows:

[0285] S1201, Receive messages from the management program.

[0286] S1202: Upon receiving a video memory reclamation request from the management program, if there is sufficient remaining video memory, proceed to S1203; otherwise, proceed to S1204.

[0287] S1203, release video memory to the video memory pool. This execution process can be referred to as steps S1002 to S1005 in Figure 10.

[0288] S1204 attempts to replace the occupied video memory with system memory.

[0289] The client machine can attempt to replace the occupied video memory with system memory, so that the remaining video memory meets the conditions for release. If the replacement is successful and the remaining video memory meets the conditions for release after replacement, then proceed to step S1203; otherwise, proceed to step S1205.

[0290] S1205 sends a response indicating recycling failure to the management program in the host.

[0291] The above solution enables time-sharing utilization of GPU resources across different client machines (vGPUs), effectively utilizing video memory resources when different clients are running different loads simultaneously. Specifically, by dynamically adjusting the video memory of each client machine, resource utilization can be effectively improved, reducing the Total Cost of Ownership (TCO). Furthermore, when multiple clients are running different loads, clients with heavier loads can achieve better performance. Additionally, adjusting video memory based on client load can prevent performance loss for individual clients.

[0292] Please refer to Figure 13, which shows a block diagram of a video memory management device provided in an exemplary embodiment of this application. This video memory management device can implement all or part of the steps described in the various method embodiments above. As shown in Figure 13, the video memory management device may include:

[0293] The remaining video memory acquisition module 1301 is used to acquire the first remaining video memory of a first client in a computer device; the computer device runs a management program and one or more clients; each client is allocated a portion of the video memory in the physical GPU of the computer device as the video memory of the virtual GPU in the client; the first client is one of the one or more clients; the first remaining video memory is the unused video memory allocated to the first client.

[0294] The video memory allocation module 1302 is used to adjust the video memory capacity of the first client machine according to the capacity of the first remaining video memory and the video memory capacity threshold.

[0295] In one possible implementation, the video memory allocation module 1302 is used for,

[0296] If the capacity of the first remaining video memory is greater than the first video memory capacity threshold, a portion of the video memory is reclaimed from the video memory allocated to the first client.

[0297] If the capacity of the first remaining video memory is less than the second video memory capacity threshold, additional video memory is allocated to the first client machine.

[0298] Wherein, the first video memory capacity threshold is greater than the second video memory capacity threshold.

[0299] In one possible implementation, the video memory allocation module 1302 is used for,

[0300] When the capacity of the first remaining video memory is greater than the first video memory capacity threshold, the first client sends a first video memory management request to the management program. The first video memory management request contains a first video memory address. The first video memory address is all or part of the address of the first remaining video memory.

[0301] The management program adds the first video memory corresponding to the first video memory address to the video memory pool, which is used to store video memory that has not been allocated to the client.

[0302] In one possible implementation, the device further includes:

[0303] The address locking module is used to lock the first video memory address through the first client before the video memory allocation module 1302 sends the first video memory management request to the management program through the first client, when the capacity of the first remaining video memory is greater than the first video memory capacity threshold; the video memory address locked by the first client is a video memory address that the program or process in the first client is prohibited from accessing.

[0304] The video memory allocation module 1302 is used to send the first video memory management request to the management program through the first client when the first video memory address is successfully locked.

[0305] In one possible implementation, the video memory allocation module 1302 is used for,

[0306] The management program queries the second video memory address based on the first video memory address; the second video memory address is the address of the first video memory in the management program.

[0307] The management program adds the second video memory address to the video memory pool.

[0308] In one possible implementation, the management program maintains a mapping relationship between the client and the address assigned to the client that is explicitly stored in the management program; the apparatus further includes:

[0309] The mapping cancellation module is used to cancel the mapping relationship between the first client and the second video memory address through the management program.

[0310] In one possible implementation, the video memory allocation module 1302 is used for,

[0311] If the capacity of the first remaining video memory is less than the second video memory capacity threshold, the first client sends a second video memory management request to the management program.

[0312] The management program allocates a second memory from the memory pool to the first client machine according to the second memory management request. The memory pool is used to store memory that has not been allocated to the client machine.

[0313] In one possible implementation, the video memory allocation module 1302 is used to send a second video memory management request to the management program through the first client when the video memory allocated to the first client does not meet the swapping conditions.

[0314] The exchange conditions include the following:

[0315] The video memory allocated to the first client does not contain swappable video memory; the swappable video memory is already occupied and can be replaced via system memory; or,

[0316] The video memory allocated to the first client includes swappable video memory, and the sum of the capacity of the swappable video memory and the capacity of the first remaining video memory is less than the second video memory capacity threshold.

[0317] In one possible implementation, the video memory allocation module 1302 is used for,

[0318] When there is sufficient video memory in the video memory pool, the third video memory address is removed from the video memory pool by the management program; the third video memory address is the address of the second video memory in the management program.

[0319] The management program sends a video memory management response to the first client, the video memory management response being used to indicate that the first client has been allocated the second video memory;

[0320] The fourth video memory address is unlocked by the first client according to the video memory management response; the fourth video memory address is the address of the second video memory in the first client.

[0321] The fourth video memory address is sent to the management program through the first client.

[0322] The management program establishes a mapping relationship between the third video memory address and the fourth video memory address.

[0323] In one possible implementation, the management program maintains a mapping relationship between the client and the address assigned to the client that is explicitly stored in the management program; the apparatus further includes:

[0324] The mapping relationship establishment module is used to establish a mapping relationship between the first client and the third video memory address through the management program.

[0325] In one possible implementation, the device further includes:

[0326] The video memory reclamation module is used to send a video memory reclamation request to a second client through the management program when the video memory in the video memory pool is insufficient; the second client is another client running on the computer device besides the first client.

[0327] The video memory allocation module 1302 is further configured to send a third video memory management request to the management program through the second client according to the video memory reclamation request, wherein the third video memory management request includes a fifth video memory address; the fifth video memory address is all or part of the address of the second remaining video memory of the second client; and the management program adds the third video memory corresponding to the fifth video memory address to the video memory pool.

[0328] In one possible implementation, the video memory allocation module 1302 is used to send a third video memory management request to the management program through the second client, based on the video memory reclamation request, when the capacity of the second remaining video memory is greater than the third video memory capacity threshold.

[0329] In one possible implementation, the video memory allocation module 1302 is further configured to:

[0330] If the capacity of the second remaining video memory is not greater than the third video memory capacity threshold, the second client queries the capacity of the swappable video memory in the video memory of the second client; the swappable video memory is video memory that has been occupied and can be replaced by system memory.

[0331] If the sum of the capacity of the swappable video memory in the second client's video memory and the capacity of the second remaining video memory is greater than the third video memory capacity threshold, the swappable video memory in the second client's video memory is replaced by system memory.

[0332] In one possible implementation, the video memory allocation module 1302 is used to reclaim a portion of the video memory allocated to the first client when the capacity of the first remaining video memory is greater than the first video memory capacity threshold and the capacity of the video memory allocated to the first client is greater than the lower limit of the video memory capacity.

[0333] In one possible implementation, the video memory allocation module 1302 is used to allocate new video memory to the first client when the capacity of the first remaining video memory is less than the second video memory capacity threshold and the video memory capacity allocated to the first client is less than the upper limit of video memory capacity.

[0334] Please refer to Figure 14, which is a schematic diagram of the structure of a computer device provided in an exemplary embodiment of this application. The computer device 1400 includes a Central Processing Unit (CPU) 1401, a system memory 1404 including Random Access Memory (RAM) 1402 and Read-Only Memory (ROM) 1403, and a system bus 1405 connecting the system memory 1404 and the CPU 1401. The computer device 1400 also includes a Basic Input / Output System (I / O System) 1406 that facilitates information transfer between various devices within the computer, and a mass storage device 1407 for storing the operating system 1413, application programs 1414, and other program modules 1415.

[0335] The basic input / output system 1406 includes a display 1408 for displaying information and an input device 1409 for user input, such as a mouse or keyboard. Both the display 1408 and the input device 1409 are connected to the central processing unit 1401 via an input / output controller 1410 connected to the system bus 1405. The basic input / output system 1406 may also include the input / output controller 1410 for receiving and processing input from multiple other devices such as a keyboard, mouse, or electronic stylus. Similarly, the input / output controller 1410 also provides output to a display screen, printer, or other types of output devices.

[0336] The mass storage device 1407 is connected to the central processing unit 1401 via a mass storage controller (not shown) connected to the system bus 1405. The mass storage device 1407 and its associated computer-readable media provide non-volatile storage for the computer device 1400. That is, the mass storage device 1407 may include computer-readable media (not shown) such as a hard disk or a CD-ROM (Compact Disc Read-Only Memory) drive.

[0337] Without loss of generality, the computer-readable medium may include computer storage media and communication media. Computer storage media include volatile and non-volatile, removable and non-removable media implemented using any method or technology for storing information such as computer-readable instructions, data structures, program modules, or other data. Computer storage media include RAM (Random Access Memory), ROM (Read-Only Memory), EPROM (Erasable Programmable Read-Only Memory), EEPROM (Electrically Erasable Programmable Read-Only Memory), flash memory or other solid-state storage technologies, CD-ROM, DVD (Digital Video Disc) or other optical storage, magnetic tape cassettes, magnetic tape, disk storage, or other magnetic storage devices. Of course, those skilled in the art will recognize that the computer storage media are not limited to the above-mentioned types. The system memory 1404 and mass storage device 1407 described above can be collectively referred to as memory.

[0338] Computer device 1400 can be connected to the Internet or other network devices via network interface unit 1411 connected to the system bus 1405.

[0339] The memory also includes one or more programs / instructions, which are stored in the memory. The central processing unit 1401 executes the one or more programs / instructions to implement all or part of the steps in the methods shown in the above embodiments of this application.

[0340] In an exemplary embodiment, a computer program product is also provided, comprising computer instructions stored in a computer-readable storage medium. A processor of a computer device reads and executes the computer instructions from the computer-readable storage medium to implement all or part of the steps of the methods shown in the above embodiments of this application.

[0341] In an exemplary embodiment, a computer-readable storage medium is also provided, which stores instructions that are loaded and executed by a processor to implement all or part of the steps of the methods shown in the above embodiments of this application.

[0342] In an exemplary embodiment, a chip is also provided, which includes programmable logic circuitry and / or program instructions, which, when the chip is run, are used to implement all or part of the steps of the methods shown in the above embodiments of this application.

Claims

1. A video memory management method, wherein, The method is performed by a computer device running one or more client machines; each client machine is allocated a portion of the video memory of the physical graphics processor (GPU) of the computer device as the video memory of a virtual GPU in the client machine. The method includes: Obtain the first remaining video memory of the first client; the first client is one of one or more clients; the first remaining video memory is the unused video memory allocated to the first client; The capacity of the first client's video memory is adjusted based on the capacity of the first remaining video memory and the video memory capacity threshold.

2. The method according to claim 1, wherein, The step of adjusting the video memory capacity of the first client machine based on the capacity of the first remaining video memory and the video memory capacity threshold includes: If the capacity of the first remaining video memory is greater than the first video memory capacity threshold, a portion of the video memory is reclaimed from the video memory allocated to the first client. If the capacity of the first remaining video memory is less than the second video memory capacity threshold, additional video memory is allocated to the first client machine. Wherein, the first video memory capacity threshold is greater than the second video memory capacity threshold.

3. The method according to claim 2, wherein, The computer device also runs a management program, wherein the step of reclaiming a portion of the video memory allocated to the first client machine when the capacity of the first remaining video memory is greater than the first video memory capacity threshold includes: If the capacity of the first remaining video memory is greater than the first video memory capacity threshold, the first client sends a first video memory management request to the management program. The first video memory management request contains a first video memory address. The first video memory address is all or part of the address of the first remaining video memory. The management program adds the first video memory corresponding to the first video memory address to the video memory pool, which is used to store video memory that has not been allocated to the client.

4. The method according to claim 3, wherein, Before sending the first video memory management request to the management program through the first client, the process also includes: If the capacity of the first remaining video memory is greater than the first video memory capacity threshold, the first video memory address is locked by the first client; the video memory address locked by the first client is a video memory address that is prohibited from being accessed by the program or process in the first client. The step of sending the first video memory management request to the management program through the first client includes: If the first video memory address is successfully locked, the first video memory management request is sent to the management program through the first client.

5. The method according to claim 3, wherein, The first video memory address is the address of the first video memory in the first client machine. The step of adding the first video memory corresponding to the first video memory address to the video memory pool through the management program includes: The management program queries the second video memory address based on the first video memory address; the second video memory address is the address of the first video memory in the management program. The management program adds the second video memory address to the video memory pool.

6. The method according to claim 2, wherein, The computer device also runs a management program, wherein when the capacity of the first remaining video memory is less than the second video memory capacity threshold, allocating new video memory to the first client includes: If the capacity of the first remaining video memory is less than the second video memory capacity threshold, the first client sends a second video memory management request to the management program. The management program allocates a second memory from the memory pool to the first client machine according to the second memory management request. The memory pool is used to store memory that has not been allocated to the client machine.

7. The method according to claim 6, wherein, The step of sending a second video memory management request to the management program through the first client includes: If the video memory allocated to the first client does not meet the swapping conditions, the first client sends a second video memory management request to the management program. The exchange conditions include the following: The video memory allocated to the first client does not contain swappable video memory; the swappable video memory is already occupied and can be replaced via system memory; or, The video memory allocated to the first client includes swappable video memory, and the sum of the capacity of the swappable video memory and the capacity of the first remaining video memory is less than the second video memory capacity threshold.

8. The method according to claim 6, wherein, The step of allocating the second video memory in the video memory pool to the first client machine according to the second video memory management request through the management program includes: When there is sufficient video memory in the video memory pool, the management program removes the third video memory address from the video memory pool; the third video memory address is the address of the second video memory in the management program. The management program sends a video memory management response to the first client, the video memory management response being used to indicate that the first client has been allocated the second video memory; The fourth video memory address is unlocked by the first client according to the video memory management response; the fourth video memory address is the address of the second video memory in the first client. The fourth video memory address is sent to the management program through the first client. The management program establishes a mapping relationship between the third video memory address and the fourth video memory address.

9. The method according to claim 6, wherein, The method further includes: If the video memory in the video memory pool is insufficient, the management program sends a video memory reclamation request to the second client; the second client is any client running on the computer device other than the first client. The second client sends a third video memory management request to the management program according to the video memory reclamation request. The third video memory management request contains a fifth video memory address. The fifth video memory address is all or part of the address of the second remaining video memory of the second client. The management program adds the third video memory corresponding to the fifth video memory address to the video memory pool.

10. The method according to claim 9, wherein, The step of sending a third video memory management request to the management program through the second client according to the video memory reclamation request includes: If the capacity of the second remaining video memory is greater than the third video memory capacity threshold, the second client sends a third video memory management request to the management program according to the video memory reclamation request.

11. The method according to claim 10, wherein, The method further includes: If the capacity of the second remaining video memory is not greater than the third video memory capacity threshold, the second client queries the capacity of the swappable video memory in the video memory of the second client; the swappable video memory is video memory that has been occupied and can be replaced by system memory. If the sum of the capacity of the swappable video memory in the second client's video memory and the capacity of the second remaining video memory is greater than the third video memory capacity threshold, the swappable video memory in the second client's video memory is replaced by system memory.

12. The method according to any one of claims 2 to 10, wherein, The step of reclaiming a portion of the video memory allocated to the first client machine when the capacity of the first remaining video memory is greater than the first video memory capacity threshold includes: If the capacity of the first remaining video memory is greater than the first video memory capacity threshold, and the capacity of the video memory allocated to the first client is greater than the lower limit of the video memory capacity, a portion of the video memory is reclaimed from the video memory allocated to the first client.

13. The method according to any one of claims 2 to 10, wherein, The step of allocating additional video memory to the first client machine when the capacity of the first remaining video memory is less than the second video memory capacity threshold includes: If the capacity of the first remaining video memory is less than the second video memory capacity threshold, and the video memory capacity allocated to the first client is less than the upper limit of video memory capacity, then additional video memory is allocated to the first client.

14. A video memory management device, wherein, The device includes: A remaining video memory acquisition module is used to acquire the first remaining video memory of a first client in a computer device; the computer device is running one or more clients; each client is allocated a portion of the video memory in the physical GPU of the computer device as the video memory of the virtual GPU in the client; the first client is one of the one or more clients; the first remaining video memory is the unused video memory allocated to the first client; The video memory allocation module is used to adjust the video memory capacity of the first client machine based on the capacity of the first remaining video memory and the video memory capacity threshold.

15. A computer device, wherein, The computer device includes a processor and a memory, the memory storing instructions which are executed by the processor to implement the video memory management method as described in any one of claims 1 to 13.

16. A computer-readable storage medium, wherein, The storage medium stores instructions that are executed by the processor of a computer device to implement the video memory management method as described in any one of claims 1 to 13.

17. A computer program product, wherein, The computer program product includes computer instructions stored in a computer-readable storage medium; the computer instructions are read and executed by a processor of a computer device to implement the video memory management method as described in any one of claims 1 to 13.

18. A chip, wherein, The chip includes programmable logic circuits and / or program instructions, which, when the chip is running, are used to implement the video memory management method as described in any one of claims 1 to 13.