Container video memory dynamic adjustment method and device, storage medium and electronic equipment
By dynamically adjusting the container video memory allocation, analyzing the reasonable use of video memory based on the process video memory usage and container identification, the problem of wasted video memory resources during container operation is solved and the utilization rate of video memory resources is improved.
Patent Information
- Application Number
- CN202410904428.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-07-05
- Publication Date
- 2024-11-01
AI Technical Summary
During the operation of the container, the fixed allocation of video memory resources leads to inconsistent with the pre-conceived situation, resulting in waste of video memory resources and reducing the utilization rate of video memory resources.
By obtaining the video memory usage and container identification of each process, the actual video memory usage of at least two containers of the shared graphics card is determined, and the reasonable use of video memory is analyzed based on this information, and the video memory allocation is dynamically adjusted to avoid waste.
It improves the utilization rate of video memory resources, avoids the waste of video memory resources, and ensures the reasonable allocation of resources.
Smart Images

Figure CN118885290A_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of basic monitoring technology, and in particular to a method, device, storage medium and electronic device for dynamically adjusting container video memory. Background Art
[0002] GPU (Graphics Processing Unit) video memory is one of the important resources required to run graphics applications in containers. In container technology, multiple containers share GPU video memory.
[0003] Currently, during the running of a container, the allocated video memory of the container usually does not change. However, as the container runs, the actual usage of the video memory is likely to be inconsistent with the pre-conceived usage. This method of allocating video memory to a fixed container is likely to cause a waste of video memory resources and reduce the utilization rate of video memory resources. Summary of the invention
[0004] In view of this, the present application provides a container video memory dynamic adjustment method, device, storage medium and electronic device, which are mainly capable of dynamically adjusting the container video memory, thereby avoiding the waste of video memory resources and improving the utilization rate of video memory resources.
[0005] According to a first aspect of the present application, a method for dynamically adjusting container video memory is provided, the method comprising:
[0006] Get the video memory usage and container ID of each process;
[0007] Determine actual video memory usage of at least two containers currently sharing the graphics card according to the video memory occupancy and the container identifier;
[0008] Analyzing reasonable usage of video memory when the at least two containers share a graphics card based on the actual video memory usage and the video memory allocation of the at least two containers;
[0009] If it is determined according to the reasonable usage of the video memory that the video memory is not used reasonably when the at least two containers share the graphics card, the allocated amount of the video memory is dynamically adjusted.
[0010] According to a second aspect of the present application, a container video memory dynamic adjustment device is provided, the device comprising:
[0011] An acquisition unit, used to obtain the video memory usage and container identifier corresponding to each process;
[0012] A determining unit, configured to determine actual video memory usage of at least two containers currently sharing a graphics card according to the video memory occupancy and the container identifier;
[0013] An analyzing unit, configured to analyze reasonable usage of video memory when the at least two containers share a graphics card based on the actual video memory usage and the video memory allocation of the at least two containers;
[0014] The adjustment unit is used to dynamically adjust the allocated amount of the video memory if it is determined according to the reasonable usage of the video memory that the video memory is not reasonably used when the at least two containers share the video card.
[0015] According to a third aspect of the present application, a storage medium is provided, on which a computer program is stored, and when the program is executed by a processor, the above-mentioned container video memory dynamic adjustment method is implemented.
[0016] According to a fourth aspect of the present application, an electronic device is provided, comprising a storage medium, a processor, and a computer program stored on the storage medium and executable on the processor, wherein the processor implements the above-mentioned container video memory dynamic adjustment method when executing the program.
[0017] By means of the above technical scheme, the present application provides a method, device, storage medium and electronic device for dynamically adjusting container video memory, which determines the actual video memory usage of at least two containers that share a graphics card, and based on the actual video memory usage, analyzes the reasonable usage of video memory when at least two containers share a graphics card. According to the reasonable usage of video memory, the video memory allocation of the container can be dynamically adjusted, thereby avoiding wasting video memory resources and improving the utilization rate of video memory resources.
[0018] The above description is only an overview of the technical solution of the present application. In order to more clearly understand the technical means of the present application, it can be implemented in accordance with the contents of the specification. In order to make the above and other purposes, features and advantages of the present application more obvious and easy to understand, the specific implementation methods of the present application are listed below. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:
[0020] Figure 1 A schematic diagram of a process of dynamically adjusting a container video memory provided by an embodiment of the present application is shown;
[0021] Figure 2 A schematic diagram of a process for obtaining the video memory usage of a process provided in an embodiment of the present application is shown;
[0022] Figure 3 A schematic diagram of a process for obtaining a container to which a process belongs provided by an embodiment of the present application is shown;
[0023] Figure 4A schematic diagram of a process for determining actual video memory usage provided by an embodiment of the present application is shown;
[0024] Figure 5 A schematic diagram of a process of another method for dynamically adjusting container video memory provided in an embodiment of the present application is shown;
[0025] Figure 6 A schematic diagram of the structure of a container video memory dynamic adjustment device provided in an embodiment of the present application is shown;
[0026] Figure 7 A schematic diagram of the structure of another container video memory dynamic adjustment device provided in an embodiment of the present application is shown. DETAILED DESCRIPTION
[0027] The present application will be described in detail below with reference to the accompanying drawings and in combination with embodiments. It should be noted that the embodiments and features in the embodiments of the present application can be combined with each other without conflict.
[0028] The existing technology will cause waste of video memory resources and reduce the utilization rate of video memory resources.
[0029] In order to solve the above problems, an embodiment of the present invention provides a method for dynamically adjusting container video memory, such as Figure 1 As shown, the method includes:
[0030] Step 101: Obtain the video memory usage and container identifier corresponding to each process.
[0031] The video memory usage refers to the amount of video memory occupied by each process, and the container identifier may specifically be a container ID.
[0032] The embodiment of the present invention is mainly applicable to the scenario of dynamically adjusting the container video memory. The execution subject of the embodiment of the present invention is a device or equipment capable of dynamically adjusting the container video memory, which can be specifically set on the server side.
[0033] For the embodiment of the present invention, in order to obtain the video memory usage of each process and the container to which each process belongs, step 101 specifically includes: using the management library function to obtain the video memory usage and graphics card information corresponding to each process; based on predefined resource restriction information, determining the container identifier to which each process belongs. The management library is specifically the NVIDIA Management Library (nvml) management library.
[0034] Specifically, the embodiment of the present invention can use the nvml management library to view the GPU information (graphics card information) and video memory usage of each process, such as Figure 2As shown in the figure, the GPU or graphics card corresponding to process 8043 is 0, and the video memory usage is 2237 MiB. At the same time, an independent cgroup is created for each container. The cgroup is a function of the Linux kernel, which is used to limit, control and separate the resources of a process group (such as CPU, memory, disk, etc.). The embodiment of the present invention uses cgroup to limit resources. Through the process identifier pid under the cgroup, it can be known which specific process belongs to which container, such as Figure 3 As shown in the figure, through the resource restrictions of the Linux control group cgroup, we can know the dockerid corresponding to process 28400, that is, to which container the process 28400 specifically belongs.
[0035] Step 102: Determine actual video memory usage of at least two containers currently sharing a graphics card according to the video memory occupancy and the container identifier.
[0036] For the embodiment of the present invention, after obtaining the video memory occupancy and GPU information (graphics card information) corresponding to each process, as well as the container identifier to which it belongs, the actual video memory usage of at least two containers currently sharing the graphics card is determined based on the video memory occupancy, the graphics card information and the container identifier.
[0037] like Figure 4 As shown, the GPU information and video memory usage corresponding to process 0, process 1 and process 2 can be determined through the nvml management library. By limiting resources through cgroup, it can be determined that process 0 and process 1 belong to container 1, and process 2 belongs to container 2. It can be determined that the GPU corresponding to process 0 and process 1 in container 1 is 0, and the video memory usage is 100 MiB. The GPU corresponding to process 2 in container 2 is 0, and the video memory usage is 200 MiB. Since the GPUs corresponding to the processes in container 1 and container 2 are both 0, it means that container 1 and container 2 share the GPU, that is, share the graphics card. Then, the video memory usage of process 0 and process 1 in container 1 is added, and the actual video memory usage of container 1 is obtained as 100+100=200 MiB. Since there is only process 2 in container 2, the actual video memory usage of container 2 is determined to be 200 MiB. Therefore, the actual video memory usage of at least two containers that share the graphics card can be determined in the above manner.
[0038] Step 103: Based on the actual video memory usage and the video memory allocation of the at least two containers, analyze reasonable video memory usage when the at least two containers share a graphics card.
[0039] The reasonable usage of video memory includes that at least two containers reasonably use the video memory and at least two containers do not reasonably use the video memory when sharing a graphics card.
[0040] For the embodiment of the present invention, after determining the actual video memory usage and video memory allocation of at least two containers, it is necessary to analyze the reasonable usage of video memory when at least two containers share a graphics card. If at least two containers use video memory reasonably, there is no need to dynamically adjust the video memory allocation of the container; if at least two containers do not use video memory reasonably, it is necessary to dynamically adjust the video memory allocation of the container. Specifically, when analyzing the reasonable usage of video memory of at least two containers, the allocated video memory utilization of each container can be calculated based on the actual video memory usage and video memory allocation of each container. For example, the video memory allocated to container 1 is 4GiB, and the current actual video memory usage is 2GiB. At this time, it can be calculated that the allocated video memory utilization of container 1 is 2 / 4=50%. Therefore, the allocated video memory utilization of each container can be calculated in the above manner.
[0041] After calculating the allocated video memory utilization of each container, determine whether the allocated video memory utilization of each container is greater than the preset utilization. If the allocated video memory utilization of each container is greater than the preset utilization, it means that at least two containers use the video memory reasonably when sharing the graphics card; if the allocated video memory utilization of any container is less than or equal to the preset utilization, it means that at least two containers do not use the video memory reasonably when sharing the graphics card.
[0042] Step 104: If it is determined according to the reasonable usage of the video memory that the video memory is not used reasonably when the at least two containers share the graphics card, dynamically adjust the allocated amount of the video memory.
[0043] For the embodiment of the present invention, if at least two containers do not use video memory properly when sharing a graphics card, a container whose allocated video memory utilization is less than a preset utilization is determined, and the video memory allocation of the container is dynamically adjusted. For example, if the actual video memory usage of the container is 2GiB and the video memory allocation of the container is 4GiB, the video memory allocation of the container can be dynamically reduced to 2.5GiB.
[0044] A method for dynamically adjusting container video memory provided by an embodiment of the present invention determines the actual video memory usage of at least two containers that share a graphics card, and based on the actual video memory usage, analyzes the reasonable video memory usage when at least two containers share a graphics card. The method can dynamically adjust the video memory allocation of the container according to the reasonable video memory usage, thereby avoiding wasting video memory resources and improving the utilization rate of video memory resources.
[0045] Further, as a refinement and extension of the specific implementation of the above embodiment, in order to fully illustrate the implementation of this embodiment, this embodiment also provides another container video memory dynamic adjustment method, such as Figure 5 As shown, the method includes:
[0046] Step 201: Obtain the video memory usage and container identifier corresponding to each process.
[0047] For the embodiment of the present invention, the nvml management library can be used to view the GPU information (graphics card information) and video memory usage of each process, and cgroup can be used to limit resources. The process identifier pid under the cgroup can be used to know which specific process belongs to which container.
[0048] Step 202: Determine actual video memory usage of at least two containers currently sharing a graphics card according to the video memory occupancy and the container identifier.
[0049] For the embodiment of the present invention, the process of determining the actual video memory usage of at least two containers currently sharing the graphics card is exactly the same as step 102, and will not be repeated here.
[0050] Step 203: Based on the actual video memory usage and the video memory allocation of the at least two containers, analyze the reasonable usage of the video memory when the at least two containers share a graphics card.
[0051] For the embodiment of the present invention, when analyzing the reasonable usage of video memory, in addition to the method of calculating the utilization rate of allocated video memory in the first embodiment, a model prediction method can also be used. With respect to the model prediction process, as an optional implementation, the method includes: determining the video memory usage feature vectors corresponding to the at least two containers respectively based on the actual video memory usage and the video memory allocation; inputting the video memory usage feature vectors into a preset video memory reasonable usage prediction model for prediction, and obtaining the reasonable usage of video memory when the at least two containers share a graphics card.
[0052] The preset video memory reasonable usage prediction model may be a preset video memory reasonable usage grade classification model, and may specifically be a neural network model, such as a multi-layer perceptron.
[0053] When determining the video memory usage characteristic vector, the average allocated video memory utilization of the at least two containers is calculated according to the actual video memory usage and the video memory allocation; the average video memory utilization of the at least two containers is calculated based on the actual video memory usage and the total video memory corresponding to the graphics card; the average video memory utilization of the at least two containers is calculated according to the actual video memory usage, and the maximum video memory usage and the minimum video memory usage are determined; the ratio between the minimum video memory usage and the maximum video memory usage is calculated according to the maximum video memory usage and the minimum video memory usage; the video memory usage characteristic vectors corresponding to the at least two containers are determined according to the average allocated video memory utilization, the average video memory utilization, the average video memory usage, the total video memory and the ratio between the minimum video memory usage and the maximum video memory usage.
[0054] Specifically, the actual video memory usage of each container in the at least two containers is divided by the video memory allocation to obtain the allocated video memory utilization of each container, and the average allocated video memory utilization is calculated based on the allocated video memory utilization of each container. At the same time, the actual video memory usage of each container is divided by the total video memory to obtain the video memory utilization of each container, and the average video memory utilization is calculated based on the video memory utilization of each container. Further, according to the actual video memory usage of each container, the average video memory usage is calculated, and the maximum video memory usage and the minimum video memory usage are determined, and the ratio between the minimum video memory usage and the maximum video memory usage is calculated.
[0055] Then, the average memory utilization is divided into multiple intervals, and different intervals correspond to different feature components. For example, when the average memory utilization is below 20%, the corresponding feature component is (1, 0, 0, 0); when the average memory utilization is between 20% and 40%, the corresponding feature component is (0, 1, 0, 0); when the average memory utilization is between 40% and 70%, the corresponding feature component is (0, 0, 1, 0); when the average memory utilization is above 70%, the corresponding feature component is (0, 0, 0, 1). Similarly, the feature components corresponding to the average memory utilization, the maximum memory usage, the minimum memory usage, the average memory usage, and the ratio between the minimum memory usage and the maximum memory usage can be determined. Finally, the feature components are horizontally spliced to obtain the memory usage feature vector corresponding to each container.
[0056] Furthermore, when using a preset video memory reasonable usage level classification model to predict video memory reasonable usage, the video memory usage feature vector is input into the preset video memory reasonable usage level classification model to perform video memory reasonable usage level classification to obtain the video memory reasonable usage level when the at least two containers share a graphics card; based on the video memory reasonable usage level, determine the reasonable usage of video memory when the at least two containers share a graphics card.
[0057] The reasonable use of video memory can be divided into multiple levels, the higher the level, the more reasonable the use of video memory; on the contrary, the lower the level, the more unreasonable the use of video memory. The preset reasonable use level classification model of video memory can be a neural network model, such as a multi-layer perceptron.
[0058] Specifically, if the reasonable usage level of video memory is higher than or equal to the preset level, it is determined that video memory is used reasonably when at least two containers share the graphics card, and there is no waste of video memory resources at present, and there is no need to dynamically shrink the allocated amount of video memory at this time; if the reasonable usage level of video memory is lower than the preset level, it is determined that video memory is not used reasonably when at least two containers share the graphics card, and there may be a waste of video memory resources at present, and there may be a need to dynamically shrink the allocated amount of video memory for the container.
[0059] The embodiment of the present invention adopts a preset video memory reasonable use level classification model to accurately grasp the current video memory reasonable use situation, so that when the container does not use the video memory reasonably, timely adjustments can be made to avoid wasting video memory resources.
[0060] Step 204: If it is determined according to the reasonable usage of the video memory that the at least two containers do not use the video memory reasonably when sharing a graphics card, obtain the current allocated video memory utilization rate and the historical allocated video memory utilization rate of the at least two containers.
[0061] For the embodiment of the present invention, the current allocated video memory utilization of each container calculated in step 203 can be directly obtained, and the allocated video memory utilization of each container at the previous time node, ie, the historical allocated video memory utilization, can be obtained from the historical records.
[0062] Step 205: predict the future allocated video memory utilizations of the at least two containers according to the current allocated video memory utilizations and the historical allocated video memory utilizations.
[0063] For the embodiment of the present invention, in order to predict the future allocated video memory utilization of each container, the current allocated video memory utilization and the historical allocated video memory utilization can be input as time series data into a preset recurrent neural network RNN for prediction to obtain the future allocated video memory utilization of the at least two containers.
[0064] For example, if the current time is 11:00, the allocated memory utilization of each container at 11:00 is obtained, and the historical allocated memory utilization of each container at 10:55 and the historical allocated memory utilization of each container at 10:50 are obtained from the historical records. Then, the current allocated memory utilization of each container at 11:00, the historical allocated memory utilization of each container at 10:55, and the historical allocated memory utilization of each container at 10:50 are input into the recurrent neural network RNN for prediction, and the allocated memory utilization of each container at 11:05 in the future is obtained.
[0065] Step 206: Based on the future allocated video memory utilization, the current allocated video memory utilization and the historical allocated video memory utilization, respectively determine the allocated video memory utilization trends of the at least two containers.
[0066] For the embodiment of the present invention, after determining the future allocated video memory utilization, the current allocated video memory utilization and the historical allocated video memory utilization of each container, the allocated video memory utilization at multiple time nodes in the past, present and future can be obtained, thereby determining the allocated video memory utilization trend of each container, and the allocated video memory utilization trend includes an upward trend, a stable trend and a downward trend.
[0067] Step 207 : Based on the allocated video memory utilization trend, determine whether the video memory allocation amount can be dynamically adjusted; if so, execute step 208 .
[0068] For the embodiment of the present invention, if the allocated video memory utilization trend of a container is an upward trend, the video memory allocation amount of the container cannot be dynamically reduced at this time; if the allocated video memory utilization trend of a container is a stable trend or a downward trend, the video memory allocation amount of the container can be dynamically reduced.
[0069] The embodiment of the present invention can accurately determine whether the container has the conditions for dynamic shrinkage by predicting the future allocated video memory utilization of the container and determining the development trend of the allocated video memory utilization, thereby preventing the situation of insufficient video memory after the container is shrunk.
[0070] Step 208: Dynamically adjust the allocated amount of video memory.
[0071] For example, the allocated video memory utilization of a container is in a stable trend, stable at about 2 GiB, and the allocated video memory of the container is 4 GiB. At this time, the allocated video memory of the container can be dynamically reduced to 2.5 GiB.
[0072] Another method for dynamically adjusting container video memory provided by an embodiment of the present invention determines the actual video memory usage of at least two containers that share a graphics card, and based on the actual video memory usage, analyzes the reasonable video memory usage when at least two containers share a graphics card. The method can dynamically adjust the video memory allocation of the container according to the reasonable video memory usage, thereby avoiding wasting video memory resources and improving the utilization rate of video memory resources.
[0073] Further, as Figure 1 and Figure 5 The specific implementation of the method shown in the embodiment provides a container memory dynamic adjustment device, such as Figure 6 As shown, the device includes: an acquisition unit 31, a determination unit 32, an analysis unit 33 and an adjustment unit 34.
[0074] The acquisition unit 31 may be used to acquire the video memory usage and container identifier corresponding to each process.
[0075] The determining unit 32 may be configured to determine actual video memory usage of at least two containers currently sharing a graphics card according to the video memory occupancy and the container identifier.
[0076] The analysis unit 33 may be configured to analyze reasonable usage of video memory when the at least two containers share a graphics card based on the actual video memory usage and the video memory allocation of the at least two containers.
[0077] The adjustment unit 34 may be configured to dynamically adjust the allocated amount of the video memory if it is determined based on the reasonable usage of the video memory that the video memory is not used reasonably when the at least two containers share the video card.
[0078] In some embodiments, the acquisition unit 31 can be specifically used to use the management library function to obtain the video memory usage and graphics card information corresponding to each process; based on pre-defined resource restriction information, determine the container identifier to which each process belongs.
[0079] In some embodiments, the determining unit 32 may be specifically configured to determine actual video memory usage of at least two containers currently sharing a graphics card according to the video memory occupancy, the graphics card information and the container identifier.
[0080] In some embodiments, the analysis unit 33, such as Figure 7 As shown, it includes: a determination module 331 and a prediction module 332.
[0081] The determination module 331 may be configured to determine the video memory usage feature vectors corresponding to the at least two containers respectively based on the actual video memory usage and the video memory allocation.
[0082] The prediction module 332 may be used to input the video memory usage feature vector into a preset video memory reasonable usage prediction model for prediction, so as to obtain the reasonable usage of the video memory when the at least two containers share a graphics card.
[0083] In some embodiments, the determination module 331 can be specifically used to calculate the average allocated video memory utilization of the at least two containers based on the actual video memory usage and the video memory allocation; calculate the average video memory utilization of the at least two containers based on the actual video memory usage and the total video memory corresponding to the graphics card; calculate the average video memory usage of the at least two containers based on the actual video memory usage, and determine the maximum video memory usage and the minimum video memory usage; calculate the ratio between the minimum video memory usage and the maximum video memory usage based on the maximum video memory usage and the minimum video memory usage; determine the video memory usage feature vectors corresponding to the at least two containers respectively based on the average allocated video memory utilization, the average video memory utilization, the average video memory usage, the total video memory and the ratio between the minimum video memory usage and the maximum video memory usage.
[0084] In some embodiments, when the preset video memory reasonable usage prediction model is a preset video memory reasonable usage level classification model, the prediction module 332 can be specifically used to input the video memory usage feature vector into the preset video memory reasonable usage level classification model to perform video memory reasonable usage level classification, and obtain the video memory reasonable usage level when the at least two containers share a graphics card; based on the video memory reasonable usage level, determine the video memory reasonable usage when the at least two containers share a graphics card.
[0085] In some embodiments, the adjustment unit 34 may be specifically configured to determine that the video memory is not used reasonably when the at least two containers share a graphics card if the reasonable usage level of the video memory is lower than a preset level, and dynamically reduce the allocated amount of the video memory.
[0086] In some embodiments, the device further includes: a prediction unit 35 and a determination unit 36 .
[0087] The acquisition unit 31 may be used to acquire the current allocated video memory utilization and the historical allocated video memory utilization of the at least two containers.
[0088] The prediction unit 35 may be configured to predict the future allocated video memory utilizations of the at least two containers according to the current allocated video memory utilization and the historical allocated video memory utilizations.
[0089] The determining unit 32 may also be configured to determine the allocated video memory utilization trends of the at least two containers based on the future allocated video memory utilization, the current allocated video memory utilization and the historical allocated video memory utilization.
[0090] The determination unit 36 may be configured to determine whether the allocated video memory amount may be dynamically adjusted based on the allocated video memory utilization trend.
[0091] In some embodiments, the prediction unit 35 can be specifically used to input the current allocated video memory utilization and the historical allocated video memory utilization as time series data into a preset recurrent neural network for prediction, so as to obtain the future allocated video memory utilization of the at least two containers.
[0092] It should be noted that for other corresponding descriptions of the functional units involved in the container video memory dynamic adjustment device provided in this embodiment, please refer to Figure 1 and Figure 5 The corresponding description in will not be repeated here.
[0093] Based on the above Figure 1 and Figure 5The method shown in the embodiment also provides a storage medium on which a computer program is stored. When the program is executed by a processor, the above-mentioned Figure 1 and Figure 5 The container video memory dynamic adjustment method shown.
[0094] Based on this understanding, the technical solution of the present application can be embodied in the form of a software product, which can be stored in a non-volatile storage medium (which can be a CD-ROM, USB flash drive, mobile hard disk, etc.), including a number of instructions for enabling an electronic device (which can be a personal computer, server, or network device, etc.) to execute the methods of various implementation scenarios of the present application.
[0095] Based on the above Figure 1 and Figure 5 The method shown, and Figure 6 and Figure 7 In order to achieve the above-mentioned purpose, the embodiment of the present application also provides an electronic device, which can be a personal computer, a tablet computer, a server, or other network equipment, etc. The device includes a storage medium and a processor; the storage medium is used to store a computer program; the processor is used to execute the computer program to achieve the above-mentioned Figure 1 and Figure 5 The container video memory dynamic adjustment method shown.
[0096] Optionally, the above-mentioned physical device may also include a user interface, a network interface, a camera, a radio frequency (RF) circuit, a sensor, an audio circuit, a WI-FI module, etc. The user interface may include a display, an input unit such as a keyboard, etc., and the optional user interface may also include a USB interface, a card reader interface, etc. The network interface may optionally include a standard wired interface, a wireless interface (such as a WI-FI interface), etc.
[0097] Those skilled in the art will appreciate that the above-mentioned physical device structure provided in this embodiment does not constitute a limitation on the physical device, and may include more or fewer components, or a combination of certain components, or different arrangements of components.
[0098] The storage medium may also include an operating system and a network communication module. The operating system is a program that manages the hardware and software resources of the above-mentioned physical device, and supports the operation of the information processing program and other software and / or programs. The network communication module is used to realize the communication between the components inside the storage medium, and the communication with other hardware and software in the information processing physical device.
[0099] Through the description of the above implementation methods, those skilled in the art can clearly understand that the present application can be implemented by means of software plus a necessary general hardware platform, or by hardware.
[0100] The embodiment of the present invention determines the actual video memory usage of at least two containers that share a graphics card, and based on the actual video memory usage, analyzes the reasonable video memory usage when at least two containers share a graphics card. According to the reasonable video memory usage, the video memory allocation of the container can be dynamically adjusted, thereby avoiding wasting video memory resources and improving the utilization rate of video memory resources.
[0101] Those skilled in the art will appreciate that the accompanying drawings are only schematic diagrams of a preferred implementation scenario, and the modules or processes in the accompanying drawings are not necessarily necessary for implementing the present application. Those skilled in the art will appreciate that the modules in the devices in the implementation scenario can be distributed in the devices of the implementation scenario according to the description of the implementation scenario, or can be changed accordingly and located in one or more devices different from the present implementation scenario. The modules of the above-mentioned implementation scenario can be combined into one module, or can be further split into multiple submodules.
[0102] The above serial numbers of this application are only for description and do not represent the advantages and disadvantages of the implementation scenarios. The above disclosure is only a few specific implementation scenarios of this application, but this application is not limited to them, and any changes that can be thought of by technicians in this field should fall within the scope of protection of this application.
Claims
1. A method for dynamically adjusting container video memory, characterized in that: include: Get the video memory usage and container ID of each process; Determine actual video memory usage of at least two containers currently sharing the graphics card according to the video memory occupancy and the container identifier; Analyzing reasonable usage of video memory when the at least two containers share a graphics card based on the actual video memory usage and the video memory allocation of the at least two containers; If it is determined according to the reasonable usage of the video memory that the video memory is not used reasonably when the at least two containers share the graphics card, the allocated amount of the video memory is dynamically adjusted.
2. The method according to claim 1, characterized in that The obtaining of the video memory usage and container identifier corresponding to each process includes: Use the management library function to obtain the video memory usage and graphics card information corresponding to each process; Based on the predefined resource restriction information, the container identifier to which each process belongs is determined.
3. The method according to claim 2, characterized in that The determining, according to the video memory occupancy and the container identifier, actual video memory usage of at least two containers currently sharing the graphics card includes: According to the video memory occupancy, the graphics card information and the container identifier, the actual video memory usage of at least two containers currently sharing the graphics card is determined.
4. The method according to claim 1, characterized in that: Based on the actual video memory usage and the video memory allocation of the at least two containers, analyzing reasonable video memory usage when the at least two containers share a graphics card, including: Determine, based on the actual video memory usage and the video memory allocation, video memory usage feature vectors corresponding to the at least two containers respectively; Inputting the video memory usage feature vector into a preset video memory reasonable usage prediction model for prediction, to obtain a reasonable usage of the video memory when the at least two containers share a graphics card; and / or before dynamically adjusting the video memory allocation amount, the method further includes: Obtaining current allocated video memory utilization rates and historical allocated video memory utilization rates of the at least two containers; Predicting future allocated video memory utilizations of the at least two containers according to the current allocated video memory utilizations and the historical allocated video memory utilizations; Based on the future allocated video memory utilization, the current allocated video memory utilization and the historical allocated video memory utilization, respectively determining allocated video memory utilization trends of the at least two containers; Based on the allocated video memory utilization trend, it is determined whether the allocated video memory amount can be dynamically adjusted.
5. The method according to claim 4, characterized in that Determining the video memory usage feature vectors corresponding to the at least two containers respectively based on the actual video memory usage and the video memory allocation amount includes: Calculating an average allocated video memory utilization rate of the at least two containers according to the actual video memory usage and the video memory allocation amount; Calculate an average video memory utilization rate of the at least two containers based on the actual video memory usage and the total video memory corresponding to the graphics card; Calculate the average video memory usage of the at least two containers according to the actual video memory usage, and determine the maximum video memory usage and the minimum video memory usage; Calculating a ratio between the minimum video memory usage and the maximum video memory usage according to the maximum video memory usage and the minimum video memory usage; Determine the video memory usage feature vectors corresponding to the at least two containers respectively according to the average distributed video memory utilization, the average video memory utilization, the average video memory usage, the total video memory and the ratio between the minimum video memory usage and the maximum video memory usage.
6. The method according to claim 5, characterized in that When the preset video memory reasonable usage prediction model is a preset video memory reasonable usage grade classification model, the video memory usage feature vector is input into the preset video memory reasonable usage prediction model for prediction to obtain the video memory reasonable usage when the at least two containers share a graphics card, including: Inputting the video memory usage feature vector into the preset video memory reasonable usage level classification model to perform video memory reasonable usage level classification, and obtaining a video memory reasonable usage level when the at least two containers share a graphics card; Based on the reasonable usage level of the graphics memory, reasonable usage of the graphics memory when the at least two containers share a graphics card is determined.
7. The method according to claim 6, characterized in that If it is determined according to the reasonable usage of the video memory that the video memory is not used reasonably when the at least two containers share the graphics card, the allocated amount of the video memory is dynamically adjusted, including: If the reasonable usage level of the video memory is lower than a preset level, it is determined that the video memory is not reasonably used when the at least two containers share the graphics card, and the allocated amount of the video memory is dynamically reduced.
8. The method according to claim 4, characterized in that According to the current allocated video memory utilization and the historical allocated video memory utilization, predict the future allocated video memory utilization of the at least two containers, Includes, including: The current allocated video memory utilization and the historical allocated video memory utilization are input as time series data into a preset recurrent neural network for prediction to obtain the future allocated video memory utilization of the at least two containers.
9. A storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the method according to any one of claims 1 to 8 is implemented.
10. An electronic device comprising a storage medium, a processor, and a computer program stored in the storage medium and executable on the processor, characterized in that: When the processor executes the computer program, the method according to any one of claims 1 to 8 is implemented.
Citation Information
Cited By
Graphic processor resource management system, method and server
CN120765447A
