A video memory sharing method, device, equipment and storage medium

By sharing memoryless video memory and task scheduling strategies in the deep learning framework, the problem of video memory cache and resource competition when multi-tasking shares the GPU is solved, achieving more efficient resource utilization and task switching, and improving the performance of GPU cluster computing.

CN114880147BActive Publication Date: 2024-10-22INSPUR SUZHOU INTELLIGENT TECH CO LTD
View PDF 6 Cites 0 Cited by

Patent Information

Application Number
CN202210611090.2
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-05-31
Publication Date
2024-10-22
Estimated Expiration
2042-05-31

AI Technical Summary

Technical Problem

In deep learning training tasks, when multiple tasks share the GPU, the video memory manager caches the video memory of all tasks, limiting the number of tasks and resource utilization, resulting in resource competition and frequent switching, resulting in performance losses.

Method used

By obtaining the memoryless memory information of multiple training tasks in the deep learning framework, the target memoryless memory is determined, and a shared memory handle is generated, passed to the task using the process communication interface, and the iterative operation is controlled based on the preset task scheduling strategy to realize the memory Sharing and task switching to avoid memory caching and data transfer.

Benefits of technology

In the case of limited video memory, the number of tasks is increased, resource utilization is improved, resource competition and context switching losses between tasks are reduced, and the efficiency of GPU cluster computing is improved.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114880147B_ABST
    Figure CN114880147B_ABST
Patent Text Reader

Abstract

The present application discloses a video memory sharing method, device, equipment and storage medium, which relates to the field of computer control technology and is applied to a video memory manager. The method includes: obtaining information of memoryless video memory of multiple training tasks in a deep learning framework and determining shared video memory based on the information of memoryless video memory; the memoryless video memory is video memory that does not need to be transferred between iterations when executing training tasks; the handle and size of the shared video memory are passed to the current training task through the first process communication interface, so that the current training task mounts the shared video memory to the deep learning framework through the second process communication interface; based on a preset task scheduling strategy, the current training task is controlled to perform a target number of iterations; after the current training task has completed the target number of iterations, the current training task is switched to other training tasks, and other training tasks are performed according to the shared video memory. Through the technical solution of the present application, video memory sharing between multiple tasks can be achieved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to the field of computer control technology, and in particular to a video memory sharing method, device, equipment and storage medium. Background Art

[0002] In the era of big data of artificial intelligence, with the continuous increase of data volume and the development of deep learning algorithms, the demand for computing power is also increasing, and various types of high-performance devices have emerged, such as general-purpose GPUs (Graphics Processing Units). In deep learning training tasks, different training models have different requirements for GPU video memory resources, but the allocation and management of the required video memory in each framework have certain commonalities. As for the current mainstream deep learning training frameworks, such as TensorFlow (an end-to-end open source machine learning platform) and PyTorch (an open source Python machine learning library), in order to speed up the speed of a single training task, they use the video memory manager in the learning framework to manage the video memory allocated for the first iter (iteration, a batch sample training process in deep learning training), such as the BFC Allocator in the TensorFlow framework (the video memory manager in TensorFlow). In this way, the execution of subsequent iters does not need to call the video memory allocation function, but directly obtains the video memory from the video memory manager in the learning framework, which improves the training rate. However, the task memory obtained by the nvidia-smi command used to obtain the video memory is the sum of the video memory of the video memory manager and cuda context (a container) in the learning framework, not the actual video memory size used by the task. When multiple tasks share the GPU by default, the video memory manager in the learning framework will cache all the video memory of all training tasks, so the number of multiple training tasks when sharing the video memory is limited, which is not conducive to multi-user use. In addition, competition for GPU resources between tasks and switching of GPU contexts also result in performance loss.

[0003] In summary, how to share the video memory among multiple tasks, avoid the GPU caching all the video memory of all tasks, increase the number of shared GPU tasks under a certain video memory condition, allow more users to use it at the same time, and avoid competition for GPU resources among multiple tasks and performance loss caused by frequent switching of GPU contexts, so as to improve the utilization rate of GPU cluster computing resources are the problems that need to be solved at present. Summary of the invention

[0004] In view of this, the purpose of the present invention is to provide a video memory sharing method, device, equipment and storage medium, which can realize the sharing of video memory among multiple tasks, avoid the GPU caching all video memory of all tasks, increase the number of shared GPU tasks under the condition of certain video memory, allow more users to use it at the same time, and avoid the competition of GPU resources among multiple tasks and the performance loss caused by frequent switching of GPU context, so as to improve the utilization rate of GPU cluster computing resources. The specific scheme is as follows:

[0005] In a first aspect, the present application discloses a video memory sharing method, which is applied to a video memory manager, comprising:

