A GPU resource allocation method, system, device and medium

By analyzing and dynamically managing the video memory requirements of deep learning tasks, allocating and releasing video memory, the problem of performance degradation caused by frequent switching of video memory in GPU time-sharing scenarios is solved, and GPU utilization and computing efficiency are improved.

CN114564302BActive Publication Date: 2024-10-15INSPUR SUZHOU INTELLIGENT TECH CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202210111346.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-01-29
Publication Date
2024-10-15
Estimated Expiration
2042-01-29

AI Technical Summary

Technical Problem

In a GPU time-sharing scenario, the performance of deep learning tasks is degraded due to frequent switching operations of video memory. Existing technology is difficult to effectively manage and allocate persistent and temporary video memory, resulting in overall performance loss.

Method used

By analyzing the video memory requirements of training tasks, persistent and temporary video memory are allocated, and dynamic management is performed during the iteration process. Temporary video memory is only released when necessary to ensure the continuous use of persistent video memory and avoid frequent switching of video memory.

Benefits of technology

It improves GPU utilization and training performance, reduces the waste of data center computing resources, and improves overall computing efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114564302B_ABST
    Figure CN114564302B_ABST
Patent Text Reader

Abstract

The present invention discloses a GPU resource allocation method, comprising the following steps: in response to receiving a training task, obtaining the type and size of video memory carried in the training task, wherein the video memory type includes persistent video memory and temporary video memory; allocating persistent video memory and / or temporary video memory of corresponding size to the training task according to the video memory type and size; in response to detecting that the current iteration of the training task ends, clearing the temporary video memory, and when the training task starts the next iteration training, reallocating the temporary video memory and continuing to use the initially allocated persistent video memory; in response to the end of the last iteration training of the training task, clearing the temporary video memory and the persistent video memory at the same time. The present invention also discloses a system, a computer device, and a readable storage medium. The solution proposed by the present invention ensures that the overall utilization of the GPU is maintained at a high level, thereby achieving the purpose of improving training performance and improving data center resource utilization.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of GPU, and in particular to a GPU resource allocation method, system, device and storage medium. Background Art

[0002] With the significant increase in computing power and the widespread implementation of artificial intelligence services, different types of high-performance devices have appeared in data centers to meet the different computing needs of artificial intelligence services, such as general-purpose GPUs (Graphics Processing Units) to meet training requirements. The purpose of this patent is to design a method for using and managing persistent video memory and temporary video memory for training, targeting the use of video memory in shared GPU technology, especially the task time slice rotation (time sharing) method. This strategy obtains and analyzes the use and allocation of GPU video memory by the model during training in the mainstream training framework, and then sets persistent video memory and temporary video memory when allocating video memory. When training multiple shared GPU tasks, only temporary video memory is swapped in and out, which can reduce the performance loss caused by frequent video memory operations when GPU time sharing is performed. This strategy can realize the analysis and management of model video memory usage through software methods, and is easy to implement and apply, thereby achieving the goals of improving GPU utilization and improving data center computing resource utilization.

[0003] The GPU resource requirements of deep learning tasks vary depending on the model. Different training frameworks have different strategies for using the underlying GPU memory. In the GPU time-sharing scenario, frequent switching operations of the memory during training will generate unnecessary overhead for the actual training tasks, resulting in a decrease in overall performance. Summary of the invention

[0004] In view of this, in order to overcome at least one aspect of the above problems, an embodiment of the present invention provides a GPU resource allocation method, comprising the following steps:

[0005] In response to receiving a training task, obtaining a type and size of a video memory carried in the training task, wherein the video memory type includes a persistent video memory and a temporary video memory;

[0006] Allocate a corresponding size of persistent video memory and / or temporary video memory to the training task according to the video memory type and size;

[0007] In response to detecting that the current iteration of the training task ends, clearing the temporary video memory, and when the training task starts the next iteration training, reallocating the temporary video memory and continuing to use the initially allocated persistent video memory;

[0008] In response to the end of the last iteration of the training task, the temporary video memory and the persistent video memory are cleared simultaneously.

