GPU control method, device, electronic device, and computer-readable storage medium
By obtaining and analyzing the access pointer data of the GPU, automatically detecting GPU exceptions, and automatically eliminating them using preset methods, the problem of reduced processing efficiency caused by GPU working exceptions is solved, and fast response and efficient operation is achieved.
Patent Information
- Application Number
- CN202211567093.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-12-07
- Publication Date
- 2025-04-29
- Estimated Expiration
- 2042-12-07
AI Technical Summary
During the use of GPU, sometimes work abnormalities occur, such as the GPU cannot respond or stutter, resulting in reduced task process processing efficiency or inability to process. The existing technology usually requires manual intervention to recover, with a long response time and high professional technology requirements, which reduces the working efficiency of the GPU.
By obtaining the GPU's access pointer data, including reading pointer data and writing pointer data, we can determine whether the GPU has an exception, and use a preset method to eliminate the exception. The specific steps include obtaining the current read pointer and write pointer address and its change value and time, calculating the time difference to judge the exception, and using the GPU management tool or operating system interface to reset or unload the overload to eliminate the exception when an exception is detected.
It realizes automatic detection and automatic elimination of GPU exceptions, improves the response speed to GPU exceptions, reduces dependence on professional and technical personnel, and improves the working efficiency of the GPU.
Smart Images

