Method and system for load balancing multiple graphics cards among different applications

Through the operating system API function and graphics card spoofer, the main display device is selected and set, which solves the compatibility and resource waste problems of graphics card load balancing in the cloud streaming system and realizes the efficient use of graphics card computing power.

CN114416376BActive Publication Date: 2025-09-26JINAN DIANLIANG SOFTWARE CO LTD
View PDF 2 Cites 0 Cited by

Patent Information

Application Number
CN202210102574.4
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-01-27
Publication Date
2025-09-26
Estimated Expiration
2042-01-27

AI Technical Summary

Technical Problem

In cloud streaming systems, how to fully utilize the rendering capabilities of multiple graphics cards and balance the computing power load of the graphics cards to multiple applications. Existing technical methods have problems such as compatibility issues, high complexity, and resource waste.

Method used

Through the built-in API function of the operating system, the graphics card information is obtained and the optimal graphics card is selected using the balancing algorithm and set as the main display device to achieve load balancing between different applications, avoid intrusion into applications and virtualization, and use a graphics card spoofer to virtualize the main display device.

Benefits of technology

It achieves simple and convenient graphics card load balancing, is compatible with various applications, has no compatibility issues, and improves resource utilization efficiency.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114416376B_ABST
    Figure CN114416376B_ABST
Patent Text Reader

Abstract

The present disclosure provides a method and system for load balancing multiple graphics cards among different applications. The method is used for a server equipped with several graphics cards, wherein the drivers for all the graphics cards are installed in the server, and an independent display device is connected to each graphics card. The method comprises: obtaining currently available graphics cards based on an operating system's built-in API function; obtaining display device information and its load status corresponding to each available graphics card; based on the attribute information, selecting the optimal graphics card from the available graphics cards using a preset balancing algorithm, and setting the display device corresponding to the graphics card as the primary display device by calling an interface function for setting the attributes of the primary display device; wherein each time an application to be run is started, the primary display device needs to be updated; and when the application to be run is started, the application is rendered using the graphics card corresponding to the primary display device.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present disclosure belongs to the field of computer technology, and more particularly relates to a method and system for load balancing multiple graphics cards among different applications. Background Art

[0002] The statements in this section merely provide background information related to the present disclosure and do not necessarily constitute prior art.

[0003] In cloud streaming business systems, 3D applications, games, etc. are all run on GPU servers. To save costs, a machine often uses a dedicated motherboard and installs 4, 8, or even more than 10 graphics cards, sharing the CPU and memory of a host. This can save hardware costs, cabinet hosting costs, energy consumption, and carbon emissions. In addition, if only a small number of 3D applications are running, the CPU and memory can be concentrated on a small number of these applications, so the speed can be better.

[0004] However, in cloud streaming systems, there is a prominent difficulty: how to fully utilize the rendering capabilities of multiple graphics cards and balance the computing power load of the graphics cards to multiple applications.

[0005] The Windows operating system only uses one independent GPU for a user session. Even if the operating system can recognize multiple GPUs, all launched applications will run on a single independent graphics card without any additional work. It cannot be run on multiple graphics cards through simple settings. Currently, there is no relevant information or mature and simple method to specify which graphics card to render an application under Windows.

[0006] The inventors have discovered that the current mainstream cloud streaming technologies (cloud rendering, cloud gaming, etc.) that fully utilize multiple graphics cards to achieve load balancing are mainly divided into the following categories, and all of them have many unresolved problems:

[0007] (1) Application developers must support API processing for multiple graphics cards during development and select which graphics card to use at startup. This approach is limited by the fact that it requires the cooperation of application developers and requires multi-graphics card compatibility during the programming and development phase. This approach is difficult to meet the needs of cloud streaming services because cloud streaming vendors need to be compatible with a lot of software that has already been developed and produced. It is unrealistic to require developers to re-modify these already released and widely used applications.

[0008] (2) Based on the method of hooking many DirectX API interfaces, this method is to inject plug-in DLL into existing 3D applications, modify their internal startup logic, and dynamically modify their original execution process when they call functions such as D3D11CreateDevice, specifying a corresponding GPU graphics card to enter these applications. This method has problems with application compatibility because it is based on plug-in injection. Many applications have anti-injection and anti-plug-in mechanisms, so this method is not feasible. In addition, DirectX and other API functions that call related GPU graphics cards are numerous, and trying to inject them one by one is also a very time-consuming task, which is not simple and stable enough.