[0006] Acquire information of memoryless video memory of multiple training tasks in a deep learning framework, and determine a target memoryless video memory based on the information of the memoryless video memory to obtain a shared video memory; wherein the memoryless video memory is a video memory that does not need to be transferred between iterations when executing the training task;

[0007] Generate a handle to the shared video memory, and pass the handle to the shared video memory and the size of the shared video memory to a current training task among the multiple training tasks through a first process communication interface, so that the current training task mounts the shared video memory to the deep learning framework through a second process communication interface;

[0008] Based on a preset task scheduling strategy, control the current training task to perform a target number of iterations; wherein the target number is the number of iterations determined based on the time slice pre-allocated to the current training task and the time required for the current training task to complete a single iteration;

[0009] When the current training task completes the target number of iterations, the current training task is switched to other training tasks among the multiple training tasks, and the other training tasks are executed according to the shared video memory.

[0010] Optionally, determining the target memoryless video memory based on the information of the memoryless video memory to obtain the shared video memory includes:

[0011] Based on the information of the memoryless video memory, the largest target memoryless video memory in the memoryless video memory is determined to obtain a shared video memory.

[0012] Optionally, after switching the current training task to another training task among the multiple training tasks and executing the other training task according to the shared video memory, the method further includes:

[0013] When a new task is created, the shared video memory is adjusted according to the memoryless video memory of the new task.

[0014] Optionally, adjusting the shared video memory according to the memoryless video memory of the new task includes:

[0015] When the memoryless video memory of the new task is larger than the shared video memory, allocating video memory to the new task using a video memory allocation function;

[0016] Determine whether the video memory is allocated successfully. If the video memory is allocated successfully, adjust the shared video memory to the memoryless video memory size of the new task. If the video memory allocation is unsuccessful, remove the new task and go back to the state before the new task is created to keep the shared cache size unchanged.

[0017] Optionally, the video memory sharing method further includes:

[0018] Before executing the first iteration of the new task, the shared video memory is released, and after the first iteration is executed, the memoryless video memory occupied by the first iteration is released.

[0019] Optionally, before executing the first iteration of the new task, releasing the shared video memory, and after the first iteration is executed, releasing the memoryless video memory occupied by the first iteration, includes:

[0020] Before executing the first iteration of the new task, the application programming interface of the unified computing device architecture is called to release the shared video memory, and after the first iteration is executed, the custom interface is called to release the memoryless video memory occupied by the first iteration.

[0021] Optionally, when the current training task completes the target number of iterations, switching the current training task to another training task among the multiple training tasks includes:

[0022] Obtaining the running status information of the current training task after executing the target number of iteration operations;

[0023] The running status information is reported to a preset node task scheduler so that the node task scheduler deletes the iteration information of the current training task and notifies the video memory manager to delete the memoryless video memory of the current training task.

[0024] In a second aspect, the present application discloses a video memory sharing device, which is applied to a video memory manager, comprising:

[0025] A shared video memory determination module, used to obtain information about memoryless video memory of multiple training tasks in a deep learning framework, and determine a target memoryless video memory based on the information about the memoryless video memory to obtain a shared video memory; wherein the memoryless video memory is a video memory that does not need to be transferred between iterations when executing the training task;

[0026] A training task execution module, used to generate a handle of the shared video memory, and pass the handle of the shared video memory and the size of the shared video memory to a current training task among the multiple training tasks through a first process communication interface, so that the current training task mounts the shared video memory to the deep learning framework through a second process communication interface;

[0027] A training task polling module, used to control the current training task to perform a target number of iterations based on a preset task scheduling strategy; wherein the target number is the number of iterations determined based on the time slice pre-allocated to the current training task and the time required for the current training task to complete a single iteration;

[0028] A training task switching module is used to switch the current training task to other training tasks among the multiple training tasks when the current training task completes the target number of iteration operations, and execute the other training tasks according to the shared video memory.

[0029] In a third aspect, the present application discloses an electronic device, comprising a processor and a memory; wherein the memory is used to store a computer program, and the computer program is loaded and executed by the processor to implement the video memory sharing method as described above.

[0030] In a fourth aspect, the present application discloses a computer-readable storage medium for storing a computer program; wherein the computer program, when executed by a processor, implements the video memory sharing method as described above.

