GPU (Graphics Processing Unit) performance monitoring data acquisition method based on manufacturer equipment management library
The GPU card type is obtained through PCI information and the acquisition thread is started. The data is summarized using the device management library, which solves the problem of maintenance of existing GPU acquisition solutions and realizes unified monitoring and management of different GPU types.
Patent Information
- Application Number
- CN202411405866.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-10-10
- Publication Date
- 2025-02-11
AI Technical Summary
The existing GPU acquisition solutions have problems such as low code reuse and difficulty in maintaining, and it is difficult to adapt to changes in different GPU types and monitoring plug-ins.
The number and type of GPU cards are obtained through PCI information, the corresponding acquisition thread is started, the monitoring indicators are collected, and data summary and processing is performed through the device management library to achieve unified monitoring of different GPU types.
It realizes comprehensive monitoring and management of GPU performance, is flexible, scalable and reliable, and is suitable for various application scenarios without the need to frequently adapt to different GPU types.
Smart Images

Figure CN119415351A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of GPU acquisition technology, and in particular to a method for acquiring GPU performance monitoring data based on device management libraries of various manufacturers. Background Art
[0002] In the traditional use of cloud servers, programmers or operation and maintenance personnel will pay attention to the basic information indicators of the cloud server, such as CPU, memory, network, storage, etc., and use them to determine whether the cloud server and the business are running normally. However, when running programs and businesses that require GPU devices, such as deep learning reasoning training and image processing, basic indicators alone are not enough to reflect the operating status of the business. In addition, when a failure occurs, it is difficult to confirm it through basic indicators, and it is impossible to provide more direct data support for GPU device troubleshooting. Therefore, when running such programs that require GPU devices, programmers or operation and maintenance personnel, in addition to paying attention to the basic indicators such as CPU and memory of the cloud server, also need to pay extra attention to the status of the cloud server's GPU device to determine whether the cloud server is running normally and whether high-performance computing is working normally.
[0003] Most of the existing GPU acquisition solutions are to adapt and develop a single type of GPU in a certain monitoring plug-in. If there is a new GPU type or monitoring plug-in, new adaptation code needs to be developed. Because the device management libraries of different GPU manufacturers are different, the acquisition function calling methods are different, and the data type definitions are different, if a monitoring acquisition program is developed separately for each GPU card, there will be problems such as low code reuse and difficult maintenance. Summary of the invention
[0004] In view of the needs and shortcomings of current technology development, the present invention provides a GPU performance monitoring data collection method based on device management libraries of various manufacturers.
[0005] The present invention provides a GPU performance monitoring data collection method based on the device management library of each manufacturer, and the technical solution adopted to solve the above technical problems is as follows:
[0006] A GPU performance monitoring data collection method based on the device management library of each manufacturer includes the following steps:
[0007] S1. Obtain the number of GPU cards and distinguish the types of GPU cards through PCI information;
[0008] S2. According to the GPU card type, start the "single GPU card type collection thread" for different GPU cards;
[0009] S3. According to the number of GPU cards, each "single GPU card type collection thread" starts one "indicator collection thread" for every two GPU cards;
[0010] S4. Each "indicator collection thread" collects monitoring indicators and returns them to the corresponding "single GPU card type collection thread";
[0011] S5, "single GPU card type collection thread" summarizes the single GPU card indicators and returns them to the main thread;
[0012] S6. The main thread summarizes the indicators of each GPU card and returns them to the caller.
[0013] Optionally, for a Linux system, step S1 specifically includes the following operations:
[0014] Read the file / proc / bus / pci / devices to obtain basic information of PCI devices, including manufacturer ID and card type ID;
[0015] Confirm the manufacturer and GPU card type according to the manufacturer ID and card type ID in the PCI device basic information, and distinguish the GPU card types with the same manufacturer ID and card type ID according to the subsys ID in the card type ID;
[0016] Based on the basic information of the PCI device, in the / sys / bus / pci / devices / directory, you can find the corresponding device node and access the files under it according to the domain and bus information to obtain the properties and status information of the PCI device; when searching for the device node, the 0000 domain is searched first.
[0017] Optionally, for a Windows system, step S1 specifically includes the following operations:
[0018] The hardware ID information of all PCI devices is obtained through the SetupDiGetClassDevs function, SetupDiEnumDeviceInfo function and SetupDiGetDeviceRegistryProperty function of the setupapi library, and the manufacturer ID, card type ID, subsys_device and subsys_vender are separated from the obtained information, which are then used to determine the type of GPU card mounted in the virtual machine.
[0019] Optionally, when executing step S1, different GPU card types are distinguished by using PCI information and relying on hardware management libraries provided by different GPU card manufacturers.
[0020] Optionally, step S2 is performed to check the status of the driver and device management library before starting the "single GPU card type acquisition thread", which specifically includes the following process:
[0021] Verify the driver and device management library separately to ensure that the relevant driver software has been correctly installed and can work normally. At the same time, confirm that the device management library supporting the driver exists and is available;
[0022] If it is found that the driver software is not installed correctly, there is an abnormality, or the corresponding device management library does not exist, the acquisition operation will not continue;
[0023] After the driver and device management library are verified, the acquisition operation will continue.
[0024] Further optionally, when executing step S2 to start the "single GPU card type acquisition thread", the device management library acquisition function of the corresponding GPU card manufacturer is called in an explicit post-loading manner, and the "single GPU card type acquisition thread" initializes the called acquisition function and starts collecting GPU performance data.
[0025] Further optionally, the "indicator collection thread" is the thread that actually performs the data collection task;
[0026] When executing step S4, the "index collection thread" calls the previously initialized collection function to collect various performance indicators of the GPU and returns them to the corresponding "single GPU card type collection thread".
[0027] Further optionally, the step S5 involved specifically includes:
[0028] The "single GPU card type collection thread" waits for all its subordinate "indicator collection threads" to complete their tasks, and collects the monitoring indicators returned by all its subordinate "indicator collection threads";
[0029] The "single GPU card type collection thread" summarizes and processes the collected monitoring indicators and returns the summarized results to the main thread.
[0030] Further optionally, the step S6 involved specifically includes:
[0031] The main thread starts all "single GPU card type collection threads" and waits for all "single GPU card type collection threads" to complete their tasks;
[0032] When all the "single GPU card type acquisition threads" started by the main thread have completed their work, the main thread collects the summary results of these threads for further processing or display, and returns all GPU performance monitoring indicators to the caller.
[0033] Compared with the prior art, the GPU performance monitoring data collection method based on the device management library of each manufacturer of the present invention has the following beneficial effects:
[0034] 1. The present invention can realize comprehensive monitoring and management of GPU performance, and has flexibility, scalability and reliability, and is applicable to various application scenarios and requirements. It does not need to pay attention to the GPU type installed on the cloud server. As long as the GPU type is in the development adaptation list, the underlying acquisition logic can be ignored, and the fixed interface acquisition can be directly called to obtain monitoring data with unified variable types, so as to facilitate subsequent data submission, storage and display; only one adaptation development is required, and when the GPU card type is changed later, only the corresponding plug-in needs to be adapted, developed and upgraded, and no other monitoring components need to be modified;
[0035] 2. The present invention can collect the performance data of GPU cards of different types and numbers, so as to understand the usage, load and performance bottleneck of GPU in real time, which is helpful to optimize the performance of application programs and improve the efficiency of the overall system; by reading the PCI device information, GPU cards of different manufacturers and models can be accurately identified, so as to perform specific optimization and configuration for different hardware environments; it is applicable to mainstream operating systems such as Linux and Windows, and can run on different platforms and collect corresponding GPU performance data; the device management library acquisition function of the corresponding GPU card manufacturer is called in an explicit post-loading manner, and the required function can be dynamically loaded at runtime, which increases flexibility and compatibility; before starting the acquisition thread, the driver and the device management library are checked for status to ensure that they are correctly installed and available, so as to effectively avoid data acquisition errors or failures caused by problems with the driver or library; according to the number of GPU cards, an indicator acquisition thread is started for every two GPU cards, so as to realize parallel processing and improve the efficiency of data acquisition; each "single GPU card type acquisition thread" is responsible for collecting the monitoring indicators returned by all its subordinate "indicator acquisition threads", summarizing and processing them, and finally returning the results to the main thread, which makes the entire data acquisition process more efficient and orderly. BRIEF DESCRIPTION OF THE DRAWINGS
[0036] Attached Figure 1 is a method flow framework diagram of Embodiment 1 of the present invention;
[0037] Attached Figure 2 It is a schematic diagram of a specific process of the first embodiment of the present invention. DETAILED DESCRIPTION
[0038] In order to make the technical solution, the technical problem solved and the technical effect of the present invention more clearly understood, the technical solution of the present invention is clearly and completely described below in conjunction with specific embodiments.
[0039] Embodiment 1:
[0040] Reference Figure 1 , 2This embodiment proposes a GPU performance monitoring data collection method based on the device management library of each manufacturer, which includes the following steps:
[0041] S1. Obtain the number of GPU cards and distinguish the types of GPU cards through PCI information.
[0042] (1) For the Linux system, step S1 specifically includes the following operations:
[0043] Read the file / proc / bus / pci / devices to obtain the basic information of the PCI device. The first column of the read file is a 4-digit hexadecimal number. The first two digits are the bus number (bus_id). The last two digits are bitwise ANDed with 7 to get the function number. The last two digits are shifted right by 3 bits to get the bus device number. The second column of the read file is an 8-digit hexadecimal number. The first four digits are the vendor ID (vender_id) and the last four digits are the card type ID (device_id). With this information, the type of GPU card mounted on the virtual machine can be determined.
[0044] Confirm the manufacturer and GPU card type according to the manufacturer ID and card type ID in the PCI device basic information, and distinguish the GPU card types with the same manufacturer ID and card type ID according to the subsys ID in the card type ID;
[0045] Based on the basic information of the PCI device, in the / sys / bus / pci / devices / directory, you can find the corresponding device node and access the files under it according to the domain and bus information to obtain the properties and status information of the PCI device; when searching for the device node, the 0000 domain is searched first.
[0046] (2) For Windows system, step S1 specifically includes the following operations:
[0047] The hardware ID information of all PCI devices is obtained through the SetupDiGetClassDevs function, SetupDiEnumDeviceInfo function and SetupDiGetDeviceRegistryProperty function of the setupapi library, and the manufacturer ID, card type ID, subsys_device and subsys_vender are separated from the obtained information, which are then used to determine the type of GPU card mounted in the virtual machine.
[0048] More specifically, for Windows systems:
[0049] First, get the device information set handle of the specified device class through the SetupDiGetClassDevs function of the setupapi library; enumerate the device information elements in the device information set through the SetupDiEnumDeviceInfo function of the setupapi library, and get the device information elements one by one by passing the device information set handle and an index value; get the value of the device registry property through the SetupDiGetDeviceRegistryProperty function of the setupapi library, and get the corresponding property value by passing the device information element handle and property identifier;
[0050] Then, call the SetupDiGetClassDevs function, pass in the device class GUID of the PCI device, and obtain the device information collection handle; use the SetupDiEnumDeviceInfo function to traverse the device information collection and obtain the device information element handle of each device; for each device information element handle, call the SetupDiGetDeviceRegistryProperty function and pass in the following property identifiers: ①SPDRP_HARDWAREID, used to obtain the hardware ID of the device; ②SPDRP_MFG, used to obtain the manufacturer ID of the device; ③SPDRP_DEVICEDESC, used to obtain the description information of the device; ④SPDRP_CLASS, used to obtain the category of the device; ⑤SPDRP_SUBSYSTEM, used to obtain the subsystem ID of the device; ⑥SPDRP_DRIVER, used to obtain the driver of the device to obtain the corresponding property value;
[0051] Finally, the type of GPU card mounted in the virtual machine is determined based on the obtained hardware ID, manufacturer ID, device description information, category, subsystem ID and driver.
[0052] It should be added that both Linux and Windows systems, while utilizing PCI information, need to rely on the hardware management library provided by different GPU card manufacturers to ultimately differentiate between different GPU card types.
[0053] S2. According to the GPU card type, start "single GPU card type collection thread" for different GPU cards.
[0054] Before starting the "single GPU card type acquisition thread", it is necessary to check the status of the driver and device management library, which includes the following process: ① Verify the driver and device management library separately to ensure that the relevant driver software has been correctly installed and can work normally. At the same time, confirm that the device management library matching the driver exists and is available; ② If it is found that the driver software is not installed correctly, there is an abnormality, or the corresponding device management library does not exist, the acquisition operation will not continue; ③ After the driver and device management library are verified, the acquisition operation will continue.
[0055] When starting the "single GPU card type collection thread", the device management library collection function of the corresponding GPU card manufacturer is called in an explicit post-loading manner. The "single GPU card type collection thread" initializes the called collection function and starts collecting GPU performance data.
[0056] S3. According to the number of GPU cards, each "single GPU card type collection thread" starts an "indicator collection thread" for every two GPU cards. The "indicator collection thread" is the thread that actually executes the data collection task.
[0057] S4. Each "indicator collection thread" collects monitoring indicators and returns them to the corresponding "single GPU card type collection thread".
[0058] It should be added that the "indicator collection thread" calls the previously initialized collection function to collect various performance indicators of the GPU and returns them to the "single GPU card type collection thread" to which it belongs.
[0059] S5, "single GPU card type collection thread" summarizes the single GPU card indicators and returns them to the main thread, including the following operations:
[0060] The "single GPU card type collection thread" waits for all its subordinate "indicator collection threads" to complete their tasks, and collects the monitoring indicators returned by all its subordinate "indicator collection threads";
[0061] The "single GPU card type collection thread" summarizes and processes the collected monitoring indicators and returns the summarized results to the main thread.
[0062] S6. The main thread summarizes the indicators of each GPU card and returns them to the caller, including the following operations:
[0063] The main thread starts all "single GPU card type collection threads" and waits for all "single GPU card type collection threads" to complete their tasks;
[0064] When all the "single GPU card type acquisition threads" started by the main thread have completed their work, the main thread collects the summary results of these threads for further processing or display, and returns all GPU performance monitoring indicators to the caller.
[0065] In summary, the GPU performance monitoring data collection method based on the device management library of each manufacturer of the present invention can collect the performance data of GPU cards of different types and quantities, so as to understand the usage, load and performance bottleneck of the GPU in real time, which is helpful to optimize the performance of the application and improve the efficiency of the overall system; by reading the PCI device information, GPU cards of different manufacturers and models can be accurately identified, so as to perform specific optimization and configuration for different hardware environments; it is applicable to mainstream operating systems such as Linux and Windows, and can run on different platforms and collect corresponding GPU performance data; it adopts explicit post-loading to call the corresponding GPU card manufacturer's The device management library acquisition function can dynamically load the required functions at runtime, which increases flexibility and compatibility. Before starting the acquisition thread, the driver and device management library are checked to ensure that they are correctly installed and available, which can effectively avoid data acquisition errors or failures caused by driver or library problems. According to the number of GPU cards, an indicator acquisition thread is started for every two GPU cards to achieve parallel processing and improve data acquisition efficiency. Each "single GPU card type acquisition thread" is responsible for collecting the monitoring indicators returned by all its subordinate "indicator acquisition threads", summarizing and processing them, and finally returning the results to the main thread, which makes the entire data acquisition process more efficient and orderly.
[0066] The above specific examples are used to explain the principles and implementation methods of the present invention in detail. These examples are only used to help understand the core technical content of the present invention. Based on the above specific embodiments of the present invention, any improvements and modifications made by technicians in this technical field without departing from the principles of the present invention should fall within the scope of patent protection of the present invention.
Claims
1. A GPU performance monitoring data collection method based on the device management library of each manufacturer, characterized in that: The steps include: S1. Obtain the number of GPU cards and distinguish the types of GPU cards through PCI information; S2. According to the GPU card type, start "single GPU card type collection thread" for different GPU cards; S3. According to the number of GPU cards, each "single GPU card type collection thread" starts an "indicator collection thread" for every two GPU cards; S4. Each "indicator collection thread" collects monitoring indicators and returns them to the corresponding "single GPU card type collection thread"; S5, "single GPU card type collection thread" summarizes the single GPU card indicators and returns them to the main thread; S6. The main thread summarizes the indicators of each GPU card and returns them to the caller.
2. The method for collecting GPU performance monitoring data based on the device management library of each manufacturer according to claim 1, characterized in that: For the Linux system, step S1 specifically includes the following operations: Read the file / proc / bus / pci / devices to obtain basic information of PCI devices, including manufacturer ID and card type ID; Confirm the manufacturer and GPU card type according to the manufacturer ID and card type ID in the PCI device basic information, and distinguish the GPU card types with the same manufacturer ID and card type ID according to the subsys ID in the card type ID; Based on the basic information of PCI devices, in the / sys / bus / pci / devices / directory, you can find the corresponding device node and access the files under it according to the domain and bus information to obtain the properties and status information of the PCI device; When searching for a device node, the 0000 domain is searched first.
3. The method for collecting GPU performance monitoring data based on the device management library of each manufacturer according to claim 1, characterized in that: For Windows system, step S1 specifically includes the following operations: The hardware ID information of all PCI devices is obtained through the SetupDiGetClassDevs function, SetupDiEnumDeviceInfo function and SetupDiGetDeviceRegistryProperty function of the setupapi library, and the manufacturer ID, card type ID, subsys_device and subsys_vender are separated from the obtained information, which are then used to determine the type of GPU card mounted in the virtual machine.
4. The method for collecting GPU performance monitoring data based on the device management library of each manufacturer according to claim 1, characterized in that: When executing step S1, different GPU card types are distinguished by using PCI information and relying on hardware management libraries provided by different GPU card manufacturers.
5. The method for collecting GPU performance monitoring data based on the device management library of each manufacturer according to claim 1, characterized in that: Execute step S2, before starting the "single GPU card type acquisition thread", check the status of the driver and device management library, which specifically includes the following process: Verify the driver and device management library separately to ensure that the relevant driver software has been correctly installed and can work normally. At the same time, confirm that the device management library supporting the driver exists and is available; If it is found that the driver software is not installed correctly, there is an abnormality, or the corresponding device management library does not exist, the acquisition operation will not continue; After the driver and device management library are verified, the acquisition operation will continue.
6. The method for collecting GPU performance monitoring data based on the device management library of each manufacturer according to claim 5, characterized in that: When executing step S2 to start the "single GPU card type acquisition thread", the device management library acquisition function of the corresponding GPU card manufacturer is called in an explicit post-loading manner. The "single GPU card type acquisition thread" initializes the called acquisition function and starts collecting GPU performance data.
7. The method for collecting GPU performance monitoring data based on the device management library of each manufacturer according to claim 6, characterized in that: "Indicator collection thread" is the thread that actually performs data collection tasks; When executing step S4, the "index collection thread" calls the previously initialized collection function to collect various performance indicators of the GPU and returns them to the "single GPU card type collection thread" to which it belongs.
8. The method for collecting GPU performance monitoring data based on the device management library of each manufacturer according to claim 1, characterized in that: The step S5 specifically includes: The "single GPU card type collection thread" waits for all its subordinate "indicator collection threads" to complete their tasks, and collects the monitoring indicators returned by all its subordinate "indicator collection threads"; The "single GPU card type collection thread" aggregates and processes the collected monitoring indicators and returns the aggregated results to the main thread.
9. The method for collecting GPU performance monitoring data based on the device management library of each manufacturer according to claim 1, characterized in that: The step S6 specifically includes: The main thread starts all "single GPU card type collection threads" and waits for all "single GPU card type collection threads" to complete their tasks; When all the "single GPU card type acquisition threads" started by the main thread have completed their work, the main thread collects the summary results of these threads for further processing or display, and returns all GPU performance monitoring indicators to the caller.