[0009] (3) Use some virtualization solutions, such as connecting each GPU to a separate virtual machine. This method is more troublesome. Moreover, after virtualization, the use of many system resources needs to go through a virtualization transfer layer, which also causes a certain amount of resource loss.

[0010] (4) From the hardware layer, multiple graphics cards can be connected together through hardware cables using technologies such as CrossFire and SLI, and used as a single graphics card. However, this model requires that all graphics card models must be exactly the same, which has many limitations. On the other hand, after connecting through CrossFire, the performance is not the sum of the two graphics cards. For example, the video memory is not the sum of the two graphics cards. After connecting two graphics cards, they may only have the performance effect of about 1.5 graphics cards, wasting a lot of GPU computing power. Summary of the Invention

[0011] To address the above-mentioned issues, the present disclosure provides a method and system for load balancing between different applications on multiple graphics cards. The solution is based on an API interface built into the operating system and achieves load balancing between different applications by switching the primary display device. The solution does not require intrusion into existing applications or complex virtualization, making it more compatible with various applications and eliminating compatibility issues.

[0012] According to a first aspect of an embodiment of the present disclosure, a method for load balancing multiple graphics cards between different applications is provided. The method is used in a server equipped with several graphics cards, wherein the drivers for all the graphics cards are installed in the server, and an independent display device is connected to each graphics card. The method includes:

[0013] Based on the built-in API function of the operating system, obtain the currently available graphics card;

[0014] Get the display device information and load status corresponding to each available graphics card;

[0015] Based on the attribute information, a preset balancing algorithm is used to select the optimal graphics card from the available graphics cards, and the display device corresponding to the graphics card is set as the primary display device by calling the system interface function for setting the primary display device attributes; wherein the primary display device needs to be updated each time the application to be run is started;

[0016] The application to be run is started, and the application is rendered using the graphics card corresponding to the primary display device.

[0017] Furthermore, the display device corresponding to the graphics card is set as the main display device, specifically: the coordinates of the main display device are set to (0, 0), and the coordinates of other display devices are obtained based on the coordinates and size of the main display device.

[0018] Furthermore, the currently available graphics card is obtained based on the built-in API function of the operating system, and the API function is specifically ChangeDisplaySettingsEx.

[0019] Furthermore, the balancing algorithm adopts a polling method or a lowest load first algorithm, wherein the polling method is to use the graphics cards in the order of their numbers each time the application to be run is started; when the number of graphics cards is insufficient, the graphics cards with the initial numbers are cycled; the lowest load limited algorithm is to select the graphics card with the lowest load from all available graphics cards.

[0020] Furthermore, the attribute information includes display device information corresponding to the graphics card and its load status.

[0021] Furthermore, the display device may be an actual main display device or a virtual main display device, and the virtual main display device may be a graphics card spoofer.

[0022] According to a second aspect of an embodiment of the present disclosure, a load balancing system for multiple graphics cards among different applications is provided, comprising:

[0023] An available graphics card acquisition unit, which is used to obtain the currently available graphics card based on the built-in API function of the operating system;

[0024] A graphics card attribute acquisition unit, which is used to obtain attribute information of each available graphics card;

[0025] a primary display device setting unit, configured to select the optimal graphics card from the available graphics cards based on the attribute information using a preset balancing algorithm, and set the display device corresponding to the graphics card as the primary display device by calling an interface function for setting the attributes of the primary display device; wherein the primary display device needs to be updated each time an application to be run is started;

[0026] The rendering unit is used to start the application to be run, and the application is rendered using the graphics card corresponding to the main display device.

[0027] According to a third aspect of an embodiment of the present disclosure, a server is provided, including a mainboard and a processor, wherein several graphics cards are installed on the mainboard, and when an application executed by the processor selects a graphics card for rendering, the application adopts the above-mentioned load balancing method for multiple graphics cards among different applications.

[0028] According to a fourth aspect of an embodiment of the present disclosure, an electronic device is provided, comprising a memory, a processor, and a computer program stored and running on the memory, wherein when the processor executes the program, a load balancing method for multiple graphics cards between different applications is implemented.

[0029] According to a fifth aspect of an embodiment of the present disclosure, a non-transitory computer-readable storage medium is provided, on which a computer program is stored. When the program is executed by a processor, it implements a method for detecting human targets in conference polling based on a combination of motion and stillness detection, and a method for load balancing between different applications on multiple graphics cards.

[0030] Compared with the prior art, the present invention has the following advantages:

[0031] (1) The present disclosure provides a method and system for load balancing multiple graphics cards between different applications. This method provides an extremely simple and convenient method for switching between different independent graphics cards and executing different applications. Compared with other existing methods, this method only requires a few simple function calls, which is very convenient. At the same time, this method is based on the use of some Windows APIs and does not require intrusion into the original application or complex virtualization. Therefore, it is more compatible with various applications and does not have compatibility issues.

[0032] (2) The solution described in this disclosure can realize GPU switching by combining the graphics card cheater and the relevant settings of the main display.

[0033] Advantages of additional aspects of the present disclosure will be given in part in the following description and in part will become apparent from the following description or learned through practice of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS

[0034] The accompanying drawings, which constitute a part of the present disclosure, are used to provide a further understanding of the present disclosure. The exemplary embodiments of the present disclosure and their descriptions are used to explain the present disclosure and do not constitute an improper limitation to the present disclosure.

[0035] Figure 1 This is a flow chart of a method for load balancing between different applications on multiple graphics cards as described in the first embodiment of the present disclosure;

[0036] Figure 2 This is a schematic diagram of the principle of setting the main display device described in the first embodiment of the present disclosure. DETAILED DESCRIPTION

[0037] The present disclosure will be further described below with reference to the accompanying drawings and embodiments.

[0038] It should be noted that the following detailed descriptions are exemplary and intended to provide further explanation of the present disclosure. Unless otherwise specified, all technical and scientific terms used herein have the same meaning as commonly understood by those skilled in the art to which the present disclosure belongs.

[0039] It should be noted that the terms used herein are only for describing specific embodiments and are not intended to limit the exemplary embodiments according to the present disclosure. As used herein, unless the context clearly indicates otherwise, the singular form is intended to include the plural form. In addition, it should be understood that when the terms "comprise" and / or "include" are used in this specification, they indicate the presence of features, steps, operations, devices, components and / or combinations thereof.

[0040] In the absence of conflict, the embodiments of the present disclosure and the features thereof may be combined with each other.

[0041] Example 1:

[0042] The purpose of this embodiment is to provide a method for load balancing multiple graphics cards between different applications. The method is used in a server equipped with several graphics cards. Drivers for all graphics cards are installed in the server, and each graphics card is connected to an independent display device. The method includes:

[0043] Based on the built-in API function of the operating system, obtain the currently available graphics card;

[0044] Get the display device information and load status corresponding to each available graphics card;

[0045] Based on the attribute information, a preset balancing algorithm is used to select the optimal graphics card from the available graphics cards, and the display device corresponding to the graphics card is set as the primary display device by calling the system interface function for setting the primary display device attributes; wherein the primary display device needs to be updated each time the application to be run is started;

[0046] The application to be run is started, and the application is rendered using the graphics card corresponding to the primary display device.

[0047] Furthermore, the display device corresponding to the graphics card is set as the main display device, specifically: the coordinates of the main display device are set to (0, 0), and the coordinates of other display devices are obtained based on the coordinates and size of the main display device.

[0048] Furthermore, the currently available graphics card is obtained based on the built-in API function of the operating system, and the API function is specifically ChangeDisplaySettingsEx.

[0049] Furthermore, the balancing algorithm adopts a polling method or a lowest load first algorithm, wherein the polling method is to use the graphics cards in the order of their numbers each time the application to be run is started; when the number of graphics cards is insufficient, the graphics cards with the initial numbers are cycled; the lowest load limited algorithm is to select the graphics card with the lowest load from all available graphics cards.

[0050] Furthermore, the attribute information includes display device information corresponding to the graphics card and its load status.

[0051] Furthermore, the display device may be an actual main display device or a virtual main display device, and the virtual main display device may be a graphics card spoofer.

[0052] Specifically, for ease of understanding, the solution disclosed herein is described in detail below with reference to the accompanying drawings:

[0053] In order to solve the problems existing in the prior art, the present disclosure provides a method for load balancing between different applications on multiple graphics cards, comprising the following steps:

[0054] Step 1: Install the drivers for all graphics cards;

[0055] Step 2: Plug in a main display device for each graphics card. Considering that it is inconvenient to plug in the main display device for IDC hosting in the computer room, you can also directly plug in a "graphics card cheater" or other hardware device that is virtualized as the main display device (available on e-commerce platforms such as JD.com).

[0056] Step 3: In the Windows operating system, use the system API function such as EnumDisplayDevices to enumerate the graphics card list and enumerate the currently available graphics cards;