[0031] In the present application, a video memory manager is applied to first obtaining information of memoryless video memories of multiple training tasks in a deep learning framework, and determining a target memoryless video memory based on the information of the memoryless video memory to obtain a shared video memory; wherein the memoryless video memory is a video memory that does not need to be transferred between iterations when executing the training task; then a handle to the shared video memory is generated, and the handle to the shared video memory and the size of the shared video memory are passed to a current training task among the multiple training tasks through a first process communication interface, so that the current training task mounts the shared video memory to the deep learning framework through a second process communication interface; based on a preset task scheduling strategy, the current training task is controlled to perform a target number of iteration operations; wherein the target number of iterations is determined based on a time slice pre-allocated to the current training task and the time required for the current training task to complete a single iteration; when the current training task completes the target number of iteration operations, the current training task is switched to other training tasks among the multiple training tasks, and the other training tasks are executed according to the shared video memory. It can be seen that the information of the memoryless video memory that does not need to be transferred between iterations when executing training tasks is obtained. By using the largest memoryless video memory as the shared video memory between multiple training tasks, the GPU can be prevented from caching all the video memory of all training tasks when multiple training tasks share the video memory, and the shared video memory can also be used by other training tasks. Under certain video memory conditions, the number of shared GPU tasks is increased to allow more users to use it. In addition, since the data information of the memoryless video memory does not need to be transferred between iterations, the data can be saved and cleaned up when switching tasks, which speeds up the switching rate between tasks. At the same time, in order to make up for the differences in the running time of multiple training tasks when sharing video memory, the training tasks are iterated using time slices to make the running time of each training task as fair as possible, and the use of time slices and preset task scheduling strategies can ensure that only a single task uses the GPU within a certain time slice, and also avoid resource competition between multiple tasks, as well as performance losses caused by frequent context switching, and improve the utilization of cluster computing resources. BRIEF DESCRIPTION OF THE DRAWINGS

[0032] 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 described below are only embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on the provided drawings without paying creative work.

[0033] Figure 1 A flow chart of a video memory sharing method disclosed in this application;

[0034] Figure 2A comparison chart of the number of memory management tasks disclosed in this application and TensorFlow;

[0035] Figure 3 A video memory sharing management method and strategy diagram disclosed in this application;

[0036] Figure 4 A flowchart of a specific video memory sharing method disclosed in this application;

[0037] Figure 5 Create a flow chart for a new task disclosed in this application;

[0038] Figure 6 A video memory sharing and iterative execution flow chart disclosed in this application;

[0039] Figure 7 A schematic diagram of the structure of a video memory sharing device disclosed in this application;

[0040] Figure 8 This is a structural diagram of an electronic device disclosed in this application. DETAILED DESCRIPTION

[0041] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.

[0042] Currently, in deep learning training tasks, when multiple tasks share the GPU by default, the video memory manager in the learning framework will cache all the video memory of all training tasks. Therefore, the number of multiple training tasks when sharing the video memory is limited, which is not conducive to multi-user use. In addition, the competition for GPU resources between tasks and the switching of GPU contexts also cause performance losses.

[0043] To this end, the present application provides a video memory sharing solution that can realize video memory sharing among multiple tasks, avoid the GPU caching all video memory of all tasks, increase the number of shared GPU tasks when the video memory is fixed, and allow more users to use it at the same time. It also avoids competition for GPU resources among multiple tasks and performance loss caused by frequent switching of GPU contexts, and improves the utilization rate of GPU cluster computing resources.

[0044] The embodiment of the present invention discloses a video memory sharing method, see Figure 1 As shown, applied to a video memory manager, the method includes:

[0045] Step S11: Obtain information about memoryless video memory of multiple training tasks in a deep learning framework, and determine a target memoryless video memory based on the information about the memoryless video memory to obtain a shared video memory; wherein the memoryless video memory is a video memory that does not need to be transferred between iterations when executing the training task.

[0046] In the embodiment of the present application, since the GPU will cache all the video memory of all tasks when the traditional multiple training tasks share the GPU, the number of shared tasks is limited, which is not conducive to the use of multiple users. Therefore, by analyzing the allocation characteristics of the video memory of the training task, an acquisition interface for free regions (free areas, a section of video memory space with continuous addresses) is added to the deep learning framework, so that the video memory manager (GPU Memory Coordinator) can obtain the information of the memoryless video memory of multiple training tasks in the deep learning framework through the preset interface. In this way, compared with the analysis of the run graph and the kernel (kernel function, the execution function placed on the GPU), the implementation is simpler and easier.

[0047] In the embodiment of the present application, since the memoryless video memory usually occupies more than half of the video memory required for the entire training task, such as when resnet 50 batch_size = 32, the memory video memory is only 1GB, and the memoryless video memory is 4GB (due to the video memory allocation mechanism of the framework, it is usually displayed as 8G). Therefore, by acquiring the memoryless video memory to analyze the management mechanism of the deep learning framework for video memory, the analysis and management of video memory can be more clearly realized. According to the dependency relationship between iterations (iter, a batch sample training process in deep learning training), the video memory of the training task can be divided into two categories: 1. Memoryless video memory, which is put back into the free list of the video memory manager after the iter ends; 2. Memory video memory, the video memory is always occupied by the tensor until the end of the task. That is, the data information of the memoryless video memory does not need to be transferred between iters, so it is invalid between iters, and the data can be saved and cleaned up when the task is switched.