[0009] In some embodiments, allocating a corresponding size of persistent video memory and / or temporary video memory to the training task according to the video memory type and size further includes:

[0010] In response to the current GPU being a shared GPU, obtaining an address of a persistent video memory allocated in the current CPU;

[0011] The persistent video memory is allocated to the training task after being offset by a preset size based on the address of the allocated persistent video memory.

[0012] In some embodiments, in response to receiving a training task, obtaining a type and size of a video memory carried in the training task, wherein the video memory type includes a persistent video memory and a temporary video memory, further comprising:

[0013] The hijacking function in the training task is used to obtain the type and size of video memory required by the training task and send it to the manager of the GPU.

[0014] In some embodiments, allocating a corresponding size of persistent video memory and / or temporary video memory to the training task according to the video memory type and size further includes:

[0015] Set up persistent and temporary areas for each GPU's video memory;

[0016] Statistics on the usage of the persistent area and temporary area in each GPU;

[0017] The persistent video memory and / or temporary video memory is allocated to the training task according to usage of the persistent area and the temporary area in each GPU.

[0018] Based on the same inventive concept, according to another aspect of the present invention, an embodiment of the present invention further provides a GPU resource allocation system, including:

[0019] An acquisition module, configured to, in response to receiving a training task, acquire a type and size of a video memory carried in the training task, wherein the video memory type includes a persistent video memory and a temporary video memory;

[0020] An allocation module, configured to allocate a corresponding size of persistent video memory and / or temporary video memory to the training task according to the video memory type and size;

[0021] A first cleaning module is configured to clean up the temporary video memory in response to detecting that the current iteration of the training task ends, and when the training task starts the next iteration training, reallocate the temporary video memory and continue to use the initially allocated persistent video memory;

[0022] The second cleaning module is configured to clean up the temporary video memory and the persistent video memory simultaneously in response to the end of the last iteration training of the training task.

[0023] In some embodiments, the allocation module is further configured to:

[0024] In response to the current GPU being a shared GPU, obtaining an address of a persistent video memory allocated in the current CPU;

[0025] The persistent video memory is allocated to the training task after being offset by a preset size based on the address of the allocated persistent video memory.

[0026] In some embodiments, the acquisition module is further configured to:

[0027] The hijacking function in the training task is used to obtain the type and size of video memory required by the training task and send it to the manager of the GPU.

[0028] In some embodiments, the acquisition module is further configured to:

[0029] Set up persistent and temporary areas for each GPU's video memory;

[0030] Statistics on the usage of the persistent area and temporary area in each GPU;

[0031] The persistent video memory and / or temporary video memory is allocated to the training task according to usage of the persistent area and the temporary area in each GPU.

[0032] Based on the same inventive concept, according to another aspect of the present invention, an embodiment of the present invention further provides a computer device, including:

[0033] at least one processor; and

[0034] A memory storing a computer program executable on the processor, wherein the processor executes the steps of any one of the above-mentioned GPU resource allocation methods when executing the program.

[0035] Based on the same inventive concept, according to another aspect of the present invention, an embodiment of the present invention further provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of any one of the GPU resource allocation methods described above are performed.

[0036] The present invention has one of the following beneficial technical effects: the solution proposed in the present invention analyzes the GPU video memory requirements (type, size) within the iteration of deep learning jobs, and especially for GPU sharing scenarios, allocates and manages the video memory types by region (persistent, temporary) in GPU time-sharing scenarios, thereby avoiding performance loss caused by frequent switching of data in the video memory when the GPU is shared, and at the same time ensuring that the overall utilization of the GPU is maintained at a high level, thereby achieving the purpose of improving training performance and improving data center resource utilization. BRIEF DESCRIPTION OF THE DRAWINGS

[0037] In order to more clearly illustrate the embodiments of the present invention or the technical solutions in the prior art, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings in the following description are only some embodiments of the present invention. For ordinary technicians in this field, other embodiments can be obtained based on these drawings without paying creative work.