[0057] As an optional implementation method, you can also select the relevant functions in the SDK of graphics card manufacturers such as NVIDIA to enumerate graphics cards;

[0058] The specific meaning of the available graphics cards is: if some graphics cards are not plugged into the graphics card cheater, or if some virtual graphics card driver is installed on the machine, they may be enumerated but their status is: unavailable; therefore, during enumeration, these unavailable graphics cards are filtered out based on whether their status is available, and the graphics cards finally obtained are available graphics cards;

[0059] Step 4: Get the coordinate position, length, width and other information of the main display device connected to each graphics card; the acquisition method uses the system's built-in EnumDisplaySettingsAPI function;

[0060] Step 5: Obtain the current usage rate and other load conditions of each graphics card; wherein, the graphics card load condition is based on the SDK function of the graphics card manufacturer to obtain the graphics card load condition; for example, for NVIDIA graphics cards, the current load condition (i.e., graphics card usage rate) is obtained based on the nvmlDeviceGetUtilizationRates function;

[0061] Step 6: Based on a balancing algorithm such as polling or lowest load priority, select a graphics card N, then find any corresponding primary display device, call the system's API function to set the primary display device properties for the primary display device: ChangeDisplaySettingsEx, set it as the primary display device, and the primary display device coordinates must be 0,0. For better results, other primary display devices need to keep the layout unchanged. According to their coordinates relative to the primary display device, the corresponding positions are calculated in combination with the length and width of the primary display device. The coordinates on the left of the primary display device are negative, and the coordinates on the right are positive. Set them together to the API function. The specific principle is as follows: Figure 2 As shown;

[0062] Here, the meaning of polling is explained. For example, the first time an application is launched, the first graphics card is used; the second time it is launched, the second graphics card is used. If there are four graphics cards in total, the fifth time it is launched, the first graphics card is used again, and so on. The lowest load priority means that before launching an application, the graphics card with the lowest current load rate is found. The graphics card with the lowest current load rate is always selected for launch.

[0063] Step 7: Start the application to be run, and the application will automatically use the computing resources of graphics card N for rendering.

[0064] Furthermore, the innovative aspect of the solution described in this disclosure lies in that, after a primary display device is set, the graphics card connected to the primary display device is treated by the operating system as the graphics card currently being used for rendering. At this point, any application launched will be rendered on this graphics card. If the graphics card becomes overloaded after running some programs, the primary display device will be switched to the primary display device connected to another graphics card. Subsequently, all applications launched will run on the other graphics card.

[0065] Example 2:

[0066] The purpose of this embodiment is to provide a load balancing system for multiple graphics cards among different applications.

[0067] A load balancing system for multiple graphics cards among different applications, comprising:

[0068] An available graphics card acquisition unit, which is used to obtain the currently available graphics card based on the built-in API function of the operating system;

[0069] A graphics card attribute acquisition unit, which is used to obtain attribute information of each available graphics card;

[0070] a primary display device setting unit, configured to select the optimal graphics card from the available graphics cards based on the attribute information using a preset balancing algorithm, and set the display device corresponding to the graphics card as the primary display device by calling an interface function for setting the attributes of the primary display device; wherein the primary display device needs to be updated each time an application to be run is started;

[0071] The rendering unit is used to start the application to be run, and the application is rendered using the graphics card corresponding to the main display device.

[0072] Example 3:

[0073] The purpose of this embodiment is to provide a server.

[0074] A server includes a mainboard and a processor. The mainboard is equipped with several graphics cards. When an application executed by the processor selects a graphics card for rendering, the server adopts the above-mentioned load balancing method for multiple graphics cards among different applications.

[0075] In further embodiments, there is also provided:

[0076] An electronic device includes a memory and a processor, and computer instructions stored in the memory and executed by the processor. When the computer instructions are executed by the processor, the method described in Example 1 is performed. For the sake of brevity, no further details are given here.

