Image task processing method and device, computer device, and storage medium
Patent Information
- Application Number
- CN202311257682.X
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-09-26
- Publication Date
- 2026-10-23
- Estimated Expiration
- 2043-09-26
AI Technical Summary
[0014]有益效果:等待第二预设数量的图像任务执行结束之后,从任务队列中重新获取第二预设数量的图像任务,自动分配图形处理器实例并执行图像任务,提高图像任务执行的效率。
Smart Images

Figure CN117314724B_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of graphics processor technology, and more specifically to methods, apparatus, computer devices, and storage media for processing image tasks. Background Technology
[0002] With the continuous development of cloud computing based on containerization technology, more and more applications with high computing and memory requirements need to run on cloud platforms, such as artificial intelligence (AI) projects, deep learning, and simulation training tasks. These applications need to run on graphics processing units (GPUs) to meet their high computing and memory requirements.
[0003] However, as the number of applications requiring GPUs increases, GPU resources become increasingly insufficient. Therefore, a new execution method has emerged: run a portion of the tasks first, and then manually run the new tasks after the previous portion is completed. This process, where the interval between the completion of one portion of tasks and the start of the next portion causes insufficient resource utilization, and the order in which tasks are executed also affects the efficiency of GPU usage.
[0004] As GPUs continue to be updated and developed, a single GPU card can now support running multiple tasks simultaneously (i.e., GPU sharing). However, when one task consumes too much computing power and video memory, other tasks will not have enough GPU resources available. Summary of the Invention
[0005] In view of this, the present invention provides a method, apparatus, computer device and storage medium for processing image tasks, in order to solve the problem that there are not enough GPU resources available for image tasks.
[0006] In a first aspect, the present invention provides a method for processing image tasks, comprising: acquiring a first preset number of image tasks, and adding the first preset number of image tasks to a task queue; selecting a second preset number of image tasks from the task queue, wherein the sum of the graphics processor resources occupied by the second preset number of image tasks is less than or equal to the total graphics processor resources, and the sum of the graphics processor resources occupied by the second preset number of image tasks plus one image task is greater than the total graphics processor resources, and the second preset number is less than or equal to the first preset number; determining the specifications of the graphics processor instance required for each image task in the second preset number of image tasks, and allocating a graphics processor instance for each image task according to the specifications of the graphics processor instance required for each image task; and executing the image task using the graphics processor instance.
[0007] Beneficial effects: In this embodiment of the invention, a first preset number of image tasks are obtained and added to a task queue. A second preset number of image tasks are selected from the task queue. The sum of the graphics processor resources occupied by the second preset number of image tasks is less than or equal to the total graphics processor resources, and the sum of the graphics processor resources occupied by the second preset number of image tasks plus one image task is greater than the total graphics processor resources. That is, the maximum number of image tasks is selected within the range of the total graphics processor resources, and as many image tasks as possible are selected for processing, thereby improving the execution efficiency of image tasks. The specifications of the graphics processor instance required for each image task in the second preset number of image tasks are determined, and graphics processor instances are allocated to each image task according to the specifications required for each image task. By allocating graphics processor instances of the corresponding specifications to each image task, the image tasks are executed using graphics processor instances, and uneven allocation of graphics processor instances does not occur, preventing waste of graphics processor resources.
[0008] In one optional implementation, after executing an image task using a graphics processor instance, the method further includes: determining whether an idle graphics processor instance is available; if an idle graphics processor instance is available, determining whether the specifications of the graphics processor instance required by the first task in the task queue are consistent with the specifications of the idle graphics processor instance; if the specifications of the graphics processor instance required by the first task in the task queue are consistent with the specifications of the idle graphics processor instance, executing the first task using the idle graphics processor instance; if the specifications of the graphics processor instance required by the first task in the task queue are inconsistent with the specifications of the idle graphics processor instance, determining the priority of the first task; if the priority of the first task is the first priority, determining whether the specifications of the graphics processor instance required by the first task are less than the specifications of the idle graphics processor instance; if the specifications of the graphics processor instance required by the first task are less than the specifications of the idle graphics processor instance, executing the first task using the idle graphics processor instance.
[0009] Beneficial effects: In this embodiment of the invention, it is determined whether an idle graphics processor instance exists. If an idle graphics processor instance exists, it indicates that a task has finished executing and an idle graphics processor instance exists. It is then determined whether the specifications of the graphics processor instance required by the task at the head of the task queue are consistent with the specifications of the idle graphics processor instance. If they are consistent, the idle graphics processor instance can be used to execute the task at the head of the queue. If they are inconsistent, the priority of the task at the head of the queue is determined. If the priority of the task at the head of the queue is first priority (where first priority is high priority), then the task at the head of the queue needs to be executed first. Therefore, it is determined whether the specifications of the graphics processor instance required by the task at the head of the queue are less than the specifications of the idle graphics processor instance. If the specifications of the graphics processor instance required by the task at the head of the queue are less than the specifications of the idle graphics processor instance, the idle graphics processor instance is used to execute the task at the head of the queue. In this embodiment of the invention, graphics processor resources are continuously used, so that resources are fully utilized.
[0010] In one optional implementation, determining whether an idle graphics processor instance is found further includes: if no idle graphics processor instance is found, waiting for the second preset number of image tasks to finish executing.
[0011] In one optional implementation, if the priority of the first task is the second priority, then wait for the second preset number of image tasks to finish executing. The second priority is lower than the first priority.
[0012] In one optional implementation, determining whether the specifications of the graphics processor instance required by the first task in the queue are less than the specifications of the idle graphics processor instance further includes: if the specifications of the graphics processor instance required by the first task in the queue are greater than the specifications of the idle graphics processor instance, then waiting for the second preset number of image tasks to finish executing.
[0013] In one alternative implementation, after waiting for the second preset number of image tasks to finish executing, the method further includes: reacquiring the second preset number of image tasks from the task queue.
[0014] Beneficial effect: After the second preset number of image tasks have finished executing, the system retrieves the second preset number of image tasks from the task queue, automatically allocates graphics processor instances, and executes the image tasks, thereby improving the efficiency of image task execution.
[0015] In one optional implementation, after obtaining a first preset number of image tasks and adding the first preset number of image tasks to the task queue, the method further includes: determining whether there are any running image tasks on the graphics processor; if there are no running image tasks, then selecting a second preset number of image tasks from the task queue.
[0016] Secondly, the present invention provides an image task processing apparatus, comprising: an image task acquisition module, configured to acquire a first preset number of image tasks and add the first preset number of image tasks to a task queue; an image task selection module, configured to select a second preset number of image tasks from the task queue, wherein the sum of the graphics processor resources occupied by the second preset number of image tasks is less than or equal to the total graphics processor resources, and the sum of the graphics processor resources occupied by the preset number of image tasks plus one image task is greater than the total graphics processor resources, and the second preset number is less than or equal to the first preset number; a graphics processor instance allocation module, configured to determine the specifications of the graphics processor instance required for each image task in the second preset number of image tasks, and allocate a graphics processor instance to each image task according to the specifications of the graphics processor instance required for each image task; and an image task execution module, configured to execute the image task using the graphics processor instance.
[0017] Beneficial Effects: In this embodiment of the invention, the image task acquisition module is used to acquire a first preset number of image tasks and add the first preset number of image tasks to a task queue. The image task selection module is used to select a second preset number of image tasks from the task queue. The sum of the graphics processor resources occupied by the second preset number of image tasks is less than or equal to the total graphics processor resources, and the sum of the graphics processor resources occupied by the second preset number of image tasks plus one image task is greater than the total graphics processor resources. That is, the maximum number of image tasks is selected within the range of the total graphics processor resources, so as to select as many image tasks as possible for processing, thereby improving the execution efficiency of image tasks. The graphics processor instance allocation module is used to determine the specifications of the graphics processor instance required for each image task in the second preset number of image tasks, and to allocate graphics processor instances to each image task according to the specifications of the graphics processor instance required for each image task. The image task execution module is used to execute image tasks using graphics processor instances, so that there will be no uneven allocation of graphics processor instances, thus preventing waste of graphics processor resources.
[0018] Thirdly, the present invention provides a computer device, comprising: a memory and a processor, the memory and the processor being communicatively connected to each other, the memory storing computer instructions, and the processor executing the computer instructions to perform the image task processing method of the first aspect or any corresponding embodiment described above.
[0019] Fourthly, the present invention provides a computer-readable storage medium storing computer instructions for causing a computer to perform the image task processing method described in the first aspect or any corresponding embodiment thereof. Attached Figure Description
[0020] To more clearly illustrate the specific embodiments of the present invention or the technical solutions in the prior art, the drawings used in the description of the specific embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are some embodiments of the present invention. For those skilled in the art, other drawings can be obtained from these drawings without creative effort.
[0021] Figure 1 This is a flowchart illustrating an image task processing method according to an embodiment of the present invention;
[0022] Figure 2 This is a flowchart illustrating another image task processing method according to an embodiment of the present invention;
[0023] Figure 3 This is a structural block diagram of a multi-instance graphics processor configuration device based on a task queue according to an embodiment of the present invention;
[0024] Figure 4 This is a structural block diagram of an image task processing apparatus according to an embodiment of the present invention;
[0025] Figure 5 This is a schematic diagram of the hardware structure of a computer device according to an embodiment of the present invention. Detailed Implementation
[0026] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0027] This invention provides a method for processing image tasks, which achieves the smooth operation of image tasks by allocating corresponding graphics processor instances to the image tasks.
[0028] According to an embodiment of the present invention, an embodiment of a method for processing an image task is provided. It should be noted that the steps shown in the flowchart in the accompanying drawings can be executed in a computer system such as a set of computer-executable instructions. Furthermore, although a logical order is shown in the flowchart, in some cases, the steps shown or described may be executed in a different order than that shown here.
[0029] This embodiment provides a method for processing image tasks, which can be used in the aforementioned computer. Figure 1This is a flowchart of an image task processing method according to an embodiment of the present invention, such as... Figure 1 As shown, the process includes the following steps:
[0030] Step S101: Obtain a first preset number of image tasks and add the first preset number of image tasks to the task queue.
[0031] Among them, image tasks are those that require the use of a graphics processing unit (GPU). A GPU, also known as a display core, visual processor, or display chip, is a microprocessor that performs image and graphics-related calculations on electronic devices.
[0032] In this embodiment of the invention, the task queue is a queue for storing image tasks. The queue is a special type of linear list that only allows deletion operations at the front (front) and insertion operations at the rear (rear), following the first-in, first-out (FIFO) principle. When adding a first preset number of image tasks to the task queue in this embodiment, the queue may be empty or may already contain image tasks awaiting execution.
[0033] In some optional implementations, after obtaining a first preset number of image tasks and adding the first preset number of image tasks to the task queue, the method further includes: determining whether there are any running image tasks on the graphics processor; if there are no running image tasks, then selecting a second preset number of image tasks from the task queue.
[0034] In this embodiment of the invention, it is determined whether there are any running image tasks on the graphics processor. If there are no running image tasks, it means that the graphics processor is idle. A second preset number of image tasks are selected from the task queue, and then the second preset number of image tasks are processed.
[0035] Step S102: Select a second preset number of image tasks from the task queue. The sum of the graphics processor resources occupied by the second preset number of image tasks is less than or equal to the total graphics processor resources, and the sum of the graphics processor resources occupied by the second preset number of image tasks plus one image task is greater than the total graphics processor resources. The second preset number is less than or equal to the first preset number.
[0036] In this embodiment of the invention, the sum of the graphics processor resources occupied by the second preset number of image tasks is less than or equal to the total graphics processor resources, and the sum of the graphics processor resources occupied by the second preset number of image tasks plus one image task is greater than the total graphics processor resources, that is, the maximum number of image tasks is selected within the range of the total graphics processor resources.
[0037] Step S103: Determine the specifications of the graphics processor instance required for each image task in the second preset number of image tasks, and allocate a graphics processor instance to each image task according to the specifications of the graphics processor instance required for each image task.
[0038] Among them, a Graphics Processing Unit (GPU) instance refers to a virtualized GPU resource service provided by a cloud computing service provider. Users can rent these GPU instances to perform tasks such as large-scale parallel computing, machine learning, and deep learning.
[0039] In this embodiment of the invention, the GPU used supports a multi-instance GPU mode, which means that the GPU is divided into several independent GPU instances, providing independent GPU resources for multiple tasks. Each GPU instance has independent hardware resources, thereby achieving shared isolation. For example, the GPU can be divided into 7 independent GPU instances, and these 7 independent GPU instances can be combined in terms of resources.
[0040] In this embodiment of the invention, the specifications of a graphics processor instance required for an image task correspond to the specifications of a graphics processor instance required for an image task. If the specifications of a graphics processor instance required for one image task are 1g.10gb, then one graphics processor instance is allocated to that image task. If the specifications of a graphics processor instance required for one image task are 2g.200gb, then two graphics processor instances are allocated to that image task. Here, 1g.10gb and 2g.200gb represent the computing power of the video memory of the graphics processor instance.
[0041] Step S104: Execute the image task using the graphics processor instance.
[0042] In this embodiment of the invention, a first preset number of image tasks are obtained and added to a task queue. A second preset number of image tasks are selected from the task queue. The sum of the graphics processor resources occupied by the second preset number of image tasks is less than or equal to the total graphics processor resources, and the sum of the graphics processor resources occupied by the second preset number of image tasks plus one image task is greater than the total graphics processor resources. That is, the maximum number of image tasks is selected within the range of the total graphics processor resources to process as many image tasks as possible and improve the execution efficiency of the image tasks. The specifications of the graphics processor instances required for each image task in the second preset number of image tasks are determined, and graphics processor instances are allocated to each image task according to the specifications required for each image task. By allocating graphics processor instances of the corresponding specifications to each image task, the image tasks are executed using graphics processor instances, which prevents uneven allocation of graphics processor instances and avoids waste of graphics processor resources.
[0043] This embodiment provides a method for processing image tasks, which can be used in the aforementioned computer. Figure 2 This is a flowchart of another image task processing method according to an embodiment of the present invention, such as... Figure 2 As shown, the process includes the following steps:
[0044] Step S201: Obtain a first preset number of image tasks and add the first preset number of image tasks to the task queue. For details, please refer to [link to relevant documentation]. Figure 1 Step S101 of the illustrated embodiment will not be described again here.
[0045] Step S202: Select a second preset number of image tasks from the task queue. The sum of the graphics processor resources occupied by the second preset number of image tasks is less than or equal to the total graphics processor resources, and the sum of the graphics processor resources occupied by the second preset number of image tasks plus one image task is greater than the total graphics processor resources. The second preset number is less than or equal to the first preset number. For details, please refer to [link to relevant documentation]. Figure 1 Step S102 of the illustrated embodiment will not be described again here.
[0046] Step S203: Determine the specifications of the graphics processor instance required for each image task in the second preset number of image tasks, and allocate graphics processor instances to each image task according to the specifications of the graphics processor instance required for each image task. See details below. Figure 1 Step S103 of the illustrated embodiment will not be described again here.
[0047] Step S204: Execute the image task using the graphics processor instance. See details below. Figure 1Step S104 of the illustrated embodiment will not be described again here.
[0048] Step S205: Determine if there is an idle graphics processor instance.
[0049] Step S206: If an idle graphics processor instance is found, determine whether the specifications of the graphics processor instance required by the task at the head of the task queue are consistent with the specifications of the idle graphics processor instance.
[0050] Step S207: If the specifications of the graphics processor instance required by the task at the head of the task queue are consistent with the specifications of the idle graphics processor instance, the task at the head of the queue is executed using the idle graphics processor instance.
[0051] In an alternative approach, if the specifications of the graphics processor instance required by the first task in the task queue are the same as those of the available graphics processor instance, then the available graphics processor instance is just available to execute the first task in the task queue. Therefore, the available graphics processor instance is used to execute the first task.
[0052] Step S208: If the specifications of the graphics processor instance required by the task at the head of the queue are inconsistent with the specifications of the idle graphics processor instance, determine whether the priority of the task at the head of the queue is the first priority.
[0053] Step S209: If the priority of the first task is first priority, determine whether the specifications of the graphics processor instance required by the first task are less than the specifications of the idle graphics processor instance.
[0054] In some optional implementations, if the priority of the first task is the first priority, it means that the priority of the first task is high and needs to be processed first. Therefore, it is determined whether the specifications of the graphics processor instance required by the first task are smaller than the specifications of the idle graphics processor instance. If they are smaller, the idle graphics processor instance is used to execute the first task.
[0055] Step S2010: If the specifications of the graphics processor instance required by the first task are smaller than the specifications of the idle graphics processor instance, the first task is executed using the idle graphics processor instance.
[0056] In step S2011, if no idle graphics processor instance is found, wait for the second preset number of image tasks to finish executing.
[0057] In step S2012, if the priority of the first task in the queue is the second priority, then wait for the second preset number of image tasks to finish executing. The second priority is lower than the first priority.
[0058] The first priority can be high priority, and the second priority can be low priority.
[0059] Step S2013: If the specifications of the graphics processor instance required by the first task are greater than the specifications of the idle graphics processor instance, then wait for the second preset number of image tasks to finish executing.
[0060] In some optional implementations, after waiting for the second preset number of image tasks to finish executing, the method further includes: reacquiring the second preset number of image tasks from the task queue.
[0061] In this embodiment of the invention, after the second preset number of image tasks have finished executing, the second preset number of image tasks are retrieved again from the task queue, and a graphics processor instance is automatically allocated and the image tasks are executed, thereby improving the efficiency of image task execution.
[0062] In this embodiment of the invention, it is determined whether an idle graphics processor instance exists. If an idle graphics processor instance exists, it indicates that a task has finished executing and an idle graphics processor instance exists. It is then determined whether the specifications of the graphics processor instance required by the task at the head of the task queue are consistent with the specifications of the idle graphics processor instance. If they are consistent, the idle graphics processor instance can be used to execute the task at the head of the queue. If they are inconsistent, the priority of the task at the head of the queue is determined. If the priority of the task at the head of the queue is first priority (where first priority is high priority), then the task at the head of the queue needs to be executed first. Therefore, it is determined whether the specifications of the graphics processor instance required by the task at the head of the queue are less than the specifications of the idle graphics processor instance. If the specifications of the graphics processor instance required by the task at the head of the queue are less than the specifications of the idle graphics processor instance, the idle graphics processor instance is used to execute the task at the head of the queue. In this embodiment of the invention, graphics processor resources are continuously used, so that resources are fully utilized.
[0063] like Figure 3 As shown, the multi-instance graphics processor configuration device based on task queue provided in this embodiment of the invention includes a cloud management platform and a graphics processor, wherein the cloud management platform includes a task queue, a task details viewer, a task selection calculator, and a multi-instance graphics processor configurator.
[0064] In addition, embodiments of the present invention also include a task queue receiver, which is used to receive image tasks added by the user into the task queue. The receiver can select the position of the task in the task queue, and can also set the priority of the task. Furthermore, it can also delete or modify image tasks in the task queue.
[0065] like Figure 3As shown, the task queue contains multiple image tasks, each containing an overview, namely the specifications and priority of the graphics processor instance required for the task. For example, Figure 3 The task queue includes five image tasks: Image Task 1, Image Task 2, Image Task 3, Image Task 4, and Image Task 5. Image Task 1 requires a 1GB .10GB GPU instance with low priority; Image Task 2 requires a 1GB .10GB GPU instance with low priority; Image Task 3 requires a 1GB .10GB GPU instance with low priority; Image Task 4 requires a 1GB .10GB GPU instance with low priority; and Image Task 5 requires a 1GB .10GB GPU instance with low priority.
[0066] The task selection calculator is used to select the current image task allocated to the GPU and whether to reconfigure the GPU instance's specifications. The selected image task includes the priority of the reference image task and the size of the available GPU instance. If the current GPU configuration does not support the use of subsequent image tasks, the GPU will be reconfigured as a graphics processor instance.
[0067] Specifically, the task selection calculator's main functions include determining which GPU instances are used for image tasks in the task queue and utilizing those instances, executing the image tasks, and calling the multi-instance GPU configurator to configure the GPUs. The detailed process is as follows:
[0068] If there are no image tasks on the GPU, it is determined whether the GPU instance specifications need to be reconfigured. The first n image tasks in the task queue are selected sequentially, ensuring that the sum of the GPU instance's memory and computing power for these n image tasks is less than or equal to that of the GPU, and the sum of the memory and computing power of the first n+1 image tasks in the queue is greater than the GPU's memory and computing power capacity. The multi-instance GPU configurator is then invoked to configure the GPU instance according to the specifications required for these n image tasks. After configuration, the first n image tasks in the queue are started.
[0069] When an image task on a GPU finishes execution and an idle GPU instance becomes available, the system checks if the specifications of the GPU instance required by the task at the head of the queue match the specifications of the idle GPU instance. If they match, the task at the head of the queue is dequeued and runs on that GPU instance. If they don't match, the system checks the priority of the task at the head of the queue. If the priority is high, it checks if the specifications of the idle GPU instance are lower than the specifications required by the task at the head of the queue. If they are lower, the task at the head of the queue is dequeued and runs on that GPU instance. Otherwise, it waits for all image tasks on the GPU to finish execution, then reconfigures the specifications of the GPU instances before running. If the priority is low, it waits for all image tasks to finish execution. If all GPU instances on the GPU are idle, and there are no image tasks in the task queue that meet the conditions for using any of the GPU instances, the specifications of the GPU instances are reconfigured in the same way as when there are no image tasks on the GPU.
[0070] The multi-instance graphics processor configurator is used to allocate a graphics processor instance to each image task based on the specifications of the GPU instance determined by the task selector calculator.
[0071] A task details viewer provides users with the sorting, priority, and specifications of the GPU instances required for each image task in the task queue. Specifically, such as... Figure 3 As shown, information in the task queue is displayed for the user to view.
[0072] like Figure 3 As shown, the cloud management platform includes a task queue, a task details viewer, a task selection calculator, and a multi-instance graphics processor configurator. Specifically, it includes: a task queue storing configuration information and priorities for multiple image tasks; a task selection calculator determining GPU instance specifications based on the specifications of the multiple image tasks in the task queue; and a multi-instance graphics processor configurator allocating a corresponding GPU instance for each image task based on the GPU instance specifications determined by the task selection calculator, using the GPU instance to execute the image task. In addition, the task details viewer provides users with information from the task queue.
[0073] In this embodiment of the invention, the multi-instance GPU configuration device based on a task queue is simple for users to operate. Users only need to place the image tasks to be executed into the task queue on the cloud management platform, specifying their positions according to their needs, and setting priority levels and the required specifications for the multi-instance GPUs. The device automatically configures the GPU instances, running image tasks sequentially from the head to the tail of the queue, selecting and using the corresponding GPU instances. When an image task is completed and a GPU instance becomes available, the device will make the following choices: run the task at the head of the queue and use the currently available GPU instance; wait for a new image task to complete and free up a new GPU instance; or call the multi-instance GPU configurator to analyze and calculate the image tasks in the current queue and then reconfigure the GPUs. Simultaneously, users can view the image task information in the task queue and the image task information using GPU instances at any time. During use, users can also adjust the order of unstarted image tasks in the task queue and modify their priorities. This embodiment of the invention automates the execution of image tasks, ensuring continuous use of GPU resources, maximizing resource utilization, automatically configuring multi-instance GPUs, reducing operational difficulty, improving management and utilization efficiency, and enhancing GPU utilization efficiency.
[0074] This embodiment also provides an image task processing apparatus for implementing the above embodiments and preferred embodiments; details already described will not be repeated. As used below, the term "module" can refer to a combination of software and / or hardware that performs a predetermined function. Although the apparatus described in the following embodiments is preferably implemented in software, hardware implementation, or a combination of software and hardware, is also possible and contemplated.
[0075] This embodiment provides an image task processing device, such as... Figure 4 As shown, it includes:
[0076] The image task acquisition module 401 is used to acquire a first preset number of image tasks and add the first preset number of image tasks to the task queue.
[0077] The image task selection module 402 is used to select a second preset number of image tasks from the task queue. The sum of the graphics processor resources occupied by the second preset number of image tasks is less than or equal to the total graphics processor resources, and the sum of the graphics processor resources occupied by the preset number of image tasks plus one image task is greater than the total graphics processor resources. The second preset number is less than or equal to the first preset number.
[0078] The graphics processor instance allocation module 403 is used to determine the specifications of the graphics processor instance required for each image task in the second preset number of image tasks, and to allocate a graphics processor instance to each image task according to the specifications of the graphics processor instance required for each image task.
[0079] The image task execution module 404 is used to execute image tasks using a graphics processor instance.
[0080] Specifically, the image processing apparatus mentioned above also includes:
[0081] The idle instance detection module is used to determine whether an idle graphics processor instance exists.
[0082] The instance specification determination module is used to determine whether the specifications of the graphics processor instance required by the first task in the task queue are consistent with the specifications of the idle graphics processor instance, based on the availability of an idle graphics processor instance.
[0083] The task execution module is used to execute the task at the head of the queue by utilizing an idle graphics processor instance, provided that the specifications of the graphics processor instance required by the task at the head of the queue match the specifications of the idle graphics processor instance.
[0084] The priority determination module is used to determine the priority of the task at the head of the task queue if the specifications of the graphics processor instance required by the task at the head of the queue are inconsistent with the specifications of the idle graphics processor instances.
[0085] The queue-first task specification judgment module is used to determine whether the specifications of the graphics processor instance required by the queue-first task are less than the specifications of the idle graphics processor instance, based on the priority of the queue-first task being the first priority.
[0086] The task execution module is also used to execute the queue-first task using an idle graphics processor instance if the specifications of the graphics processor instance required by the queue-first task are smaller than the specifications of the idle graphics processor instance.
[0087] The waiting module is configured to wait for the second preset number of image tasks to finish execution if no idle graphics processor instance is found, and to wait for the second preset number of image tasks to finish execution if the priority of the first task in the queue is the second priority, where the second priority is lower than the first priority. It is also configured to wait for the second preset number of image tasks to finish execution if the specifications of the graphics processor instance required by the first task in the queue are greater than the specifications of the idle graphics processor instance.
[0088] Specifically, after the image task acquisition module 401 described above, the image task processing device further includes:
[0089] The running task detection module is used to determine whether there are any running image tasks on the graphics processor.
[0090] The image task selection module 402 is used to select a second preset number of image tasks from the task queue if there are no currently running image tasks.
[0091] In this embodiment of the invention, the image task acquisition module 401 is used to acquire a first preset number of image tasks and add the first preset number of image tasks to a task queue. The image task selection module 402 is used to select a second preset number of image tasks from the task queue. The sum of the graphics processor resources occupied by the second preset number of image tasks is less than or equal to the total graphics processor resources, and the sum of the graphics processor resources occupied by the second preset number of image tasks plus one image task is greater than the total graphics processor resources. That is, the maximum number of image tasks is selected within the range of the total graphics processor resources, so as to select as many image tasks as possible for processing and improve the execution efficiency of image tasks. The graphics processor instance allocation module 403 is used to determine the specifications of the graphics processor instance required for each image task in the second preset number of image tasks, and allocate graphics processor instances for each image task according to the specifications of the graphics processor instance required for each image task. The image task execution module 404 is used to execute image tasks using graphics processor instances, so that there is no uneven allocation of graphics processor instances and the waste of graphics processor resources is prevented.
[0092] Further functional descriptions of the above modules and units are the same as those in the corresponding embodiments described above, and will not be repeated here.
[0093] In this embodiment, the image processing device is presented in the form of a functional unit. Here, a unit refers to an ASIC (Application Specific Integrated Circuit) circuit, a processor and memory that execute one or more software or fixed programs, and / or other devices that can provide the above functions.
[0094] This invention also provides a computer device having the above-described features. Figure 4 The image processing device shown.
[0095] Please see Figure 5 , Figure 5 This is a schematic diagram of the structure of a computer device provided in an optional embodiment of the present invention, such as... Figure 5As shown, the computer device includes one or more processors 10, memory 20, and interfaces for connecting the components, including high-speed interfaces and low-speed interfaces. The components communicate with each other via different buses and can be mounted on a common motherboard or otherwise installed as needed. The processors can process instructions executed within the computer device, including instructions stored in or on memory to display graphical information of a GUI on external input / output devices (such as display devices coupled to the interfaces). In some alternative implementations, multiple processors and / or multiple buses can be used with multiple memories and multiple memory modules, if desired. Similarly, multiple computer devices can be connected, each providing some of the necessary operations (e.g., as a server array, a group of blade servers, or a multiprocessor system). Figure 5 Take a processor 10 as an example.
[0096] Processor 10 may be a central processing unit, a network processor, or a combination thereof. Processor 10 may further include a hardware chip. The hardware chip may be an application-specific integrated circuit (ASIC), a programmable logic device (PLD), or a combination thereof. The programmable logic device may be a complex programmable logic device (CAMP), a field-programmable gate array (FPGA), a general-purpose array logic (GDA), or any combination thereof.
[0097] The memory 20 stores instructions executable by at least one processor 10 to cause the at least one processor 10 to perform the method shown in the above embodiments.
[0098] The memory 20 may include a program storage area and a data storage area. The program storage area may store the operating system and applications required for at least one function; the data storage area may store data created based on the use of the computer device. Furthermore, the memory 20 may include high-speed random access memory and may also include non-transitory memory, such as at least one disk storage device, flash memory device, or other non-transitory solid-state storage device. In some alternative embodiments, the memory 20 may optionally include memory remotely located relative to the processor 10, which can be connected to the computer device via a network. Examples of such networks include, but are not limited to, the Internet, intranets, local area networks, mobile communication networks, and combinations thereof.
[0099] The memory 20 may include volatile memory, such as random access memory; the memory may also include non-volatile memory, such as flash memory, hard disk or solid-state drive; the memory 20 may also include a combination of the above types of memory.
[0100] The computer device also includes a communication interface 30 for communicating with other devices or communication networks.
[0101] This invention also provides a computer-readable storage medium. The methods described above according to embodiments of the invention can be implemented in hardware or firmware, or implemented as computer code that can be recorded on a storage medium, or implemented as computer code downloaded via a network and originally stored on a remote storage medium or a non-transitory machine-readable storage medium and then stored on a local storage medium. Thus, the methods described herein can be processed by software stored on a storage medium using a general-purpose computer, a dedicated processor, or programmable or dedicated hardware. The storage medium can be a magnetic disk, optical disk, read-only memory, random access memory, flash memory, hard disk, or solid-state drive, etc.; further, the storage medium can also include combinations of the above types of memory. It is understood that computers, processors, microprocessor controllers, or programmable hardware include storage components capable of storing or receiving software or computer code, which, when accessed and executed by the computer, processor, or hardware, implements the methods shown in the above embodiments.
[0102] Although embodiments of the invention have been described in conjunction with the accompanying drawings, those skilled in the art can make various modifications and variations without departing from the spirit and scope of the invention, and such modifications and variations all fall within the scope defined by the appended claims.
Claims
1. A method for processing image tasks, characterized in that, include: Obtain a first preset number of image tasks and add the first preset number of image tasks to the task queue; A second preset number of image tasks are selected from the task queue. The sum of the graphics processor resources occupied by the second preset number of image tasks is less than or equal to the total graphics processor resources, and the sum of the graphics processor resources occupied by the second preset number of image tasks plus one image task is greater than the total graphics processor resources. The second preset number is less than or equal to the first preset number. The specifications of the graphics processor instance required for each of the second preset number of image tasks are determined, and a graphics processor instance is allocated to each image task according to the specifications of the graphics processor instance required for each image task; the graphics processor is divided into several independent graphics processor instances to provide independent graphics processor resources for multiple image tasks; The image task is executed using the graphics processor instance. After performing the image task using the graphics processor instance, the method further includes: Determine if an idle graphics processor instance is available; If an idle graphics processor instance is found, determine whether the specifications of the graphics processor instance required by the task at the head of the task queue are consistent with the specifications of the idle graphics processor instance. If the specifications of the graphics processor instance required by the first task in the task queue are the same as those of the idle graphics processor instance, the first task is executed using the idle graphics processor instance. If the specifications of the graphics processor instance required by the first task in the task queue are inconsistent with the specifications of the idle graphics processor instance, the priority of the first task is determined. If the priority of the first task is the first priority, determine whether the specifications of the graphics processor instance required by the first task are less than the specifications of the idle graphics processor instance. If the specifications of the graphics processor instance required for the first task are smaller than the specifications of the available graphics processor instance, the first task is executed using the available graphics processor instance. The method for determining whether an idle graphics processor instance exists also includes: If no idle graphics processor instance is available, wait for the second preset number of image tasks to finish executing; After the second preset number of image tasks have finished executing, the process further includes: re-acquiring the second preset number of image tasks from the task queue.
2. The method according to claim 1, characterized in that, The determination of the priority of the task at the head of the queue also includes: If the priority of the first task in the queue is the second priority, then wait for the second preset number of image tasks to finish executing. The second priority is lower than the first priority.
3. The method according to claim 1, characterized in that, The step of determining whether the specifications of the graphics processor instance required for the task at the head of the queue are less than the specifications of the idle graphics processor instance further includes: If the specifications of the graphics processor instance required by the first task are greater than the specifications of the idle graphics processor instance, then wait for the second preset number of image tasks to finish executing.
4. The method according to claim 1, characterized in that, After obtaining a first preset number of image tasks and adding the first preset number of image tasks to the task queue, the method further includes: Determine whether the image task is running on the graphics processor; If no image task is currently running, a second preset number of image tasks are selected from the task queue.
5. An image processing apparatus, characterized in that, The device includes: The image task acquisition module is used to acquire a first preset number of image tasks and add the first preset number of image tasks to the task queue; An image task selection module is used to select a second preset number of image tasks from the task queue. The sum of the graphics processor resources occupied by the second preset number of image tasks is less than or equal to the total graphics processor resources, and the sum of the graphics processor resources occupied by the preset number of image tasks plus one image task is greater than the total graphics processor resources. The second preset number is less than or equal to the first preset number. A graphics processor instance allocation module is used to determine the specifications of the graphics processor instance required for each of the second preset number of image tasks, and to allocate a graphics processor instance to each image task according to the specifications of the graphics processor instance required for each image task; and to divide the graphics processor into several independent graphics processor instances to provide independent graphics processor resources for multiple image tasks; An image task execution module is used to execute the image task using the graphics processor instance; The image processing apparatus mentioned above also includes: The idle instance detection module is used to determine whether an idle graphics processor instance has been found. The instance specification determination module is used to determine whether the specifications of the graphics processor instance required by the first task in the task queue are consistent with the specifications of the idle graphics processor instance, based on the availability of an idle graphics processor instance. The task execution module is used to execute the task at the head of the queue by utilizing an idle graphics processor instance, based on the requirement of the graphics processor instance required by the task at the head of the queue and the requirement of an idle graphics processor instance. The priority determination module is used to determine the priority of the task at the head of the task queue based on the fact that the specifications of the graphics processor instance required by the task at the head of the queue are inconsistent with the specifications of the idle graphics processor instances. The queue-first task specification judgment module is used to determine whether the specifications of the graphics processor instance required by the queue-first task are less than the specifications of the idle graphics processor instance, based on the priority of the queue-first task being the first priority. The task execution module is also used to execute the task at the head of the queue by utilizing an idle graphics processor instance if the specifications of the graphics processor instance required by the task at the head of the queue are smaller than the specifications of an idle graphics processor instance. The method for determining whether an idle graphics processor instance exists also includes: If no idle graphics processor instance is available, wait for the second preset number of image tasks to finish executing; After the second preset number of image tasks have finished executing, the process further includes: re-acquiring the second preset number of image tasks from the task queue.
6. A computer device, characterized in that, include: A memory and a processor are communicatively connected, the memory stores computer instructions, and the processor executes the computer instructions to perform the image task processing method according to any one of claims 1 to 4.
7. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer instructions for causing the computer to perform the image task processing method according to any one of claims 1 to 4.
Citation Information
Patent Citations
GPU instance allocation method and device, electronic equipment and computer readable medium
CN111580974A
Resource scheduling method and device, electronic equipment and storage medium
CN112148468A
GPU virtual resource allocation method and device, computer equipment and storage medium
CN112162856A