[0048] Further, based on the information of the memoryless video memory, the largest target memoryless video memory in the memoryless video memory is determined to obtain the shared video memory. It should be noted that when multiple tasks share the GPU, the video memory manager is used to record the information of the memoryless video memory of each task, and select the largest memoryless video memory in the shared task as the size of the shared video memory. For example, the information of the memoryless video memory of each task can be recorded as jobi_temp, then shared_memory = MAX(jobi_temp).

[0049] Step S12: Generate a handle to the shared video memory, and pass the handle to the shared video memory and the size of the shared video memory to the current training task among the multiple training tasks through the first process communication interface, so that the current training task mounts the shared video memory to the deep learning framework through the second process communication interface.

[0050] In an embodiment of the present application, after determining the largest target memoryless video memory in the memoryless video memory to obtain the shared video memory, a handle to the shared video memory is generated, and then the handle to the shared video memory and the size of the shared video memory are passed to the current training task among the multiple training tasks through the first process communication interface. In this way, the current training task mounts the shared video memory to the deep learning framework through the second process communication interface, and then can perform iterations according to the shared video memory to complete the scheduling of the training tasks.

[0051] In a specific implementation, when a task is running, the video memory manager passes the handle and size of the shared video memory to the training task through linux IPC (Inter-Process Communication), so that the training task can use the corresponding interfaces such as cuda IPC (Compute Unified Device Architecture) to map and mount the shared video memory to the deep learning framework after receiving it. It is understandable that when executing a training task, the memoryless video memory occupied by the first iteration will be released after the first iteration ends, so the video memory needs to be expanded when the iteration is executed again. In theory, the size of the expanded video memory is the size of the memoryless video memory occupied by the first iteration. Therefore, the transfer, mapping and use of video memory between tasks are realized through interfaces such as linux IPC and cuda IPC, and the function of shared video memory use between multiple tasks is realized.

[0052] Step S13: Based on a preset task scheduling strategy, control the current training task to perform a target number of iterations; wherein the target number is the number of iterations determined based on the time slice pre-allocated to the current training task and the time required for the current training task to complete a single iteration.

[0053] In an embodiment of the present application, the video memory manager controls the logic of task scheduling and video memory sharing based on a preset task scheduling strategy. For example, the training tasks can be controlled to queue up and adopt a "first come, first served" strategy. It should be pointed out that the default GPU underlying execution mode is based on the rotation of time slices, which requires that all video memory data of the task is located on the GPU. In order to make up for the difference in iterative running time between tasks, the polling method combining time slices and iterations is used to achieve the sharing of video memory between multiple tasks, while ensuring the correctness and speed of each task training. Under the premise of increasing the number of tasks that can be trained on a single GPU. For example, assuming that the time slice time required for a training task is △T, and the iterative running time of the task is t, when the task is scheduled, the number of iterations to be run is △T / t, which is rounded to at least 1 iteration. When the time of one training task is less than the running time of another training task, the fairness of the shared task running time can be achieved as much as possible by increasing the number of iterations of the training task with less training time.

[0054] For example, Figure 2 The figure shows the comparison between the embodiment of the present application and TensorFlow memory management when GPUv100 resnet50 batch_size=32. (a) is a graph of the number of tasks that can be executed by the embodiment of the present application, and (b) is a graph of the number of tasks that can be executed by TensorFlow memory management. It can be seen that compared with TensorFlow memory management, the embodiment of the present application can execute more training tasks, which can not only achieve fast switching between tasks, but also increase the number of shared GPU tasks for more users to use.

[0055] Step S14: when the current training task completes the target number of iterations, the current training task is switched to another training task among the multiple training tasks, and the other training tasks are executed according to the shared video memory.

[0056] In the embodiment of the present application, the switching between tasks only occurs at the end of the iteration, so there is no need to save the data of the memoryless video memory of the task when switching tasks. After the current training task has completed the target number of iteration operations, that is, when the training task is finished, the training task will report its own running status information to the preset node task scheduler (local scheduler), and the preset node task scheduler records the information of the running of the task iteration. In this way, when the preset node task scheduler receives the running status information of the current training task, it will delete the iteration information of the current training task, and notify the video memory manager to delete the memoryless video memory information of the current training task, ensuring that the task will not be scheduled later.

[0057] For example, Figure 3 The invention shows a multi-task GPU sharing management method and strategy based on polling, which may include a local scheduler (preset node task scheduler) scheduling module, a GPU Memory Coordinator (video memory manager) module, a communication module, and a training framework control module. In the specific implementation, the preset node task scheduler (local scheduler) and the video memory manager (GPU Memory Coordinator) are started to record the video memory information of each GPU on the node and the information of the shared GPU task, such as the process PID, the memoryless video memory information, the task running status, etc., and further control the task scheduling and video memory sharing logic according to the scheduling strategy. Since the local scheduler scheduling module records the information of the running of the task iteration, the local scheduler scheduling module can collect the running time of each task iteration and the running status of the task, report the message of the start and end of the iteration, and complete the scheduling of the task. The GPU Memory coordinator module manages the memoryless video memory information of each task and adjusts the shared video memory. In addition, a synchronization and scheduling management module can be added to the deep learning framework to synchronize the execution logic and the task information reporting logic.