[0077] It should be understood that in this embodiment, the processor may be a central processing unit (CPU), or may be other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), off-the-shelf field-programmable gate arrays (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor, etc.

[0078] The memory may include a read-only memory and a random access memory, and provides instructions and data to the processor. A portion of the memory may also include a non-volatile random access memory. For example, the memory may also store information about the device type.

[0079] A computer-readable storage medium is used to store computer instructions, and when the computer instructions are executed by a processor, the method described in embodiment 1 is performed.

[0080] The method in Example 1 can be directly implemented as being executed by a hardware processor, or by a combination of hardware and software modules within the processor. The software module can be located in a storage medium well-established in the art, such as random access memory, flash memory, read-only memory, programmable read-only memory, electrically erasable programmable memory, or registers. The storage medium is located in the memory, and the processor reads the information in the memory and, in conjunction with its hardware, completes the steps of the above method. To avoid repetition, a detailed description is not given here.

[0081] Those skilled in the art will appreciate that the units, i.e., algorithm steps, of the various examples described in this embodiment can be implemented using electronic hardware or a combination of computer software and electronic hardware. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Professionals and technicians may use different methods to implement the described functions for each specific application, but such implementation should not be considered beyond the scope of this disclosure.

[0082] The load balancing method and system for multiple graphics cards among different applications provided in the above embodiment can be implemented and has broad application prospects.

[0083] The foregoing description is merely a preferred embodiment of the present disclosure and is not intended to limit the present disclosure. Those skilled in the art will readily appreciate that various modifications and variations are possible. Any modifications, equivalent substitutions, or improvements made within the spirit and principles of the present disclosure shall be included within the scope of protection of the present disclosure.

Claims

1. A method for load balancing between multiple graphics cards and different applications, characterized in that: The method is used to install a server with several graphics cards, install the drivers of all graphics cards in the server, and connect an independent display device to each graphics card. The method includes: Based on the built-in API function of the operating system, obtain the currently available graphics card; Get the display device information and load status corresponding to each available graphics card; Based on the display device information corresponding to the graphics card and its load, a preset balancing algorithm is used to screen out the optimal graphics card from the available graphics cards, and the display device corresponding to the graphics card is set as the primary display device by calling the system's interface function for setting the primary display device attributes; wherein, each time the application to be run is started, the primary display device needs to be updated; Starting the application to be run, wherein the application is rendered using the graphics card corresponding to the primary display device; The step of setting the display device corresponding to the graphics card as the primary display device comprises the following steps: setting the coordinates of the primary display device to (0, 0), and obtaining the coordinates of other display devices based on the coordinates and size of the primary display device; The balancing algorithm adopts a round-robin method or a lowest load first algorithm. The polling method uses the graphics cards in the order of their numbers each time an application to be run is started. When the number of graphics cards is insufficient, the graphics cards with the initial number are cycled. The lowest load limited algorithm selects the graphics card with the lowest load from all available graphics cards. After the primary display device is set, the graphics card connected to the primary display device is used by the operating system as the graphics card for rendering. When the graphics card starts some programs and the load is high, the primary display device will be switched to the primary display device connected to another graphics card. Then, all subsequent programs will run on the other graphics card. The display device may be an actual main display device or a virtual main display device, and the virtual main display device may be a graphics card spoofer; The currently available graphics card is obtained based on the built-in API function of the operating system, and the API function is specifically ChangeDisplaySettingsEx.

2. A load balancing system for multiple graphics cards among different applications, using the load balancing method for multiple graphics cards among different applications as claimed in claim 1, characterized in that: include: An available graphics card acquisition unit, which is used to obtain the currently available graphics card based on the built-in API function of the operating system; A graphics card attribute acquisition unit, which is used to obtain attribute information of each available graphics card; a primary display device setting unit, configured to select the optimal graphics card from the available graphics cards based on the attribute information using a preset balancing algorithm, and set the display device corresponding to the graphics card as the primary display device by calling an interface function for setting the attributes of the primary display device; wherein the primary display device needs to be updated each time an application to be run is started; The rendering unit is used to start the application to be run, and the application is rendered using the graphics card corresponding to the main display device.

3. A server, characterized in that: The system comprises a motherboard and a processor, wherein a plurality of graphics cards are installed on the motherboard, and an application program executed by the processor adopts a load balancing method for multiple graphics cards among different applications as claimed in claim 1 when selecting a graphics card for rendering.

4. An electronic device comprising a memory, a processor, and a computer program stored and running on the memory, characterized in that: When the processor executes the program, the load balancing method for multiple graphics cards among different applications according to claim 1 is implemented.

5. A non-transitory computer-readable storage medium having a computer program stored thereon, characterized in that: When the program is executed by a processor, the method for load balancing between different applications on multiple graphics cards as claimed in claim 1 is implemented.

Citation Information

Patent Citations

  • Display card load optimization method and device and computer equipment

    CN110399214A

  • Load balancing method and device and electronic equipment

    CN111274026A