Virtualization method and device of graphics processing unit (GPU) in container, equipment and storage medium

By monitoring the container's call commands to the GPU in GPU container virtualization and dynamically allocating GPU resources, the problem in the existing technology that it is difficult to meet the dynamic allocation of GPU memory and computing resources is solved, and flexible management and efficient utilization of resources are achieved.

CN119597404AActive Publication Date: 2025-03-11CHINA TELECOM CLOUD TECH CO LTD
View PDF 5 Cites 0 Cited by

Patent Information

Application Number
CN202411715390.0
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-11-27
Publication Date
2025-03-11
Estimated Expiration
2044-11-27

AI Technical Summary

Technical Problem

Existing GPU container virtualization technology is difficult to meet the user needs of dynamic allocation and adjustment of GPU video memory and computing resources.

Method used

By activating the monitoring thread when a GPU resource request is detected, monitoring the container's call command to the GPU, determining the GPU computing resources and video memory capacity, and allocating resources to the container through the GPU driver when the container's video memory quota is met.

Benefits of technology

It realizes flexible management of GPU video memory capacity and computing resources, improves the utilization rate of GPU resources, and reduces resource waste.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119597404A_ABST
    Figure CN119597404A_ABST
Patent Text Reader

Abstract

A virtualization method, apparatus and device for a graphics processing unit (GPU) in a container, and a storage medium, the method comprising: activating a monitoring thread corresponding to a first container when a GPU resource request submitted through the first container is detected; under the condition that the starting operation for the application program in the first container is detected, monitoring a calling command of the first container for the first GPU through the monitoring thread; determining a first GPU computing power resource and a first GPU video memory capacity based on the calling command; when it is determined that the first GPU video memory capacity is smaller than or equal to the video memory quota corresponding to the first container, the first GPU computing power resource and the first GPU video memory capacity are sent to a driver corresponding to the first GPU; and allocating a first GPU computing power resource and a first GPU video memory capacity to the first container through the drive corresponding to the first GPU. In this way, the GPU computing power resource and the GPU video memory capacity can be flexibly managed.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a method, device, equipment and storage medium for virtualizing a graphics processing unit (GPU) in a container. Background Art

[0002] With the rapid development of fields such as artificial intelligence and machine learning, the demand for graphics processing unit (GPU) computing power is growing exponentially. This demand has driven the development of GPU container virtualization technology to utilize hardware resources more efficiently. Among them, GPU container virtualization technology encapsulates GPU resources through containers to achieve resource sharing and isolation. Compared with traditional virtualization technology, GPU container virtualization technology has higher performance and flexibility. It supports multi-user isolation scheduling strategies to achieve reasonable allocation of computing power. However, the GPU container virtualization method is difficult to fully meet the needs of users who need to dynamically allocate and adjust GPU video memory and computing power resources.

[0003] Therefore, how to achieve flexible management of GPU memory capacity and computing power resources has become an urgent problem to be solved. Summary of the invention

[0004] The embodiments of the present application provide a method, apparatus, device and storage medium for virtualizing a graphics processing unit (GPU) in a container, which can flexibly manage GPU memory capacity and computing power resources.

[0005] In a first aspect, an embodiment of the present application provides a method for virtualizing a graphics processor (GPU) in a container, the method comprising:

[0006] When a GPU resource request submitted through the first container is detected, a monitoring thread corresponding to the first container is activated; the GPU resource request includes the first GPU computing power resource and the first GPU memory capacity of the applied first GPU;

[0007] In the case of detecting a startup operation for an application in the first container, monitoring a call command of the first container for the first GPU through a monitoring thread; the call command is determined by the first container based on a GPU resource request; and the call command is used to call a first GPU computing power resource and a first GPU video memory capacity of the first GPU;

[0008] Based on the calling command, determine the first GPU computing power resources and the first GPU video memory capacity;

[0009] When it is determined that the video memory capacity of the first GPU is less than or equal to the video memory quota corresponding to the first container, the first GPU computing power resource and the video memory capacity of the first GPU are sent to a driver corresponding to the first GPU;

[0010] The first GPU computing resources and the first GPU memory capacity are allocated to the first container through the driver corresponding to the first GPU.

[0011] In one of the embodiments, the method further includes: determining the first GPU corresponding to the first container and the second GPU corresponding to the second container when it is determined that the GPU video memory capacity of the first GPU called by the first container is less than or equal to the video memory quota corresponding to the first container, and the second GPU video memory capacity of the second GPU called by the second container is less than or equal to the video memory quota corresponding to the second container; determining the target GPU computing power resources based on the first GPU computing power resources and the second GPU computing power resources called by the second container when it is determined that the first GPU and the second GPU are the same; and determining the target GPU video memory capacity based on the first GPU video memory capacity and the second GPU video memory capacity; sending the target GPU computing power resources and the target GPU video memory capacity to the driver corresponding to the first GPU or the second GPU; and allocating the target GPU computing power resources and the target GPU video memory capacity to the first container and the second container through the driver corresponding to the first GPU or the second GPU.

[0012] In one of the embodiments, the method further includes: when it is determined that the first GPU and the second GPU are different, sending the first GPU computing power resources and the first GPU video memory capacity to the driver of the first GPU, and sending the second GPU computing power resources and the second GPU video memory capacity to the driver of the second GPU; allocating the first GPU computing power resources and the first GPU video memory capacity to the first container through the driver of the first GPU, and allocating the second GPU computing power resources and the second GPU video memory capacity to the second container through the driver of the second GPU.

[0013] In one of the embodiments, the method also includes: performing time slicing processing on the computing tasks in the first container and the computing tasks in the second container respectively, to obtain multiple first time slice tasks corresponding to the first container, and multiple second time slice tasks corresponding to the second container; when it is determined that the first GPU and the second GPU are the same, based on the first GPU computing power resources and the second GPU computing power resources, the multiple first time slice tasks and the multiple second time slice tasks are re-arranged to obtain multiple time slice tasks after arrangement; wherein the time slice ratios of the multiple first time slice tasks and the multiple second time slice tasks are respectively the same as the ratio of the GPU computing power resources called by each container; and sending the multiple time slice tasks after arrangement to the driver of the first GPU or the second GPU, so that the driver of the first GPU or the second GPU executes the multiple time slice tasks after arrangement.

[0014] In one embodiment, the method further includes: when determining that the first GPU and the second GPU are different, sending multiple first time slice tasks to the driver of the first GPU so that the driver of the first GPU executes the multiple first time slice tasks, and sending multiple second time slice tasks to the driver of the second GPU so that the driver of the second GPU executes the multiple second time slice tasks.

[0015] In one of the embodiments, the GPU resource request also includes instruction information for obtaining additional GPU resources; the method also includes: monitoring the usage information of GPU computing power resources and GPU video memory capacity corresponding to the first container through a monitoring thread; when it is determined that the GPU resources required for the first container exceed the GPU resources applied for by the first container, and it is determined that there are idle GPU resources in the GPU, allocating additional GPU resources to the first container; GPU resources include GPU computing power resources and GPU video memory capacity.

[0016] In a second aspect, the present application provides a virtualization device for a graphics processor GPU in a container, the device comprising:

[0017] A processing module, configured to activate a monitoring thread corresponding to the first container when a GPU resource request submitted through the first container is detected; the GPU resource request includes a first GPU computing power resource and a first GPU memory capacity of the applied first GPU;

[0018] A monitoring module, configured to monitor, through a monitoring thread, a call command of the first container for the first GPU when a startup operation for the application in the first container is detected; the call command is determined by the first container based on the GPU resource request; the call command is used to call the first GPU computing power resources and the first GPU video memory capacity of the first GPU;

[0019] A determination module, used to determine the first GPU computing power resources and the first GPU video memory capacity based on the call command;

[0020] a processing module, configured to send the first GPU computing power resource and the first GPU memory capacity to a driver corresponding to the first GPU when it is determined that the first GPU memory capacity is less than or equal to the memory quota corresponding to the first container;

[0021] The allocation module is used to allocate the first GPU computing power resources and the first GPU memory capacity to the first container through the driver corresponding to the first GPU.

[0022] In a third aspect, the present application provides a computer device, including a memory and a processor, wherein the memory stores a computer program, and when the processor executes the computer program, the following steps are implemented:

[0023] When a GPU resource request submitted through the first container is detected, a monitoring thread corresponding to the first container is activated; the GPU resource request includes the first GPU computing power resource and the first GPU memory capacity of the applied first GPU;