[0038] Figure 1 A flowchart of a GPU resource allocation method provided by an embodiment of the present invention;

[0039] Figure 2 A schematic diagram of the GPU memory area configuration according to an embodiment of the present invention;

[0040] Figure 3 A flowchart of a GPU resource allocation method provided by an embodiment of the present invention;

[0041] Figure 4 A schematic diagram of the structure of a GPU resource allocation system provided by an embodiment of the present invention;

[0042] Figure 5 A schematic diagram of the structure of a computer device provided by an embodiment of the present invention;

[0043] Figure 6 A schematic diagram of the structure of a computer-readable storage medium provided for an embodiment of the present invention. DETAILED DESCRIPTION

[0044] In order to make the objectives, technical solutions and advantages of the present invention more clearly understood, the embodiments of the present invention are further described in detail below in combination with specific embodiments and with reference to the accompanying drawings.

[0045] It should be noted that all expressions using "first" and "second" in the embodiments of the present invention are for distinguishing two non-identical entities with the same name or non-identical parameters. It can be seen that "first" and "second" are only for the convenience of expression and should not be understood as limitations on the embodiments of the present invention. The subsequent embodiments will not explain this one by one.

[0046] According to one aspect of the present invention, an embodiment of the present invention provides a GPU resource allocation method, such as Figure 1 As shown, it may include the steps of:

[0047] S1, in response to receiving a training task, obtaining a type and size of a video memory carried in the training task, wherein the video memory type includes a persistent video memory and a temporary video memory;

[0048] S2, allocating a corresponding size of persistent video memory and / or temporary video memory to the training task according to the video memory type and size;

[0049] S3, in response to detecting that the current iteration of the training task ends, clearing the temporary video memory, and when the training task starts the next iteration training, reallocating the temporary video memory and continuing to use the initially allocated persistent video memory;

[0050] S4, in response to the end of the last iteration of the training task, clearing the temporary video memory and the persistent video memory at the same time.

[0051] The solution proposed in the present invention analyzes the GPU video memory requirements (type, size) within the iteration of deep learning jobs, and especially for the GPU sharing scenario, allocates and manages the video memory type by region (persistent, temporary) in the GPU time-sharing scenario. When the training task is switched in time-sharing, only the temporary video memory is released, and the next time the task is allocated, a specific memory area will be specified for allocation. This design can achieve fast switching of training tasks and efficient video memory management, avoiding performance loss caused by frequent switching of data in the video memory when the GPU is shared, and at the same time ensuring that the overall utilization of the GPU is maintained at a high level, thereby achieving the purpose of improving training performance and improving the utilization of data center resources.

[0052] In some embodiments, S1, in response to receiving a training task, obtaining a type and size of a video memory carried in the training task, wherein the video memory type includes a persistent video memory and a temporary video memory, further comprising:

[0053] The hijacking function in the training task is used to obtain the type and size of video memory required by the training task and send it to the manager of the GPU.

[0054] Specifically, before submitting the training task to the GPU for execution, add a corresponding custom built-in hijacking function to the training framework to collect the video memory usage information required for training and send it to the video memory usage manager. The information required by the video memory usage manager mainly includes the video memory type and corresponding size required for the training task to be run (obtained through the corresponding cuda API). In this way, before the training task is launched to a specific GPU, the framework obtains the video memory type and size information of the model through the CUDA API and stores it in the manager.

[0055] In some embodiments, allocating a corresponding size of persistent video memory and / or temporary video memory to the training task according to the video memory type and size further includes:

[0056] Set up persistent and temporary areas for each GPU's video memory;

[0057] Statistics on the usage of the persistent area and temporary area in each GPU;

[0058] The persistent video memory and / or temporary video memory is allocated to the training task according to usage of the persistent area and the temporary area in each GPU.