[0058] In the present application, a video memory manager is applied to first obtaining information of memoryless video memories of multiple training tasks in a deep learning framework, and determining a target memoryless video memory based on the information of the memoryless video memory to obtain a shared video memory; wherein the memoryless video memory is a video memory that does not need to be transferred between iterations when executing the training task; then a handle to the shared video memory is generated, and the handle to the shared video memory and the size of the shared video memory are passed to a current training task among the multiple training tasks through a first process communication interface, so that the current training task mounts the shared video memory to the deep learning framework through a second process communication interface; based on a preset task scheduling strategy, the current training task is controlled to perform a target number of iteration operations; wherein the target number of iterations is determined based on a time slice pre-allocated to the current training task and the time required for the current training task to complete a single iteration; when the current training task completes the target number of iteration operations, the current training task is switched to other training tasks among the multiple training tasks, and the other training tasks are executed according to the shared video memory. It can be seen that the information of the memoryless video memory that does not need to be transferred between iterations when executing training tasks is obtained. By using the largest memoryless video memory as the shared video memory between multiple training tasks, the GPU can be prevented from caching all the video memory of all training tasks when multiple training tasks share the video memory, and the shared video memory can also be used by other training tasks. Under certain video memory conditions, the number of shared GPU tasks is increased to allow more users to use it. In addition, since the data information of the memoryless video memory does not need to be transferred between iterations, the data can be saved and cleaned up when switching tasks, which speeds up the switching rate between tasks. At the same time, in order to make up for the differences in the running time of multiple training tasks when sharing video memory, the training tasks are iterated using time slices to make the running time of each training task as fair as possible, and the use of time slices and preset task scheduling strategies can ensure that only a single task uses the GPU within a certain time slice, and also avoid resource competition between multiple tasks, as well as performance losses caused by frequent context switching, and improve the utilization of cluster computing resources.

[0059] The present application embodiment discloses a specific video memory sharing method, see Figure 4 As shown, the method includes:

[0060] Step S21: when a new task is created, the shared video memory is adjusted according to the memoryless video memory of the new task.

[0061] In the embodiment of the present application, when a task is running, the video memory manager will pass the handle and size of the shared video memory to the task through the first process communication interface, and after receiving it, use the corresponding interface such as the second process communication to map and mount the shared video memory to the deep learning framework. It is understandable that if the shared video memory does not change subsequently, the shared video memory only needs to be mapped and mounted once, and it will only be remapped when a new task is added later.

[0062] In an embodiment of the present application, when a new task is created, if the memoryless video memory of the new task is larger than the current memoryless video memory, it is necessary to adjust the size of the current memoryless video memory to the size of the memoryless video memory of the new task. Specifically, when the memoryless video memory of the new task is larger than the shared video memory, a video memory allocation function is used to allocate video memory to the new task; it is determined whether the video memory is allocated successfully. If the video memory allocation is successful, the shared video memory is adjusted to the size of the memoryless video memory of the new task. If the video memory allocation is unsuccessful, the new task is removed and the state before the new task is created is traced back to keep the shared cache size unchanged. In this way, by backtracking to determine whether the training task can be added, the creation of the new task is realized, that is, it is determined whether the introduced new task causes the failure of the previous task. If the creation is successful, the information of the shared video memory needs to be further adjusted. This method and strategy is a pure software architecture, which is easy to implement and apply.

[0063] like Figure 5 The flowchart of creating a new task is shown. It should be pointed out that the shared video memory is released before executing the first iteration of the new task. The purpose is to ensure that there is enough video memory when the new task executes the first iteration, and the memoryless video memory occupied by the first iteration is released after the first iteration is completed. In a specific implementation, the application programming interface (cuda API) of the unified computing device architecture is called to release the shared video memory. In addition, the release and application of the shared video memory can be directly allocated by the video memory manager by calling the cuda API. After the first iteration is completed, the linux IPC interface reports the information of the memoryless video memory occupied by the first iteration to the video memory manager, and calls the custom interface to release the memoryless video memory occupied by the first iteration. After receiving the memoryless video memory information of the new task, the video memory manager adjusts the size of the shared video memory, calls the cuMemAlloc video memory allocation function to create a new shared video memory, and adds the task if the allocation is successful. If the allocation fails, indicating that the new task will affect the previously running task, the task is killed and the previous state is traced back.