Figure CN116010138B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of electronic information, and in particular to a GPU control method, device, electronic device and computer-readable storage medium. Background Art
[0002] Graphics Processing Unit (GPU), also known as display core, visual processor, display chip, is a microprocessor that specializes in image and graphics related computing on personal computers, workstations, game consoles and some mobile devices (such as tablets, smart phones, etc.). GPU reduces the graphics card's dependence on the CPU (Central Processing Unit) and performs some of the original CPU's work. With the rapid development of GPU (Graphics Processing Unit) technology, GPU has been promoted and used in more and more application fields, such as machine learning and artificial intelligence applications.
[0003] However, during the use of the GPU, work anomalies may occasionally occur, such as GPU failure to respond, GPU freezing, etc., which will reduce the efficiency of task process processing or even make it impossible to process. After the anomaly occurs, manual intervention is usually used in the existing technology to recover it. However, the response time of manual recovery is long and the professional and technical requirements of the processing personnel are also high, which greatly reduces the work efficiency of the GPU. Summary of the invention
[0004] The object of the present invention is to provide a GPU control method, device, electronic device and computer-readable storage medium, which can automatically detect anomalies that occur during the operation of the GPU and automatically eliminate the anomalies.
[0005] In the first aspect, the present invention provides a GPU control method, which is applied to a GPU control device, including: obtaining access pointer data of a GPU, wherein the access pointer data includes read pointer data and write pointer data of the GPU; judging whether the GPU is abnormal according to the access pointer data; and eliminating the abnormality using a preset method. Wherein, obtaining the access pointer data of the GPU includes: reading the current read pointer address from a read pointer register, reading the last change value of the currently stored read pointer address, and the last change time of the currently stored read pointer address from a preset register, and using the current read pointer address, the last change value of the currently stored read pointer address, and the last change time of the currently stored read pointer address as the read pointer data; writing the current write pointer address from a write pointer register, reading the last change value of the currently stored write pointer address, and the last change time of the currently stored write pointer address from a preset register, and using the current write pointer address, the last change value of the currently stored write pointer address, and the last change time of the currently stored write pointer address as the write pointer data.
[0006] Wherein, judging whether the GPU is abnormal according to the access pointer data includes: obtaining the last change value of the actual read pointer address and the actual last change time of the read pointer address according to the access pointer data; obtaining the last change value of the actual write pointer address and the actual last change time of the write pointer address according to the access pointer data; judging whether the GPU is abnormal according to the last change value of the actual read pointer address, the actual last change time of the read pointer address, the actual last change value of the write pointer address, and the actual last change time of the write pointer address.
[0007] Among them, obtaining the last change value of the actual read pointer address and the last change time of the actual read pointer address according to the access pointer data includes: in response to the current read pointer address being the same as the current write pointer address, using the current read pointer address as the last change value of the actual read pointer address, and using the current time as the last change time of the actual read pointer address.
[0008] Among them, the method of obtaining the last change value of the actual read pointer address and the last change time of the actual read pointer address according to the access pointer data also includes: in response to the current read pointer address being different from the current write pointer address, determining whether the current read pointer address is the same as the last change value of the currently stored read pointer address; if the current read pointer address is the same as the last change value of the currently stored read pointer address, using the last change value of the currently stored read pointer address as the last change value of the actual read pointer address, and using the last change time of the currently stored read pointer address as the last change time of the actual read pointer address; if the current read pointer address is different from the last change value of the currently stored read pointer address, using the current read pointer address as the last change value of the actual read pointer address, and using the current time as the last change time of the actual read pointer address.
[0009] Among them, the method of obtaining the last change value of the actual write pointer address and the last change time of the actual write pointer address according to the access pointer data includes: in response to the current read pointer address being the same as the current write pointer address, using the current write pointer address as the last change value of the actual write pointer address, and using the current time as the last change time of the actual write pointer address.
[0010] Among them, the method of obtaining the last change value of the actual write pointer address and the last change time of the actual write pointer address according to the access pointer data also includes: in response to the current read pointer address being different from the current write pointer address, determining whether the current write pointer address is the same as the last change value of the currently stored write pointer address; if the current write pointer address is the same as the last change value of the currently stored write pointer address, using the last change value of the currently stored write pointer address as the last change value of the actual write pointer address, and using the last change time of the currently stored write pointer address as the last change time of the actual write pointer address; if the current write pointer address is different from the last change value of the currently stored write pointer address, using the current write pointer address as the last change value of the actual write pointer address, and using the current time as the last change time of the actual write pointer address.
[0011] Wherein, judging whether the GPU is abnormal according to the last change value of the actual read pointer address, the last change time of the actual read pointer address, the last change value of the actual write pointer address, and the last change time of the actual write pointer address includes: calculating the time difference between the last change time of the actual read pointer address and the last change time of the actual write pointer address; if the last change value of the actual read pointer address is different from the last change value of the actual write pointer address, and the time difference is greater than or equal to a preset threshold, judging that the GPU is abnormal; if the last change value of the actual read pointer address is the same as the last change value of the actual write pointer address, or the time difference is less than the preset threshold, judging that the GPU is not abnormal.
[0012] The method further includes: obtaining cache usage of the GPU, and judging whether the GPU is abnormal according to the cache usage. Using the cache usage of the GPU to judge whether the GPU is abnormal can reduce the occurrence of missed judgments of GPU abnormalities and improve the accuracy of GPU abnormality detection.
[0013] The method further includes: obtaining a target task process, the target task process being a task process that has finished running on a CPU connected to the GPU; obtaining a running result of the target task process on the GPU, and judging whether the GPU is abnormal according to the running result. The additional use of the running result of the target task process on the GPU to judge whether the GPU is abnormal can reduce the occurrence of missed judgments of GPU abnormalities and improve the accuracy of detecting GPU abnormalities.
[0014] Wherein, a preset detection program is run on the GPU to obtain a return result of the preset detection program; and whether the GPU is abnormal is determined according to the return result. The return result of the preset detection program is additionally used to determine whether the GPU is abnormal, which can reduce the occurrence of missed judgments of GPU abnormalities and improve the detection accuracy of GPU abnormalities.
[0015] Wherein, eliminating the abnormality by using a preset method includes: resetting the GPU by using a preset GPU management tool to eliminate the abnormality.
[0016] Wherein, eliminating the exception by using a preset method includes: calling a preset operating system interface to eliminate the exception.
[0017] The calling of a preset operating system interface to eliminate the exception includes: calling a first preset operating system interface to unload the GPU; and calling a second preset operating system interface to reload the GPU to eliminate the exception.
[0018] Wherein, eliminating the exception by using a preset method includes: uninstalling a board driver of the GPU and then reloading the board driver to eliminate the exception.
[0019] In a second aspect, an embodiment of the present invention provides a GPU control device, comprising: a data acquisition module, the data acquisition module is used to acquire access pointer data of the GPU, the access pointer data includes read pointer data and write pointer data of the GPU; a data processing module, the data processing module is used to determine whether an abnormality occurs in the GPU based on the access pointer data; and an exception handling module, the exception handling module is used to eliminate the exception using a preset method when an abnormality occurs in the GPU.
[0020] In a third aspect, an embodiment of the present invention provides an electronic device, comprising: at least one processor; and a memory and a GPU communicatively connected to the at least one processor; wherein the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the aforementioned GPU control method to control the GPU.
[0021] In a fourth aspect, an embodiment of the present invention provides a computer-readable storage medium storing a computer program, wherein the computer program is executed by a processor to implement the aforementioned GPU control method.
[0022] In the GPU control method, system, electronic device and computer-readable storage medium provided in the embodiments of the present invention, the access pointer data of the GPU is automatically obtained. Since the access pointer data includes the read pointer data and write pointer data of the GPU, the read pointer data and the write pointer data can represent the execution status of the task instructions currently issued by the GPU to the CPU, so that it can be judged whether the GPU has an abnormality based on the access pointer data. When the GPU has an abnormality, the abnormality is responded to and a preset method is used to eliminate the abnormality, thereby achieving the effect of automatically detecting GPU abnormalities and automatically eliminating the abnormalities when the abnormalities are detected, improving the response speed to GPU abnormalities without the need for professional technicians to perform special processing, thereby improving the work efficiency of the GPU. BRIEF DESCRIPTION OF THE DRAWINGS
[0023] In order to more clearly illustrate the technical solutions of the embodiments of the present invention, the drawings required for use in the embodiments are briefly introduced below. It should be understood that the following drawings only show certain embodiments of the present invention and therefore should not be regarded as limiting the scope. For ordinary technicians in this field, other related drawings can be obtained based on these drawings without creative work.
[0024] Figure 1A flowchart of a GPU control method provided in Embodiment 1 of the present invention;
[0025] Figure 2 A schematic diagram of a flow chart of determining whether an abnormality occurs in a GPU according to access pointer data in a GPU control method provided in Embodiment 1 of the present invention;
[0026] Figure 3 A schematic diagram of a flow chart of obtaining the actual last changed value of the read pointer address and the actual last changed time of the read pointer address in the GPU control method provided in the first embodiment of the present invention;
[0027] Figure 4 A schematic diagram of a flow chart of obtaining the actual last change value of the write pointer address and the actual last change time of the write pointer address in the GPU control method provided in the first embodiment of the present invention;
[0028] Figure 5 A flowchart of a GPU control method provided in Embodiment 2 of the present invention;
[0029] Figure 6 A flowchart of a GPU control method provided in Embodiment 3 of the present invention;
[0030] Figure 7 A flowchart of a GPU control method provided in Embodiment 4 of the present invention;
[0031] Figure 8 A schematic diagram of the structure of a GPU control device provided in Embodiment 5 of the present invention;
[0032] Fig. 9 This is a schematic diagram of the structure of an electronic device provided in Embodiment 6 of the present invention. DETAILED DESCRIPTION
[0033] In order to make the purpose, technical solutions and advantages of the embodiments of the present invention clearer, the technical solutions in the embodiments of the present invention will be clearly and completely described below in conjunction with the drawings in the embodiments of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Generally, the components of the embodiments of the present invention described and shown in the drawings here can be arranged and designed in various different configurations.
[0034] Therefore, the following detailed description of the embodiments of the present invention provided in the accompanying drawings is not intended to limit the scope of the invention claimed for protection, but merely represents selected embodiments of the present invention. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0035] It should be noted that similar reference numerals and letters denote similar items in the following drawings, and therefore, once an item is defined in one drawing, further definition and explanation thereof is not required in subsequent drawings.
[0036] In the description of the present invention, it should be noted that if the terms "upper", "lower", "inside", "outside", etc. appear to indicate an orientation or position relationship, they are based on the orientation or position relationship shown in the accompanying drawings, or are the orientation or position relationship in which the product of the invention is usually placed when used. They are only for the convenience of describing the present invention and simplifying the description, and do not indicate or imply that the device or element referred to must have a specific orientation, be constructed and operated in a specific orientation, and therefore cannot be understood as a limitation on the present invention.
[0037] In addition, the terms “first”, “second”, etc., if used, are merely used to distinguish between the descriptions and should not be understood as indicating or implying relative importance.
[0038] It should be noted that, in the absence of conflict, the features in the embodiments of the present invention may be combined with each other.
[0039] Embodiment 1 of the present invention provides a GPU control method, such as Figure 1 As shown, the following steps are included:
[0040] Step S101: Obtain access pointer data of the GPU.
[0041] In an embodiment of the present invention, the access pointer data includes the read pointer data and write pointer data of the GPU. Specifically, the CPU controls the operation of the GPU by sending commands to the GPU. The commands sent by the CPU to the GPU use the buffer on the GPU as the carrier of the commands, that is, the CPU writes commands to the buffer, and then the GPU reads commands from the buffer. Among them, the write pointer is a pointer indicating the command write position when the CPU writes commands to the buffer, and the read pointer is a pointer indicating the command read position when the GPU reads commands from the buffer.
[0042] When the CPU writes a command to the cache area, it first obtains the address currently pointed to by the write pointer in the cache area. In some embodiments of the present invention, a write pointer register area can be set to record and store the address currently pointed to by the write pointer, that is, the current write pointer address. The CPU can directly obtain the address currently pointed to by the write pointer from the write pointer register area. The address currently pointed to by the write pointer is the location where the command has been written in the current cache area. According to the address currently pointed to by the write pointer, it is judged whether there is enough cache space in the cache area to store the command currently needed to be written. If there is enough cache space, the command is written to the cache area starting from the address currently pointed to by the write pointer. If there is not enough cache space, it is written to another cache area. After the command is written, the write pointer address of the cache area will be updated in the write pointer register area. The current write pointer address read by the CPU from the write pointer register next time is the updated write pointer address.
[0043] When the GPU reads a command from the cache area, it first obtains the address currently pointed to by the read pointer in the cache area. In some embodiments of the present invention, a read pointer register can also be set to record and store the address currently pointed to by the read pointer in the cache area, that is, the current read pointer address. The GPU can directly obtain the address currently pointed to by the read pointer from the read pointer register. The address currently pointed to by the read pointer is the position currently read by the GPU in the cache area. When the GPU reads the command, it directly starts reading from the address currently pointed to by the read pointer. After the GPU command is read, the read pointer address of the cache area will be updated in the read pointer register area. The current write pointer address read by the GPU from the write pointer register next time is the read pointer address after this update.
[0044] In different embodiments of the present invention, the read pointer register and the write pointer register can be the same register or different register areas, as long as they can record the read pointer data and the write pointer data respectively. Using a single register as both the read pointer register and the write pointer register can simplify the structure, while using different registers as the read pointer register and the write pointer register can avoid mutual interference between the read pointer data and the write pointer data, and can be flexibly applied according to actual needs.
[0045] When the GPU is working normally, during system initialization, the read pointer and write pointer of the cache area are both located at the starting position of the cache area, and the cache area is empty. When the CPU sends a command to the GPU, the CPU first writes the command data to the cache area. After the command data is written, the cache area write pointer moves to the next free command position, and the cache area write pointer address is recorded in the write pointer register; at this time, the GPU detects that the write pointer address in the write pointer register has changed, and the read pointer address is inconsistent with the write pointer address. It will read the relevant command of the cache area, read the length of the command, and move the read pointer to the next command position, record the read pointer address of the cache area in the read pointer register, and then execute the relevant command read from the cache area; after the command is executed, continue to detect whether the write pointer address in the write pointer register is consistent with the read pointer address in the read pointer register. If they are inconsistent, continue to read until all command processing is completed, then the read pointer address is consistent with the write pointer address, and then continue to monitor whether the write pointer address in the write pointer register has changed.
[0046] In an embodiment of the present invention, the last change value of the read pointer address, the last change time of the read pointer address, the last change value of the write pointer address, and the last change time of the write pointer address are additionally recorded in a preset register. Each time a change in the write pointer address in the write pointer register is detected, the write pointer address after the change is recorded as the last change value of the write pointer address, and the time when the write pointer address changes is recorded as the last change time of the write pointer address. Each time the read pointer changes, the read pointer address after the change is recorded as the last change value of the read pointer address, and the time when the read pointer address changes is recorded as the last change time of the read pointer address. It can be understood that the preset register can be the same register as the aforementioned read pointer storage area and / or write pointer register, or it can be an additional separate register, and can be flexibly set according to actual needs.
[0047] In this embodiment, when judging whether the GPU is working normally, the current read pointer address of the read pointer in the cache is obtained from the read pointer register, the last change value of the currently stored read pointer address, and the last change time of the read pointer address are obtained from the preset register as read pointer data; the current write pointer address of the write pointer in the cache is obtained from the write pointer register, the last change value of the currently stored write pointer address is obtained from the pre-register, and the last change time of the write pointer address are obtained as write pointer data.
[0048] Step S102: determining whether an abnormality occurs in the GPU according to the access pointer data.
[0049] like Figure 2 As shown, the specific steps are as follows.
[0050] Step S201: Obtain the actual last change value of the read pointer address and the actual last change time of the read pointer address according to the access pointer data.
[0051] like Figure 3 As shown, the specific steps are as follows.
[0052] Step S301: Determine whether the current read pointer address is the same as the current write pointer address. If the current read pointer address is the same as the current write pointer address, execute step S302; if the current read pointer address is not the same as the current write pointer address, execute step S303.
[0053] Step S302: Use the current read pointer address as the actual last changed value of the read pointer address, and use the current time as the actual last changed time of the read pointer address.
[0054] Step S303: Determine whether the current read pointer address is the same as the last changed value of the currently stored read pointer address. If the current read pointer address is the same as the last changed value of the currently stored read pointer address, execute step S304; if the current read pointer address is not the same as the last changed value of the currently stored read pointer address, execute step S305.
[0055] Step S304: using the last change value of the currently stored read pointer address as the actual last change value of the read pointer address, and using the last change time of the currently stored read pointer address as the actual last change time of the read pointer address.
[0056] Step S305: Use the current read pointer address as the actual last changed value of the read pointer address, and use the current time as the actual last changed time of the read pointer address.
[0057] Step S202: Obtain the actual last change value of the write pointer address and the actual last change time of the write pointer address according to the access pointer data.
[0058] like Figure 4 As shown, the specific steps are as follows.
[0059] Step S401: Determine whether the current read pointer address is the same as the current write pointer address. If the current read pointer address is the same as the current write pointer address, execute step S402; if the current read pointer address is not the same as the current write pointer address, execute step S404.
[0060] Step S402: Use the current write pointer address as the actual last change value of the write pointer address, and use the current time as the actual last change time of the write pointer address.
[0061] Step S403: Determine whether the current write pointer address is the same as the last change value of the currently stored write pointer address. If the current write pointer address is the same as the last change value of the currently stored write pointer address, execute step S404; if the current write pointer address is not the same as the last change value of the currently stored write pointer address, execute step S405.
[0062] Step S404: using the last change value of the currently stored write pointer address as the actual last change value of the write pointer address, and using the last change time of the currently stored write pointer address as the actual last change time of the write pointer address.
[0063] Step S405: Use the current write pointer address as the actual last change value of the write pointer address, and use the current time as the actual last change time of the write pointer address.
[0064] Step S203: judging whether the GPU is abnormal according to the actual last changed value of the read pointer address, the actual last changed time of the read pointer address, the actual last changed value of the write pointer address, and the actual last changed time of the write pointer address.
[0065] In this step, the time difference between the actual last change time of the read pointer address and the actual last change time of the write pointer address is calculated; if the actual last change value of the read pointer address is different from the actual last change value of the write pointer address, and the time difference is greater than or equal to the preset threshold, it is determined that the GPU has an abnormality; if the actual last change value of the read pointer address is the same as the actual last change value of the write pointer address, or the time difference is less than the preset threshold, it is determined that the GPU has no abnormality.
[0066] Step S103: Eliminate the abnormality using a preset method.
[0067] Specifically, in one embodiment of the present invention, a GPU management tool can be preset. When an abnormality is detected in the GPU, the preset GPU management tool is run to reset the GPU, thereby eliminating the abnormality in the GPU and allowing the GPU to resume normal operation. In actual application, different GPU management tools can be used to reset the GPU for different types and brands of GPUs. For example, there is an ixsmi command in the software stack of some types of GPUs. The ixsmi command can reset the GPU. For such GPUs, the reset of the GPU can be completed by calling the ixsmi command through the preset GPU management tool. There is an nvdia-smi command in the software stack of other types of GPUs. The nvdia-smi command can also reset the GPU. For such GPUs, the reset of the GPU can also be completed by calling the nvdia-smi command through the preset GPU management tool. Regardless of calling the ixsmi command or the nvdia-smi command to reset the GPU, the basic principle is to call the GPU driver through a preset GPU management tool, and reset the GPU through the driver. Therefore, in other embodiments of the present invention, for an actual GPU, any other command can be used to call the GPU driver, and reset the GPU through the driver. The specific settings can be flexibly made according to the actual type of GPU.
[0068] It can be understood that the aforementioned resetting of the GPU through the preset GPU management tool to eliminate the GPU abnormality and restore the GPU to normal operation is only a specific implementation method for eliminating the GPU abnormality in some embodiments of the present invention. In other embodiments of the present invention, other methods may also be used, such as eliminating the abnormality by calling a preset operating system interface, restarting the system, or uninstalling the GPU board driver. These methods can be flexibly used according to actual needs.
[0069] Wherein, eliminating the abnormality by calling the preset operating system interface is specifically: first calling the first preset operating system interface to unload the GPU, and then calling the second preset operating system interface to reload the GPU, and eliminating the abnormality in the GPU through the unloading and loading process of the GPU. Wherein, taking the Linux system as an example, the first preset operating system interface can be, for example, the operating system pci device address remove node, and the unloading of the GPU can be completed by using the "echo 1> / sys / bus / pci / devices / pci device address / remove" command at this node; the second preset operating system interface can be, for example, a device scanning node, and the rescanning and loading of the GPU can be completed by using the "echo 1> / sys / bus / pci / rescan" command at the device scanning node, and the abnormality in the GPU can be eliminated by the unloading and loading process of the GPU. It can be understood that the above is only a specific example of an embodiment of the present invention. In other embodiments of the present invention, other interfaces can also be used as the first preset operating system interface and the second preset operating system interface, and other commands can be used to complete the unloading and rescanning and loading of the GPU. It can be used flexibly according to actual conditions. It only needs to complete the unloading and rescanning and loading process of the GPU to achieve the effect of eliminating the GPU abnormality, and is not limited to the above-mentioned specific interfaces and commands.
[0070] In other embodiments of the present invention, the specific steps of eliminating the abnormality by uninstalling the board driver of the GPU are: first use the "rmmod bi_driver" command to uninstall the board driver of the GPU, and then use the "insmod bi_driver.ko" command to reload the GPU board driver. During the driver loading process, the GPU will be initialized and reset to restore the GPU to normal. It can be understood that the above is only a specific example of an embodiment of the present invention. In other embodiments of the present invention, other commands can also be used to complete the unloading and reloading of the board driver of the GPU. It can be used flexibly according to actual conditions. It only needs to complete the unloading and reloading process of the board driver of the GPU to achieve the effect of eliminating the GPU abnormality, and it is not limited to the examples of the above specific commands.
[0071] In addition, in other embodiments of the present invention, the GPU abnormality may be eliminated by restarting the device or other methods, which are not listed here one by one.
[0072] Furthermore, in some embodiments of the present invention, when the automatic elimination of the GPU abnormality cannot be completed, manual processing can be requested by issuing an alarm (for example, issuing a warning sound effect, sending a warning message to a preset terminal, etc.) to complete the elimination of the GPU abnormality.
[0073] In addition, in some embodiments of the present invention, depending on different usage scenarios, such as the process of debugging a GPU, it can also be preset that when a GPU control device detects an abnormality in the GPU, it does not automatically recover the GPU abnormality temporarily, but sends the abnormality to an administrator, so that the administrator can better analyze the cause of the GPU abnormality. Whether to automatically recover the abnormality can be determined based on the administrator's relevant instructions for the next step.
[0074] In the GPU control method provided in the first embodiment of the present invention, the access pointer data of the GPU is automatically obtained. Since the access pointer data includes the read pointer data and the write pointer data of the GPU, the read pointer data and the write pointer data can represent the current execution status of the GPU for the task instructions issued by the CPU. Therefore, it can be judged whether the GPU has an abnormality based on the access pointer data. When the GPU has an abnormality, the GPU has an abnormality and a preset method is used to eliminate the abnormality, thereby achieving the effect of automatically detecting GPU abnormalities and automatically eliminating the abnormality when the abnormality is detected, improving the response speed to GPU abnormalities without the need for professional technicians to perform special processing, thereby improving the work efficiency of the GPU.
[0075] A second embodiment of the present invention provides a GPU control method, such as Figure 5 As shown, the following steps are included:
[0076] Step S501: Obtain access pointer data of the GPU.
[0077] Step S502: Determine whether the GPU is abnormal based on the access pointer data.
[0078] Step S503: Obtain the cache usage of the GPU, and determine whether the GPU is abnormal based on the cache usage.
[0079] The GPU generates a large amount of intermediate data in the process of executing the commands sent by the CPU, and these intermediate data will be put into the cache for temporary storage. In this embodiment, the GPU will record and store the usage time of each cache each time it uses the cache, including storing data in the cache and reading data from the cache. When detecting whether the GPU is abnormal, the recorded and stored cache usage time can be directly obtained to obtain the last cache usage time, calculate the time difference between the current time and the last cache usage time, and determine whether the time difference is greater than the preset maximum time length. The maximum time length is the preset maximum time interval when the GPU does not use the cache under normal working conditions. If the current calculated time difference is greater than the preset maximum time length, it means that the GPU is not in a normal working state, and it can be determined that the GPU is abnormal.
[0080] Since each GPU includes a large number of computing units, these computing units may be assigned to complete different tasks during use, that is, a large number of computing units are classified into a plurality of different task execution modules. In some embodiments of the present invention, the use time of the cache by each different task execution module in the GPU can also be recorded and stored separately, and then when detecting whether the GPU is abnormal, the use time of the cache of the different task execution modules of the GPU recorded and stored can be directly obtained, so as to obtain the last use time of the different task execution modules of the cached GPU, calculate the time difference between the current time and the last use time of the cache by the different task execution modules of the GPU, and determine whether there is a time difference greater than the preset maximum duration among these time differences. If there is at least one currently calculated time difference greater than the preset maximum duration, it means that some task execution modules in the GPU are not in a normal working state, and it can be determined that the GPU is abnormal.
[0081] In addition, since the actual situations of executing tasks by different task execution modules of the GPU are different, in other embodiments of the present invention, when the currently calculated time difference value is greater than the preset maximum duration, it is not necessary to directly determine that the GPU is abnormal, but to perform a secondary determination on whether the GPU is abnormal based on the number of time difference values greater than the preset maximum duration, that is, to determine again whether the number of time difference values greater than the preset maximum duration is greater than a preset number. If the number of time difference values greater than the preset maximum duration is greater than the preset number, the GPU is determined to be abnormal.
[0082] Furthermore, since each task execution module may not use the maximum time interval of the cache in the process of executing different tasks, there may also be differences. Therefore, in some embodiments of the present invention, it is also possible to record and store the use time of the cache by each different task execution module in the GPU, and preset different maximum durations for each task execution module. When detecting whether the GPU is abnormal, the use time of the cache of the different task execution modules of the GPU recorded and stored can be directly obtained, so as to obtain the last use time of the different task execution modules of the cache GPU, calculate the time difference between the current moment and the last use time of the cache by the different task execution modules of the GPU, and then compare the time difference calculated by each different task execution module with the preset maximum duration corresponding to the task execution module, and finally judge whether the GPU is abnormal according to whether there is a time difference greater than the preset maximum duration and the number of time differences greater than the preset maximum duration. For example, it can be that as long as there is a situation where the time difference is greater than the preset maximum duration, it is determined that the GPU is abnormal, or it can be that the number of time differences greater than the preset maximum duration is greater than the preset number before the GPU is determined to be abnormal. It can be used flexibly according to actual needs.
[0083] Step S504: Eliminate the anomaly using a preset method.
[0084] It can be understood that steps S501, S502, and S504 in the second embodiment of the present invention are substantially the same as steps S101 to S103 in the first embodiment, and the details can be referred to the specific description in the first embodiment.
[0085] Compared with the prior art, the GPU control method provided in the second embodiment of the present invention retains all the technical features of the first embodiment and has the same technical effects as the first embodiment. In addition, the GPU control method provided in the second embodiment of the present invention also uses the GPU to judge whether the GPU has an abnormality based on the cache usage, which can reduce the occurrence of missed judgments of GPU abnormalities and improve the detection accuracy of GPU abnormalities.
[0086] Embodiment 3 of the present invention provides a GPU control method, such as Figure 6 As shown, the following steps are included:
[0087] Step S601: Obtain access pointer data of the GPU.
[0088] Step S602: Determine whether the GPU is abnormal based on the access pointer data.
[0089] Step S603: Obtain the target task progress.
[0090] In this step, the target task process is the task process that has been completed on the CPU connected to the GPU. In the actual application process, the task process spans the CPU and the GPU, that is, a complete task process includes both the part running in the CPU and the part running in the GPU. In this step, the target task process is the task process that has been completed on the CPU.
[0091] Step S604: Obtain the running result of the target task process on the GPU, and determine whether the GPU is abnormal based on the running result.
[0092] In this embodiment, the running result of the target task process on the GPU includes whether the target task process has been completed on the GPU. If the target task process has also been completed on the GPU, it is determined that the GPU is working normally. If the target task process has not been completed on the GPU, the running time of the target task process on the GPU is obtained to determine whether the running time is greater than the preset maximum running time. If the running time is greater than the preset maximum running time, it is determined that the GPU is abnormal. On the contrary, if the running time is less than or equal to the preset maximum running time, it is determined that the GPU is not abnormal.
[0093] Step S605: Eliminate the anomaly using a preset method.
[0094] It can be understood that steps S601, S602, and S605 in the second embodiment of the present invention are substantially the same as steps S101 to S103 in the first embodiment, and the details can be referred to the specific description in the first embodiment.
[0095] Compared with the prior art, the GPU control method provided in the second embodiment of the present invention retains all the technical features of the first embodiment and has the same technical effects as the first embodiment. In addition, the GPU control method provided in the second embodiment of the present invention also uses the running results of the target task process on the GPU to determine whether the GPU has an abnormality, which can reduce the occurrence of missed detection of GPU abnormalities and improve the detection accuracy of GPU abnormalities.
[0096] Embodiment 4 of the present invention provides a GPU control method, such as Figure 7 As shown, the following steps are included:
[0097] Step S701: Obtain access pointer data of the GPU.
[0098] Step S702: Determine whether the GPU is abnormal based on the access pointer data.
[0099] Step S703: Run a preset detection program on the GPU.
[0100] In this step, the preset detection program is a preset application program, and the preset detection program can call the GPU to execute a fixed preset task when running.
[0101] Step S704: Obtain the return result of the preset detection program, and determine whether the GPU is abnormal according to the return result.
[0102] In this embodiment, the preset detection program calls the GPU to execute a fixed preset task when it is running. After the GPU executes the preset task under normal working conditions, it will return the processing result of the preset task within the preset execution time. The processing result returned by the GPU is compared with the processing result that the preset task is expected to return. If there is a difference between the two, it is determined that the GPU is abnormal. In addition, if the GPU does not return the processing result within the preset execution time, it is also determined that the GPU is abnormal.
[0103] Step S705: Eliminate the anomaly using a preset method.
[0104] It can be understood that steps S701, S702, and S705 in the second embodiment of the present invention are substantially the same as steps S101 to S103 in the first embodiment, and the details can be referred to the specific description in the first embodiment.
[0105] Compared with the prior art, the GPU control method provided in the second embodiment of the present invention retains all the technical features of the first embodiment and has the same technical effects as the first embodiment. In addition, the GPU control method provided in the second embodiment of the present invention also uses the return result of a preset detection program to determine whether the GPU has an abnormality, which can reduce the occurrence of missed detection of GPU abnormalities and improve the detection accuracy of GPU abnormalities.
[0106] Embodiment 5 of the present invention provides a GPU control device, such as Figure 8 As shown, it includes: a data acquisition module 801, which is used to obtain the access pointer data of the GPU, and the access pointer data includes the read pointer data and the write pointer data of the GPU; a data processing module 802, which is used to determine whether the GPU has an abnormality according to the access pointer data; and an exception handling module 803, which is used to eliminate the exception using a preset method when an exception occurs in the GPU.
[0107] Compared with the prior art, in the GPU control device provided in the fifth embodiment of the present invention, the access pointer data of the GPU is automatically acquired through the data acquisition module 801. Since the access pointer data includes the read pointer data and the write pointer data of the GPU, the read pointer data and the write pointer data can represent the execution status of the task instructions currently issued by the GPU to the CPU. The data processing module 802 can determine whether the GPU has an abnormality based on the access pointer data. When an abnormality occurs in the GPU, the abnormality processing module 803 responds to the GPU abnormality and eliminates the abnormality using a preset method, thereby achieving the effect of automatically detecting GPU abnormalities and automatically eliminating the abnormality when the abnormality is detected, improving the response speed to GPU abnormalities without the need for professional technicians to perform special processing, thereby improving the work efficiency of the GPU.
[0108] It is not difficult to find that the GPU control device provided in the fifth embodiment of the present invention is a device embodiment corresponding to the embodiment of the aforementioned GPU control method of the present invention. Therefore, the technical details in the embodiment of the aforementioned GPU control method of the present invention can also be applied in the fifth embodiment of the present invention.
[0109] Embodiment 6 of the present invention relates to an electronic device, such as Fig. 9 As shown, it includes: at least one processor 901; and a memory 902 and a GPU 903 that are communicatively connected to the at least one processor 901; wherein the memory 902 stores instructions that can be executed by the at least one processor 901, and the instructions are executed by the at least one processor 901 so that the at least one processor 901 can execute the GPU control method in the above-mentioned embodiments to realize control of the GPU 903.
[0110] Among them, the memory and the processor are connected in a bus manner, and the bus may include any number of interconnected buses and bridges, and the bus connects various circuits of one or more processors and memories together. The bus can also connect various other circuits such as peripherals, voltage regulators, and power management circuits, which are well known in the art and are therefore not further described herein. The bus interface provides an interface between the bus and the transceiver. The transceiver can be one element or multiple elements, such as multiple receivers and transmitters, providing a unit for communicating with various other devices on a transmission medium. The data processed by the processor is transmitted on a wireless medium via an antenna, and further, the antenna also receives data and transmits the data to the processor.
[0111] The processor is responsible for managing the bus and general processing, and can also provide various functions, including timing, peripheral interfaces, voltage regulation, power management, and other control functions. Memory can be used to store data used by the processor when performing operations.
[0112] Embodiment 7 of the present invention relates to a computer-readable storage medium storing a computer program. When the computer program is executed by a processor, the above method embodiment is implemented.
[0113] That is, those skilled in the art can understand that all or part of the steps in the above-mentioned embodiment method can be completed by instructing the relevant hardware through a program, and the program is stored in a storage medium, including several instructions to enable a device (which can be a single-chip microcomputer, chip, etc.) or a processor to execute all or part of the steps of each embodiment method of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk and other media that can store program codes.
[0114] The above are only specific embodiments of the present invention, but the protection scope of the present invention is not limited thereto. Any changes or substitutions that can be easily thought of by a person skilled in the art within the technical scope disclosed by the present invention should be included in the protection scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.
Claims
1. A GPU control method, characterized in that: Applicable to GPU control devices, including: Acquire access pointer data of the GPU, the access pointer data including read pointer data and write pointer data of the GPU, the read pointer data including a current read pointer address, a last change value of a currently stored read pointer address, and a last change time of the currently stored read pointer address, and the write pointer data including a current write pointer address, a last change value of a currently stored write pointer address, and a last change time of the currently stored write pointer address; Determining whether an abnormality occurs in the GPU according to the access pointer data; Eliminate the anomaly using a preset method; The determining whether the GPU is abnormal according to the access pointer data includes: Acquire the last changed value of the actual read pointer address and the last changed time of the actual read pointer address according to the access pointer data; Acquire the last change value of the actual write pointer address and the last change time of the actual write pointer address according to the access pointer data; Calculate the time difference between the last change time of the actual read pointer address and the last change time of the actual write pointer address; If the actual last changed value of the read pointer address is different from the actual last changed value of the write pointer address, and the time difference is greater than or equal to a preset threshold, it is determined that the GPU is abnormal; If the actual last changed value of the read pointer address is the same as the actual last changed value of the write pointer address, or the time difference is less than the preset threshold, it is determined that the GPU is not abnormal.
2. The method according to claim 1, characterized in that The obtaining of the access pointer data of the GPU includes: Reading a current read pointer address from a read pointer register, reading a last change value of a currently stored read pointer address and a last change time of a currently stored read pointer address from a preset register, and using the current read pointer address, the last change value of the currently stored read pointer address, and the last change time of the currently stored read pointer address as the read pointer data; Write the current write pointer address from the write pointer register, read the last change value of the currently stored write pointer address and the last change time of the currently stored write pointer address from the preset register, and use the current write pointer address, the last change value of the currently stored write pointer address, and the last change time of the currently stored write pointer address as the write pointer data.
3. The method according to claim 1, characterized in that The step of obtaining the last changed value of the actual read pointer address and the last changed time of the actual read pointer address according to the access pointer data comprises: In response to the current read pointer address being the same as the current write pointer address, the current read pointer address is used as the last changed value of the actual read pointer address, and the current time is used as the last changed time of the actual read pointer address.
4. The method according to claim 3, characterized in that: The method of acquiring the last changed value of the actual read pointer address and the last changed time of the actual read pointer address according to the access pointer data further includes: In response to the current read pointer address being different from the current write pointer address, determining whether the current read pointer address is the same as the last changed value of the currently stored read pointer address; If the current read pointer address is the same as the last changed value of the currently stored read pointer address, use the last changed value of the currently stored read pointer address as the last changed value of the actual read pointer address, and use the last changed time of the currently stored read pointer address as the last changed time of the actual read pointer address; If the current read pointer address is different from the last changed value of the currently stored read pointer address, the current read pointer address is used as the last changed value of the actual read pointer address, and the current time is used as the last changed time of the actual read pointer address.
5. The method according to claim 1, characterized in that The step of obtaining the last change value of the actual write pointer address and the last change time of the actual write pointer address according to the access pointer data comprises: In response to the current read pointer address being the same as the current write pointer address, the current write pointer address is used as the last changed value of the actual write pointer address, and the current time is used as the last changed time of the actual write pointer address.
6. The method according to claim 5, characterized in that The method of acquiring the last change value of the actual write pointer address and the last change time of the actual write pointer address according to the access pointer data further includes: In response to the current read pointer address being different from the current write pointer address, determining whether the current write pointer address is the same as the last changed value of the currently stored write pointer address; If the current write pointer address is the same as the last changed value of the currently stored write pointer address, use the last changed value of the currently stored write pointer address as the last changed value of the actual write pointer address, and use the last changed time of the currently stored write pointer address as the last changed time of the actual write pointer address; If the current write pointer address is different from the last change value of the currently stored write pointer address, the current write pointer address is used as the last change value of the actual write pointer address, and the current time is used as the last change time of the actual write pointer address.
7. The method according to claim 1, characterized in that The method further comprises: Obtain cache usage of the GPU, and determine whether an abnormality occurs in the GPU according to the cache usage.
8. The method according to claim 1, characterized in that The method further comprises: Obtain a target task process, where the target task process is a task process that has been completed on a CPU connected to the GPU; Obtain the running result of the target task process on the GPU, and determine whether the GPU is abnormal according to the running result.
9. The method according to claim 1, characterized in that: The method further comprises: Running a preset detection program on the GPU to obtain a return result of the preset detection program; Determine whether the GPU is abnormal based on the returned result.
10. The method according to any one of claims 1 to 9, characterized in that The using a preset method to eliminate the anomaly includes: The GPU is reset using a preset GPU management tool to eliminate the abnormality.
11. The method according to any one of claims 1 to 9, characterized in that The using a preset method to eliminate the anomaly includes: Call a preset operating system interface to eliminate the exception.
12. The method according to claim 11, characterized in that The calling of a preset operating system interface to eliminate the exception includes: Calling a first preset operating system interface to uninstall the GPU; A second preset operating system interface is called to reload the GPU to eliminate the exception.
13. The method according to any one of claims 1 to 9, characterized in that The using a preset method to eliminate the anomaly includes: After uninstalling the board driver of the GPU, reload the board driver to eliminate the exception.
14. A GPU control device, characterized in that: include: A data acquisition module, the data acquisition module is used to acquire access pointer data of the GPU, the access pointer data includes read pointer data and write pointer data of the GPU, the read pointer data includes a current read pointer address, a last change value of a currently stored read pointer address, and a last change time of the currently stored read pointer address, and the write pointer data includes a current write pointer address, a last change value of a currently stored write pointer address, and a last change time of the currently stored write pointer address; A data processing module, the data processing module is used to obtain the actual last change value of the read pointer address and the actual last change time of the read pointer address according to the access pointer data; obtain the actual last change value of the write pointer address and the actual last change time of the write pointer address according to the access pointer data; calculate the time difference between the actual last change time of the read pointer address and the actual last change time of the write pointer address; If the actual last changed value of the read pointer address is different from the actual last changed value of the write pointer address, and the time difference is greater than or equal to a preset threshold, it is determined that the GPU is abnormal; If the actual last change value of the read pointer address is the same as the actual last change value of the write pointer address, or the time difference is less than the preset threshold, it is determined that the GPU is not abnormal; The exception handling module is used to eliminate the exception using a preset method when an exception occurs in the GPU.
15. An electronic device, characterized in that: include: at least one processor; and, a memory and a GPU communicatively coupled to the at least one processor; The memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the GPU control method as described in any one of claims 1 to 13 to control the GPU.
16. A computer-readable storage medium storing a computer program, characterized in that: The computer program is executed by a processor to implement the GPU control method according to any one of claims 1 to 13.
Citation Information
Patent Citations
Self-test during idle cycles for shader core of GPU
CN111417932A
Exception handler for sampling drawing dispatch identifiers
CN114424169A