[0024] In the case of detecting a startup operation for an application in the first container, monitoring a call command of the first container for the first GPU through a monitoring thread; the call command is determined by the first container based on a GPU resource request; and the call command is used to call a first GPU computing power resource and a first GPU video memory capacity of the first GPU;

[0025] Based on the calling command, determine the first GPU computing power resources and the first GPU video memory capacity;

[0026] When it is determined that the video memory capacity of the first GPU is less than or equal to the video memory quota corresponding to the first container, the first GPU computing power resource and the video memory capacity of the first GPU are sent to a driver corresponding to the first GPU;

[0027] The first GPU computing resources and the first GPU memory capacity are allocated to the first container through the driver corresponding to the first GPU.

[0028] In a fourth aspect, the present application further provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the following steps are implemented:

[0029] When a GPU resource request submitted through the first container is detected, a monitoring thread corresponding to the first container is activated; the GPU resource request includes the first GPU computing power resource and the first GPU memory capacity of the applied first GPU;

[0030] In the case of detecting a startup operation for an application in the first container, monitoring a call command of the first container for the first GPU through a monitoring thread; the call command is determined by the first container based on a GPU resource request; and the call command is used to call a first GPU computing power resource and a first GPU video memory capacity of the first GPU;

[0031] Based on the calling command, determine the first GPU computing power resources and the first GPU video memory capacity;

[0032] When it is determined that the video memory capacity of the first GPU is less than or equal to the video memory quota corresponding to the first container, the first GPU computing power resource and the video memory capacity of the first GPU are sent to a driver corresponding to the first GPU;

[0033] The first GPU computing resources and the first GPU memory capacity are allocated to the first container through the driver corresponding to the first GPU.

[0034] In a fifth aspect, the present application further provides a computer program product, including a computer program, which implements the following steps when executed by a processor:

[0035] When a GPU resource request submitted through the first container is detected, a monitoring thread corresponding to the first container is activated; the GPU resource request includes the first GPU computing power resource and the first GPU memory capacity of the applied first GPU;

[0036] In the case of detecting a startup operation for an application in the first container, monitoring a call command of the first container for the first GPU through a monitoring thread; the call command is determined by the first container based on a GPU resource request; and the call command is used to call a first GPU computing power resource and a first GPU video memory capacity of the first GPU;

[0037] Based on the calling command, determine the first GPU computing power resources and the first GPU video memory capacity;

[0038] When it is determined that the video memory capacity of the first GPU is less than or equal to the video memory quota corresponding to the first container, the first GPU computing power resource and the video memory capacity of the first GPU are sent to a driver corresponding to the first GPU;

[0039] The first GPU computing resources and the first GPU memory capacity are allocated to the first container through the driver corresponding to the first GPU.

[0040] The above-mentioned method, device, equipment and storage medium for virtualizing the graphics processor GPU in the container, the computer device can activate the monitoring thread corresponding to the first container when detecting a GPU resource request submitted through the first container; the GPU resource request includes the first GPU computing power resources and the first GPU video memory capacity of the applied first GPU; when the startup operation for the application in the first container is detected, the first container is monitored through the monitoring thread for the call command for the first GPU; the call command is determined by the first container based on the GPU resource request; the call command is used to call the first GPU computing power resources and the first GPU video memory capacity of the first GPU; based on the call command, the first GPU computing power resources and the first GPU video memory capacity are determined; when it is determined that the first GPU video memory capacity is less than or equal to the video memory quota corresponding to the first container, the first GPU computing power resources and the first GPU video memory capacity are sent to the driver corresponding to the first GPU; the first GPU computing power resources and the first GPU video memory capacity are allocated to the first container through the driver corresponding to the first GPU. By adopting this method, the computer device can determine the GPU computing power resources and GPU video memory capacity of the GPU to be called by the container by monitoring the calling commands of the container for the GPU, and when it is determined that the GPU video memory capacity to be called by the container is less than or equal to the video memory quota corresponding to the container, the corresponding GPU computing power resources and GPU video memory capacity are allocated to the container through the driver corresponding to the GPU. In this way, the computer device can flexibly manage the GPU resources (i.e., GPU computing power resources and GPU video memory capacity) in the GPU according to actual needs, thereby improving the utilization rate of GPU resources and reducing the waste of GPU resources. BRIEF DESCRIPTION OF THE DRAWINGS

[0041] In order to more clearly illustrate the technical solutions in the embodiments of the present application or related technologies, the drawings required for use in the embodiments of the present application or related technical descriptions will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without paying creative work.

[0042] Figure 1 This is a schematic diagram of an application scenario of a GPU virtualization method in a container provided in an embodiment of the present application;

[0043] Figure 2 It is a flowchart of a method for virtualizing a GPU in a container provided by an embodiment of the present application;

[0044] Figure 3 It is a flowchart of another GPU virtualization method in a container provided by an embodiment of the present application;

[0045] Figure 4is a schematic diagram of another GPU virtualization method in a container provided in an embodiment of the present application;

[0046] Figure 5 It is a structural schematic diagram of a virtualization device of a graphics processor GPU in a container provided by an embodiment of the present application;

[0047] Figure 6 It is a structural diagram of a computer device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0048] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.

[0050] See also Figure 1 , Figure 1 Schematic diagram of an application scenario of a GPU virtualization method in a container provided by an embodiment of the present application. Figure 1 As shown, the computer device 100 includes a graphics processor GPU 101.

[0051] The computer device 100 may activate the monitoring thread corresponding to the first container when a GPU resource request submitted through the first container is detected; the GPU resource request includes the first GPU computing power resources and the first GPU video memory capacity of the applied first GPU; when a startup operation for an application in the first container is detected, the calling command of the first container for the first GPU is monitored through the monitoring thread; the calling command is determined by the first container based on the GPU resource request; the calling command is used to call the first GPU computing power resources and the first GPU video memory capacity of the first GPU; based on the calling command, the first GPU computing power resources and the first GPU video memory capacity are determined; when it is determined that the first GPU video memory capacity is less than or equal to the video memory quota corresponding to the first container, the first GPU computing power resources and the first GPU video memory capacity are sent to the driver corresponding to the first GPU; and the first GPU computing power resources and the first GPU video memory capacity are allocated to the first container through the driver corresponding to the first GPU. By adopting this method, the computer device can determine the GPU computing power resources and GPU video memory capacity of the GPU to be called by the container by monitoring the calling commands of the container for the GPU, and when it is determined that the GPU video memory capacity to be called by the container is less than or equal to the video memory quota corresponding to the container, the corresponding GPU computing power resources and GPU video memory capacity are allocated to the container through the driver corresponding to the GPU. In this way, the computer device can flexibly manage the GPU resources (i.e., GPU computing power resources and GPU video memory capacity) in the GPU according to actual needs, thereby improving the utilization rate of GPU resources and reducing the waste of GPU resources.

[0052] Optionally, the computer device 100 may be a server. The server mentioned here may be an independent physical server, or a server cluster or a distributed system composed of multiple physical servers.

[0053] See also Figure 2 , Figure 2 1 is a flow chart of a method for virtualizing a GPU in a container provided by an embodiment of the present application. The method can be executed by a computer device (for example, the computer device 100 described above). Figure 2 As shown, the GPU virtualization method in the container may include but is not limited to the following steps:

[0054] S201. When a GPU resource request submitted through a first container is detected, a monitoring thread corresponding to the first container is activated; the GPU resource request includes a first GPU computing power resource and a first GPU memory capacity of the applied first GPU.

[0055] The GPU resource request may be submitted by the user in the first container displayed in the user interface.

[0056] The monitoring thread corresponding to the first container can be used to track the call commands for GPU resources in the first container and continuously monitor the usage of GPU resources. In this way, it can be determined that the resource usage complies with the established allocation strategy and monitoring requirements.

[0057] Exemplarily, the computer device may activate the monitoring thread corresponding to container 1 when detecting a GPU resource request submitted by a user through container 1, wherein the GPU resource request includes the GPU computing power resources (e.g., 80%) and GPU memory capacity (e.g., 1GB) of GPU 1 applied for container 1. The computer device may also activate the monitoring thread corresponding to container 2 when detecting a GPU resource request submitted by a user through container 2.

[0058] S202: When a startup operation for an application in a first container is detected, monitor a call command of the first container for a first GPU by monitoring a monitoring thread.

[0059] The calling command is determined by the first container based on the GPU resource request; the calling command is used to call the first GPU computing power resources and the first GPU memory capacity of the first GPU.

