A method, apparatus and device for vGPU performance monitoring
By establishing a short connection between the vGPU performance monitoring module written in Python and the vGPU driver module, the problems of low upgrade efficiency and data transmission lag in existing technologies are solved. This enables upgrades without compilation and real-time performance data query, improving the independence and timeliness of the monitoring module.
Patent Information
- Application Number
- CN202111435730.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-11-29
- Publication Date
- 2025-10-24
- Estimated Expiration
- 2041-11-29
AI Technical Summary
The existing vGPU performance monitoring module requires recompilation and virtual machine restart when upgrading, resulting in low upgrade efficiency and data transmission delays, making it impossible to quickly respond to changes in the performance monitoring module.
A vGPU performance monitoring module written in Python is used to establish a communication connection with the vGPU driver module through the ctypes protocol. It uses a performance monitoring dynamic link library to query performance data and disconnects the connection after the query is completed, thus avoiding compilation and restarting of the virtual machine.
It enables compilation-free upgrades, improves the upgrade efficiency of the vGPU performance monitoring module, allows for real-time performance data querying, and has good independence, timeliness, and scalability, avoiding data lag issues.
Smart Images

Figure CN114201361B_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the field of data transmission, and in particular to a vGPU performance monitoring method, device and equipment. BACKGROUND
[0002] A virtual machine refers to a complete computer system that is simulated by software, has complete hardware system functions, and runs in a completely isolated environment. When a virtual machine is created in a computer, part of the hard disk and memory capacity of the entity machine is used as the hard disk and memory capacity of the virtual machine. Virtual machines are widely used in the field of software development, but when they are applied to CAD or other 3D rendering software in a virtual machine environment, the early virtual machines use Software 3D technology to perform graphics processing using the CPU, and the graphics processing capability is very limited. GPU is widely used in cloud desktop, AI, public cloud and other fields, and its graphics processing capability is very powerful. In order to improve the ability of virtual machines to process 3D graphics, vGPU technology (GPU virtualization technology) has emerged. The vGPU technology virtualizes a physical GPU into multiple virtual GPUs, realizing the function of multiple virtual machines using one physical GPU. As a kind of expensive physical resource, it is necessary to effectively monitor the use of vGPU by the program inside the virtual machine. The widely used vGPU performance monitoring module (a program for monitoring vGPU) is implemented based on C language programming, which realizes access to the virtual machine by calling the C language interface in the dynamic link library, and then queries the performance data of the vGPU used by the virtual machine, and then forwards it to the cloud platform for data processing and presents the performance graphics. However, this method has poor business expansion, and when new extension functions are added, the performance monitoring module needs to be recompiled and packaged, and the dynamic link library needs to be dynamically linked in the virtual machine startup. If the performance monitoring module on the host changes, the dynamic link library inside the virtual machine cannot immediately respond to the change of the performance monitoring module, and the virtual machine needs to be restarted to make the new function of the performance monitoring module effective in the virtual machine. Therefore, how to improve the upgrade efficiency of the vGPU performance monitoring module is a problem to be solved. SUMMARY
[0003] Therefore, the embodiments of the present application provide a vGPU performance monitoring method, device and equipment, thereby improving the upgrade efficiency of the vGPU performance monitoring module.
[0004] According to a first aspect, the present application provides a vGPU performance monitoring method applied to a vGPU performance monitoring module in a host computer, wherein the vGPU performance monitoring module is based on python, a virtual machine is deployed on the host computer, and the virtual machine uses a vGPU virtually output by a GPU on the host computer through GPU virtualization technology, and the method comprises: when a query instruction of a cloud platform is received, a communication connection is established with a vGPU driver module on the host computer through a query interface in a performance monitoring dynamic link library, and performance data is acquired from the vGPU driver module, wherein the query instruction is used to query a use condition of the virtual machine on the vGPU, and the performance data is used to represent the use condition of the virtual machine on the vGPU; the communication connection with the vGPU driver module is disconnected, and the performance data is sent to the cloud platform.
[0005] Optionally, the communication connection with the vGPU driver module on the host computer through the query interface in the performance monitoring dynamic link library comprises: loading the performance monitoring dynamic link library through a cdll object in a ctypes protocol; and calling the query interface in the performance monitoring dynamic link library to establish the communication connection with the vGPU driver module.
[0006] Optionally, the performance data is queried from the vGPU driver module, comprising: defining a Class data object based on a data structure of the performance data; sending the Class data object to the query interface, so that the vGPU driver module fills the performance data into the Class data object; and retrieving the Class data object.
[0007] Optionally, the performance data is sent to the cloud platform, comprising: converting the performance data in a C language format into a python language data format, and packing the performance data; and sending the packed performance data to the cloud platform through a query script.
[0008] According to a second aspect, the present application provides a vGPU performance monitoring device applied to a vGPU performance monitoring module in a host computer, the vGPU performance monitoring module being based on python, a virtual machine being deployed on the host computer, the virtual machine using a vGPU virtually output by a GPU on the host computer through a GPU virtualization technology, the device comprising: a query unit configured to, when receiving a query instruction of a cloud platform, establish a communication connection with a vGPU driver module on the host computer through a query interface in a performance monitoring dynamic link library, and acquire performance data from the vGPU driver module, the query instruction being used to query a usage of the vGPU by the virtual machine, and the performance data being used to represent the usage of the vGPU by the virtual machine; and a sending unit configured to disconnect the communication connection with the vGPU driver module, and send the performance data to the cloud platform.
[0009] Optionally, the query unit comprises: a dynamic library calling unit configured to load the performance monitoring dynamic link library through a cdll object in a ctypes protocol; and a connection unit configured to call the query interface in the performance monitoring dynamic link library to establish the communication connection with the vGPU driver module.
[0010] Optionally, the query unit further comprises: a Class data object creating unit configured to define a Class data object based on a data structure of the performance data; an object sending unit configured to send the Class data object to the query interface, so that the vGPU driver module fills the performance data into the Class data object; and an object recycling unit configured to retrieve the Class data object.
[0011] Optionally, the sending unit comprises: a format conversion unit configured to convert the performance data in a C language format into a python language data format, and package the performance data; and an uploading unit configured to send the packaged performance data to the cloud platform through a query script.
[0012] According to a third aspect, an embodiment of the present application provides a vGPU performance monitoring device, comprising: a memory and a processor, which are in communication connection with each other, the memory stores computer instructions, and the processor executes the computer instructions to perform the method in the first aspect or any optional implementation manner of the first aspect.
[0013] According to a fourth aspect, an embodiment of the present application provides a computer readable storage medium, which stores computer instructions, and the computer instructions are used to make the computer perform the method in the first aspect or any optional implementation manner of the first aspect.
[0014] The technical scheme provided in the application has the following advantages.
[0015] The technical scheme provided in the application changes the vGPU performance monitoring module to be written in the python language, and when the vGPU performance data is queried, the vGPU performance monitoring module calls the query interface in the performance monitoring dynamic link library and accesses the vGPU driver module in the host computer. On the one hand, when the queried performance data changes, according to the characteristics of the python file, only the mapping relationship of the data object in the vGPU performance monitoring module needs to be adjusted, and the original python file can be directly replaced without the need for compilation. On the other hand, the way in which python calls the dynamic library is different from the C language main program, and when the data is queried, the connection with the vGPU driver module is established through the query interface, and the connection is disconnected after the query is completed. The dynamic link library does not need to be dependent on the virtual machine at startup, and does not need to be long-term running in the virtual machine memory. The vGPU performance monitoring module realizes the non-compilation upgrade, and does not need to restart the virtual machine, greatly improves the upgrade efficiency, and the single query time is short, the performance data is returned after real-time query, and there is no data time lag problem, and has good independence, timeliness and expansibility. BRIEF DESCRIPTION OF DRAWINGS
[0016] The features and advantages of the present application will be more clearly understood through reference to the following drawings, which are presented as exemplary and should not be construed as limiting the application, in which:
[0017] Figure 1 A step schematic diagram of a vGPU performance monitoring method in an embodiment of the application is shown;
[0018] Figure 2 An architecture diagram of a vGPU performance monitoring method in an embodiment of the application is shown;
[0019] Figure 3 A structure schematic diagram of a vGPU performance monitoring device in an embodiment of the application is shown;
[0020] Figure 4 A structure schematic diagram of a vGPU performance monitoring device in an embodiment of the application is shown. DETAILED DESCRIPTION
[0021] In order to make the purpose, technical scheme and advantages of the embodiments of the present application more clear, the technical scheme in the embodiments of the present application will be described clearly and completely below with reference to the drawings in the embodiments of the present application. Obviously, the described embodiments are part of the embodiments of the present application, rather than all the embodiments of the present application. Based on the embodiments in the present application, all other embodiments obtained by those skilled in the art without creative labor fall within the scope of protection of the present application.
[0022] Referring to Figure 1 and Figure 2 In one embodiment, a vGPU performance monitoring method is applied to a vGPU performance monitoring module in a host computer, the vGPU performance monitoring module is written based on python, a virtual machine is deployed on the host computer, and the virtual machine uses a vGPU virtually output by a GPU on the host computer through GPU virtualization technology, and the method specifically comprises the following steps:
[0023] Step S101: When a query instruction of a cloud platform is received, a communication connection is established with a vGPU driver module through a query interface in a performance monitoring dynamic link library, and performance data is obtained from the vGPU driver module, wherein the query instruction is used to query the use of the vGPU by the virtual machine, and the performance data is used to represent the use of the vGPU by the virtual machine.
[0024] Step S102: The communication connection with the vGPU driver module is disconnected, and the performance data is sent to the cloud platform.
[0025] Specifically, in the embodiment, the vGPU performance monitoring module on the host computer is written based on python, and the vGPU performance monitoring module written by using a compiled language such as C / C++ in the prior art needs to be converted from a source file into a machine language used by a computer, and after being linked by a linker, a binary executable file is formed, and when the program is run, the binary program is loaded from a hard disk into a memory for running. However, for python, the python source code does not need to be compiled into a binary code, and the program can be directly run from the source code. When the python file program is run, the python interpreter converts the source code into bytecode, and then the python interpreter executes the bytecode. Therefore, when the performance data to be extracted changes, only the corresponding data object mapping relationship in the python file needs to be modified, and the original python file is replaced, without the need for compilation. For example, in a performance data class, the performance data currently extracted is the overall video memory usage rate and the encoding and decoding usage rate, and now it is intended to obtain the video memory usage rate of a program A in a virtual machine using a vGPU, and then a data object to be mapped is directly added to the Class performance data, and a code example is as follows:
[0026] Class performance data
[0027] def__init__(A, A program video memory usage rate):
[0028] A.A program video memory usage rate = A program video memory usage rate
[0029] Then, the original file is replaced with the modified file. In addition, the vGPU performance monitoring module based on Python can call the performance monitoring dynamic link library when the performance monitoring dynamic link library is used, and establish a communication connection with the vGPU driver module. When the performance monitoring dynamic link library is not used, the vGPU performance monitoring module does not need to be called, so as to disconnect the communication connection with the vGPU driver module. Based on the characteristics of Python, the calling mechanism of the vGPU performance monitoring module does not need to create a dependency relationship for the dynamic link library file in advance in the virtual machine when the dynamic link library is called. Therefore, when the Python file is changed, the virtual machine does not need to be restarted, so as to realize continuous business upgrading. In addition, the short connection query mode has short single query time, and the performance data is returned after real-time query, so that there is no data time lag problem, and the short connection query mode has good independence, timeliness and expansibility.
[0030] Specifically, in an embodiment, the step S101 specifically includes the following steps.
[0031] Step one: load the performance monitoring dynamic link library through the cdll object in the ctypes protocol.
[0032] Step two: call the query interface in the performance monitoring dynamic link library to establish a communication connection with the vGPU driver module.
[0033] Specifically, ctypes is an external function library of Python, which provides data types compatible with C language, and allows functions in DLL or shared library to be called. The module can be encapsulated in pure Python form, ctypes exports the cdll object, and by operating the attributes of the cdll object, the external C language dynamic link library can be loaded. Then, the query interface in the dynamic link library is called to establish a communication connection with the vGPU driver module. When no query is performed, the vGPU performance monitoring module is disconnected from the query interface, so as to disconnect the connection with the vGPU driver module. The short connection query mode of performance data query is realized, and the timeliness of query data is improved.
[0034] Specifically, in an embodiment, under the condition of using the GPU of the NVIDIA architecture, the performance monitoring dynamic link library can use the libnvidia_ml.so dynamic library file provided by the NVIDIA manufacturer, the query interface is a nvml (nvidia management library) function set built in libnvidia_ml.so, and the connection with the driver module GRID of the vGPU is established to extract the related performance data from the driver module of the vGPU. Under the NVIDIA architecture, no additional dynamic link library needs to be developed, and the development efficiency of the vGPU performance monitoring module is improved.
[0035] Specifically, in an embodiment, the step S102 specifically includes the following steps.
[0036] Step three: define the Class data object based on the data structure of performance data.
[0037] Step four: send the Class data object to the query interface to enable the vGPU driver module to fill the performance data into the Class data object.
[0038] Step five: retrieve the Class data object.
[0039] Specifically, in the present embodiment, when querying data, first, the Class data object in the Class class is defined according to the preset data structure of performance data. For example:
[0040] Class performance data
[0041] def__init__(A,A program video memory usage):
[0042] A.A program video memory usage = A program video memory usage
[0043] After that, the object is sent to the query interface to enable the vGPU driver module to fill the performance data into the Class data object, and after the data filling is completed, the Class data object is retrieved. Through the above steps, the required collected data is retrieved in the form of a data object at one time, and data stream transmission is not performed. The vGPU performance monitoring module process avoids long-time occupation of data channel resources, avoids data loss, and thus improves the working efficiency of the host computer and ensures the reliability of data transmission.
[0044] Specifically, in an embodiment, the above step S103 specifically includes the following steps:
[0045] Step six: convert the performance data in C language format into python language data format, and package the performance data.
[0046] Step seven: send the packaged performance data to the cloud platform through the query script.
[0047] Specifically, on the one hand, the data type extracted by the C language dynamic link library needs to be converted into the python language type, so that the vGPU performance monitoring module written in python can recognize and use it, for example, the data type double in C language corresponds to float in python. On the other hand, the performance data table extracted by the dynamic library may not be in the format required by the cloud platform, so the vGPU performance monitoring module converts the table format of the collected performance data, packages the performance data, and sends the performance data to the cloud platform through the preset query script, so that the cloud platform can directly recognize and use the data without other conversion operations.
[0048] Through the above steps, the technical scheme provided by the application changes the vGPU performance monitoring module to be generated by using the python language, when querying the vGPU performance data, the vGPU performance monitoring module calls the query interface in the performance monitoring dynamic link library, and accesses the driving module of the vGPU on the host computer. On the one hand, when the queried performance data changes, only the mapping relationship of the data object in the vGPU performance monitoring module needs to be adjusted, and the original python file is directly replaced, without the need for compilation. On the other hand, the way of calling the dynamic library by python is different from the C language main program, and when the data needs to be queried, the communication connection is established with the vGPU driving module through the query interface, and the connection is disconnected after the query is completed. The dynamic link library does not need to be dependent on the virtual machine when starting, and does not need to be long-term running in the virtual machine memory. The vGPU performance monitoring module realizes the non-compilation upgrade, and does not need to restart the virtual machine, greatly improves the upgrading efficiency, and the single query time is short, the performance data is returned after real-time query, and there is no data time lag problem, with good independence, timeliness and expansibility.
[0049] As shown in Figure 3 The embodiment also provides a vGPU performance monitoring device, which is applied to a vGPU performance monitoring module in a host computer, the vGPU performance monitoring module is based on python, a virtual machine is deployed on the host computer, and the virtual machine uses a vGPU virtually output by a GPU on the host computer through a GPU virtualization technology. The device comprises:
[0050] A query unit 101 is configured to, when receiving a query instruction of a cloud platform, establish a communication connection with a vGPU driving module on a host computer through a query interface in a performance monitoring dynamic link library, and acquire performance data from the vGPU driving module, the query instruction is used to query the use of the vGPU by the virtual machine, and the performance data is used to represent the use of the vGPU by the virtual machine. For details, refer to the related description of step S101 in the above method embodiment, which will not be repeated here.
[0051] A sending unit 102 is configured to disconnect the communication connection with the vGPU driving module, and send the performance data to the cloud platform. For details, refer to the related description of step S102 in the above method embodiment, which will not be repeated here.
[0052] Specifically, in an embodiment, the above query unit 101 comprises:
[0053] A dynamic library calling unit is configured to load the performance monitoring dynamic link library through a cdll object in the ctypes protocol. For details, refer to the related description of step one in the above method embodiment, which will not be repeated here.
[0054] The connection unit is configured to call a query interface in the performance monitoring dynamic link library to establish a communication connection with the vGPU driver module.
[0055] Specifically, in an embodiment, the query unit 101 further includes:
[0056] The object creation unit is configured to declare a Class data object based on a data structure of the performance data. Details are described in the step three of the method embodiment above, and will not be repeated here.
[0057] The object sending unit is configured to send the Class data object to the query interface, so that the vGPU driver module fills the performance data into the Class data object. Details are described in the step four of the method embodiment above, and will not be repeated here.
[0058] The object recycling unit is configured to retrieve the Class data object. Details are described in the step five of the method embodiment above, and will not be repeated here.
[0059] Specifically, in an embodiment, the sending unit 102 includes:
[0060] The format conversion unit is configured to convert the performance data in C language format into python language data format, and pack the performance data. Details are described in the step six of the method embodiment above, and will not be repeated here.
[0061] The uploading unit is configured to send the packed performance data to the cloud platform through the query script. Details are described in the step seven of the method embodiment above, and will not be repeated here.
[0062] The vGPU performance monitoring device provided by the embodiment of the present application is used to execute the vGPU performance monitoring method provided by the above-mentioned embodiment, and the implementation manner and principle are the same, and the details are described in the related description of the method embodiment above, and will not be repeated here.
[0063] Through the cooperation of the above various components, the technical scheme provided by the embodiment of the application changes the vGPU performance monitoring module to be generated by using the python language, and when the vGPU performance data is queried, the vGPU performance monitoring module calls the query interface in the performance monitoring dynamic link library and accesses the drive module of the vGPU in the host computer. On the one hand, when the queried performance data changes, only the mapping relationship of the data object in the vGPU performance monitoring module needs to be adjusted, and the original python file is directly replaced, without the need for compilation. On the other hand, the way in which python calls the dynamic library is different from the C language main program, and when the data is queried, the connection with the vGPU drive module is established through the query interface, and the connection is disconnected after the query is completed. The dynamic link library does not need to be dependent on the virtual machine at startup, and does not need to be long-term running in the virtual machine memory. The vGPU performance monitoring module realizes the non-compilation upgrade, and does not need to restart the virtual machine, greatly improves the upgrade efficiency, and the single query time is short, the performance data is returned after real-time query, and there is no data time lag problem, and has good independence, timeliness and expansibility.
[0064] Figure 4 A vGPU performance monitoring device of an embodiment of the application is shown, which comprises a processor 901 and a memory 902, which can be connected through a bus or other means, Figure 4 For example, the connection through the bus is taken as an example.
[0065] The processor 901 can be a central processing unit (CPU). The processor 901 can also be other general-purpose processors, digital signal processors (DSP), application specific integrated circuits (ASIC), field programmable gate arrays (FPGA) or other programmable logic devices, discrete gates or transistor logic devices, discrete hardware components, etc. chips, or combinations of the above various chips.
[0066] The memory 902 is a non-transitory computer readable storage medium, which can be used to store non-transitory software programs, non-transitory computer executable programs and modules, such as the program instructions / modules corresponding to the methods in the above method embodiments. The processor 901 performs various functional applications and data processing of the processor by running the non-transitory software programs, instructions and modules stored in the memory 902, that is, implements the methods in the above method embodiments.
[0067] The memory 902 can include a program storage area and a data storage area, where the program storage area can store an operating system, application programs required by at least one function, and the like; and the data storage area can store data created by the processor 901 and the like. In addition, the memory 902 can include a high-speed random access memory, and can also include a non-transitory memory, such as at least one disk memory device, a flash memory device, or other non-transitory solid-state memory device. In some embodiments, the memory 902 can optionally include a memory disposed remotely from the processor 901, which can be connected to the processor 901 through a network. Examples of the above network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0068] One or more modules are stored in the memory 902, which, when executed by the processor 901, perform the methods in the above method embodiments.
[0069] The above vGPU performance monitoring device specific details can be understood in correspondence with the relevant description and effects of the corresponding description in the above method embodiments, which will not be described here.
[0070] Those skilled in the art can understand that all or part of the processes in the above embodiments can be completed by a computer program instructing related hardware, and the implemented program can be stored in a computer readable storage medium. When the program is executed, it can include the processes of the above embodiments. The storage medium can be a magnetic disk, an optical disk, a read-only memory (ROM), a random access memory (RAM), a flash memory, a hard disk drive (HDD) or a solid-state drive (SSD), etc. The storage medium can also include a combination of the above types of memories.
[0071] Although the embodiments of the present application are described in conjunction with the accompanying drawings, various modifications and changes can be made by those skilled in the art without departing from the spirit and scope of the present application, and such modifications and changes fall within the scope defined by the appended claims.
Claims
1. A method for monitoring performance of a vGPU, the method comprising: The vGPU performance monitoring module applied to a host computer is written based on python, a virtual machine is deployed on the host computer, the virtual machine uses a vGPU virtually output by a GPU on the host computer through GPU virtualization technology, and the method comprises the following steps: When receiving a query instruction of a cloud platform, a communication connection is established with a vGPU driver module on the host computer through a query interface in a performance monitoring dynamic link library, and performance data is obtained from the vGPU driver module, the query instruction is used to query the use of the vGPU by the virtual machine, and the performance data is used to represent the use of the vGPU by the virtual machine; the communication connection established with the vGPU driver module through the query interface in the performance monitoring dynamic link library comprises the following steps: the performance monitoring dynamic link library is loaded through a cdll object in a ctypes protocol; the communication connection is established with the vGPU driver module through the query interface in the performance monitoring dynamic link library; the performance data is obtained from the vGPU driver module, which comprises the following steps: a Class data object is defined based on the data structure of the performance data; the Class data object is sent to the query interface, so that the vGPU driver module fills the performance data into the Class data object; the Class data object is retrieved; The communication connection with the vGPU driver module is disconnected, and the performance data is sent to the cloud platform.
2. The method of claim 1, wherein, The performance data is sent to the cloud platform, which comprises the following steps: The performance data in C language format is converted into python language data format, and the performance data is packaged; The packaged performance data is sent to the cloud platform through a query script.
3. A vGPU performance monitoring apparatus, characterized by, The vGPU performance monitoring module applied to a host computer is written based on python, a virtual machine is deployed on the host computer, the virtual machine uses a vGPU virtually output by a GPU on the host computer through GPU virtualization technology, and the device comprises the following steps: The query unit is configured to, when receiving a query instruction of a cloud platform, establish a communication connection with a vGPU drive module on a host through a query interface in a performance monitoring dynamic link library, and acquire performance data from the vGPU drive module, wherein the query instruction is used to query usage of the vGPU by the virtual machine, and the performance data is used to represent the usage of the vGPU by the virtual machine. The sending unit is configured to disconnect the communication connection with the vGPU drive module, and send the performance data to the cloud platform.
4. The apparatus of claim 3, wherein, The query unit comprises: The calling dynamic library unit is configured to load the performance monitoring dynamic link library through a cdll object in a ctypes protocol. The connection unit is configured to call the query interface in the performance monitoring dynamic link library to establish the communication connection with the vGPU drive module.
5. The apparatus of claim 3, wherein, The query unit further comprises: The object creation unit is configured to define a Class data object based on a data structure of the performance data. The object sending unit is configured to send the Class data object to the query interface, so that the vGPU drive module fills the performance data into the Class data object. The object recycling unit is configured to retrieve the Class data object.
6. The apparatus of claim 3, wherein, The sending unit comprises: The format conversion unit is configured to convert the performance data in a C language format into a python language data format, and pack the performance data. The uploading unit is configured to send the packed performance data to the cloud platform through a query script.
7. A vGPU performance monitoring device, comprising: The memory and the processor are communicatively connected, and the memory stores computer instructions. The computer readable storage medium stores computer instructions, which are used to make the computer execute the method of any one of claims 1-2.
8. A computer-readable storage medium, characterized in that,
Citation Information
Patent Citations
Resource scheduling system based on immediate feedback of application effect under display card virtualization
CN102890643A
Changing between virtual machines on a graphics processing unit
CN104025050A