[0064] like Figure 6As shown in the figure, it is a flowchart of video memory sharing and iterative execution. When the task is scheduled and iterated again, the memoryless video memory is released after the first iteration. Therefore, the video memory needs to be expanded when the iteration is run again. At this time, the video memory allocation function is not directly called to expand the video memory. Instead, a custom extension function is called to map the handle and size of the shared video memory passed by the Linux IPC to the task through interfaces such as the CUDA IPC. At the same time, the mapped shared video memory is mounted to the video memory manager of the framework to complete the execution of subsequent iterations.

[0065] Step S22: Generate a handle to the shared video memory, and pass the handle to the shared video memory and the size of the shared video memory to the current training task among the multiple training tasks through the first process communication interface, so that the current training task mounts the shared video memory to the deep learning framework through the second process communication interface.

[0066] Step S23: Based on a preset task scheduling strategy, control the current training task to perform a target number of iterations; wherein the target number is the number of iterations determined based on the time slice pre-allocated to the current training task and the time required for the current training task to complete a single iteration.

[0067] Step S24: when the current training task completes the target number of iterations, the current training task is switched to another training task among the multiple training tasks, and the other training tasks are executed according to the shared video memory.

[0068] Among them, for more specific processing procedures of the above-mentioned steps S22, S23 and S24, reference can be made to the corresponding contents disclosed in the above-mentioned embodiments, which will not be repeated here.

[0069] In the present application, it is applied to a video memory manager. When a new task is created, the shared video memory is adjusted according to the memoryless video memory of the new task; then a handle to the shared video memory is generated, and the handle to the shared video memory and the size of the shared video memory are passed to a current training task among the multiple training tasks through a first process communication interface, so that the current training task mounts the shared video memory to the deep learning framework through a second process communication interface; based on a preset task scheduling strategy, the current training task is controlled to perform a target number of iteration operations; wherein the target number of iterations is determined based on a time slice pre-allocated to the current training task and the time required for the current training task to complete a single iteration; when the current training task completes the target number of iterations, the current training task is switched to other training tasks among the multiple training tasks, and the other training tasks are executed according to the shared video memory. It can be seen that the information of the memoryless video memory that does not need to be transferred between iterations when executing training tasks is obtained. By using the largest memoryless video memory as the shared video memory between multiple training tasks, the GPU can be prevented from caching all the video memory of all training tasks when multiple training tasks share the video memory, and the shared video memory can also be used by other training tasks. Under certain video memory conditions, the number of shared GPU tasks is increased to allow more users to use it. In addition, since the data information of the memoryless video memory does not need to be transferred between iterations, the data can be saved and cleaned up when switching tasks, which speeds up the switching rate between tasks. At the same time, in order to make up for the differences in the running time of multiple training tasks when sharing video memory, the training tasks are iterated using time slices to make the running time of each training task as fair as possible, and the use of time slices and preset task scheduling strategies can ensure that only a single task uses the GPU within a certain time slice, and also avoid resource competition between multiple tasks, as well as performance losses caused by frequent context switching, and improve the utilization of cluster computing resources.

[0070] Correspondingly, the embodiment of the present application also discloses a video memory sharing device, see Figure 7 As shown, it is applied to a video memory manager, and the device includes:

[0071] A shared video memory determination module 11 is used to obtain information about memoryless video memory of multiple training tasks in a deep learning framework, and determine a target memoryless video memory based on the information about the memoryless video memory to obtain a shared video memory; wherein the memoryless video memory is a video memory that does not need to be transferred between iterations when executing the training task;

[0072] A training task execution module 12 is used to generate a handle of the shared video memory, and pass the handle of the shared video memory and the size of the shared video memory to a current training task among the multiple training tasks through a first process communication interface, so that the current training task mounts the shared video memory to the deep learning framework through a second process communication interface;

[0073] The training task polling module 13 is used to control the current training task to perform a target number of iterations based on a preset task scheduling strategy; wherein the target number of iterations is determined based on the time slice pre-allocated to the current training task and the time required for the current training task to complete a single iteration;

[0074] The training task switching module 14 is used to switch the current training task to other training tasks among the multiple training tasks when the current training task completes the target number of iteration operations, and execute the other training tasks according to the shared graphics memory.

[0075] Among them, for more specific working processes of the above-mentioned modules, please refer to the corresponding contents disclosed in the aforementioned embodiments, which will not be repeated here.