[0060] In an optional embodiment, when a computer device detects a startup operation for an application in a first container, monitoring a call command of the first container for a first GPU through a monitoring thread may include: determining a call command for the first GPU based on a GPU resource request through the first container; when a startup operation for an application in the first container is detected, sending the call command to the virtual GPU through the first container, and monitoring the call command through the monitoring thread.

[0061] Exemplarily, the computer device may first determine a call command for GPU1 based on a GPU resource request through container 1; the corresponding monitoring thread monitors the call command of container 1 for the first GPU; then, when a startup operation for application (Application, APP) 1 in container 1 is detected, the call command is sent to the virtual GPU through container 1, and the call command is monitored through the monitoring thread.

[0062] S203: Determine the first GPU computing power resources and the first GPU video memory capacity based on the calling command.

[0063] The information included in the GPU resource request is the same as the information included in the call command. The difference between the GPU resource request and the call command is that the GPU resource request is a user requesting GPU resources through the first container, while the call command is used by the first container to call the GPU resources.

[0064] Since the calling command is determined by the first container based on the GPU resource request, and the GPU resource request includes the first GPU computing power resources and the first GPU video memory capacity of the applied first GPU, the computer device can determine the first GPU computing power resources and the first GPU video memory capacity based on the calling command.

[0065] In an optional implementation, the computer device determines the first GPU computing power resources and the first GPU video memory capacity based on the calling command, and may determine the first GPU computing power resources and the first GPU video memory capacity based on the calling command by monitoring a thread.

[0066] S204: When it is determined that the video memory capacity of the first GPU is less than or equal to the video memory quota corresponding to the first container, send the first GPU computing power resources and the video memory capacity of the first GPU to a driver corresponding to the first GPU.

[0067] The video memory quota corresponding to the first container is declared when the first container is created.

[0068] In an optional implementation, when the computer device determines that the video memory capacity of the first GPU is less than or equal to the video memory quota corresponding to the first container, the first GPU computing power resources and the first GPU video memory capacity are sent to the driver corresponding to the first GPU. This may be done by a monitoring thread. When the computer device determines that the video memory capacity of the first GPU is less than or equal to the video memory quota corresponding to the first container, the first GPU computing power resources and the first GPU video memory capacity are sent to the driver corresponding to the first GPU.

[0069] That is, the computer device may apply for GPU resources from the driver corresponding to the first GPU when it determines through the monitoring thread that the video memory capacity of the first GPU called by the first container is less than or equal to the video memory quota corresponding to the first container.

[0070] For example, assuming that the GPU memory capacity called by container 1 is 1GB, and the memory quota corresponding to container 1 is 1.2GB, in this case, the computer device can determine that the GPU memory capacity of 1GB called by container 1 is less than the memory quota of 1.2GB corresponding to container 1. At this time, the computer device can send the GPU resources (GPU computing power resources and GPU memory capacity) called by container 1 to the driver corresponding to the GPU called by container 1.

[0071] In an optional implementation, the computer device may also output indication information when determining through the monitoring thread that the first GPU video memory capacity is greater than the video memory quota corresponding to the first container, the indication information being used to indicate that the GPU video memory capacity called by the first container is greater than the video memory quota corresponding to the first container. Optionally, the indication information may be an ERR_MEM_MALLOC error signal.

[0072] For example, assuming that the GPU memory capacity called by container 2 is 1GB, and the memory quota corresponding to container 2 is 0.8GB, in this case, the computer device can determine that the GPU memory capacity of 1GB called by container 2 is greater than the memory quota of 0.8GB corresponding to container 1. At this time, the computer device can output the ERR_MEM_MALLOC error signal through the monitoring thread corresponding to container 2.

[0073] S205. Allocate first GPU computing resources and first GPU memory capacity to the first container through a driver corresponding to the first GPU.

[0074] That is, when the computer device determines that the first GPU memory capacity is less than or equal to the memory quota corresponding to the first container, the computer device can allocate the called first GPU computing power resources and the first GPU memory capacity to the first container through the memory corresponding to the first GPU.

[0075] For example, assuming that the GPU computing power resources of GPU1 called by container 1 are 80% and the GPU video memory capacity is 1GB, the computer device can allocate 80% of the GPU computing power resources and 1GB of video memory capacity in GPU1 to container 1 through the driver corresponding to GPU1 when the GPU video memory capacity of 1GB called by container 1 is less than the video memory quota corresponding to container 1.

[0076] In an embodiment of the present application, a computer device may activate a monitoring thread corresponding to the first container when a GPU resource request submitted through a first container is detected; the GPU resource request includes the first GPU computing power resources and the first GPU video memory capacity of the applied first GPU; when a startup operation for an application in the first container is detected, the first container is monitored through the monitoring thread for a call command for the first GPU; the call command is determined by the first container based on the GPU resource request; the call command is used to call the first GPU computing power resources and the first GPU video memory capacity of the first GPU; based on the call command, the first GPU computing power resources and the first GPU video memory capacity are determined; when it is determined that the first GPU video memory capacity is less than or equal to the video memory quota corresponding to the first container, the first GPU computing power resources and the first GPU video memory capacity are sent to a driver corresponding to the first GPU; and the first GPU computing power resources and the first GPU video memory capacity are allocated to the first container through the driver corresponding to the first GPU. By adopting this method, the computer device can determine the GPU computing power resources and GPU video memory capacity of the GPU to be called by the container by monitoring the calling commands of the container for the GPU, and when it is determined that the GPU video memory capacity to be called by the container is less than or equal to the video memory quota corresponding to the container, the corresponding GPU computing power resources and GPU video memory capacity are allocated to the container through the driver corresponding to the GPU. In this way, the computer device can flexibly manage the GPU resources (i.e., GPU computing power resources and GPU video memory capacity) in the GPU according to actual needs, thereby improving the utilization rate of GPU resources and reducing the waste of GPU resources.

[0077] See also Figure 3 , Figure 3 1 is a flow chart of another method for virtualizing a GPU in a container provided by an embodiment of the present application. Figure 2 Compared to the GPU virtualization method shown in the figure, Figure 3 The method shown also describes how the computer device sends the GPU resources requested by different containers to the driver corresponding to the GPU when different containers call GPU resources at the same time. Figure 3 As shown, the method may include but is not limited to the following steps:

[0078] S301. When a first GPU resource request submitted through a first container is detected, a first monitoring thread corresponding to the first container is activated; and when a second GPU resource request submitted through a second container is detected, a second monitoring thread corresponding to the second container is activated.

[0079] The first GPU resource request includes the first GPU computing power resources and the first GPU memory capacity of the first GPU applied for the first container; the second GPU resource request includes the first GPU computing power resources and the second GPU memory capacity of the second GPU applied for the second container.

[0080] Optionally, the minimum allocation unit of the GPU computing power resources may be 1%, that is, the GPU computing power resources applied for the first container or the second container may be any one of 1%, 2%, 3%, ..., 100%.

[0081] S302: When a startup operation for an application in a first container is detected, monitor, by a first monitoring thread, a first call command for a first GPU in the first container; and, when a startup operation for an application in a second container is detected, monitor, by a second monitoring thread, a first call command for a second GPU in the second container.

[0082] Among them, the first calling command is determined by the first container based on the first GPU resource request, and the first calling command is used to call the first GPU computing power resources and the first GPU video memory capacity of the first GPU; the second calling command is determined by the second container based on the second GPU resource request, and the second calling command is used to call the second GPU computing power resources and the second GPU video memory capacity of the second GPU.

[0083] S303: Determine the first GPU computing power resources and the first GPU video memory capacity based on the first calling command, and determine the second GPU computing power resources and the second GPU video memory capacity based on the second calling command.

[0084] In an optional implementation, the relevant descriptions of steps S301 to S303 may refer to the descriptions of the aforementioned steps S201 to S203, and will not be repeated here.

[0085] S304: When it is determined that the GPU memory capacity of the first GPU called by the first container is less than or equal to the memory quota corresponding to the first container, and the second GPU memory capacity of the second GPU called by the second container is less than or equal to the memory quota corresponding to the second container, determine a first GPU corresponding to the first container and a second GPU corresponding to the second container.

[0086] The video memory quota corresponding to the first container is declared when the first container is created; the video memory quota corresponding to the second container is declared when the second container is created.

[0087] For example, assuming that the GPU memory capacity called by container 1 is 1GB, the memory quota corresponding to container 1 is 1.2GB, the GPU memory capacity called by container 2 is 1GB, and the memory quota corresponding to container 2 is 0.8GB, in this case, the computer device can determine GPU1 where the GPU resources that container 1 needs to call are located, and determine GPU2 where the GPU resources that container 2 needs to call are located.