[0059] Specifically, Figure 2 and Figure 3 As shown, a GPU video memory sharing manager process can be designed to mainly implement GPU video memory usage statistics, obtain actual video memory requirements and allocation for training, so that before the training task is started, the GPU video memory sharing manager obtains and updates the resource and task information of each GPU of the current node. Then, according to the existing GPU usage information in the manager, the memory mode and allocation method of the GPU task to be run are determined, that is, the persistent area is designated to allocate the persistent video memory area, and the temporary area is designated to allocate the temporary video memory. Here, the starting addresses of the persistent and temporary video memories are as far apart as possible while ensuring the usage size, so as to ensure the normal use of subsequent shared tasks. And when the task running on the current GPU time ends, the temporary video memory cleanup action is triggered immediately, and the persistent video memory is not processed. If the task is already the last iteration, the persistent video memory will be cleaned up synchronously.

[0060] In some embodiments, allocating a corresponding size of persistent video memory and / or temporary video memory to the training task according to the video memory type and size further includes:

[0061] In response to the current GPU being a shared GPU, obtaining an address of a persistent video memory allocated in the current CPU;

[0062] The persistent video memory is allocated to the training task after being offset by a preset size based on the address of the allocated persistent video memory.

[0063] Specifically, if a new shared task is submitted to the same GPU, proceed to step 2. When executing step 3, the persistent video memory is allocated to the task of the previous GPU time slice, and there needs to be enough offset. According to experience, it is generally set to several hundred MB to several GB depending on the model and data volume (here it is temporarily designed to be user-defined, the default is 100MB), and then the GPU usage information in the manager is updated.

[0064] The solution proposed in the present invention analyzes the demand pattern of GPU video memory of the deep learning framework within the job iteration, divides the video memory used for training into persistent video memory and temporary video memory, and designs and utilizes the GPU video memory sharing manager to achieve control.

[0065] The GPU memory manager needs to obtain the GPU resources and usage of the current node, and then update the information. Before submitting the training task to the GPU for running, add the corresponding custom function in the training framework to collect the memory usage information required for training and send it to the memory usage manager. The information required by the memory usage manager mainly includes the memory type and corresponding size required for the training task to be run (obtained through the corresponding cuda API). Secondly, after obtaining the memory usage of the training task, it is used when allocating the memory according to the GPU usage in the current node. There are the following situations for single-task and multi-task sharing:

[0066] 1. The GPU only runs a single task, and the video memory management is completely managed by the video memory management mechanism of the training framework. The video memory manager of this patent does not perform any operation;

[0067] 2. When the GPU is a shared device, a memory area will be designated for persistent video memory usage when a training task is assigned for the first time, and its corresponding task information will be recorded in the manager. The video memory will not be released after the current GPU time slice task is completed. The video memory usage of the new task is determined based on the video memory address used by the current training task and the information of the new shared training.

[0068] 3. The principle of using temporary video memory is that when it is not a shared GPU task, the actual running framework is responsible. When it is a GPU shared task, since this patent is aimed at time-sharing tasks, when allocating and using video memory, the memory address of the temporary video memory is also specified for use. Therefore, when each task running in the current GPU time slice is completed, an active video memory cleanup action is performed to provide for use by subsequent shared tasks.

[0069] In this way, when the training framework sends a kernel request to the GPU for a training task, it includes the GPU memory usage type (persistent or temporary) and size required in the training process. The current task memory usage type and size are analyzed and recorded, and this information will be uniformly scheduled by the GPU memory sharing controller. Since multiple tasks share a GPU in the GPU time-sharing scenario, it is necessary to specify memory areas for allocation when allocating persistent and temporary memory. In this way, when switching tasks, the persistent memory part can directly use the allocated memory address, and the temporary memory can be cleaned up as it is used, thereby achieving the purpose of improving training performance and improving data center resource utilization.

[0070] Based on the same inventive concept, according to another aspect of the present invention, an embodiment of the present invention further provides a GPU resource allocation system 400, such as Figure 4 As shown, including:

[0071] The acquisition module 401 is configured to, in response to receiving a training task, acquire the type and size of the video memory carried in the training task, wherein the video memory type includes a persistent video memory and a temporary video memory;