[0076] It can be seen that, through the above scheme of this embodiment, applied to the video memory manager, firstly, the information of the memoryless video memory of multiple training tasks in the deep learning framework is obtained, and the target memoryless video memory is determined based on the information of the memoryless video memory to obtain the shared video memory; wherein, the memoryless video memory is a video memory that does not need to be transferred between iterations when executing the training task; then a handle of the shared video memory is generated, and the handle of the shared video memory and the size of the shared video memory are passed to the current training task among the multiple training tasks through the first process communication interface, so that the current training task mounts the shared video memory to the deep learning framework through the second process communication interface; based on the preset task scheduling strategy, the current training task is controlled to perform the target number of iteration operations; wherein, the target number is the number of iterations determined according to the time slice pre-allocated to the current training task and the time required for the current training task to complete a single iteration; when the current training task completes the target number of iteration operations, the current training task is switched to other training tasks among the multiple training tasks, and the other training tasks are executed according to the shared video memory. It can be seen that the information of the memoryless video memory that does not need to be transferred between iterations when executing training tasks is obtained. By using the largest memoryless video memory as the shared video memory between multiple training tasks, the GPU can be prevented from caching all the video memory of all training tasks when multiple training tasks share the video memory, and the shared video memory can also be used by other training tasks. Under certain video memory conditions, the number of shared GPU tasks is increased to allow more users to use it. In addition, since the data information of the memoryless video memory does not need to be transferred between iterations, the data can be saved and cleaned up when switching tasks, which speeds up the switching rate between tasks. At the same time, in order to make up for the differences in the running time of multiple training tasks when sharing video memory, the training tasks are iterated using time slices to make the running time of each training task as fair as possible, and the use of time slices and preset task scheduling strategies can ensure that only a single task uses the GPU within a certain time slice, and also avoid resource competition between multiple tasks, as well as performance losses caused by frequent context switching, and improve the utilization of cluster computing resources.

[0077] Furthermore, the present application also discloses an electronic device. Figure 8 This is a structural diagram of an electronic device 20 according to an exemplary embodiment, and the content in the diagram cannot be considered as any limitation on the scope of use of the present application.

[0078] Figure 8The present invention provides a schematic diagram of the structure of an electronic device 20 provided in an embodiment of the present application. The electronic device 20 may specifically include: at least one processor 21, at least one memory 22, a power supply 23, a communication interface 24, an input / output interface 25, and a communication bus 26. The memory 22 is used to store a computer program, and the computer program is loaded and executed by the processor 21 to implement the relevant steps in the video memory sharing method disclosed in any of the aforementioned embodiments. In addition, the electronic device 20 in this embodiment may specifically be a video memory manager.

[0079] In this embodiment, the power supply 23 is used to provide working voltage for each hardware device on the electronic device 20; the communication interface 24 can create a data transmission channel between the electronic device 20 and the external device, and the communication protocol it follows is any communication protocol that can be applied to the technical solution of the present application, and is not specifically limited here; the input and output interface 25 is used to obtain external input data or output data to the outside world, and its specific interface type can be selected according to specific application needs and is not specifically limited here.

[0080] In addition, the memory 22 as a carrier for resource storage may be a read-only memory, a random access memory, a disk or an optical disk, etc. The resources stored thereon may include an operating system 221, a computer program 222 and data 223, etc. The data 223 may include various data. The storage method may be temporary storage or permanent storage.

[0081] The operating system 221 is used to manage and control the hardware devices on the electronic device 20 and the computer program 222, which can be Windows Server, Netware, Unix, Linux, etc. In addition to including a computer program that can be used to complete the video memory sharing method performed by the electronic device 20 disclosed in any of the aforementioned embodiments, the computer program 222 can further include a computer program that can be used to complete other specific tasks.

[0082] Furthermore, the embodiment of the present application also discloses a computer-readable storage medium, wherein the computer-readable storage medium mentioned here includes a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a magnetic disk or an optical disk, or any other form of storage medium known in the technical field. Wherein, when the computer program is executed by the processor, the aforementioned video memory sharing method is implemented. For the specific steps of the method, reference can be made to the corresponding contents disclosed in the aforementioned embodiment, and no further description will be given here.

[0083] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.

[0084] The steps of the video memory sharing method or algorithm described in conjunction with the embodiments disclosed herein can be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module can be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the technical field.

[0085] Finally, it should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device. In the absence of further restrictions, the elements defined by the sentence "comprise a ..." do not exclude the presence of other identical elements in the process, method, article or device including the elements.

[0086] The above is a detailed introduction to a video memory sharing method, device, equipment and storage medium provided by the present invention. Specific examples are used in this article to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. At the same time, for those skilled in the art, according to the idea of ​​the present invention, there will be changes in the specific implementation method and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.

Claims