[0088] S305. When it is determined that the first GPU and the second GPU are the same, determine the target GPU computing resources based on the first GPU computing resources and the second GPU computing resources called by the second container; and determine the target GPU memory capacity based on the first GPU memory capacity and the second GPU memory capacity.

[0089] In an optional implementation, the computer device determines the target GPU computing power resources based on the first GPU computing power resources and the second GPU computing power resources called by the second container. The first GPU computing power resources called by the first container and the second GPU computing power resources called by the second container may be summed to obtain the sum of the GPU computing power resources; and the sum of the GPU computing power resources is used as the target GPU computing power resources.

[0090] Continuing with the example in step S304 above, assuming that GPU1 (the GPU where the GPU resources required to be called by container 1 are located) and GPU2 (the GPU where the GPU resources required to be called by container 2 are located) are the same, and assuming that the GPU computing power resources required to be called by container 1 are 50%, and the GPU computing power resources required to be called by container 2 are 30%, in this case, the computer device can use the sum of 50% of the GPU computing power resources required to be called by container 1 and 30% of the GPU computing power resources required to be called by container 2, that is, 80% of the GPU computing power resources, as the target GPUS computing power resources.

[0091] In an optional implementation, the computer device determines the target GPU memory capacity based on the first GPU memory capacity and the second GPU memory capacity, which may be by summing the first GPU memory capacity called by the first container and the second GPU memory capacity called by the second container to obtain the total GPU memory capacity; and using the total GPU memory capacity as the target GPU computing power resource.

[0092] Continuing with the example in step S304 above, assuming that GPU1 (the GPU where the GPU resources required to be called by container 1 are located) and GPU2 (the GPU where the GPU resources required to be called by container 2 are located) are the same, and assuming that the GPU video memory capacity required to be called by container 1 is 1GB, and the GPU video memory capacity required to be called by container 2 is 0.8GB, in this case, the computer device can use the sum of the GPU video memory capacity of 1GB required to be called by container 1 and the GPU video memory capacity of 0.8GB required to be called by container 2, that is, the GPU video memory capacity of 1.8GB, as the target GPUS video memory capacity.

[0093] S306: Send the target GPU computing power resources and the target GPU memory capacity to a driver corresponding to the first GPU or the second GPU.

[0094] As can be seen from the foregoing, the target CPU computing power resources and the target GPU memory capacity are determined by the computer device when it is determined that the first GPU and the second GPU are the same. Therefore, the driver corresponding to the first GPU or the second GPU is the same driver. The computer device sends the target GPU computing power resources and the target GPU memory capacity to the driver corresponding to the first GPU or the second GPU, that is, the computer device can send the target GPU computing power resources and the target GPU memory capacity to the target GPU, which is the GPU where the GPU resources to be called by container 1 and container 2 are located.

[0095] S307: Allocate target GPU computing resources and target GPU video memory capacity to the first container and the second container through a driver corresponding to the first GPU or the second GPU.

[0096] Among them, the computer device allocates target GPU computing power resources and target GPU video memory capacity to the first container and the second container through the driver corresponding to the first GPU or the second GPU. It can also be understood that through the driver corresponding to the first GPU or the second GPU, the target GPU computing power resources and target GPU video memory capacity in the first GPU or the second GPU are determined as the GPU computing power resources and GPU video memory capacity used to execute the computing tasks in the first container and the computing tasks in the second container.

[0097] For example, assuming that the target GPU computing power resources are 80% and the target GPU video memory capacity is 1.8 GB, the computer device can determine, through the driver of the first GPU or the second GPU, to use 80% of the GPU computing power resources and 1.8 GB of GPU video memory capacity in the first GPU or the second GPU as GPU resources for executing computing tasks in container 1 and computing tasks in container 2.

[0098] In an embodiment of the present application, a computer device may call GPU resources in different containers at the same time, and when the GPU memory capacities called by different containers are all less than or equal to the memory quotas corresponding to the containers, determine the GPUs where the GPU resources called by different containers are located; when it is determined that the GPUs where the GPU resources called by different containers are located are the same, integrate the GPU resources called by different containers to obtain target GPU computing power resources and target GPU memory capacities, and send the target GPU computing power resources and target GPU memory capacities to drivers of the same GPU corresponding to different containers; and through the driver of the GPU, allocate target GPU computing power resources and target GPU memory capacities to different containers. In this way, on the one hand, by comparing the GPU video memory capacity called by different containers with the video memory quota corresponding to the container, and executing subsequent steps when the GPU video memory capacity called by different containers is less than or equal to the video memory quota corresponding to the container, the compliance of the use of video memory capacity can be ensured and over-allocation of video memory capacity can be prevented; on the other hand, by integrating the GPU resources called by different containers and sending the integrated GPU resources to the drivers of the same GPU corresponding to different containers, it is possible to avoid sending the GPU resources called by different containers to the driver of the same GPU multiple times, which is beneficial to improving the efficiency of GPU resource allocation.

[0099] In an optional implementation, after step S304, that is, after the computer device determines the first GPU and the second GPU, the computer device may further perform the following steps:

[0100] Step 1: When it is determined that the first GPU and the second GPU are different, the first GPU computing power resources and the first GPU memory capacity are sent to the driver of the first GPU, and the second GPU computing power resources and the second GPU memory capacity are sent to the driver of the second GPU.

[0101] For example, assuming that container 1 needs to call 50% of the GPU computing power resources and 1GB of GPU video memory capacity in GPU1, and container 2 needs to call 30% of the GPU computing power resources and 0.5GB of GPU video memory capacity in GPU2, then when GPU1 and GPU2 are different, the computer device sends 50% of the GPU computing power resources and 1GB of GPU video memory capacity to the driver of GPU1, and sends 30% of the GPU computing power resources and 0.5GB of GPU video memory capacity to the driver of GPU2.

[0102] Step 2: Allocate first GPU computing power resources and first GPU video memory capacity to the first container through the driver of the first GPU, and allocate second GPU computing power resources and second GPU video memory capacity to the second container through the driver of the second GPU.

[0103] That is, the computer device can determine the first GPU computing power resources and the first GPU video memory capacity in the first GPU as GPU resources for executing computing tasks in the first container through the driver of the first GPU, and determine the second GPU computing power resources and the second GPU video memory capacity in the second GPU as GPU resources for executing computing tasks in the second container through the driver of the second GPU.

[0104] Continuing with the above example, the computer device can use 50% of the GPU computing power resources and 1GB of GPU video memory capacity in GPU1 as GPU resources for executing computing tasks in container 1 through the driver of GPU1, and use 30% of the GPU computing power resources and 0.5GB of GPU video memory capacity in GPU2 as GPU resources for executing computing tasks in container 2 through the driver of GPU2.

[0105] By adopting this implementation mode, the computer device can send the GPU resources required by different containers to the driver of the GPU corresponding to the container when the GPU resources required by different containers are located in different GPUs. In this way, flexible management of GPU video memory capacity and GPU computing power resources can be achieved.

[0106] In an optional embodiment, Figure 3 In the method shown, the computer device may further perform the following steps:

[0107] Step 1: Time slice the computing tasks in the first container and the computing tasks in the second container respectively to obtain a plurality of first time slice tasks corresponding to the first container and a plurality of second time slice tasks corresponding to the second container.

[0108] Optionally, the minimum slice value may be 1MB, that is, the size of each time slice task may be 1MB.

[0109] Exemplarily, the computer device may perform time slicing processing on the computing tasks in the first container and the computing tasks in the second container in units of 2 milliseconds to obtain multiple first time slice tasks corresponding to the first container and multiple second time slice tasks corresponding to the second container.

[0110] In an optional implementation, after the computer device executes step 1, it may also execute the following steps 2 and 3, or execute the following step 4.

[0111] Step 2. When it is determined that the first GPU and the second GPU are the same, based on the first GPU computing power resources and the second GPU computing power resources, multiple first time slice tasks and multiple second time slice tasks are re-arranged to obtain multiple time slice tasks after arrangement; wherein the time slice ratios of the multiple first time slice tasks and the multiple second time slice tasks are the same as the ratio of the GPU computing power resources called by each container.

[0112] Exemplarily, assuming that the multiple first time slice tasks corresponding to container 1 are APP0_0, APP0_1, and APP0_2, and the multiple second time slice tasks corresponding to container 2 are APP1_0, APP1_1, and APP1_2, and assuming that the first GPU computing power resource is 80% and the second GPU computing power resource is 20%, then the computer device can re-arrange the multiple first time slice tasks and the multiple second time slice tasks based on the first GPU computing power resource and the second GPU computing power resource when determining that the first GPU and the second GPU are the same, and obtain the multiple time slice tasks after arrangement as APP0_0, APP1_0, APP0_1, APP1_1, APP0_2, and APP1_2. Among them, the ratio of the time slices of the multiple first time slice tasks and the multiple second time slice tasks is the same as the ratio of the GPU computing power resources called by container 1 and container 2, which is 8:2.