[0072] An allocation module 402 is configured to allocate a corresponding size of persistent video memory and / or temporary video memory to the training task according to the video memory type and size;

[0073] A first cleaning module 403 is configured to clean up the temporary video memory in response to detecting that the current iteration of the training task ends, and when the training task starts the next iteration training, reallocate the temporary video memory and continue to use the initially allocated persistent video memory;

[0074] The second cleaning module 404 is configured to clean up the temporary video memory and the persistent video memory simultaneously in response to the end of the last iteration training of the training task.

[0075] In some embodiments, the allocation module 402 is further configured to:

[0076] In response to the current GPU being a shared GPU, obtaining an address of a persistent video memory allocated in the current CPU;

[0077] The persistent video memory is allocated to the training task after being offset by a preset size based on the address of the allocated persistent video memory.

[0078] In some embodiments, the acquisition module 401 is further configured to:

[0079] The hijacking function in the training task is used to obtain the type and size of video memory required by the training task and send it to the manager of the GPU.

[0080] In some embodiments, the acquisition module 401 is further configured to:

[0081] Set up persistent and temporary areas for each GPU's video memory;

[0082] Statistics on the usage of the persistent area and temporary area in each GPU;

[0083] The persistent video memory and / or temporary video memory is allocated to the training task according to usage of the persistent area and the temporary area in each GPU.

[0084] Based on the same inventive concept, according to another aspect of the present invention, Figure 5As shown, an embodiment of the present invention further provides a computer device 501, including:

[0085] at least one processor 520; and

[0086] The memory 510 stores a computer program 511 that can be run on the processor. When the processor 520 executes the program, the processor 520 performs the steps of any of the above GPU resource allocation methods.

[0087] Based on the same inventive concept, according to another aspect of the present invention, Figure 6 As shown, an embodiment of the present invention further provides a computer-readable storage medium 601, which stores computer program instructions 610. When the computer program instructions 610 are executed by a processor, the steps of any one of the above GPU resource allocation methods are performed.

[0088] Finally, it should be noted that a person skilled in the art can understand that all or part of the processes in the above-mentioned embodiment methods can be implemented by instructing related hardware through a computer program, and the program can be stored in a computer-readable storage medium. When the program is executed, it can include the processes of the embodiments of the above-mentioned methods.

[0089] Furthermore, it should be appreciated that the computer-readable storage medium (eg, memory) herein may be either a volatile memory or a nonvolatile memory, or may include both volatile and nonvolatile memory.

[0090] It will also be appreciated by those skilled in the art that various exemplary logic blocks, modules, circuits and algorithm steps described in conjunction with the disclosure herein can be implemented as electronic hardware, computer software or a combination of the two. In order to clearly illustrate this interchangeability of hardware and software, a general description has been given to the functions of various schematic components, blocks, modules, circuits and steps. Whether this function is implemented as software or hardware depends on specific applications and the design constraints imposed on the entire system. Those skilled in the art can implement the function in various ways for each specific application, but this implementation decision should not be interpreted as causing a departure from the disclosed scope of the embodiments of the present invention.

[0091] The above are exemplary embodiments disclosed in the present invention, but it should be noted that various changes and modifications may be made without departing from the scope disclosed in the embodiments of the present invention as defined in the claims. The functions, steps and / or actions of the method claims according to the disclosed embodiments described herein do not need to be performed in any particular order. In addition, although the elements disclosed in the embodiments of the present invention may be described or required in individual form, they may also be understood as multiple unless explicitly limited to the singular.

[0092] It should be understood that, as used herein, the singular forms "a", "an" are intended to include the plural forms as well, unless the context clearly supports an exception. It should also be understood that, as used herein, "and / or" refers to any and all possible combinations including one or more of the associated listed items.

[0093] The serial numbers of the embodiments disclosed in the above embodiments of the present invention are only for description and do not represent the advantages or disadvantages of the embodiments.

