A GPU-based deep neural network multi-model parallel reasoning method
By building multiple inference engines in the deep neural network and binding them to the Stream object of the GPU, using inference grouping and managers to manage multi-thread execution, the problem of data allocation and synchronization in multi-model parallel inference is solved, and time consistency and time consistency are achieved. Efficient use of resources.
Patent Information
- Application Number
- CN202111354003.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Priority Date
- 2021-11-03
- Filing Date
- 2021-11-12
- Publication Date
- 2024-09-17
- Estimated Expiration
- Not applicable · inactive patent
AI Technical Summary
Existing technology is difficult to effectively support the multi-model parallel inference tasks of deep neural networks. In particular, there are defects in data allocation and synchronization mechanisms, which lead to data redundancy and inference synchronization errors, and cannot fully utilize GPU resources.
By building multiple inference engines and binding them to the GPU's Stream object, using inference grouping and inference managers to manage multi-threaded parallel execution, fine-grained execution binding and data sharing are achieved to ensure time consistency and resource utilization.
It achieves time consistency of multi-model inference tasks and full utilization of GPU resources, reduces data redundancy and improves inference efficiency.
Smart Images

Figure CN114004730B_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the field of computer technology, and in particular to a deep neural network multi-model parallel reasoning method based on a graphics processor. Background Art
[0002] Deep neural network technology is widely used in the field of artificial intelligence, especially in image recognition, target detection, speech recognition and other fields. It has achieved great success. The specific use process of deep neural network can be divided into two parts: model training and model reasoning. Due to the participation of major open source communities, the methods and tools for model training have become relatively mature. Currently, there are several open source training frameworks such as TensorFlow, PyTorch, and MXNet. As for the model reasoning part, due to its certain particularity, there are still many problems to be solved. The existing technologies mainly include: using model parallel methods, multi-inference engine scheduling methods and CPU thread binding GPU device methods. Among them, the model parallel method is mainly aimed at model training tasks, splitting a model into multiple parts, each part Training in parallel, this design idea can only be used for a single model, and because the model needs to be split, it has certain requirements on the structure of the model itself, and cannot adapt to the multi-model reasoning task of any model; although the multi-reasoning engine scheduling method can achieve parallel execution, its design lacks the data allocation and synchronization mechanism required for multi-model reasoning tasks, which may cause data redundancy and reasoning synchronization errors in practical applications; the thread binding GPU device method is to achieve multi-GPU parallel processing of data through multi-threaded execution, but the design of this method still lacks data allocation and synchronization mechanism, and directly binding threads to GPU devices will cause certain restrictions on the number of threads and GPU devices in practical applications, and GPU resources cannot be fully utilized in reasoning tasks. Patent "201711251410.3" designs a deep learning GPU parallel acceleration method, which adopts a hybrid architecture, and the layers before the softmax layer are trained in data parallel mode, and the softmax layer is trained in model parallel mode. Each GPU trains its own model slice separately, thereby realizing parallel execution of tasks. However, this method is mainly proposed for model training tasks, and its design structure can only support the execution of a single model, which cannot meet the needs of multi-model reasoning. Patent "202010537231.1" designs a scheduling method for an inference engine, which can calculate the total load of the inference task based on the request of the application layer, and then determine the target engine that executes the current inference task based on the load of each inference engine. Although this method realizes parallel reasoning based on multiple engines, the design does not involve mechanisms such as data allocation and inter-thread synchronization suitable for multi-model reasoning, and therefore cannot be applied to multi-model parallel reasoning tasks.Patent "201410281130.7" proposes a model parallel processing method based on multiple graphics processors. This method creates multiple threads in the central processing unit (CPU), and then binds each thread to a GPU device, and realizes data parallel processing of multiple GPUs through multi-threaded parallel execution. However, the design goal of this method is to target model training tasks, and the design also lacks data binding and thread synchronization mechanisms for reasoning tasks. Moreover, binding threads to GPUs is a relatively rough binding method, which will impose certain restrictions on the number of threads and GPU devices in practical applications. Therefore, there is an urgent need for a multi-model parallel reasoning method for deep neural networks based on graphics processors. Summary of the invention
[0003] In view of this, the present invention aims to propose a multi-model parallel reasoning method for deep neural networks based on a graphics processing unit to solve the shortcomings of the above-mentioned problems.
[0004] To achieve the above object, the technical solution of the present invention is achieved as follows:
[0005] In a first aspect, an embodiment of the present invention provides a multi-model parallel reasoning method for a deep neural network based on a graphics processor, comprising the following steps: S1, constructing a plurality of corresponding reasoning engines according to the network model to be reasoned, each reasoning engine being responsible for executing the reasoning task of the corresponding network model;
[0006] S2. Bind the inference engine to the corresponding input data address and the Stream object of the GPU device;
[0007] S3. Build the required reasoning groups according to multi-threaded reasoning, and each reasoning group corresponds to a CPU thread object;
[0008] S4. Bind each inference group to the corresponding CPU thread object;
[0009] S5. Add the inference engine to the inference group. The inference engine contained in the inference group is managed by the CPU thread object corresponding to the inference group.
[0010] S6. Build an inference manager. The inference manager manages the execution process of the inference grouping and is responsible for collecting data input and output features in the inference task.
[0011] S7, adding the reasoning group to the reasoning manager;
[0012] S8. The inference manager initiates multi-threaded parallel inference operations.
[0013] Furthermore, in step S2, each inference engine is bound to the corresponding input data address in a many-to-many manner according to the input data name, and at the same time, each inference engine is bound to the Stream object of the GPU device.
[0014] Furthermore, the input data is stored in the form of data blocks and input into the reasoning manager. The reasoning manager processes the input data according to the data storage location and stores the required data at the location pointed to by the data address bound to the reasoning engine. The reasoning engine performs data reading and reasoning operations based on the bound data address.
[0015] In a second aspect, this embodiment further provides an electronic device, comprising a processor, and a memory that is communicatively connected to the processor and is used to store instructions executable by the processor, wherein when the processor executes the instructions, the steps of a deep neural network multi-model parallel reasoning method based on a graphics processor described in the first aspect are implemented.
[0016] In a third aspect, an embodiment of the present invention further provides a server comprising at least one processor and a memory communicatively connected to the processor, wherein the memory stores instructions executable by the at least one processor, and is characterized in that: the instructions are executed by the processor so that the at least one processor executes the steps of a deep neural network multi-model parallel reasoning method based on a graphics processor as described in the first aspect.
[0017] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of a deep neural network multi-model parallel reasoning method based on a graphics processor as described in the first aspect.
[0018] Compared with the prior art, the multi-model parallel reasoning method of a deep neural network based on a graphics processor described in the present invention has the following beneficial effects:
[0019] In the design of multi-threaded parallel computing, the method for multi-model parallel reasoning of a deep neural network based on a graphics processor described in the present invention uses a design method for reasoning grouping to bind each reasoning group to a CPU thread, thereby facilitating the design of synchronous operations and ensuring the temporal consistency of reasoning tasks; at the same time, by adding a reasoning engine to the reasoning group, the CPU thread is associated with the Stream object of the GPU to achieve thread-level parallel execution;
[0020] In the design of the inference engine, each inference engine responsible for the inference calculation of a single model is bound to a Stream object of a GPU, thereby achieving fine-grained execution binding, which can give full play to the parallel computing capabilities of the GPU device itself;
[0021] In the data allocation design, the inference engine is bound to the address of the corresponding input data according to the input data name, so that multiple inference engines can share the same input data. There is no need to prepare input data for each inference engine separately, reducing data redundancy. BRIEF DESCRIPTION OF THE DRAWINGS
[0022] The accompanying drawings constituting a part of the present invention are used to provide a further understanding of the present invention. The exemplary embodiments of the present invention and their descriptions are used to explain the present invention and do not constitute an improper limitation of the present invention. In the accompanying drawings:
[0023] Figure 1 This is a flow chart of a multi-model parallel reasoning method for a deep neural network based on a graphics processor according to an embodiment of the present invention;
[0024] Figure 2 A schematic diagram of a calculation process according to an embodiment of the present invention;
[0025] Figure 3 A schematic diagram of thread synchronization according to an embodiment of the present invention;
[0026] Figure 4 The data flow diagram of the embodiment of the present invention is shown in FIG. DETAILED DESCRIPTION
[0027] It should be noted that, in the absence of conflict, the embodiments of the present invention and the features in the embodiments may be combined with each other.
[0028] The present invention will be described in detail below with reference to the accompanying drawings and in conjunction with embodiments.
[0029] See also Figure 1 As shown, an embodiment of the present invention provides a multi-model parallel reasoning method for a deep neural network based on a graphics processor, comprising the following steps: S1, constructing a plurality of corresponding reasoning engines according to the network model to be reasoned, each reasoning engine is responsible for executing the reasoning task of the corresponding network model;
[0030] S2. Bind the inference engine with the corresponding input data address and the Stream object of the GPU device. Different inference engines can be bound to the same input data address to achieve input data sharing.
[0031] S3. Build the required reasoning groups according to multi-threaded reasoning, and each reasoning group corresponds to a CPU thread object;
[0032] S4. Bind each inference group to the corresponding CPU thread object. Thread synchronization can be performed between each inference group. Compared with the solution without synchronization design, this solution can ensure the time consistency of multi-model inference tasks. At the same time, bind each inference engine in the group to a Stream object in a GPU. Compared with the design of directly binding threads to GPU devices, this solution has a smaller binding granularity, so it can make more full use of the parallel computing capabilities of the GPU itself.
[0033] S5. Add the inference engine to the inference group. One inference group may contain multiple inference engines. The inference engines contained in the inference group are managed by the CPU thread object corresponding to the inference group.
[0034] S6. Build an inference manager. The inference manager manages the execution process of the inference grouping and is responsible for collecting data input and output features in the inference task.
[0035] S7, adding the reasoning group to the reasoning manager;
[0036] S8. The inference manager initiates a multi-threaded parallel inference operation, in which each inference group will be executed in a CPU thread, and the inference engine managed internally is executed by the Stream object of its corresponding GPU device.
[0037] In step S2, each inference engine is bound to the corresponding input data address in a many-to-many manner according to the input data name, and at the same time, each inference engine is bound to the Stream object of the GPU device.
[0038] The input data is stored in the form of data blocks and input into the inference manager. The inference manager processes the input data according to the data storage location and stores the required data at the location pointed to by the data address bound to the inference engine. The inference engine performs data reading and inference operations based on the bound data address.
[0039] During the parallel reasoning execution process, the specific calculation process is as follows Figure 2 As shown, first, multiple inference engines will be added to multiple inference groups, and at the same time, multiple inference groups will be added to the inference manager. At this time, the inference group has been bound to the CPU thread, and the inference engine has been bound to the Stream object of the GPU device. After all the addition operations are completed, the overall inference operation is initiated by the inference manager, and is executed by multiple threads after the inference group, and then enters the inference engine for further execution by the GPU Stream object, forming a fine-grained parallel execution mode. In the multi-threaded execution based on the inference group, in order to ensure the time consistency in the multi-model inference process, each inference operation needs to be synchronized with the thread, such as Figure 3 As shown, through synchronization operations between threads, multiple inference results generated by multiple models can be controlled at the same time point to ensure the consistency of inference information.
[0040] From the perspective of data execution process, such as Figure 4 As shown, the input data is first stored in the form of data blocks on the host side or GPU device side, and then input into the inference manager in a whole form. The inference manager processes the data according to the storage location of the data, and stores the required data at the location pointed to by the data address bound to the inference engine; then the inference engine reads and performs inference operations according to the bound data address, and each inference engine executes independently and in parallel with each other, and finally obtains the inference output result data; the inference manager collects and organizes the output results to form the final output result.
[0041] An embodiment of the present invention also provides an electronic device, including a processor, and a memory that is communicatively connected to the processor and is used to store instructions executable by the processor. When the processor executes the instructions, the steps of a deep neural network multi-model parallel reasoning method based on a graphics processor described in the above embodiment are implemented.
[0042] An embodiment of the present invention also provides a server, comprising at least one processor, and a memory communicatively connected to the processor, wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the processor to enable the at least one processor to perform the steps of a deep neural network multi-model parallel reasoning method based on a graphics processor as described in the above embodiment.
[0043] An embodiment of the present invention also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of a deep neural network multi-model parallel reasoning method based on a graphics processor as described in the above embodiment.
[0044] Those of ordinary skill in the art will appreciate that the units and method steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in terms of function in the above description. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0045] In the several embodiments provided in the present application, it should be understood that the disclosed methods and systems can be implemented in other ways. For example, the division of the units described above is only a logical function division, and there may be other division methods in actual implementation, such as multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. The above-mentioned units may or may not be physically separated, and the components displayed as units may or may not be physical units, that is, they may be located in one place, or they may be distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the embodiments of the present invention.
[0046] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or replace some or all of the technical features therein by equivalents. These modifications or replacements do not make the essence of the corresponding technical solutions deviate from the scope of the technical solutions of the embodiments of the present invention, and they should all be included in the scope of the claims and specification of the present invention.
[0047] The above description is only a preferred embodiment of the present invention and is not intended to limit the present invention. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principle of the present invention should be included in the protection scope of the present invention.
Claims
1. A multi-model parallel reasoning method for deep neural networks based on graphics processors, It is characterized in that The following steps are involved: S1. Build multiple corresponding inference engines according to the network model to be inferred, and each inference engine is responsible for executing the inference task of the corresponding network model; S2. Bind the inference engine to the corresponding input data address and the Stream object of the GPU device; S3. Build the required reasoning groups according to multi-threaded reasoning, each reasoning group corresponds to a CPU thread object; S4. Bind each inference group to the corresponding CPU thread object; S5. Add the inference engine to the inference group. The inference engine contained in the inference group is managed by the CPU thread object corresponding to the inference group. S6. Build an inference manager. The inference manager manages the execution process of the inference grouping and is responsible for collecting data input and output features in the inference task. S7, adding the reasoning group to the reasoning manager; S8, the inference manager initiates a multi-threaded parallel inference operation; In step S2, each inference engine is bound to the corresponding input data address in a many-to-many manner according to the input data name, and at the same time, each inference engine is bound to the Stream object of the GPU device.
2. According to claim 1, a deep neural network multi-model parallel reasoning method based on a graphics processor, Features: The input data is stored in the form of data blocks and input into the inference manager. The inference manager processes the input data according to the data storage location and stores the required data at the location pointed to by the data address bound to the inference engine. The inference engine performs data reading and inference operations based on the bound data address.
3. An electronic device comprising a processor and a memory connected to the processor for storing instructions executable by the processor, Features: When the processor executes the instructions, the steps of a deep neural network multi-model parallel reasoning method based on a graphics processor as described in any one of claims 1-2 are implemented.
4. A server comprising at least one processor and a memory in communication with the processor, wherein the memory stores instructions executable by the at least one processor. Features: The instructions are executed by the processor so that the at least one processor performs the steps of a deep neural network multi-model parallel reasoning method based on a graphics processor as described in any one of claims 1-2.
5. A computer-readable storage medium storing a computer program, Features: When the computer program is executed by a processor, the steps of a multi-model parallel reasoning method for a deep neural network based on a graphics processor as described in any one of claims 1-2 are implemented.