[0113] Step three: Send the arranged multiple time slice tasks to the driver of the first GPU or the second GPU, so that the driver of the first GPU or the second GPU executes the arranged multiple time slice tasks.

[0114] Exemplarily, following the above example, the computer device may send APP0_0, APP1_0, APP0_1, APP1_1, APP0_2, and APP1_2 to the driver of the first GPU or the second GPU, so that the first GPU or the second GPU first executes the computing task in container 1 for 8ms, and then executes the computing task in container 2 for 2ms. That is, the computing tasks in container 1 and the container are executed in the following order: execute APP0_0 task for 8ms, execute APP1_0 task for 2ms, execute APP0_1 task for 8ms, execute APP1_1 task for 2ms, execute APP0_2 task for 8ms, and execute APP1_2 task for 2ms.

[0115] Step 4. When it is determined that the first GPU and the second GPU are different, multiple first time slice tasks are sent to the driver of the first GPU so that the driver of the first GPU executes the multiple first time slice tasks, and multiple second time slice tasks are sent to the driver of the second GPU so that the driver of the second GPU executes the multiple second time slice tasks.

[0116] For example, assuming that the multiple first time slice tasks corresponding to container 1 are APP0_0, APP0_1 and APP0_2, and the multiple second time slice tasks corresponding to container 2 are APP1_0, APP1_1 and APP1_2, then when the GPU1 where the GPU resources called by container 1 are located and the GPU2 where the GPU resources called by container 2 are located are different, the computer device may send APP0_0, APP0_1 and APP0_2 to the driver of GPU1, and send APP1_0, APP1_1 and APP1_2 to the driver of GPU2.

[0117] In this implementation, the computer device can perform time slicing on the computing tasks in different containers to obtain multiple time slicing tasks, and when the GPUs where the GPU resources called by different containers are located are the same, the multiple time slicing tasks are re-arranged, and the multiple time slicing tasks after the arrangement are sent to the driver of the GPU where the GPU resources called by different containers are located; when the GPUs where the GPU resources called by different containers are located are different, the time slicing tasks corresponding to the different containers are respectively sent to the driver of the GPU where the GPU resources called by different containers are located, so that the computing tasks in different containers can be executed at the same time, thereby improving the computing efficiency.

[0118] In an optional embodiment, Figure 1 The GPU resource request mentioned in the illustrated GPU virtualization method may also include instruction information for obtaining additional GPU resources.

[0119] In this implementation, the computer device may further perform the following steps:

[0120] Step 1: Monitor the usage information of the GPU computing resources and GPU memory capacity corresponding to the first container through a monitoring thread.

[0121] Step 2: When it is determined that the GPU resources required by the first container exceed the GPU resources applied for by the first container and it is determined that there are idle GPU resources in the GPU, additional GPU resources are allocated to the first container.

[0122] Among them, GPU resources include GPU computing resources and GPU video memory capacity.

[0123] For example, assuming that the GPU resources required by the first container include 1.5 GB of video memory capacity in GPU1, and the video memory capacity applied for by container 1 is 1 GB of video memory capacity in GPU1, and assuming that there is 1 GB of free GPU video memory capacity in GPU1, in this case, the computer device can allocate an additional 0.5 GB of GPU video memory capacity to container 1 through the driver of GPU1.

[0124] In an optional implementation, the computer device may also release the additional GPU resources occupied by the first container after determining that the computing task in the first container is completed, thereby further improving the flexibility of GPU resource management.

[0125] By adopting this implementation, the computer device can monitor the usage information of the GPU computing resources and GPU video memory capacity corresponding to the first container through the monitoring thread; when it is determined that the GPU resources required by the first container exceed the GPU resources applied for by the first container, and when it is determined that there are idle GPU resources in the GPU, additional GPU resources are allocated to the first container. In this way, even if the GPU resources used by the first container occasionally exceed the GPU resources applied for, the computer device can allocate additional GPU resources to the first container when it is determined that there are idle GPU resources in the GPU, thus avoiding the waste of idle GPU resources and improving the utilization rate of GPU resources. In addition, by adopting this implementation, the dynamic scalability of GPU resources can also be improved.

[0126] The following uses the GPU resources called by container 1 and container 2 as an example to introduce the GPU virtualization method in the container provided by the embodiment of the present application. Figure 4 , Figure 4 It is a schematic diagram of another GPU virtualization method in a container provided in an embodiment of the present application.

[0127] like Figure 4 As shown in the figure, it includes the computing power control unit (referred to as scheduler_control) and the video memory control unit (referred to as memory_control). Among them, scheduler_control is the allocation management unit of the streaming multiprocessors (SM) inside the GPU. Memory_control is the key control unit responsible for the management and allocation of the video memory inside the GPU.

[0128] like Figure 4 As shown, the user can apply for 80% of the GPU computing power resources and 16GB of GPU memory capacity through container 1, and apply for 20% of the GPU computing power resources and 8GB of GPU memory capacity through container 2; then, the user can start application 0 running in container 1, and start application 1 running in container 2.

[0129] Then, the computer device can monitor the call command 1 of the GPU of container 1 through the monitoring thread 1 corresponding to container 1, and the call command 1 includes that the GPU computing power resource 1 required to be called by container 1 is 80%, and the GPU video memory capacity 1 is 16GB, and monitor the call command 2 of the GPU of container 2 through the monitoring thread 2 corresponding to container 2, and the call command 2 includes that the GPU computing power resource 2 required to be called by container 2 is 20%, and the GPU video memory capacity 2 is 8GB. After that, after determining the GPU computing power resource 1 called by container 1 through the monitoring thread 1, determine whether the GPU computing power resource 1 exceeds the video memory quota corresponding to container 1; if it exceeds, send the ERR_MEM_MALLOC error signal to application 0, otherwise, send the GPU video memory capacity 1 to memory_control; perform time slicing processing on the computing task corresponding to application 0 to obtain application 0_0, application 0_1, ..., application 0_n. After determining the GPU computing power resource 1 called by container 2 through monitoring thread 2, determine whether the GPU computing power resource 2 exceeds the video memory quota corresponding to container 2; if exceeded, send an ERR_MEM_MALLOC error signal to application 1, otherwise, send the GPU video memory capacity 2 to memory_control; perform time slicing on the computing task corresponding to application 1 to obtain application 1_0, application 1_1, ..., application 1_n.

[0130] Next, the computer device may send application 0_0, application 0_1, ..., application 0_2, and application 1_0, application 1_1, ..., application 1_2 to scheduler_control, and scheduler_control to schedule the received multiple time slice tasks to obtain the scheduled multiple time slice tasks, namely, application 0_0, application 1_0, application 0_1, and application 1_1, ..., application 1_n, ..., application 1_n; and integrate GPU video memory capacity 1 and GPU video memory capacity 2 through memory_control.

[0131] Afterwards, the computer device may send the orchestrated multiple time slice tasks and the integrated GPU memory capacity to the driver corresponding to the GPU, so that the driver corresponding to the GPU allocates GPU resources to container 1 and container 2.

[0132] In this way, by isolating computing power and video memory at the driver level, tasks can be ensured to run independently. In addition, it can be completely transparent to user programs, and users will not feel any interference or changes during use, thus ensuring a smooth experience for users when using applications.

[0133] It should be understood that, although the various steps in the flowcharts involved in the above-mentioned embodiments are displayed in sequence according to the indication of the arrows, these steps are not necessarily executed in sequence according to the order indicated by the arrows. Unless there is a clear explanation in this article, the execution of these steps does not have a strict order restriction, and these steps can be executed in other orders. Moreover, at least a part of the steps in the flowcharts involved in the above-mentioned embodiments can include multiple steps or multiple stages, and these steps or stages are not necessarily executed at the same time, but can be executed at different times, and the execution order of these steps or stages is not necessarily to be carried out in sequence, but can be executed in turn or alternately with other steps or at least a part of the steps or stages in other steps.

[0134] Based on the same inventive concept, the embodiment of the present application also provides a virtualization device for a graphics processor GPU in a container for implementing the aforementioned method for virtualizing a graphics processor GPU in a container. The implementation solution provided by the device for solving the problem is similar to the implementation solution recorded in the aforementioned method, so the specific limitations in the embodiments of the virtualization device for one or more graphics processor GPUs in a container provided below can be found in the above definition of the method for virtualizing a graphics processor GPU in a container, and will not be repeated here.