1. A video memory sharing method, characterized in that: Applies to the video memory manager, including: Acquire information of memoryless video memory of multiple training tasks in a deep learning framework, and determine a target memoryless video memory based on the information of the memoryless video memory to obtain a shared video memory; wherein the memoryless video memory is a video memory that does not need to be transferred between iterations when executing the training task; Generate a handle to the shared video memory, and pass the handle to the shared video memory and the size of the shared video memory to a current training task among the multiple training tasks through a first process communication interface, so that the current training task mounts the shared video memory to the deep learning framework through a second process communication interface; Based on a preset task scheduling strategy, control the current training task to perform a target number of iterations; wherein the target number is the number of iterations determined based on the time slice pre-allocated to the current training task and the time required for the current training task to complete a single iteration; When the current training task completes the target number of iterations, the current training task is switched to another training task among the multiple training tasks, and the other training tasks are executed according to the shared video memory; The step of determining the target memoryless video memory based on the information of the memoryless video memory to obtain the shared video memory comprises: determining the largest target memoryless video memory in the memoryless video memory based on the information of the memoryless video memory to obtain the shared video memory; After the current training task is switched to another training task among the multiple training tasks and the other training tasks are executed according to the shared video memory, the method further includes: when a new task is created, adjusting the shared video memory according to the memoryless video memory of the new task; The adjusting the shared video memory according to the memoryless video memory of the new task includes: When the memoryless video memory of the new task is larger than the shared video memory, allocating video memory to the new task using a video memory allocation function; Determine whether the video memory is allocated successfully. If the video memory is allocated successfully, adjust the shared video memory to the memoryless video memory size of the new task. If the video memory allocation is unsuccessful, remove the new task and go back to the state before the new task is created to keep the shared video memory size unchanged.

2. The video memory sharing method according to claim 1, characterized in that: Also includes: Before executing the first iteration of the new task, the shared video memory is released, and after the first iteration is executed, the memoryless video memory occupied by the first iteration is released.

3. The video memory sharing method according to claim 2, characterized in that: The step of releasing the shared video memory before executing the first iteration of the new task, and releasing the memoryless video memory occupied by the first iteration after the first iteration is completed, includes: Before executing the first iteration of the new task, the application programming interface of the unified computing device architecture is called to release the shared video memory, and after the first iteration is executed, the custom interface is called to release the memoryless video memory occupied by the first iteration.

4. The video memory sharing method according to any one of claims 1 to 3, characterized in that: When the current training task completes the target number of iterations, the current training task is switched to another training task among the multiple training tasks, including: Obtaining the running status information of the current training task after executing the target number of iteration operations; The running status information is reported to a preset node task scheduler so that the node task scheduler deletes the iteration information of the current training task and notifies the video memory manager to delete the memoryless video memory of the current training task.

5. A video memory sharing device, characterized in that: Applies to the video memory manager, including: A shared video memory determination module, used to obtain information about memoryless video memory of multiple training tasks in a deep learning framework, and determine a target memoryless video memory based on the information about the memoryless video memory to obtain a shared video memory; wherein the memoryless video memory is a video memory that does not need to be transferred between iterations when executing the training task; A training task execution module, used to generate a handle of the shared video memory, and pass the handle of the shared video memory and the size of the shared video memory to a current training task among the multiple training tasks through a first process communication interface, so that the current training task mounts the shared video memory to the deep learning framework through a second process communication interface; A training task polling module, used to control the current training task to perform a target number of iterations based on a preset task scheduling strategy; wherein the target number is the number of iterations determined based on the time slice pre-allocated to the current training task and the time required for the current training task to complete a single iteration; A training task switching module, configured to switch the current training task to another training task among the multiple training tasks when the current training task completes the target number of iterations, and execute the other training tasks according to the shared video memory; Wherein, the shared video memory determination module is specifically used for: Determine the largest target memoryless video memory in the memoryless video memory based on the information of the memoryless video memory to obtain a shared video memory; The video memory sharing device is further used for: When a new task is created, adjusting the shared video memory according to the memoryless video memory of the new task; The video memory sharing device is further used for: When the memoryless video memory of the new task is larger than the shared video memory, allocating video memory to the new task using a video memory allocation function; Determine whether the video memory is allocated successfully. If the video memory is allocated successfully, adjust the shared video memory to the memoryless video memory size of the new task. If the video memory allocation is unsuccessful, remove the new task and go back to the state before the new task is created to keep the shared video memory size unchanged.

6. An electronic device, characterized in that: The electronic device comprises a processor and a memory; wherein the memory is used to store a computer program, and the computer program is loaded and executed by the processor to implement the video memory sharing method according to any one of claims 1 to 4.

7. A computer-readable storage medium, characterized in that: Used to store computer programs; wherein the computer program, when executed by a processor, implements the video memory sharing method as claimed in any one of claims 1 to 4.

Citation Information

Patent Citations

  • GPU memory optimization method and system for a deep learning training task

    CN109919310A

  • Model training method, server and computer readable storage medium

    CN110134636A

  • Training task monitoring method and device

    CN111767188A

  • GPU card video memory-based hybrid scheduling method, device, the equipment, and medium

    CN111858025A

  • Video memory management method and device, model training method and device, electronic equipment and storage medium

    CN112882830A