Memory information processing method, hardware acceleration module, device, and storage medium
Through the hardware acceleration module, the dynamic link library is rewrited, the application's memory management function is called, and the GPU memory usage information during deep learning model training is obtained, which solves the memory overflow and resource waste caused by the model's memory occupancy and not release, and realizes the precise management of GPU memory usage.
Patent Information
- Application Number
- PCT/CN2024/105771
- Authority / Receiving Office
- WO · WO
- Patent Type
- Applications
- Current Assignee / Owner
- Priority Date
- 2023-09-28
- Filing Date
- 2024-07-16
- Publication Date
- 2025-04-03
AI Technical Summary
During the deep learning model training process, the model occupies GPU memory and is not released, causing other processes to be unable to apply for sufficient GPU memory, causing memory overflow and resource waste.
The first dynamic link library is provided through the hardware acceleration module, rewrite it to realize access to the third dynamic link library, call its memory management function, obtain the application's current memory usage information, and realize precise management of GPU memory usage.
Without intruding into the application, accurately obtain the application's memory usage information, solve the problems of memory overflow and resource waste, and improve the utilization efficiency of memory resources.
Smart Images

Figure CN2024105771_03042025_PF_FP_ABST
Abstract
Description
Memory information processing method, hardware acceleration module, device and storage medium Technical Field
[0001] The present disclosure relates to the field of cloud storage technology, and in particular to a memory information processing method, a hardware acceleration module, a device, and a storage medium. Background Art
[0002] In recent years, deep learning has made significant progress, particularly in areas such as computer vision (CV), natural language processing (NLP), and recommendation systems. Because deep learning often relies on massive amounts of data and computing power, graphics processing units (GPUs) are often used to accelerate the training of deep learning models.
[0003] During model training, model parameters, sample data used for training, and intermediate result data need to be stored in GPU memory. If the model training process occupies a large amount of GPU memory and is not released, this can cause other problems in some scenarios, such as preventing other processes running on the GPU from requesting sufficient GPU memory. To properly control the GPU memory usage during model training, it is necessary to accurately obtain the amount of GPU memory used by model training without intruding on the model training process.
[0004] Summary of the Invention
[0005] Various aspects of the present disclosure provide a memory information processing method, a hardware acceleration module, a device, and a storage medium for accurately obtaining the memory usage of an application without intruding on the application.
[0006] An embodiment of the present disclosure provides a memory information processing method, which is applied to a hardware acceleration module, wherein the hardware acceleration module provides a first dynamic link library for applications, and the applications running on the hardware acceleration module include at least the first application. The method comprises: responding to a trigger event for obtaining current memory usage information of the first application, accessing a third dynamic link library based on rewriting the first dynamic link library, wherein the third dynamic link library is a dynamic link library provided by the first application for using the hardware acceleration module; calling a target memory management function in the third dynamic link library to obtain current memory usage information of the first application, wherein the current memory usage information represents the current usage of the memory resources of the hardware acceleration module by the first application; and performing a processing operation corresponding to the trigger event based on the current memory usage information of the first application.
[0007] An embodiment of the present disclosure also provides a hardware acceleration module, including: a storage unit and a processing unit, wherein the storage unit is used to store a computer program corresponding to the memory information processing method, and the processing unit is coupled to the storage unit to execute the computer program corresponding to the memory information processing method to implement the steps in the above method.
[0008] An embodiment of the present disclosure also provides an electronic device, including: a hardware acceleration module, the hardware acceleration module including a storage unit and a processing unit, the storage unit is used to store a computer program corresponding to the memory information processing method, and the processing unit is coupled to the storage unit to execute the computer program corresponding to the memory information processing method, so as to implement the steps in the above method.
[0009] An embodiment of the present disclosure further provides a computer-readable storage medium storing a computer program, wherein when the computer program is executed by a processor, the processor is caused to implement the steps in the above method.
[0010] In the disclosed embodiment, the hardware acceleration module provides a first dynamic link library to the application so that the application can use the hardware acceleration device for acceleration; in addition, the application can also bring its own dynamic link library that uses the hardware acceleration device, which is recorded as a third dynamic link library; further, by rewriting the first dynamic link library to achieve access to the third dynamic link library, and then calling the target memory management function in the third dynamic link library to obtain the current memory usage information of the application, the current memory usage information of the application can be accurately obtained without intruding into the application, which is conducive to solving various memory problems caused by unreasonable application memory usage, such as memory overflow problems and resource waste problems. BRIEF DESCRIPTION OF THE DRAWINGS
[0011] The drawings described herein are used to provide a further understanding of the present disclosure and constitute a part of the present disclosure. The exemplary embodiments of the present disclosure and their descriptions are used to explain the present disclosure and do not constitute an improper limitation of the present disclosure. In the drawings:
[0012] FIG1a is a schematic flow chart of a method for processing memory information according to an exemplary embodiment of the present disclosure;
[0013] FIG1b is a schematic diagram of a CUDA software architecture adapted to a GPU provided by an exemplary embodiment of the present disclosure;
[0014] FIG1c is a schematic diagram of a process of preloading a second dynamic link library provided by an exemplary embodiment of the present disclosure;
[0015] FIG1d is a schematic diagram of a process of accessing a third dynamic link library and calling a target memory management function according to a second dynamic link library, provided by an exemplary embodiment of the present disclosure;
[0016] FIG2 is a schematic diagram of the structure of a memory information processing device provided by an exemplary embodiment of the present disclosure;
[0017] FIG3 is a schematic structural diagram of a hardware acceleration module provided by an exemplary embodiment of the present disclosure;
[0018] FIG4 is a schematic structural diagram of an electronic device provided by an exemplary embodiment of the present disclosure. DETAILED DESCRIPTION
[0019] To make the objectives, technical solutions, and advantages of the present disclosure more clear, the technical solutions of the present disclosure will be clearly and completely described below in conjunction with the specific embodiments of the present disclosure and the corresponding drawings. Obviously, the described embodiments are only part of the embodiments of the present disclosure, not all of the embodiments. Based on the embodiments of the present disclosure, all other embodiments obtained by ordinary technicians in this field without making creative efforts are within the scope of protection of the present disclosure.
[0020] It should be noted that the user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data used for analysis, stored data, displayed data, etc.) involved in this disclosure are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data must comply with the relevant laws, regulations and standards of relevant countries and regions, and provide corresponding operation entrances for users to choose to authorize or refuse.
[0021] In the prior art, GPUs can be used to accelerate the model training process of deep learning, that is, to use GPUs for model training. In the process of using GPUs for model training, due to the use of a caching mechanism, other problems may arise in some application scenarios. For example, in a GPU sharing scenario, since the process used for model training will occupy GPU memory that is not actually needed and will not be released, other processes may not be able to apply for enough GPU memory and a memory overflow (OOM) problem may occur. For another example, in a data migration scenario, since the process used for model training will occupy GPU memory that is not actually needed and will not be released, the data in the GPU memory that is not actually needed will also need to be migrated, which will cause a waste of resources due to migrating useless data.
[0022] In view of the above problems, the embodiments of the present disclosure provide a solution that can accurately obtain application memory usage information. When obtaining application memory usage information, various problems caused by unreasonable application memory usage can be solved. Specifically, in the embodiments of the present disclosure, the hardware acceleration module provides a first dynamic link library to the application so that the application can use the hardware acceleration device for acceleration; in addition, the application can also bring its own dynamic link library required for using the hardware acceleration device, which is recorded as a third dynamic link library; further, by rewriting the first dynamic link library, access to the third dynamic link library is achieved, and then the target memory management function in the third dynamic link library is called to obtain the current memory usage information of the application. The current memory usage information of the application can be accurately obtained without intruding the application, which is conducive to solving various memory problems caused by unreasonable application memory usage, such as memory overflow problems and resource waste problems.
[0023] The embodiments of the present disclosure do not limit the hardware acceleration module, and can be any chip, module, or device that has an acceleration effect and memory storage function compared to a traditional processor (Central Processing Unit, CPU). For example, the hardware acceleration module in the embodiments of the present disclosure can be, but is not limited to: a GPU, a Tensor Processing Unit (TPU), and an Application Specific Integrated Circuit (ASIC). It should be noted that the hardware acceleration module can also be a composite chip composed of any combination of a GPU, a TPU, and an ASIC.
[0024] A GPU, also known as a display core, visual processor, or display chip, is a microprocessor that performs image and graphics-related operations on personal computers, workstations, game consoles, and some mobile devices (such as tablets and smartphones). GPUs have a large number of parallel computing units, capable of executing thousands or even tens of thousands of instructions simultaneously. They also have large amounts of memory and high-speed bandwidth. Using GPUs to accelerate applications can reduce their reliance on the CPU, allowing the CPU to perform other tasks.
[0025] ASICs are integrated circuits with specialized specifications customized to meet specific product requirements. They are designed and manufactured based on the needs of specific users and electronic systems. ASIC chip technology connects all interface modules (including control modules) to a matrix backplane. Direct forwarding from ASIC chip to ASIC chip enables simultaneous communication between multiple modules. ASIC chip technology is rapidly developing, and forwarding performance between ASIC chips can typically reach 1Gbs or even higher, providing an excellent foundation for switch matrices. Furthermore, each module's cache only processes the input and output queues for that module, placing significantly lower demands on memory chip performance than shared memory. In short, switch matrices are characterized by high access efficiency, suitability for simultaneous multi-point access, ease of providing very high bandwidth, and easy performance expansion, without being constrained by CPU, bus, and memory technology limitations.
[0026] The embodiments of the present disclosure do not limit the applications that use the hardware acceleration device. They can be various software programs that can run on the hardware acceleration module, such as but not limited to: model training applications, video processing applications, streaming processing applications, game applications, shopping applications, autonomous driving applications, medical image analysis applications, financial risk control applications, etc. During operation, these applications will occupy the memory resources of the hardware acceleration module. The occupied memory resources can store the application's own program code, application parameters, temporary data generated during the application's operation, and result data, etc. The method provided by the embodiments of the present disclosure can obtain the memory usage information of any application running on the hardware acceleration module, and can achieve non-intrusion to the relevant applications. Users do not need to modify the source code of the relevant applications, and it has universality.
[0027] The technical solutions provided by various embodiments of the present disclosure are described in detail below with reference to the accompanying drawings.
[0028] Figure 1a is a flow chart of a memory information processing method provided by an exemplary embodiment of the present disclosure. The memory information processing method of this embodiment is applied to a hardware acceleration module. The applications running on the hardware acceleration module include at least a first application. In this embodiment of the present disclosure, taking the first application as an example, a detailed description is given of how to obtain memory usage information of the first application without intruding on the application. As shown in Figure 1a, the method includes:
[0029] 101. In response to a triggering event for obtaining current memory usage information of a first application, access is implemented to a third dynamic link library based on rewriting the first dynamic link library, where the third dynamic link library is a dynamic link library provided by the first application and used for using a hardware acceleration module;
[0030] 102. Call a target memory management function in a third dynamic link library to obtain current memory usage information of the first application, where the current memory usage information represents current usage of memory resources of the hardware acceleration module by the first application.
[0031] 103. Execute a processing operation corresponding to the triggering event according to the current memory usage information of the first application.
[0032] In this embodiment, the example of the hardware acceleration module is as described above and will not be repeated here. In this embodiment, the hardware acceleration module provides the ability to accelerate computing for applications, which can be specifically achieved through the dynamic link library (DLL) provided by the hardware acceleration module for applications. That is, the application running on the hardware acceleration device can load the dynamic link library provided by the hardware acceleration module to facilitate the use of the hardware acceleration module. A dynamic link library is a program module that can be shared by applications, which encapsulates some functions that can be shared by applications. These functions can simplify the application's use of the hardware acceleration module, which can both simplify the application code and improve the application's use of the hardware acceleration module. The dynamic link library provided by the hardware acceleration module contains a driver for controlling the operation of the hardware acceleration module and library functions required to use the hardware acceleration module for accelerated computing. These library functions can increase the running speed of the application, and the dynamic link library is applicable to any application for which the hardware acceleration module is targeted. For ease of description and distinction, the dynamic link library provided by the hardware acceleration module is referred to as the first dynamic link library.
[0033] Depending on the hardware acceleration module, the implementation of the first dynamic link library will be different, and the library functions contained in the first dynamic link library will also be different. For example, when the hardware acceleration module is implemented as a GPU, the first dynamic link library can be the Compute Unified Device Architecture (CUDA). CUDA is a parallel computing platform and programming model provided by GPU manufacturers and supported by the Software Development Kit (SDK) software library. As shown in Figure 1b, the CUDA software system is divided into three layers: the CUDA library, the CUDA runtime API, and the CUDA driver API. The functions and APIs in these three layers can be collectively referred to as library functions. Among them, the CUDA driver API can achieve higher performance by directly operating the GPU hardware to perform corresponding functions; the CUDA runtime API encapsulates the CUDA driver API to a certain extent, making it more convenient to use. In actual applications, the CUDA runtime API is more commonly used, that is, the application indirectly operates the GPU hardware to perform corresponding functions by calling the CUDA runtime API to obtain the performance brought by the GPU. Among them, the CUDA function library includes but is not limited to: a function library for deep convolutional neural networks, a function library for Fourier transforms, a complete standard matrix and vector operation library for accelerated versions, a function library for parallel operations, and so on.
[0034] In this embodiment, one or more applications can be run on the hardware acceleration module, and when multiple applications are run, the multiple applications may be of the same type or of different types, which is not limited to this. Among them, the applications running on the hardware acceleration module include at least a first application, and the first application can be any application running on the hardware acceleration module, such as a deep learning application, a game application, a shopping application, a short video application, etc. Regardless of the type of application the first application is, from the perspective of the first application, the first application can bring its own dynamic link library that facilitates the use of the hardware acceleration module. For the sake of distinction and description, the dynamic link library required for the use of the hardware acceleration module brought by the first application is referred to as a third dynamic link library. The third dynamic link library also includes library functions, for example, library functions related to memory management. These library functions provide an application programming interface (API) to the outside world. Through these APIs, library functions can be called to manage the application's memory usage, such as allocating memory and obtaining memory usage, such as the starting address of the memory, the size of the address block, and whether it is active, etc.
[0035] In this embodiment, in order to obtain the memory usage information of the first application without the first application being aware of it (i.e., without intrusion to the first application), an implicit call to a memory management function contained in a third dynamic link library can be used. The third dynamic link library contains multiple functions. For ease of distinction and description, the function used for memory management is referred to as a target memory management function. Implicitly calling the target memory management function means calling the target memory management function in some way without modifying the source code of the first application.
[0036] In this embodiment, implicit access to the third dynamic link library is achieved by rewriting the first dynamic link library, thereby achieving the purpose of obtaining the memory usage information of the first application without the first application's awareness and without intruding on the process running on the hardware acceleration module that needs to obtain the memory usage information of the first application. Furthermore, relevant processing can be performed based on the memory usage information of the first application to achieve precise management of the memory usage of the hardware acceleration device. Based on this, during the process of the hardware acceleration module running various applications, if a trigger event occurs that requires obtaining the current memory usage information of the first application, the trigger event can be responded to and access to the third dynamic link library can be achieved based on the rewriting of the first dynamic link library. The target memory management function in the third dynamic link library can then be called to obtain the current memory usage information of the first application.
[0037] In the embodiment of the present disclosure, the method of rewriting the first dynamic link library is not limited. Optionally, the implicit call function of the target memory management function can be implemented as a dynamic link library, i.e., the second dynamic link library, by rewriting the first dynamic link library. Considering that each application running on the hardware acceleration module is implemented based on the driver and library function programming in the first dynamic link library, that is, each application needs to rely on at least some library functions in the first dynamic link library, such as the CUDA runtime API. Based on this, the library name of the second dynamic link library and the names of the library functions contained in the second dynamic link library are the same as the name of the first dynamic link library and the names of the library functions contained in the first dynamic link library, thereby hijacking the first dynamic link library, i.e., the second dynamic link library is loaded instead of the first dynamic link library, so that the process running on the hardware acceleration module that needs to obtain the memory usage information of the first application can be non-intrusive without the first application being aware of it. That is, the source code of the process that needs to obtain the memory usage information of the first application does not need to be modified. Among them, the process that needs to obtain the memory usage information of the first application can be an application process or a system process. However, the functions of at least some of the library functions in the second dynamic link library are obtained by rewriting the functions of the corresponding library functions with the same names in the first dynamic link library. In other words, the functional logic of at least some of the library functions in the second dynamic link library after being rewritten is different from the functional logic of the corresponding library functions with the same names in the first dynamic link library. Among them, at least some of the library functions in the second dynamic link library after being rewritten are used to implement access to the third dynamic link library and call the target memory management function in the third dynamic link library, that is, to implement the implicit call function of the target memory management function.
[0038] In the embodiment of the present disclosure, it is not limited to which library functions in the first dynamic link library are rewritten. Any library function can be rewritten. Preferably, the functions related to memory management in the first dynamic link library can be rewritten. Accordingly, the application uses the target memory management function in the third dynamic link library that comes with it to perform memory management. Depending on the first dynamic link library, the functions related to memory management will also be different. In the embodiment of the present disclosure, taking CUDA adapted to the GPU as an example, the functions related to memory management can be the memory allocation function cudaMalloc() and the memory release function cudaFree() in the CUDA runtime API, or the memory allocation function cudaMemAlloc() and the memory release function cudaMemFree() in the CUDA driver API, and there is no limitation on this. In addition, in the embodiment of the present disclosure, there is no limitation on the way to rewrite the functions related to memory management in the first dynamic link library. For example, on the basis of implementing the original function function, an "implicit call function to the target memory management function" can be added, or the original function function can be partially modified, that is, a part of the original function function is replaced by the "implicit call function to the target memory management function", and the rest of the function remains unchanged.
[0039] When the second dynamic link library is obtained, the second dynamic link library can be stored in a preset path in advance, and the value of the dynamic link library's preload (LD_PRELOAD) environment variable can be set to the preset path. That is, before other applications that need to obtain the memory usage information of the first application are started, the second dynamic link library hijacks the first dynamic link library through the dynamic link library's preload environment variable. Among them, the preload environment variable corresponds to the preset path, and the preset path is used to store the second dynamic link library. The default environment variable of the dynamic link library corresponds to the default path, and the default path is used to store the first dynamic link library. The priority of the preload environment variable is higher than the default environment variable. That is to say, relative to the first dynamic link library, the function with the same name in the second dynamic link library will be called first when the application is running. As shown in Figure 1c, during the loading process of the dynamic link library, the dynamic linker will read the value of the preloaded environment variable (i.e., the preset path) and preload the second dynamic link library read from the preset path. In this embodiment, other applications need to rely on the second dynamic link library to access the third dynamic link library of the first application and call the target memory management function in the third dynamic link library, ultimately achieving the purpose of obtaining the current memory usage information of the first application through the target memory management function.
[0040] Based on the above, in the process of the hardware acceleration module running various applications, if a trigger event occurs that requires obtaining the current memory usage information of the first application, the trigger event can be responded to and the second dynamic link library saved in the preset path can be loaded first; after loading the second dynamic link library, the third dynamic link library can be accessed based on the second dynamic link library; in the process of accessing the third dynamic link library, the target memory management function in the third dynamic link library can be called to obtain the current memory usage information of the first application through the target memory management function.
[0041] In the embodiments of the present disclosure, the triggering events that require obtaining the current memory usage information of the first application are not limited. The triggering events can be one or more, and can be application events or system events. Among them, application events refer to events generated by other applications running on the hardware acceleration module that require obtaining the current memory usage information of the first application, such as memory overflow events or data migration events, etc.; correspondingly, system events refer to events generated by the operating system of the device where the hardware acceleration module is located that require obtaining the current memory usage information of the first application, such as memory-related system crash events or system operation abnormality events, etc. Application events can be flexibly set according to the application conditions running on the hardware acceleration module. The following examples illustrate application events:
[0042] In addition to the first application, the applications running on the hardware acceleration module may also include the second application. The memory usage of the first application will affect the second application. Of course, the impact of the memory usage of the first application on the second application will be different depending on the second application. The events that depend on the current memory usage information of the first application during the operation of the second application can be pre-set and referred to as preset events. Of course, the preset events will also be different depending on the second application. Based on this, during the operation of the second application, it is possible to monitor whether the preset event occurs; when the preset event is monitored, the second dynamic link library saved on the preset path is loaded, and the third dynamic link library is accessed based on the second dynamic link library; in the process of accessing the third dynamic link library, the target memory management function in the third dynamic link library can be called to obtain the current memory usage information of the first application through the target memory management function.
[0043] In the embodiments disclosed herein, the implementation method of loading the second dynamic link library in response to a trigger event is not limited. For example, the operation of loading the second dynamic link library and subsequent operations can be automatically executed when a trigger event is detected. For another example, when a trigger event is detected, a command window can be displayed, and the command window contains prompt information, which is used to prompt that the current memory usage information of the first application needs to be obtained; the target command for obtaining the current memory usage information of the first application entered by the user in the command window according to the prompt information is obtained; and in response to the target command, the operation of loading the second dynamic link library saved in the preset path and subsequent operations are executed.
[0044] Optionally, the second application may be an application that shares memory with the first application, and accordingly, the preset event may be an event in which the second application fails to apply for memory resources. Alternatively, the second application may be an application responsible for migrating the memory data of the first application, and accordingly, the preset event may be an event in which the second application migrates the memory data of the first application. Regardless of the type of application, after obtaining the current memory usage information of the first application, the second application performs a processing operation corresponding to the triggering event based on the current memory usage information of the first application, specifically: processing the preset event based on the current memory usage information of the first application.
[0045] Optionally, if the preset event is an event in which the second application fails to apply for memory resources, the preset event is processed according to the current memory usage information of the first application, including: determining the amount of releasable memory resources in the memory resources occupied by the first application according to the current memory usage information of the first application; and releasing at least part of the memory resources occupied by the first application according to the amount of releasable memory resources. The memory resources occupied by the first application are greater than or equal to the memory resources currently used by the first application. For example, the memory resources occupied by the first application are 500M, but the memory resources currently used by the first application are 100M, and the amount of releasable memory resources in the memory resources occupied by the first application is 400M. Therefore, any memory resources not exceeding 400M can be released, and the released memory resources can be allocated to the second application for use, which is conducive to the second application applying for sufficient memory resources. When the first application is a model training application, such as a model training framework running on a hardware acceleration module, and the model training framework adopts caching technology, during the model training process, in each iteration round, it can be determined whether the memory resources occupied by the previous iteration round meet the memory resource requirements of the current iteration round. If the memory resources occupied by the previous iteration round are less than the memory resources required by the current iteration round, the model training application can initiate a memory application request; at this time, the function for memory management can receive a memory application request initiated by the model training application when the memory resources occupied by the previous iteration round are less than the memory resources required by the current iteration round, and allocate new memory resources to the model training application according to the memory application request to obtain the memory resources occupied by the current iteration round. The memory resources occupied by the current iteration round include the memory resources occupied by the previous iteration round and the newly added memory resources; of course, due to the memory caching technology, when the memory resources occupied by the previous iteration round are greater than the memory resources required by the current iteration round, the memory resources occupied by the previous iteration round can be directly used as the memory resources occupied by the current iteration round, and the memory resources will not be automatically released. If an event occurs in which a second application fails to apply for memory resources in a certain iteration round during the model training process, various operations in the embodiments of the present disclosure may be triggered to obtain the memory usage of the model training application in the iteration round, and then compare it with the currently occupied memory resources to determine whether the model training application has releasable memory resources in the iteration round; if so, at least part of the memory resources occupied by the model training application in the iteration round are released based on the releasable memory resources in the iteration round, and at least part of the released memory resources are allocated to the second application. It should be noted that when releasing memory resources, the model training application should ensure that the amount of retained memory resources is not less than its usage.
[0046] Optionally, if the preset event is an event in which the second application migrates the memory data of the first application, the preset event is processed according to the current memory usage information of the first application, including: determining the memory resources to be migrated in the memory resources occupied by the first application according to the current memory usage information of the first application; wherein the memory resources to be migrated are the memory resources currently used by the first application, and the data in the memory resources to be migrated are migrated. Among them, the memory resources occupied by the first application are greater than or equal to the memory resources currently used by the first application, that is, the memory resources to be migrated. For example, the memory resources occupied by the first application are 500M, and the memory resources currently used are 300M. The second application only needs to migrate the data in the 300M memory resources currently used by the first application. The data in the remaining 200M memory resources are outdated or invalid data, and there is no need to migrate data, which can save the amount of resources consumed by data migration.
[0047] In an embodiment of the present disclosure, a second dynamic link library is obtained by rewriting the first dynamic link library, a function for accessing a third dynamic link library is implemented in the second dynamic link library, and the second dynamic link library is injected in advance with the aid of a library hijacking technique. In this way, when a trigger event occurs that requires obtaining the current memory usage information of the first application, the second dynamic link library can be loaded, and access to the third dynamic link library is achieved based on the second dynamic link library, and then the target memory management function in the third dynamic link library is called to obtain the current memory usage information of the application. The current memory usage information of the application can be accurately obtained without intruding on the application, which is conducive to solving various memory problems caused by unreasonable application memory usage, such as memory overflow problems and resource waste problems. In particular, when the first application and the second application are run simultaneously on the hardware acceleration module, the method provided by the embodiment of the present disclosure is non-invasive to both the first application and the second application while accurately obtaining the current memory usage information of the first application, and has universal applicability.
[0048] In the embodiment of the present disclosure, the first application may have different version information, and different version information may result in different names and data structures of the target memory management functions contained in the corresponding third dynamic library. Based on this, as shown in FIG1d , an optional implementation method of accessing the third dynamic link library based on the second dynamic link library includes the following operations:
[0049] 1021. Call a target library function for memory information processing in a second dynamic link library to perform the following operations, where the target library function is used to implement an implicit call function to a target memory management function.
[0050] 1022. Obtain a name of a third dynamic link library opened by the first application and attribute information of the first application, where the attribute information includes at least version information;
[0051] 1023. Determine the name and data structure of the target memory management function included in the third dynamic link library based on the version information of the first application.
[0052] 1024. Open the third dynamic link library according to the name of the third dynamic link library, and find the target memory management function in the third dynamic link library according to the name and data structure of the target memory management function.
[0053] Furthermore, as shown in FIG1d , after step 1024 , the method further includes: step 1025 , calling a target memory management function in a third dynamic link library to obtain current memory usage information of the first application.
[0054] Optionally, obtaining the name of the third dynamic link library opened by the first application and the attribute information of the first application includes: accessing the memory management file corresponding to the first application in the file system to which the hardware acceleration module belongs, the memory management file recording the mapping information of the virtual address space of the first application, the virtual address space is the address space of the virtual memory allocated to the first application, and the virtual memory allocated to the first application corresponds to the physical memory on the hardware acceleration module. The mapping information of the virtual address space includes the names and storage addresses of the various resource files of the first application mapped (or stored) in the virtual address space; traversing the names of the files mapped to the virtual address space, the file name with a specified suffix can be obtained as the name of the third dynamic link library, wherein the specified suffix identifies the third dynamic link library, and the file name with the specified suffix is the name of the third dynamic link library; in addition, the resource package file corresponding to the first application can be accessed to obtain the attribute information of the first application from the resource package file, and the resource package file stores the attribute information of the first application, such as type, version information, application provider, etc. The resource package file is also stored in the virtual address space allocated to the first application. Therefore, while traversing the names of the files mapped to the virtual address space, the path information of the resource package file can be obtained at the same time, and the resource package file can be accessed based on the path information.
[0055] Further optionally, the correspondence between the application version of the first application and the name and data structure of the memory management function can be pre-maintained in the second dynamic link library, and the correspondence can be dynamically updated as the application version is updated. Based on this, after obtaining the version information of the first application, the name and data structure of the target memory management function contained in the third dynamic link library are determined according to the version information of the first application, including: according to the version information of the first application, querying the correspondence between the pre-maintained application version and the name and data structure of the memory management function to obtain the name and data structure of the target memory management function; wherein, the correspondence is dynamically updated as the version of the first application is updated. Optionally, a custom class (Class) can be defined in the second dynamic link library, and the correspondence between the application version of the first application and the name and data structure of the memory management function can be saved through this class. "Class" is the basis for object-oriented programming (OOP) to implement information encapsulation. It is a user-defined reference data type and belongs to the prior art and will not be described in detail here.
[0056] Optionally, opening the third dynamic link library according to the name of the third dynamic link library includes: using the name of the third dynamic link library as an input parameter of a file open command, and executing the file open command to open the third dynamic link library. The file open command is a command provided by the operating system for opening a library file and loading it into memory. The file open command may vary depending on the operating system. Taking the Linux operating system as an example, the file open command may be dlopen().
[0057] Further optionally, after opening the third dynamic link library, the target memory management function is found in the third dynamic link library according to the name and data structure of the target memory management function, including: determining the existence status of the target memory management function in the third dynamic link library according to the version information of the first application; if the target memory management function exists directly in the third dynamic link library, executing the dynamic library loading function according to the name and data structure of the target memory function to obtain the target function pointer corresponding to the target memory management function, so as to call the target memory management function through the target function pointer; if the target memory management function exists in the third dynamic link library as a member function of a class, executing a file viewing command to view the dynamic symbol table in the third dynamic link library, the dynamic symbol table containing each method name and its method address; obtaining the target method name and global variable corresponding to the target memory management function from the dynamic symbol table, so as to call the target memory management function through the target method name and global variable.
[0058] Depending on the version of the first application, the existence status of the target memory management function in the third dynamic link library will be different. For example, in some versions, the target memory management function exists directly in the third dynamic link library. By executing the dynamic library loading function, the target function pointer corresponding to the target memory management function can be directly obtained. The target function pointer points to the target memory management function, and the target memory management function can be called through the target function pointer. The dynamic library loading function is a command provided by the operating system for searching for related functions (or symbols) in an open library file. Depending on the operating system, the dynamic library loading function will be different. Taking the Linux operating system as an example, the file opening command can be dlsym(). For example, in some other versions, the target memory management function may be encapsulated and exist in a third dynamic link library. It is common to encapsulate it as a member function of a class into a class and then exist in the third dynamic link library as a member function of the class. In this case, the target memory management function cannot be directly found by executing the dynamic library load function. Instead, a file viewing command can be executed to view the dynamic symbol table in the third dynamic link library. The dynamic symbol table contains various method names and their method addresses; the target method name and global variable corresponding to the target memory management function are obtained from the dynamic symbol table, wherein the target method name and global variable point to the member function of the class encapsulating the target memory management function, that is, the target memory management function can be called through the target method name and global variable. In the embodiment of the present disclosure, the target method name and global variable are not limited. All method names and global variables that comply with OOP programming rules are applicable to the embodiment of the present disclosure. The file viewing command is a command provided by the operating system for viewing file information. For example, it can view the dynamic symbol table contained in the dynamic link library or view information about the executable file. The file viewing command will vary depending on the operating system. Taking the Linux operating system as an example, the file open command can be readelf().
[0059] Further optionally, the target memory management function in the third dynamic link library is called to obtain the current memory usage information of the first application, including: if the target memory management function exists directly in the third dynamic link library, the target function pointer pointing to the target memory management function can be obtained, and the target memory management function can be called according to the target function pointer to enable the target memory management function to obtain and return the current memory usage information of the first application; if the target memory management function exists in the third dynamic link library as a member function of a class, the target memory management function can be called according to the target method name and global variables to enable the target memory management function to obtain and return the current memory usage information of the first application.
[0060] Further optionally, after obtaining the current memory usage information of the first application, the current memory usage information of the first application can also be output. The embodiments of the present disclosure do not limit the specific implementation method of outputting the current memory usage information of the first application. For example, the current memory usage information of the first application can be output through screen display (such as a pop-up window or page); or, the current memory usage information of the first application can be output by sending an email; or, the current memory usage information of the first application can be output by text message, or, the current memory usage information of the first application can be output by voice, or, the current memory usage information of the first application can be output by printing, etc.
[0061] It should be noted that the technical solution provided by the embodiments of the present disclosure is universal and can be applied to various hardware acceleration modules such as GPU, TPU, and is not limited to the first application, second application, etc. running on the hardware acceleration module. In some optional embodiments of the present disclosure, the first application can be a model training application implemented based on a deep learning framework. Model training is carried out with the help of a hardware acceleration module to accelerate the speed and efficiency of model training. Among them, the deep learning framework can be a Pytorch framework or a tensorflow framework. PyTorch is an open source Python-first deep learning framework, and Python is a simple computer programming language. Tensorflow is an open source framework for machine learning that can be used to quickly build neural networks, and quickly train, evaluate and save networks. It is mainly used for machine learning for perception and language understanding tasks.
[0062] In these deep learning frameworks, the model training process includes forward propagation, backpropagation, and parameter updates. Model parameters and sample data used for training are often stored in the memory of a hardware acceleration module (such as a GPU) and used for subsequent calculations. Furthermore, forward propagation calculates model loss using sample data and model parameters. This loss and some intermediate results, such as feature maps, are also often cached in the memory of the hardware acceleration module (such as a GPU) for subsequent backpropagation calculations. During backpropagation, the gradients of the model parameters are calculated using information such as the loss and feature maps stored in the memory of the hardware acceleration module (such as a GPU). Finally, the model parameters are updated based on the gradients.
[0063] The cache technology is used in the above-mentioned deep learning framework. Based on this cache mechanism, tensors from the same shape and data type can be allocated to the same block of memory, and in a forward propagation-backward propagation iteration, memory resources that are not actually used can continue to be retained, which can facilitate the use of memory resources for the next iteration and help improve training efficiency. This cache mechanism allows the deep learning framework to retain memory resources that are not actually used, which may also cause other problems in some scenarios. The solution provided by the embodiment of the present disclosure can obtain memory usage information in the current iteration round of the model training process on demand without intruding these deep learning frameworks during the model training process based on these deep learning frameworks, and perform corresponding processing on the affected trigger events based on the memory usage information in the current iteration round.
[0064] Below, taking the first application as an example, which is a model training application based on the Pytorch framework, and taking the hardware acceleration module running the model training application as a GPU, and the operating system of the device where the GPU is located as a Linux system as an example, the memory information processing method provided by the embodiment of the present disclosure is described in detail.
[0065] The GPU provides the CUDA dynamic link library for applications, which is the first dynamic link library mentioned above. The CUDA dynamic link library provides the memory allocation function cudaMalloc() and the memory release function cudaFree(). In the Pytorch framework, GPU memory can be applied for and released through cudaMalloc() and cudaFree() in the CUDA dynamic link library provided by the GPU for applications. In order to avoid frequent calls to cudaMalloc() and cudaFree(), a cache mechanism is adopted, which allows locking of GPU memory that is not actually used. In addition, in the Pytorch framework, its virtual address space is divided into several segments. Different segments correspond to the GPU memory applied for each call to cudaMalloc(), and the corresponding data structure is maintained to store information about the currently used GPU memory.
[0066] In addition, the Pytorch framework allows for the management of the requested GPU memory, thereby enabling the reuse of GPU memory. The Pytorch framework comes with a built-in dynamic link library required for using the GPU, namely the third dynamic link library. The third dynamic link library includes functions related to memory management, namely some APIs in the cache allocator (cachingAllocator). Through these APIs, information related to the currently used GPU memory can be obtained, thereby enabling the management of the requested GPU memory. Taking Pytorch as an example, Pytorch provides two APIs in version 1.1xx: snapshot and getDeviceStatus. These two APIs can obtain information about the current GPU memory usage. Snapshot can obtain relevant information about all currently used GPU memory, including the memory start address, address block size, and whether the memory is active, while getDeviceStatus can obtain summary information about the current GPU memory and the total size of the currently active memory.
[0067] In the disclosed embodiment, the CUDA dynamic link library is rewritten and compiled to obtain a rewritten CUDA dynamic link library. The rewritten CUDA dynamic link library can call some APIs in cachingAllocator to obtain memory usage information of the model training application in the current round of iteration. The rewritten CUDA dynamic link library is the second dynamic link library mentioned above. The process of calling some APIs in cachingAllocator based on the rewritten CUDA dynamic link library to obtain memory usage information of the Pytorch process in the current round of iteration includes:
[0068] (1) Get the dynamic link library used by the Pytorch process, that is, the dynamic link library containing cachingAllocator;
[0069] (2) Get the version information of Pytorch;
[0070] (3) Obtain the name of the function used for GPU memory management and the related data structure under the version information;
[0071] (4) Make a function call using the name of the function used for GPU memory management under the version information and the related data structure to obtain GPU memory usage information.
[0072] (1) Get the dynamic link library used by the Pytorch process
[0073] By setting the LD_PRELOAD environment variable, the rewritten CUDA dynamic link library can be loaded first before the Pytorch process starts.
[0074] Within the rewritten CUDA dynamic link library, the mapping information for the virtual address space of the model training application belonging to the Pytorch process is obtained by reading the mapping (maps) file in the / proc / self / maps directory in the Linux file system. By parsing the maps file, the mapping information for all virtual address spaces of the Pytorch process can be obtained, from which information about all files opened by the Pytorch process can be obtained. By traversing all file information mapped into the virtual address space, the system searches for files with the suffix libc10_cuda.so in the file name. If so, the dynamic link library containing the cachingAllocator used by the Pytorch process is determined. The proc directory on the Linux system is a file system, namely the proc file system. Unlike common file systems, proc is a pseudo-file system (i.e., a virtual system) that stores a series of files (i.e., library functions in context) that represent the current kernel running state. Users can use these files to view information about the system hardware and currently running processes, and can even change the kernel running state by modifying certain files. The maps file is an example of the memory management file mentioned above.
[0075] (2) Get Pytorch version information
[0076] Inside the rewritten CUDA dynamic link library, in the process of obtaining the dynamic link library containing cachingAllocator, the directory where the dynamic link library is located can be obtained, which is generally in the form of: / xxx / xx / torch / lib / libc10_cuda.so. Among them, through this directory, the directory where the init.py file corresponding to the Pytorch process is located can be obtained, which is generally / xxx / xx / torch / init.py. In the / xxx / xx / torch / directory where init.py is located, the information in the version.py file can be read to obtain the version information of Pytorch. Among them, the init.py file is a file used to manage related Python modules in the Pytorch framework, and the version.py file is a file used to store the version information of Pytorch. Both belong to the existing technology and will not be described in detail here. Among them, init.py and version.py are examples of resource package files mentioned above.
[0077] (3) Obtain the name of the function used for GPU memory management and the related data structure under the version information;
[0078] As Pytorch is updated and iterated, the names of the dynamic link libraries used by Pytorch, as well as the names of the functions and data structures contained in these dynamic link libraries for managing GPU memory information, will change. In this case, as Pytorch is updated and iterated, the resource packages of the new versions of Pytorch can be parsed to obtain the mapping between the names of the dynamic link libraries corresponding to the current version of Pytorch and the names and data structures of the functions used to manage GPU memory information, and then updated to the custom class in this case. Pytorch version information includes but is not limited to: versions 1.13.1 and earlier and versions 2.0.0 and later.
[0079] In this case, a custom class is created in the rewritten CUDA dynamic link library. This custom class is used to pre-store the names and data structures of the functions used to manage GPU memory information under each Pytorch version. This defined class is part of the functionality of the rewritten CUDA dynamic link library. Within the rewritten CUDA dynamic link library, based on the directory information / xxx / xx / torch / lib / libc10_cuda.so mentioned above, the dynamic link library containing cachingAllocator under the current version information can be opened using the dlopen command. The various library functions contained in the dynamic link library can then be called. Based on the names and data structures of the functions used to manage GPU memory information under the current version information stored in the custom class above, the functions used to manage GPU memory information, namely the two APIs snapshot and getDeviceStatus, can be obtained.
[0080] Specifically, before Pytorch version 1.13.1, the snapshot / getDeviceStatus APIs existed directly in the dynamic link library containing the cachingAllocator. Therefore, the corresponding function pointer could be directly obtained by providing the corresponding function name through the dynamic library loading function dlsym, and then the obtained function pointer could be used to obtain GPU memory usage information.
[0081] After PyTorch version 2.0.0, the snapshot / getDeviceStatus APIs were additionally encapsulated. The original APIs were encapsulated within a new class and made available as class member functions. However, class member functions were no longer treated as dynamic symbols, making it impossible to obtain direct function addresses using dlsym. To address this issue, the readelf command was used to retrieve all symbols from the dynamic link library containing the cachingAllocator class. This allowed the APIs corresponding to the snapshot and getDeviceStatus methods to be moved into the class. Furthermore, the symbols retrieved through the readelf command also allowed the global variables defined by the cachingAllocator class. After locating the global variables, the function names needed to call snapshot and getDeviceStatus were obtained. Since C++ class calls actually use a pointer to the class object as the first argument, a method similar to SnapShot(pointer_to_allocator) was used to call these functions. Symbols in dynamic link libraries primarily refer to method symbols (or method names) and their corresponding method addresses.
[0082] Furthermore, the target memory management function is called based on the target function pointer or the target method name and global variables, so that the target memory management function obtains and returns the current memory usage information of the model training application. For example, the call can be performed using the command line "Kill -s SIGUSR1 `pidof python`". After obtaining the current memory usage information of the model training application, the current memory usage information of the model training application can be output to the screen, email, text message, etc.
[0083] This embodiment uses the LD_PRELOAD environment variable to introduce some required operations (i.e., the rewritten CUDA dynamic link library) into the virtual address space of the process before the process actually runs. It then implicitly calls the dynamic link library and memory management-related functions used by the Pytorch process through commands such as dlopen / dlsym to obtain GPU memory usage information. This implementation does not require the user to modify any Pytorch framework code or use a customized Pytorch framework. While obtaining GPU memory usage information for the Pytorch framework, it achieves a Pytorch-insensitive and non-invasive approach.
[0084] FIG2 is a schematic diagram of the structure of a memory information processing device provided by an embodiment of the present disclosure. The device is applied to a hardware acceleration module. The hardware acceleration module provides a first dynamic link library for applications. The applications running on the hardware acceleration module include at least the first application. As shown in FIG2 , the device includes:
[0085] a dynamic link library access module 21 for responding to a trigger event for obtaining current memory usage information of the first application and accessing a third dynamic link library based on rewriting the first dynamic link library, where the third dynamic link library is a dynamic link library provided by the first application for using the hardware acceleration module;
[0086] A memory usage information acquisition module 23 is configured to call a target memory management function in a third dynamic link library to acquire current memory usage information of the first application, where the current memory usage information represents current usage of memory resources of the hardware acceleration module by the first application;
[0087] The memory information processing module 22 is configured to execute a processing operation corresponding to a triggering event according to the current memory usage information of the first application.
[0088] In an optional embodiment, the dynamic link library access module 21 is specifically used to: respond to a trigger event of obtaining the current memory usage information of the first application, load a second dynamic link library stored in a preset path, where the second dynamic link library is a dynamic link library rewritten based on the first dynamic link library; and access the third dynamic link library based on the second dynamic link library.
[0089] In an embodiment of the present disclosure, the application running on the hardware acceleration module also includes a second application; based on this, when the dynamic link library access module 21 responds to a trigger event for obtaining the current memory usage information of the first application and loads the second dynamic link library stored on a preset path, it is specifically used to: monitor whether a preset event occurs during the running of the second application, and the preset event refers to an event that depends on the current memory usage information of the first application; when a preset event is detected, load the second dynamic link library stored on the preset path.
[0090] Correspondingly, the memory information processing module 22 is specifically configured to process a preset event according to the current memory usage information of the first application after obtaining the current memory usage information of the first application.
[0091] Optionally, when the memory information processing module 22 is used to process a preset event based on the current memory usage information of the first application, it is specifically used to: if the preset event is an event in which the second application fails to apply for memory resources, determine the amount of releasable memory resources in the memory resources occupied by the first application based on the current memory usage information of the first application; release at least part of the memory resources occupied by the first application based on the amount of releasable memory resources; and / or if the preset event is an event in which the second application migrates the memory data of the first application, determine the memory resources to be migrated in the memory resources occupied by the first application based on the current memory usage information of the first application; and migrate the data in the memory resources to be migrated.
[0092] In an optional embodiment, when the dynamic link library access module 21 is used to access the third dynamic link library based on the second dynamic link library, it is specifically used to: call the target library function for memory information processing in the second dynamic link library to perform the following operations: obtain the name of the third dynamic link library opened by the first application and the attribute information of the first application, the attribute information including at least version information; determine the name and data structure of the target memory management function contained in the third dynamic link library based on the version information of the first application; open the third dynamic link library based on the name of the third dynamic link library, and find the target memory management function in the third dynamic link library based on the name and data structure of the target memory management function.
[0093] Optionally, when the dynamic link library access module 21 is used to obtain the name of the third dynamic link library opened by the first application and the version information of the first application, it is specifically used to: access the memory management file corresponding to the first application in the file system to which the hardware acceleration module belongs, and the memory management file records the mapping information of the virtual address space of the first application; traverse the files mapped to the virtual address space to obtain the file name with a specified suffix as the name of the third dynamic link library, and the specified suffix identifies the dynamic link library; access the resource package file corresponding to the first application, and obtain the attribute information of the first application from the resource package file.
[0094] Optionally, when the dynamic link library access module 21 is used to determine the name and data structure of the target memory management function contained in the third dynamic link library based on the version information of the first application, it is specifically used to: query the correspondence between the pre-maintained application version and the name and data structure of the memory management function based on the version information of the first application, and obtain the name and data structure of the target memory management function; wherein the correspondence is dynamically updated as the version of the first application is updated.
[0095] Optionally, when the dynamic link library access module 21 is used to open the third dynamic link library according to its name, it is specifically used to: use the name of the third dynamic link library as an input parameter of a file open command, execute the file open command to open the third dynamic link library.
[0096] Optionally, when the dynamic link library access module 21 is used to find the target memory management function in the third dynamic link library based on the name and data structure of the target memory management function, it is specifically used to: determine the existence status of the target memory management function in the third dynamic link library based on the version information of the first application; if the target memory management function exists directly in the third dynamic link library, then execute the dynamic library loading function according to the name and data structure of the target memory function to obtain the target function pointer corresponding to the target memory management function, so as to call the target memory management function through the target function pointer; if the target memory management function exists in the third dynamic link library as a member function of a class, then execute a file viewing command to view the dynamic symbol table in the third dynamic link library, the dynamic symbol table contains various method names and their method addresses; obtain the target method name and global variables corresponding to the target memory management function from the dynamic symbol table, so as to call the target memory management function through the target method name and global variables.
[0097] In the embodiment of the present disclosure, when the memory usage information acquisition module 23 is used to call the target memory management function in the third dynamic link library to obtain the current memory usage information of the first application, it is specifically used to: call the target memory management function according to the target function pointer or target method name and global variables, so that the target memory management function can obtain and return the current memory usage information of the first application.
[0098] In an embodiment of the present disclosure, when the dynamic link library access module 21 is used to respond to a trigger event for obtaining the current memory usage information of the first application and load the second dynamic link library saved on a preset path, it is specifically used to: respond to the trigger event for obtaining the current memory usage information of the first application, display a command window, the command window contains prompt information, and the prompt information is used to prompt that the current memory usage information of the first application needs to be obtained; according to the prompt information, obtain the target command entered by the user in the command window for obtaining the current memory usage information of the first application; and in response to the target command, execute the operation of loading the second dynamic link library saved on the preset path and subsequent operations.
[0099] Further optionally, the device further includes a memory information output module, configured to output current memory information of the first application after acquiring current memory usage information of the first application.
[0100] Further optionally, the hardware acceleration module includes: at least one of a GPU, a TPU, and an ASIC.
[0101] In an optional embodiment, the first application is a model training application implemented based on a deep learning framework, wherein the deep learning framework adopts caching technology to enable the model training application to retain unused memory resources during each round of model training; the preset event processing module is used to release at least part of the memory resources occupied by the first application according to the amount of releasable memory resources, and is specifically used to: in the current iteration round, release at least part of the memory resources occupied by the model training application according to the amount of releasable memory resources.
[0102] It should be noted that the modules or devices provided in this embodiment can implement the technical solutions described in the above embodiments. The specific implementation principles of the above modules or units can be found in the corresponding contents of the above method embodiments, which will not be repeated here.
[0103] FIG3 is a schematic diagram of the structure of a hardware acceleration module provided in an embodiment of the present disclosure. The hardware acceleration module provides a first dynamic link library for applications, and the applications running on the hardware acceleration module include at least the first application. As shown in FIG3 , the hardware acceleration module includes: a storage unit 30a and a processing unit 30b. The storage unit 30a is used to store the computer program corresponding to the above-mentioned memory information processing method, and the processing unit 30b is coupled to the storage unit 30a and is used to execute the computer program corresponding to the above-mentioned memory information processing method for the following steps:
[0104] In response to a triggering event for obtaining current memory usage information of a first application, access to a third dynamic link library is achieved based on rewriting the first dynamic link library, where the third dynamic link library is a dynamic link library that comes with the first application and is used to use a hardware acceleration module; a target memory management function in the third dynamic link library is called to obtain current memory usage information of the first application, where the current memory usage information represents the current usage of memory resources of the hardware acceleration module by the first application; and a processing operation corresponding to the triggering event is executed based on the current memory usage information of the first application.
[0105] When the processing unit 30b responds to the triggering event of obtaining the current memory usage information of the first application and implements access to the third dynamic link library based on rewriting the first dynamic link library, it is specifically used to: respond to the triggering event of obtaining the current memory usage information of the first application, load the second dynamic link library saved on a preset path, where the second dynamic link library is a dynamic link library obtained by rewriting the first dynamic link library; and access the third dynamic link library based on the second dynamic link library.
[0106] In an embodiment of the present disclosure, the application running on the hardware acceleration module also includes a second application; based on this, when the processing unit 30b is used to respond to a trigger event for obtaining the current memory usage information of the first application and load the second dynamic link library stored on a preset path, it is specifically used to: monitor whether a preset event occurs during the running of the second application, and the preset event refers to an event that depends on the current memory usage information of the first application; when the preset event is detected, load the second dynamic link library stored on the preset path; accordingly, after obtaining the current memory usage information of the first application, the processing unit 30b is also used to process the preset event according to the current memory usage information of the first application.
[0107] Optionally, when the processing unit 30b is used to process a preset event based on the current memory usage information of the first application, it is specifically used to: if the preset event is an event in which the second application fails to apply for memory resources, determine the amount of releasable memory resources in the memory resources occupied by the first application based on the current memory usage information of the first application; release at least part of the memory resources occupied by the first application based on the amount of releasable memory resources; and / or if the preset event is an event in which the second application migrates the memory data of the first application, determine the memory resources to be migrated in the memory resources occupied by the first application based on the current memory usage information of the first application; and migrate the data in the memory resources to be migrated.
[0108] In an optional embodiment, when the processing unit 30b is used to access the third dynamic link library based on the second dynamic link library, it is specifically used to: call the target library function for memory information processing in the second dynamic link library to perform the following operations: obtain the name of the third dynamic link library opened by the first application and the attribute information of the first application, the attribute information including at least version information; determine the name and data structure of the target memory management function contained in the third dynamic link library based on the version information of the first application; open the third dynamic link library based on the name of the third dynamic link library, and find the target memory management function in the third dynamic link library based on the name and data structure of the target memory management function.
[0109] Optionally, when the processing unit 30b is used to obtain the name of the third dynamic link library opened by the first application and the version information of the first application, it is specifically used to: access the memory management file corresponding to the first application in the file system to which the hardware acceleration module belongs, the memory management file recording the mapping information of the virtual address space of the first application; traverse the files mapped to the virtual address space to obtain the file name with a specified suffix as the name of the third dynamic link library, the specified suffix identifies the dynamic link library; access the resource package file corresponding to the first application, and obtain the attribute information of the first application from the resource package file.
[0110] Optionally, when the processing unit 30b is used to determine the name and data structure of the target memory management function contained in the third dynamic link library based on the version information of the first application, it is specifically used to: query the correspondence between the pre-maintained application version and the name and data structure of the memory management function based on the version information of the first application, and obtain the name and data structure of the target memory management function; wherein the correspondence is dynamically updated as the version of the first application is updated.
[0111] Optionally, when the processing unit 30b is used to open the third dynamic link library according to the name of the third dynamic link library, it is specifically used to: use the name of the third dynamic link library as an input parameter of a file open command, execute the file open command, and open the third dynamic link library.
[0112] Optionally, when the processing unit 30b is used to find the target memory management function in the third dynamic link library based on the name and data structure of the target memory management function, it is specifically used to: determine the existence status of the target memory management function in the third dynamic link library based on the version information of the first application; if the target memory management function exists directly in the third dynamic link library, execute the dynamic library loading function according to the name and data structure of the target memory function to obtain the target function pointer corresponding to the target memory management function, so as to call the target memory management function through the target function pointer; if the target memory management function exists in the third dynamic link library as a member function of a class, execute a file viewing command to view the dynamic symbol table in the third dynamic link library, the dynamic symbol table contains various method names and their method addresses; obtain the target method name and global variables corresponding to the target memory management function from the dynamic symbol table, so as to call the target memory management function through the target method name and global variables.
[0113] In the embodiment of the present disclosure, when the processing unit 30b is used to call the target memory management function in the third dynamic link library to obtain the current memory usage information of the first application, it is specifically used to: call the target memory management function according to the target function pointer or target method name and global variables, so that the target memory management function can obtain and return the current memory usage information of the first application.
[0114] In an embodiment of the present disclosure, when the processing unit 30b is used to respond to a trigger event for obtaining the current memory usage information of the first application and load the second dynamic link library saved on a preset path, it is specifically used to: respond to the trigger event for obtaining the current memory usage information of the first application, display a command window, the command window containing prompt information, the prompt information being used to prompt that the current memory usage information of the first application needs to be obtained; according to the prompt information, obtain the target command entered by the user in the command window for obtaining the current memory usage information of the first application; and in response to the target command, execute the operation of loading the second dynamic link library saved on the preset path and subsequent operations.
[0115] Further optionally, after obtaining the current memory usage information of the first application, the processing unit 30b is further configured to output the current memory information of the first application.
[0116] Further optionally, the hardware acceleration module includes: at least one of a GPU, a TPU, and an ASIC.
[0117] In an optional embodiment, the first application is a model training application implemented based on a deep learning framework, wherein the deep learning framework adopts a caching technology to enable the model training application to retain unused memory resources during each round of model training; the processing unit 30b is further used to: during the model training process, receive a memory application request initiated when the memory resources occupied by the model training application in the previous iteration round are less than the memory resources required by the current iteration round, allocate new memory resources to the model training application according to the memory application request to obtain the memory resources occupied by the current iteration round; and when the memory resources occupied by the previous iteration round are greater than the memory resources required by the current iteration round, directly use the memory resources occupied by the previous iteration round as the memory resources occupied by the current iteration round. Based on this, when the processing unit 30b is used to release at least part of the memory resources occupied by the first application according to the amount of releasable memory resources, it is specifically used to: determine the iteration round corresponding to the event of the failure of the second application to apply for memory resources, and release at least part of the memory resources occupied by the model training application in the iteration round according to the amount of releasable memory resources in the iteration round.
[0118] Furthermore, as shown in FIG3 , the electronic device further includes other components such as a communication unit 30 c and a power supply unit 30 d.
[0119] It should be noted that the modules or devices provided in this embodiment can implement the technical solutions described in the above embodiments. The specific implementation principles of the above modules or units can be found in the corresponding contents of the above method embodiments, which will not be repeated here.
[0120] FIG4 is a schematic diagram of the structure of an electronic device provided by an embodiment of the present disclosure. As shown in FIG4 , the electronic device includes a hardware acceleration module 40. The hardware acceleration module 40 provides a first dynamic link library for applications, and the applications running on the hardware acceleration module 40 include at least a first application. The hardware acceleration module 40 includes a storage unit 40a and a first processing unit 40b. The storage unit 40a is used to store a computer program corresponding to the memory information processing method. The first processing unit 40b is coupled to the storage unit 40a and is used to execute the computer program corresponding to the memory information processing method to perform the following steps:
[0121] In response to a triggering event for obtaining current memory usage information of a first application, access to a third dynamic link library is achieved based on rewriting the first dynamic link library, where the third dynamic link library is a dynamic link library provided by the first application for using a hardware acceleration module; a target memory management function in the third dynamic link library is called to obtain current memory usage information of the first application, where the current memory usage information represents the first application's current usage of memory resources of the hardware acceleration module.
[0122] When the first processing unit 40b responds to a triggering event for obtaining the current memory usage information of the first application and implements access to the third dynamic link library based on rewriting the first dynamic link library, it is specifically used to: respond to the triggering event for obtaining the current memory usage information of the first application, load a second dynamic link library saved on a preset path, where the second dynamic link library is a dynamic link library obtained by rewriting the first dynamic link library; and access the third dynamic link library based on the second dynamic link library.
[0123] In an embodiment of the present disclosure, the application running on the hardware acceleration module also includes a second application; based on this, when the first processing unit 40b is used to respond to a trigger event for obtaining the current memory usage information of the first application and load the second dynamic link library stored on a preset path, it is specifically used to: monitor whether a preset event occurs during the running of the second application, and the preset event refers to an event that depends on the current memory usage information of the first application; when the preset event is monitored, load the second dynamic link library stored on the preset path; accordingly, after obtaining the current memory usage information of the first application, the first processing unit 40b is also used to process the preset event according to the current memory usage information of the first application.
[0124] Optionally, when the first processing unit 40b is used to process a preset event based on the current memory usage information of the first application, it is specifically used to: if the preset event is an event in which the second application fails to apply for memory resources, determine the amount of releasable memory resources in the memory resources occupied by the first application based on the current memory usage information of the first application; release at least part of the memory resources occupied by the first application based on the amount of releasable memory resources; and / or if the preset event is an event in which the second application migrates the memory data of the first application, determine the memory resources to be migrated in the memory resources occupied by the first application based on the current memory usage information of the first application; and migrate the data in the memory resources to be migrated.
[0125] In an optional embodiment, when the first processing unit 40b is used to access the third dynamic link library based on the second dynamic link library, it is specifically used to: call the target library function for memory information processing in the second dynamic link library to perform the following operations: obtain the name of the third dynamic link library opened by the first application and the attribute information of the first application, which attribute information includes at least version information; determine the name and data structure of the target memory management function contained in the third dynamic link library based on the version information of the first application; open the third dynamic link library based on the name of the third dynamic link library, and find the target memory management function in the third dynamic link library based on the name and data structure of the target memory management function.
[0126] Optionally, when the first processing unit 40b is used to obtain the name of the third dynamic link library opened by the first application and the version information of the first application, it is specifically used to: access the memory management file corresponding to the first application in the file system to which the hardware acceleration module belongs, the memory management file recording the mapping information of the virtual address space of the first application; traverse the files mapped to the virtual address space to obtain the file name with a specified suffix as the name of the third dynamic link library, the specified suffix identifies the dynamic link library; access the resource package file corresponding to the first application, and obtain the attribute information of the first application from the resource package file.
[0127] Optionally, when the first processing unit 40b is used to determine the name and data structure of the target memory management function contained in the third dynamic link library based on the version information of the first application, it is specifically used to: query the correspondence between the pre-maintained application version and the name and data structure of the memory management function based on the version information of the first application, and obtain the name and data structure of the target memory management function; wherein the correspondence is dynamically updated as the version of the first application is updated.
[0128] Optionally, when opening the third dynamic link library according to its name, the first processing unit 40b is specifically configured to: use the name of the third dynamic link library as an input parameter of a file open command, and execute the file open command to open the third dynamic link library.
[0129] Optionally, when the first processing unit 40b is used to find the target memory management function in the third dynamic link library according to the name and data structure of the target memory management function, it is specifically used to: determine the existence status of the target memory management function in the third dynamic link library according to the version information of the first application; if the target memory management function exists directly in the third dynamic link library, execute the dynamic library loading function according to the name and data structure of the target memory function to obtain the target function pointer corresponding to the target memory management function, so as to call the target memory management function through the target function pointer; if the target memory management function exists in the third dynamic link library as a member function of a class, execute a file viewing command to view the dynamic symbol table in the third dynamic link library, the dynamic symbol table contains various method names and their method addresses; obtain the target method name and global variables corresponding to the target memory management function from the dynamic symbol table, so as to call the target memory management function through the target method name and global variables.
[0130] In the embodiment of the present disclosure, when the first processing unit 40b is used to call the target memory management function in the third dynamic link library to obtain the current memory usage information of the first application, it is specifically used to: call the target memory management function according to the target function pointer or target method name and global variables, so that the target memory management function can obtain and return the current memory usage information of the first application.
[0131] In an embodiment of the present disclosure, when the first processing unit 40b is used to respond to a trigger event for obtaining the current memory usage information of the first application and load the second dynamic link library saved on a preset path, it is specifically used to: respond to the trigger event for obtaining the current memory usage information of the first application, display a command window, the command window containing prompt information, and the prompt information is used to prompt that the current memory usage information of the first application needs to be obtained; according to the prompt information, obtain the target command entered by the user in the command window for obtaining the current memory usage information of the first application; and in response to the target command, execute the operation of loading the second dynamic link library saved on the preset path and subsequent operations.
[0132] Further optionally, after obtaining the current memory usage information of the first application, the first processing unit 40b is further configured to output the current memory information of the first application.
[0133] Further optionally, the hardware acceleration module includes: at least one of a GPU, a TPU, and an ASIC.
[0134] In an optional embodiment, the first application is a model training application implemented based on a deep learning framework, wherein the deep learning framework adopts a caching technology to enable the model training application to retain unused memory resources during each round of model training; the first processing unit 40b is further used to: during the model training process, receive a memory application request initiated when the memory resources occupied by the model training application in the previous iteration round are less than the memory resources required by the current iteration round, allocate new memory resources to the model training application according to the memory application request to obtain the memory resources occupied by the current iteration round; and when the memory resources occupied by the previous iteration round are greater than the memory resources required by the current iteration round, directly use the memory resources occupied by the previous iteration round as the memory resources occupied by the current iteration round. Based on this, when the first processing unit 40b is used to release at least part of the memory resources occupied by the first application according to the amount of releasable memory resources, it is specifically used to: determine the iteration round corresponding to the event of the failure of the second application to apply for memory resources, and release at least part of the memory resources occupied by the model training application in the iteration round according to the amount of releasable memory resources in the iteration round.
[0135] Furthermore, as shown in FIG4 , the electronic device also includes other components such as a second processing unit 40f, a communication unit 40c, a power supply unit 40d and a display unit 40e. FIG4 only schematically shows some components, which does not mean that the electronic device only includes the components shown in FIG4 . The electronic device of this embodiment can be implemented as an electronic device such as a desktop computer, a laptop computer, a smart phone or an IOT device, or as a server-side device such as a conventional server, a cloud server or a server array. If the electronic device of this embodiment is implemented as a terminal device such as a desktop computer, a laptop computer, a smart phone, etc., it may include the components in the dotted box in FIG4 ; if the electronic device of this embodiment is implemented as a server-side device such as a conventional server, a cloud server or a server array, it may not include the components in the dotted box in FIG4 .
[0136] It should be noted that the modules or devices provided in this embodiment can implement the technical solutions described in the above embodiments. The specific implementation principles of the above modules or units can be found in the corresponding contents of the above method embodiments, which will not be repeated here.
[0137] The embodiment of the present disclosure further provides a computer-readable storage medium storing a computer program. When the computer program is executed by a processor, the processor is caused to implement the steps in the above-described method.
[0138] The above-mentioned memory can be implemented by any type of volatile or non-volatile memory device or a combination thereof, such as static random-access memory (SRAM), electrically erasable programmable read-only memory (EEPROM), erasable programmable read-only memory (EPROM), programmable read-only memory (PROM), read-only memory (ROM), magnetic memory, flash memory, magnetic disk or optical disk.
[0139] The above-mentioned communication component is configured to facilitate wired or wireless communication between the device where the communication component is located and other devices. The device where the communication component is located can access a wireless network based on a communication standard, such as WiFi, 2G, 3G, 4G / LTE, 5G and other mobile communication networks, or a combination thereof. In an exemplary embodiment, the communication component receives a broadcast signal or broadcast-related information from an external broadcast management system via a broadcast channel. In an exemplary embodiment, the communication component also includes a near field communication (NFC) module to facilitate short-range communication. For example, the NFC module can be implemented based on radio frequency identification (RFID) technology, infrared data association (IrDA) technology, ultra-wideband (UWB) technology, Bluetooth (BT) technology and other technologies.
[0140] The above-mentioned display includes a screen, which may include a liquid crystal display (LCD) and a touch panel (TP). If the screen includes a touch panel, the screen may be implemented as a touch screen to receive input signals from the user. The touch panel includes one or more touch sensors to sense touch, slide, and gestures on the touch panel. The touch sensor can not only sense the boundary of the touch or slide action, but also detect the duration and pressure associated with the touch or slide operation.
[0141] The power supply assembly provides power to various components of the device in which the power supply assembly is located. The power supply assembly may include a power management system, one or more power supplies, and other components associated with generating, managing, and distributing power to the device in which the power supply assembly is located.
[0142] The above-mentioned audio component can be configured to output and / or input audio signals. For example, the audio component includes a microphone (MIC), and when the device where the audio component is located is in an operating mode, such as call mode, recording mode, and voice recognition mode, the microphone is configured to receive external audio signals. The received audio signal can be further stored in a memory or sent via a communication component. In some embodiments, the audio component also includes a speaker for outputting audio signals.
[0143] Those skilled in the art will appreciate that the embodiments of the present disclosure may be provided as methods, systems, or computer program products. Therefore, the present disclosure may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Furthermore, the present disclosure may take the form of a computer program product implemented on one or more computer-readable storage media (including but not limited to magnetic disk storage, compact disc read-only memory (CD-ROM), optical storage, etc.) containing computer-usable program code.
[0144] The present disclosure is described with reference to the flowcharts and / or block diagrams of the methods, devices (systems), and computer program products according to the embodiments of the present disclosure. It should be understood that each process and / or box in the flowchart and / or block diagram, as well as the combination of the processes and / or boxes in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device produce a device for implementing the functions specified in one or more processes in the flowchart and / or one or more boxes in the block diagram.
[0145] These computer program instructions may also be stored in a computer-readable memory that can direct a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce a product including an instruction device that implements the functions specified in one or more processes in the flowchart and / or one or more boxes in the block diagram.
[0146] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, so that the instructions executed on the computer or other programmable device provide steps for implementing the functions specified in one or more processes in the flowchart and / or one or more boxes in the block diagram.
[0147] In a typical configuration, a computing device includes one or more processors (Central Processing Unit, CPU), input / output interfaces, network interfaces, and memory.
[0148] Memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. Memory is an example of a computer-readable medium.
[0149] Computer-readable media include permanent and non-permanent, removable and non-removable media that can be used to store information using any method or technology. Information can be computer-readable instructions, data structures, program modules, or other data. Examples of computer storage media include, but are not limited to, phase-change random access memory (PRAM), static random access memory (SRAM), dynamic random access memory (DRAM), other types of random access memory (RAM), read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technologies, compact disc read-only memory (CD-ROM), digital versatile disc (DVD) or other optical storage, magnetic cassettes, magnetic disk storage or other magnetic storage devices, or any other non-transmission media that can be used to store information that can be accessed by a computing device. As defined herein, computer-readable media does not include transitory computer-readable media such as modulated data signals and carrier waves.
[0150] It should also be noted that the terms "comprises," "includes," or any other variations thereof are intended to encompass non-exclusive inclusion, such that a process, method, commodity, or apparatus that includes a series of elements includes not only those elements but also other elements not explicitly listed, or includes elements inherent to such process, method, commodity, or apparatus. In the absence of further limitations, an element defined by the phrase "comprises a ..." does not exclude the presence of other identical elements in the process, method, commodity, or apparatus that includes the element.
[0151] The above are merely examples of the present disclosure and are not intended to limit the present disclosure. Various modifications and variations are possible for those skilled in the art. Any modifications, equivalent substitutions, improvements, etc. made within the spirit and principles of the present disclosure are intended to be included within the scope of the claims of the present disclosure.
Claims
1. A memory information processing method, applied to a hardware acceleration module, wherein the hardware acceleration module provides a first dynamic link library for an application, and the application running on the hardware acceleration module includes at least a first application, and the method comprises: In response to a triggering event of obtaining current memory usage information of the first application, access to a third dynamic link library is implemented based on rewriting the first dynamic link library, where the third dynamic link library is a dynamic link library provided by the first application and used to use the hardware acceleration module; Calling a target memory management function in the third dynamic link library to obtain current memory usage information of the first application, where the current memory usage information represents current usage of the memory resources of the hardware acceleration module by the first application; According to the current memory usage information of the first application, a processing operation corresponding to the triggering event is performed.
2. The method according to claim 1, wherein: In response to a triggering event of obtaining current memory usage information of a first application, access to a third dynamic link library is implemented based on rewriting the first dynamic link library, including: In response to a trigger event of obtaining current memory usage information of the first application, loading a second dynamic link library stored in a preset path, where the second dynamic link library is a dynamic link library obtained by rewriting the first dynamic link library; According to the second dynamic link library, the third dynamic link library is accessed.
3. The method according to claim 2, wherein: The application running on the hardware acceleration module also includes a second application; In response to a triggering event of obtaining current memory usage information of the first application, loading a second dynamic link library stored in a preset path includes: During the running of the second application, monitoring whether a preset event occurs, wherein the preset event refers to an event that depends on the current memory usage information of the first application; When a preset event is detected, a second dynamic link library stored in a preset path is loaded.
4. The method according to claim 3, wherein: Executing a processing operation corresponding to the triggering event according to the current memory usage information of the first application includes: If the preset event is an event in which the second application fails to apply for memory resources, determining the amount of releasable memory resources in the memory resources occupied by the first application according to the current memory usage information of the first application; and releasing at least part of the memory resources occupied by the first application according to the releasable memory resources; and / or If the preset event is an event in which the second application migrates memory data of the first application, memory resources to be migrated from memory resources occupied by the first application are determined based on current memory usage information of the first application; and data in the memory resources to be migrated are migrated.
5. The method according to claim 2, wherein: Accessing a third dynamic link library according to the second dynamic link library comprises: Calling the target library function for memory information processing in the second dynamic link library to perform the following operations: Obtaining a name of a third dynamic link library opened by the first application and attribute information of the first application, wherein the attribute information includes at least version information; Determining, according to the version information of the first application, the name and data structure of the target memory management function included in the third dynamic link library; The third dynamic link library is opened according to the name of the third dynamic link library, and the target memory management function is found in the third dynamic link library according to the name and data structure of the target memory management function.
6. The method according to claim 5, wherein: Acquiring the name of the third dynamic link library opened by the first application and the attribute information of the first application, including: Accessing a memory management file corresponding to the first application in the file system to which the hardware acceleration module belongs, wherein the memory management file records mapping information of a virtual address space of the first application; Traversing the names of files mapped into the virtual address space to obtain a file name with a specified suffix as the name of the third dynamic link library, wherein the specified suffix identifies the third dynamic link library; Access a resource package file corresponding to the first application, and obtain attribute information of the first application from the resource package file.
7. The method according to claim 5, wherein: Determining the name and data structure of the target memory management function included in the third dynamic link library according to the version information of the first application includes: According to the version information of the first application, query the correspondence between the pre-maintained application version and the name and data structure of the memory management function to obtain the name and data structure of the target memory management function; The corresponding relationship is dynamically updated as the version of the first application is updated.
8. The method according to claim 5, wherein: Finding the target memory management function in the third dynamic link library according to the name and data structure of the target memory management function includes: Determine, according to the version information of the first application, the existence status of the target memory management function in the third dynamic link library; If the target memory management function directly exists in the third dynamic link library, then according to the name and data structure of the target memory function, a dynamic library loading function is executed to obtain a target function pointer corresponding to the target memory management function, so as to call the target memory management function through the target function pointer; If the target memory management function exists in the third dynamic link library as a member function of a class, execute a file viewing command to view the dynamic symbol table in the third dynamic link library, wherein the dynamic symbol table contains various method names and method addresses thereof; obtain the target method name and global variables corresponding to the target memory management function from the dynamic symbol table, so as to call the target memory management function through the target method name and global variables.
9. The method according to claim 8, wherein: Calling a target memory management function in the third dynamic link library to obtain current memory usage information of the first application includes: The target memory management function is called according to the target function pointer or the target method name and the global variable, so that the target memory management function obtains and returns the current memory usage information of the first application.
10. The method according to any one of claims 2 to 9, wherein: In response to a triggering event of obtaining current memory usage information of the first application, loading a second dynamic link library stored in a preset path includes: In response to a triggering event of obtaining current memory usage information of the first application, displaying a command window, wherein the command window includes prompt information, and the prompt information is used to prompt that the current memory usage information of the first application needs to be obtained; Acquire a target command for acquiring current memory usage information of the first application input by the user in the command window according to the prompt information; In response to the target command, an operation of loading a second dynamic link library stored in a preset path and subsequent operations are performed.
11. The method according to claim 4, wherein: The first application is a model training application implemented based on a deep learning framework, and the method further includes: During the model training process, a memory application request is received when the memory resources occupied by the model training application in the previous iteration round are less than the memory resources required by the current iteration round, and new memory resources are allocated to the model training application according to the memory application request to obtain the memory resources occupied by the current iteration round; and when the memory resources occupied by the previous iteration round are greater than the memory resources required by the current iteration round, the memory resources occupied by the previous iteration round are directly used as the memory resources occupied by the current iteration round; According to the amount of releasable memory resources, releasing at least part of the memory resources occupied by the first application, including: determining the iteration round corresponding to the event that the second application fails to apply for memory resources, and according to the amount of releasable memory resources in the iteration round, releasing at least part of the memory resources occupied by the model training application in the iteration round.
12. A hardware acceleration module, wherein: include: A storage unit and a processing unit, wherein the storage unit is used to store a computer program corresponding to the memory information processing method, and the processing unit is coupled to the storage unit and is used to execute the computer program corresponding to the memory information processing method, so as to implement the steps in the method described in any one of claims 1 to 11.
13. An electronic device, wherein: include: A hardware acceleration module, the hardware acceleration module comprising a storage unit and a processing unit, the storage unit being used to store a computer program corresponding to the memory information processing method, the processing unit being coupled to the storage unit and being used to execute the computer program corresponding to the memory information processing method, so as to implement the steps in the method described in any one of claims 1 to 11.
14. A computer-readable storage medium storing a computer program, wherein: When the computer program is executed by a processor, the processor is caused to implement the steps in the method according to any one of claims 1 to 11.
Citation Information
Patent Citations
Method for hardware acceleration of image processing function in OpenCV library
CN106874059A
Method and apparatus for monitoring internal storage of application program and electronic equipment
CN107085548A
Memory allocation information processing method, device, electronic equipment and storage medium
CN113778687A
Memory use information acquisition method and device, storage medium and electronic device
CN115599588A
Memory allocation method and related device
CN115686810A