[0135] See also Figure 5 , Figure 5 Schematic diagram of a virtualization device of a graphics processor GPU in a container provided by an embodiment of the present application. Figure 5 As shown, the virtualization device of the graphics processor GPU in the container may include but is not limited to:

[0136] The processing module 501 is used to activate the monitoring thread corresponding to the first container when a GPU resource request submitted through the first container is detected; the GPU resource request includes the first GPU computing power resource and the first GPU memory capacity of the applied first GPU;

[0137] The monitoring module 502 is used to monitor, through a monitoring thread, a call command of the first container for the first GPU when a startup operation for the application in the first container is detected; the call command is determined by the first container based on the GPU resource request; the call command is used to call the first GPU computing power resources and the first GPU video memory capacity of the first GPU;

[0138] A determination module 503 is used to determine the first GPU computing power resources and the first GPU video memory capacity based on the call command;

[0139] Processing module 501 is used to send the first GPU computing power resources and the first GPU memory capacity to a driver corresponding to the first GPU when it is determined that the first GPU memory capacity is less than or equal to the memory quota corresponding to the first container;

[0140] The allocation module 504 is used to allocate the first GPU computing power resources and the first GPU memory capacity to the first container through the driver corresponding to the first GPU.

[0141] In one embodiment, the determination module 50 is also used to: determine the first GPU corresponding to the first container and the second GPU corresponding to the second container when it is determined that the GPU memory capacity of the first GPU called by the first container is less than or equal to the memory quota corresponding to the first container, and the second GPU memory capacity of the second GPU called by the second container is less than or equal to the memory quota corresponding to the second container; determine the target GPU computing power resources based on the first GPU computing power resources and the second GPU computing power resources called by the second container when it is determined that the first GPU and the second GPU are the same; and determine the target GPU memory capacity based on the first GPU memory capacity and the second GPU memory capacity; the processing module 501 is also used to: send the target GPU computing power resources and the target GPU memory capacity to the driver corresponding to the first GPU or the second GPU; and allocate the target GPU computing power resources and the target GPU memory capacity to the first container and the second container through the driver corresponding to the first GPU or the second GPU.

[0142] In one embodiment, the processing module 501 is further used to: when it is determined that the first GPU and the second GPU are different, send the first GPU computing power resources and the first GPU video memory capacity to the driver of the first GPU, and send the second GPU computing power resources and the second GPU video memory capacity to the driver of the second GPU; allocate the first GPU computing power resources and the first GPU video memory capacity to the first container through the driver of the first GPU, and allocate the second GPU computing power resources and the second GPU video memory capacity to the second container through the driver of the second GPU.

[0143] In one embodiment, the processing module 501 is also used to: perform time slicing processing on the computing tasks in the first container and the computing tasks in the second container respectively, to obtain multiple first time slicing tasks corresponding to the first container, and multiple second time slicing tasks corresponding to the second container; when it is determined that the first GPU and the second GPU are the same, based on the first GPU computing power resources and the second GPU computing power resources, the multiple first time slicing tasks and the multiple second time slicing tasks are re-arranged to obtain multiple time slicing tasks after arrangement; wherein the time slice ratios of the multiple first time slicing tasks and the multiple second time slicing tasks are respectively the same as the ratio of the GPU computing power resources called by each container; and the multiple time slicing tasks after arrangement are sent to the driver of the first GPU or the second GPU, so that the driver of the first GPU or the second GPU executes the multiple time slicing tasks after arrangement.

[0144] In one embodiment, the processing module 501 is also used to: when it is determined that the first GPU and the second GPU are different, send multiple first time slice tasks to the driver of the first GPU so that the driver of the first GPU executes multiple first time slice tasks, and send multiple second time slice tasks to the driver of the second GPU so that the driver of the second GPU executes multiple second time slice tasks.

[0145] In one embodiment, the GPU resource request also includes instruction information for obtaining additional GPU resources; the monitoring module 502 is also used to monitor the usage information of the GPU computing power resources and GPU video memory capacity corresponding to the first container through the monitoring thread; the processing module 501 is also used to allocate additional GPU resources to the first container when it is determined that the GPU resources required for the first container exceed the GPU resources applied for by the first container and it is determined that there are idle GPU resources in the GPU; GPU resources include GPU computing power resources and GPU video memory capacity.

[0146] Each module in the virtualization device of the above-mentioned graphics processor GPU in the container can be implemented in whole or in part by software, hardware and their combination. The above-mentioned modules can be embedded in or independent of the processor in the terminal device in the form of hardware, or can be stored in the memory of the terminal device in the form of software, so that the processor can call and execute the operations corresponding to the above modules.

[0147] In an exemplary embodiment, the present application provides a computer device, which may be a terminal, and its internal structure diagram may be as follows: Figure 6As shown. The computer device includes a processor, a memory, an input / output interface, a communication interface and an input device. The processor, the memory and the input / output interface are connected through a system bus, and the communication interface and the input device are connected to the system bus through the input / output interface. The processor of the computer device is used to provide computing and control capabilities. The memory of the computer device includes a non-volatile storage medium and an internal memory. The non-volatile storage medium stores an operating system and a computer program. The internal memory provides an environment for the operation of the operating system and the computer program in the non-volatile storage medium. The input / output interface of the computer device is used to exchange information between the processor and an external device. The communication interface of the computer device is used to communicate with an external terminal in a wired or wireless manner, and the wireless manner can be implemented through WIFI, a mobile cellular network, near field communication (Near Field Communication, NFC) or other technologies. When the computer program is executed by the processor, a virtualization method of a graphics processor GPU in a container is implemented.

[0148] Those skilled in the art will understand that Figure 6 The structure shown in the figure is only a block diagram of a part of the structure related to the solution of the present application, and does not constitute a limitation on the computer device to which the solution of the present application is applied. The specific computer device may include more or fewer components than those shown in the figure, or combine certain components, or have a different arrangement of components.

[0149] In an exemplary embodiment, the present application provides a computer device, including a memory and a processor, wherein a computer program is stored in the memory, and when the processor executes the computer program, the following steps are implemented:

[0150] When a GPU resource request submitted through the first container is detected, a monitoring thread corresponding to the first container is activated; the GPU resource request includes the first GPU computing power resource and the first GPU memory capacity of the applied first GPU;

[0151] In the case of detecting a startup operation for an application in the first container, monitoring a call command of the first container for the first GPU through a monitoring thread; the call command is determined by the first container based on a GPU resource request; and the call command is used to call a first GPU computing power resource and a first GPU video memory capacity of the first GPU;

[0152] Based on the calling command, determine the first GPU computing power resources and the first GPU video memory capacity;

[0153] When it is determined that the video memory capacity of the first GPU is less than or equal to the video memory quota corresponding to the first container, the first GPU computing power resource and the video memory capacity of the first GPU are sent to a driver corresponding to the first GPU;

[0154] The first GPU computing resources and the first GPU memory capacity are allocated to the first container through the driver corresponding to the first GPU.

[0155] In one embodiment, the processor executes the computer program to further implement the following steps: determining the first GPU corresponding to the first container and the second GPU corresponding to the second container when it is determined that the GPU video memory capacity of the first GPU called by the first container is less than or equal to the video memory quota corresponding to the first container, and the second GPU video memory capacity of the second GPU called by the second container is less than or equal to the video memory quota corresponding to the second container; determining the target GPU computing power resources based on the first GPU computing power resources and the second GPU computing power resources called by the second container when it is determined that the first GPU and the second GPU are the same; and determining the target GPU video memory capacity based on the first GPU video memory capacity and the second GPU video memory capacity; sending the target GPU computing power resources and the target GPU video memory capacity to the driver corresponding to the first GPU or the second GPU; and allocating the target GPU computing power resources and the target GPU video memory capacity to the first container and the second container through the driver corresponding to the first GPU or the second GPU.

[0156] In one embodiment, the processor executes the computer program to further implement the following steps: when it is determined that the first GPU and the second GPU are different, the first GPU computing power resources and the first GPU video memory capacity are sent to the driver of the first GPU, and the second GPU computing power resources and the second GPU video memory capacity are sent to the driver of the second GPU; through the driver of the first GPU, the first GPU computing power resources and the first GPU video memory capacity are allocated to the first container, and, through the second GPU driver, the second GPU computing power resources and the second GPU video memory capacity are allocated to the second container.