[0094] A person skilled in the art will understand that all or part of the steps to implement the above embodiments may be accomplished by hardware or by instructing related hardware through a program, and the program may be stored in a computer-readable storage medium, and the above-mentioned storage medium may be a read-only memory, a disk or an optical disk, etc.

[0095] A person skilled in the art should understand that the discussion of any of the above embodiments is only exemplary and is not intended to imply that the scope of the disclosure of the embodiments of the present invention (including the claims) is limited to these examples; under the concept of the embodiments of the present invention, the technical features in the above embodiments or different embodiments can also be combined, and there are many other changes in different aspects of the embodiments of the present invention as above, which are not provided in detail for the sake of simplicity. Therefore, any omissions, modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the embodiments of the present invention should be included in the protection scope of the embodiments of the present invention.

Claims

1. A GPU resource allocation method, characterized in that: The following steps are involved: In response to receiving a training task, obtaining a type and size of a video memory carried in the training task, wherein the video memory type includes a persistent video memory and a temporary video memory; Allocate a corresponding size of persistent video memory and / or temporary video memory to the training task according to the video memory type and size; In response to detecting that the current iteration of the training task ends, clearing the temporary video memory, and when the training task starts the next iteration training, reallocating the temporary video memory and continuing to use the initially allocated persistent video memory; In response to the end of the last iteration of the training task, the temporary video memory and the persistent video memory are cleared simultaneously.

2. The method according to claim 1, characterized in that Allocating a corresponding size of persistent video memory and / or temporary video memory to the training task according to the video memory type and size, further comprising: In response to the current GPU being a shared GPU, obtaining an address of a persistent video memory allocated in the current CPU; The persistent video memory is allocated to the training task after being offset by a preset size based on the address of the allocated persistent video memory.

3. The method according to claim 1, characterized in that In response to receiving a training task, obtaining a type and size of a video memory carried in the training task, wherein the video memory type includes a persistent video memory and a temporary video memory, further comprising: The hijacking function in the training task is used to obtain the type and size of video memory required by the training task and send it to the manager of the GPU.

4. The method according to claim 3, characterized in that Allocating a corresponding size of persistent video memory and / or temporary video memory to the training task according to the video memory type and size, further comprising: Set up persistent and temporary areas for each GPU's video memory; Statistics on the usage of the persistent area and temporary area in each GPU; The persistent video memory and / or temporary video memory is allocated to the training task according to usage of the persistent area and the temporary area in each GPU.

5. A GPU resource allocation system, characterized in that: include: An acquisition module, configured to, in response to receiving a training task, acquire a type and size of a video memory carried in the training task, wherein the video memory type includes a persistent video memory and a temporary video memory; An allocation module, configured to allocate a corresponding size of persistent video memory and / or temporary video memory to the training task according to the video memory type and size; A first cleaning module is configured to clean up the temporary video memory in response to detecting that the current iteration of the training task ends, and when the training task starts the next iteration training, reallocate the temporary video memory and continue to use the initially allocated persistent video memory; The second cleaning module is configured to clean up the temporary video memory and the persistent video memory simultaneously in response to the end of the last iteration training of the training task.

6. The system according to claim 5, characterized in that The allocation module is also configured to: In response to the current GPU being a shared GPU, obtaining an address of a persistent video memory allocated in the current CPU; The persistent video memory is allocated to the training task after being offset by a preset size based on the address of the allocated persistent video memory.

7. The system according to claim 5, characterized in that The fetch module is also configured as: The hijacking function in the training task is used to obtain the type and size of video memory required by the training task and send it to the manager of the GPU.

8. The system according to claim 7, characterized in that The fetch module is also configured as: Set up persistent and temporary areas for each GPU's video memory; Statistics on the usage of the persistent area and temporary area in each GPU; The persistent video memory and / or temporary video memory is allocated to the training task according to usage of the persistent area and the temporary area in each GPU.

9. A computer device comprising: at least one processor; as well as A memory storing a computer program executable on the processor, wherein the processor executes the steps of the method according to any one of claims 1 to 4 when executing the program.

10. A computer-readable storage medium storing 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 4 are performed.