[0157] In one embodiment, the processor executes the computer program to further implement the following steps: time-slice the computing tasks in the first container and the computing tasks in the second container respectively to obtain multiple first time-slice tasks corresponding to the first container and multiple second time-slice tasks corresponding to the second container; when it is determined that the first GPU and the second GPU are the same, re-arrange the multiple first time-slice tasks and the multiple second time-slice tasks based on the first GPU computing power resources and the second GPU computing power resources to obtain multiple time-slice tasks after arrangement; wherein the time slice ratios of the multiple first time-slice tasks and the multiple second time-slice tasks are respectively the same as the ratio of the GPU computing power resources called by each container; and send the multiple time-slice tasks after arrangement to the driver of the first GPU or the second GPU, so that the driver of the first GPU or the second GPU executes the multiple time-slice tasks after arrangement.

[0158] In one embodiment, when the processor executes the computer program, the following steps are also implemented: when it is determined that the first GPU and the second GPU are different, multiple first time slice tasks are sent to the driver of the first GPU so that the driver of the first GPU executes multiple first time slice tasks, and multiple second time slice tasks are sent to the driver of the second GPU so that the driver of the second GPU executes multiple second time slice tasks.

[0159] In one embodiment, the GPU resource request also includes instruction information for obtaining additional GPU resources; the processor executing the computer program further implements the following steps: monitoring the usage information of the GPU computing power resources and GPU video memory capacity corresponding to the first container through a monitoring thread; when it is determined that the GPU resources required for the first container exceed the GPU resources applied for by the first container, and it is determined that there are idle GPU resources in the GPU, allocating additional GPU resources to the first container; GPU resources include GPU computing power resources and GPU video memory capacity.

[0160] In an exemplary embodiment, the present application provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the following steps are implemented:

[0161] When a GPU resource request submitted through the first container is detected, a monitoring thread corresponding to the first container is activated; the GPU resource request includes the first GPU computing power resource and the first GPU memory capacity of the applied first GPU;

[0162] In the case of detecting a startup operation for an application in the first container, monitoring a call command of the first container for the first GPU through a monitoring thread; the call command is determined by the first container based on a GPU resource request; and the call command is used to call a first GPU computing power resource and a first GPU video memory capacity of the first GPU;

[0163] Based on the calling command, determine the first GPU computing power resources and the first GPU video memory capacity;

[0164] When it is determined that the video memory capacity of the first GPU is less than or equal to the video memory quota corresponding to the first container, the first GPU computing power resource and the video memory capacity of the first GPU are sent to a driver corresponding to the first GPU;

[0165] The first GPU computing resources and the first GPU memory capacity are allocated to the first container through the driver corresponding to the first GPU.

[0166] In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: when it is determined that the GPU video memory capacity of the first GPU called by the first container is less than or equal to the video memory quota corresponding to the first container, and the second GPU video memory capacity of the second GPU called by the second container is less than or equal to the video memory quota corresponding to the second container, determine the first GPU corresponding to the first container and the second GPU corresponding to the second container; when it is determined that the first GPU and the second GPU are the same, determine the target GPU computing power resources based on the first GPU computing power resources and the second GPU computing power resources called by the second container; and determine the target GPU video memory capacity based on the first GPU video memory capacity and the second GPU video memory capacity; send the target GPU computing power resources and the target GPU video memory capacity to the driver corresponding to the first GPU or the second GPU; and allocate the target GPU computing power resources and the target GPU video memory capacity to the first container and the second container through the driver corresponding to the first GPU or the second GPU.

[0167] In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: when it is determined that the first GPU and the second GPU are different, the first GPU computing power resources and the first GPU video memory capacity are sent to the driver of the first GPU, and the second GPU computing power resources and the second GPU video memory capacity are sent to the driver of the second GPU; through the driver of the first GPU, the first GPU computing power resources and the first GPU video memory capacity are allocated to the first container, and, through the second GPU driver, the second GPU computing power resources and the second GPU video memory capacity are allocated to the second container.

[0168] In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: the computing tasks in the first container and the computing tasks in the second container are time sliced ​​respectively to obtain multiple first time slice tasks corresponding to the first container and multiple second time slice tasks corresponding to the second container; when it is determined that the first GPU and the second GPU are the same, the multiple first time slice tasks and the multiple second time slice tasks are re-arranged based on the first GPU computing power resources and the second GPU computing power resources to obtain multiple time slice tasks after arrangement; wherein the time slice ratios of the multiple first time slice tasks and the multiple second time slice tasks are the same as the ratio of the GPU computing power resources called by each container; and the multiple time slice tasks after arrangement are sent to the driver of the first GPU or the second GPU, so that the driver of the first GPU or the second GPU executes the multiple time slice tasks after arrangement.

[0169] In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: when it is determined that the first GPU and the second GPU are different, multiple first time slice tasks are sent to the driver of the first GPU so that the driver of the first GPU executes multiple first time slice tasks, and multiple second time slice tasks are sent to the driver of the second GPU so that the driver of the second GPU executes multiple second time slice tasks.

[0170] In one embodiment, the GPU resource request also includes instruction information for obtaining additional GPU resources; when the computer program is executed by the processor, the following steps are also implemented: by monitoring the usage information of the GPU computing power resources and GPU video memory capacity corresponding to the first container through the monitoring thread; when it is determined that the GPU resources required for the first container exceed the GPU resources applied for by the first container, and it is determined that there are idle GPU resources in the GPU, additional GPU resources are allocated to the first container; GPU resources include GPU computing power resources and GPU video memory capacity.

[0171] In an exemplary embodiment, the present application provides a computer program product, including a computer program, which implements the following steps when executed by a processor:

[0172] When a GPU resource request submitted through the first container is detected, a monitoring thread corresponding to the first container is activated; the GPU resource request includes the first GPU computing power resource and the first GPU memory capacity of the applied first GPU;

[0173] In the case of detecting a startup operation for an application in the first container, monitoring a call command of the first container for the first GPU through a monitoring thread; the call command is determined by the first container based on a GPU resource request; and the call command is used to call a first GPU computing power resource and a first GPU video memory capacity of the first GPU;

[0174] Based on the calling command, determine the first GPU computing power resources and the first GPU video memory capacity;

[0175] When it is determined that the video memory capacity of the first GPU is less than or equal to the video memory quota corresponding to the first container, the first GPU computing power resource and the video memory capacity of the first GPU are sent to a driver corresponding to the first GPU;

[0176] The first GPU computing resources and the first GPU memory capacity are allocated to the first container through the driver corresponding to the first GPU.

[0177] In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: when it is determined that the GPU video memory capacity of the first GPU called by the first container is less than or equal to the video memory quota corresponding to the first container, and the second GPU video memory capacity of the second GPU called by the second container is less than or equal to the video memory quota corresponding to the second container, determine the first GPU corresponding to the first container and the second GPU corresponding to the second container; when it is determined that the first GPU and the second GPU are the same, determine the target GPU computing power resources based on the first GPU computing power resources and the second GPU computing power resources called by the second container; and determine the target GPU video memory capacity based on the first GPU video memory capacity and the second GPU video memory capacity; send the target GPU computing power resources and the target GPU video memory capacity to the driver corresponding to the first GPU or the second GPU; and allocate the target GPU computing power resources and the target GPU video memory capacity to the first container and the second container through the driver corresponding to the first GPU or the second GPU.

[0178] In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: when it is determined that the first GPU and the second GPU are different, the first GPU computing power resources and the first GPU video memory capacity are sent to the driver of the first GPU, and the second GPU computing power resources and the second GPU video memory capacity are sent to the driver of the second GPU; through the driver of the first GPU, the first GPU computing power resources and the first GPU video memory capacity are allocated to the first container, and, through the second GPU driver, the second GPU computing power resources and the second GPU video memory capacity are allocated to the second container.

[0179] In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: the computing tasks in the first container and the computing tasks in the second container are time sliced ​​respectively to obtain multiple first time slice tasks corresponding to the first container and multiple second time slice tasks corresponding to the second container; when it is determined that the first GPU and the second GPU are the same, the multiple first time slice tasks and the multiple second time slice tasks are re-arranged based on the first GPU computing power resources and the second GPU computing power resources to obtain multiple time slice tasks after arrangement; wherein the time slice ratios of the multiple first time slice tasks and the multiple second time slice tasks are the same as the ratio of the GPU computing power resources called by each container; and the multiple time slice tasks after arrangement are sent to the driver of the first GPU or the second GPU, so that the driver of the first GPU or the second GPU executes the multiple time slice tasks after arrangement.

[0180] In one embodiment, when the computer program is executed by the processor, the following steps are also implemented: when it is determined that the first GPU and the second GPU are different, multiple first time slice tasks are sent to the driver of the first GPU so that the driver of the first GPU executes multiple first time slice tasks, and multiple second time slice tasks are sent to the driver of the second GPU so that the driver of the second GPU executes multiple second time slice tasks.

[0181] In one embodiment, the GPU resource request also includes instruction information for obtaining additional GPU resources; when the computer program is executed by the processor, the following steps are also implemented: by monitoring the usage information of the GPU computing power resources and GPU video memory capacity corresponding to the first container through the monitoring thread; when it is determined that the GPU resources required for the first container exceed the GPU resources applied for by the first container, and it is determined that there are idle GPU resources in the GPU, additional GPU resources are allocated to the first container; GPU resources include GPU computing power resources and GPU video memory capacity.

[0182] It should be noted that the data involved in this application (including but not limited to GPU resource requests, the first GPU, the first GPU computing resources, the first GPU memory capacity, the memory quota, etc.) are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with relevant regulations.

[0183] A person of ordinary skill in the art can understand that all or part of the processes in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a computer program, and the computer program can be stored in a non-volatile computer-readable storage medium. When the computer program is executed, it can include the processes of the embodiments of the above-mentioned methods. Among them, any reference to the memory, database or other medium used in the embodiments provided in the present application can include at least one of non-volatile memory and volatile memory. Non-volatile memory can include read-only memory (ROM), magnetic tape, floppy disk, flash memory, optical memory, high-density embedded non-volatile memory, resistive random access memory (ReRAM), magnetic random access memory (MRAM), ferroelectric random access memory (FRAM), phase change memory (PCM), graphene memory, etc. Volatile memory can include random access memory (RAM) or external cache memory, etc. As an illustration and not limitation, RAM can be in various forms, such as static random access memory (SRAM) or dynamic random access memory (DRAM). The database involved in each embodiment provided in this application may include at least one of a relational database and a non-relational database. Non-relational databases may include distributed databases based on blockchains, etc., but are not limited to this. The processor involved in each embodiment provided in this application may be a general-purpose processor, a central processing unit, a graphics processor, a digital signal processor, a programmable logic device, a data processing logic device based on quantum computing, an artificial intelligence (AI) processor, etc., but are not limited to this.

[0184] The technical features of the above embodiments may be combined arbitrarily. To make the description concise, not all possible combinations of the technical features in the above embodiments are described. However, as long as there is no contradiction in the combination of these technical features, they should be considered to be within the scope of this application.

[0185] The above-described embodiments only express several implementation methods of the present application, and the descriptions thereof are relatively specific and detailed, but they cannot be understood as limiting the scope of the present application. It should be pointed out that, for a person of ordinary skill in the art, several variations and improvements can be made without departing from the concept of the present application, and these all belong to the protection scope of the present application. Therefore, the protection scope of the present application shall be subject to the attached claims.

Claims

1. A method for virtualizing a graphics processor GPU in a container, characterized in that: The method comprises: When a GPU resource request submitted through a first container is detected, a monitoring thread corresponding to the first container is activated; the GPU resource request includes a first GPU computing power resource and a first GPU memory capacity of the applied first GPU; In the case of detecting a startup operation for the application in the first container, monitoring, through the monitoring thread, a call command of the first container for the first GPU; the call command is determined by the first container based on the GPU resource request; the call command is used to call the first GPU computing power resources and the first GPU video memory capacity of the first GPU; Based on the calling command, determining the first GPU computing power resources and the first GPU video memory capacity; When it is determined that the video memory capacity of the first GPU is less than or equal to the video memory quota corresponding to the first container, sending the first GPU computing power resources and the video memory capacity of the first GPU to a driver corresponding to the first GPU; The first GPU computing resources and the first GPU video memory capacity are allocated to the first container through a driver corresponding to the first GPU.

2. The method according to claim 1, characterized in that The method further comprises: When it is determined that the GPU video memory capacity of the first GPU called by the first container is less than or equal to the video memory quota corresponding to the first container, and the second GPU video memory capacity of the second GPU called by the second container is less than or equal to the video memory quota corresponding to the second container, determine the first GPU corresponding to the first container and the second GPU corresponding to the second container; When it is determined that the first GPU and the second GPU are the same, determining the target GPU computing resources based on the first GPU computing resources and the second GPU computing resources called by the second container; and determining the target GPU memory capacity based on the first GPU memory capacity and the second GPU memory capacity; Sending the target GPU computing power resources and the target GPU video memory capacity to a driver corresponding to the first GPU or the second GPU; The target GPU computing resources and the target GPU video memory capacity are allocated to the first container and the second container through a driver corresponding to the first GPU or the second GPU.

3. The method according to claim 2, characterized in that The method further comprises: When it is determined that the first GPU and the second GPU are different, sending the computing power resources of the first GPU and the video memory capacity of the first GPU to a driver of the first GPU, and sending the computing power resources of the second GPU and the video memory capacity of the second GPU to a driver of the second GPU; The first GPU computing power resources and the first GPU video memory capacity are allocated to the first container through the driver of the first GPU, and the second GPU computing power resources and the second GPU video memory capacity are allocated to the second container through the driver of the second GPU.

4. The method according to claim 3, characterized in that The method further comprises: Performing time slicing processing on the computing tasks in the first container and the computing tasks in the second container respectively, to obtain a plurality of first time slice tasks corresponding to the first container and a plurality of second time slice tasks corresponding to the second container; When it is determined that the first GPU and the second GPU are the same, based on the computing power resources of the first GPU and the computing power resources of the second GPU, a plurality of the first time slice tasks and a plurality of the second time slice tasks are re-arranged to obtain a plurality of arranged time slice tasks; wherein the time slice ratios of the plurality of the first time slice tasks and the plurality of the second time slice tasks are respectively the same as the ratio of the GPU computing power resources called by each container; The multiple time slice tasks after the arrangement are sent to the driver of the first GPU or the second GPU, so that the driver of the first GPU or the second GPU executes the multiple time slice tasks after the arrangement.

5. The method according to claim 4, characterized in that The method further comprises: When it is determined that the first GPU and the second GPU are different, multiple first time slice tasks are sent to the driver of the first GPU so that the driver of the first GPU executes multiple first time slice tasks, and multiple second time slice tasks are sent to the driver of the second GPU so that the driver of the second GPU executes multiple second time slice tasks.

6. The method according to any one of claims 1 to 5, characterized in that: The GPU resource request also includes instruction information for obtaining additional GPU resources; the method further includes: Monitoring, through the monitoring thread, usage information of the GPU computing resources and GPU memory capacity corresponding to the first container; When it is determined that the GPU resources required by the first container exceed the GPU resources applied for by the first container, and it is determined that there are idle GPU resources in the GPU, additional GPU resources are allocated to the first container; the GPU resources include GPU computing power resources and GPU video memory capacity.

7. A virtualization device for a graphics processor GPU in a container, characterized in that: The device comprises: A processing module, configured to activate a monitoring thread corresponding to the first container when a GPU resource request submitted through a first container is detected; the GPU resource request includes a first GPU computing power resource and a first GPU memory capacity of the applied first GPU; a monitoring module, configured to monitor, through the monitoring thread, a call command of the first container for the first GPU when a startup operation for the application in the first container is detected; the call command is determined by the first container based on the GPU resource request; the call command is used to call the first GPU computing power resources and the first GPU video memory capacity of the first GPU; A determination module, configured to determine the computing power resources of the first GPU and the video memory capacity of the first GPU based on the calling command; The processing module is configured to send the first GPU computing power resources and the first GPU memory capacity to a driver corresponding to the first GPU when it is determined that the first GPU memory capacity is less than or equal to the memory quota corresponding to the first container; An allocation module is used to allocate the first GPU computing power resources and the first GPU memory capacity to the first container through a driver corresponding to the first GPU.

8. A computer device, characterized in that: The method comprises a memory and a processor, wherein the memory stores a computer program, and the processor implements the steps of the method according to any one of claims 1 to 6 when executing the computer program.

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

10. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.

Citation Information

Patent Citations

  • Container-based resource scheduling method and device and container cluster management device

    CN113157428A

  • Resource scheduling method and device, electronic equipment and storage medium

    CN116414561A

  • Container-based internet of things platform GPU virtualization control system

    CN117349008A

  • Resource allocation method, device and equipment based on GPU (Graphics Processing Unit) and storage medium

    CN117591282A

  • GPU virtualization method and device, equipment and storage medium

    CN117788264A