CN111400035A - Video memory allocation method and device, electronic equipment and storage medium - Google Patents

Video memory allocation method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN111400035A
CN111400035A CN202010144896.6A CN202010144896A CN111400035A CN 111400035 A CN111400035 A CN 111400035A CN 202010144896 A CN202010144896 A CN 202010144896A CN 111400035 A CN111400035 A CN 111400035A
Authority
CN
China
Prior art keywords
video memory
video
current application
total
memories
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202010144896.6A
Other languages
Chinese (zh)
Inventor
陈兴友
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Hangzhou Hikvision System Technology Co Ltd
Original Assignee
Hangzhou Hikvision System Technology Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Hangzhou Hikvision System Technology Co Ltd filed Critical Hangzhou Hikvision System Technology Co Ltd
Priority to CN202010144896.6A priority Critical patent/CN111400035A/en
Publication of CN111400035A publication Critical patent/CN111400035A/en
Pending legal-status Critical Current

Links

Images

Classifications

    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5011Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
    • G06F9/5016Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals the resource being the memory
    • GPHYSICS
    • G06COMPUTING; CALCULATING OR COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/46Multiprogramming arrangements
    • G06F9/50Allocation of resources, e.g. of the central processing unit [CPU]
    • G06F9/5005Allocation of resources, e.g. of the central processing unit [CPU] to service a request
    • G06F9/5011Allocation of resources, e.g. of the central processing unit [CPU] to service a request the resources being hardware resources other than CPUs, Servers and Terminals
    • G06F9/5022Mechanisms to release resources

Landscapes

  • Engineering & Computer Science (AREA)
  • Software Systems (AREA)
  • Theoretical Computer Science (AREA)
  • Physics & Mathematics (AREA)
  • General Engineering & Computer Science (AREA)
  • General Physics & Mathematics (AREA)
  • Television Signal Processing For Recording (AREA)

Abstract

According to the video memory allocation method, the video memory allocation device, the electronic equipment and the storage medium, when the video memory is applied by the current application, the number of the video memory applied by the current application is obtained, and the number of the video memory to be applied is obtained; reading the total distributed video memory quantity and the used video memory quantity in a preset configuration file corresponding to the current application; judging whether the sum of the number of the video memories to be applied and the number of the used video memories is larger than the total distributed video memory number or not; if the sum of the number of the video memories to be applied and the number of the used video memories is not more than the total distributed number of the video memories, distributing the video memories of the number of the video memories to be applied for the current application, and if the sum of the number of the video memories to be applied and the number of the used video memories is more than the total distributed number of the video memories, sending video memory shortage information of a specified format to the current application. Under the condition of ensuring the use of the current application video memory, the situation that the number of the application video memory exceeds the whole video memory of the GPGPU to cause the contention for the video memory is prevented, so that the video memory supply of each application is ensured, and the use efficiency of the video memory is improved.

Description

Video memory allocation method and device, electronic equipment and storage medium
Technical Field
The present application relates to the field of information technologies, and in particular, to a method and an apparatus for allocating video memory, an electronic device, and a storage medium.
Background
With the rapid development of technologies such as deep learning, model calculation is more and more widely applied, a large amount of Graphics Processing Unit (GPU) calculation resources are required in the process of training a model, and the demand for Graphics memory is greatly reduced when the trained model is actually used. And the difference between the front and the back can reach one or two orders of magnitude through technologies such as model compression, pruning and the like.
However, at present, the multiplexing of the video memory is generally performed by dividing the time period to use the video memory in ways of oral or written negotiation, etc., so as to achieve the purpose of multiplexing the video memory. However, in the same time period, the redundant video memory is not used, which is only wasted, and at the same time, the mainstream deep learning software is prompted to try to apply for the video memory as much as possible, thereby causing the low use efficiency of the video memory.
Content of application
An embodiment of the present application provides a method and an apparatus for allocating video memory, an electronic device, and a storage medium, so as to achieve the purpose of improving the utilization efficiency of the video memory. The specific technical scheme is as follows:
in a first aspect, the present application provides a method for allocating video memory, including:
when the current application applies for the video memory, acquiring the number of the video memory applied by the current application to obtain the number of the video memory to be applied;
reading the total distributed video memory quantity and the used video memory quantity in a preset configuration file corresponding to the current application, wherein the total distributed video memory quantity is the upper limit of the preset video memory quantity distributed to the current application, and the used video memory quantity is the video memory quantity distributed to the current application;
judging whether the sum of the number of the video memories to be applied and the number of the used video memories is larger than the total distributed video memory number or not;
if the sum of the number of the video memories to be applied and the number of the used video memories is not more than the total distributed video memory number, distributing the video memories of the number of the video memories to be applied for the current application;
and if the sum of the number of the video memories to be applied and the number of the used video memories is larger than the total distributed video memory number, sending the video memory shortage information in the specified format to the current application.
Optionally, when the video memory is applied by the current application, before the number of the video memory applied by the current application is obtained and the number of the video memory to be applied is obtained, the method further includes:
starting a current application, and creating a current application configuration file, wherein the configuration file comprises the total allocated video memory quantity and the used video memory quantity, the total allocated video memory quantity is the upper limit of the video memory quantity allocated to the current application, and the value of the used video memory quantity is zero in an initial state;
judging whether the total available video memory quantity is larger than the total allocated video memory quantity or not, wherein the total available video memory quantity is the video memory quantity which is not used in the image processor;
and if the total available video memory quantity is larger than the total distributed video memory quantity, judging that the current application configuration file configuration is finished.
Optionally, after determining whether the total available video memory amount is greater than the total allocated video memory amount, the method further includes:
and if the total available video memory quantity is not more than the total allocated video memory quantity, giving the value of the total available video memory quantity to the total allocated video memory quantity.
Optionally, after allocating the video memory of the number of the video memories to be applied to the current application, the method further includes:
and updating the used video memory quantity according to the video memory quantity to be applied.
Optionally, the method further includes:
when the current application releases the video memory, acquiring the quantity of the video memory release of the current application to obtain the quantity of the video memory release;
and updating the used video memory quantity according to the video memory release quantity.
In a second aspect, the present application provides a video memory allocation apparatus, including:
the video memory application module is used for acquiring the number of the video memories applied by the current application when the current application applies for the video memories, and acquiring the number of the video memories to be applied;
the video memory reading module is used for reading the total distributed video memory quantity and the used video memory quantity in a preset configuration file corresponding to the current application, wherein the total distributed video memory quantity is the preset upper limit of the video memory quantity distributed to the current application, and the used video memory quantity is the video memory quantity distributed to the current application;
the video memory judging module is used for judging whether the sum of the number of the video memories to be applied and the number of the used video memories is larger than the total distributed video memory number or not;
the application allocation module is used for allocating the video memory with the video memory amount to be applied for the current application if the sum of the video memory amount to be applied and the used video memory amount is not more than the total allocated video memory amount;
and the information sending module is used for sending the insufficient video memory information in the specified format to the current application if the sum of the number of the video memories to be applied and the number of the used video memories is greater than the total distributed video memory number.
Optionally, the apparatus further comprises:
the file creating module is used for starting the current application and creating a current application configuration file, wherein the configuration file comprises the total allocated video memory quantity and the used video memory quantity, the total allocated video memory quantity is the upper limit of the video memory quantity allocated to the current application, and the value of the used video memory quantity is zero in an initial state;
the quantity judging module is used for judging whether the total available video memory quantity is larger than the total allocated video memory quantity or not, wherein the total available video memory quantity is the video memory quantity which is not used in the image processor;
and the completion judging module is used for judging that the configuration of the current application configuration file is completed if the total available video memory quantity is greater than the total distributed video memory quantity.
Optionally, the apparatus further comprises:
and the video memory assignment module is used for assigning the value of the total available video memory quantity to the total allocated video memory quantity if the total available video memory quantity is not greater than the total allocated video memory quantity.
Optionally, the apparatus further comprises:
and the video memory updating module is used for updating the used video memory quantity according to the video memory quantity to be applied.
Optionally, the apparatus further comprises:
the release information module is used for acquiring the quantity of the video memory release of the current application when the current application releases the video memory, so as to obtain the quantity of the video memory release;
and the quantity updating module is used for updating the quantity of the used video memory according to the quantity of the released video memory.
According to a third aspect of the embodiments of the present disclosure, an electronic device is provided, which includes a processor, a communication interface, a memory, and a communication bus, where the processor, the communication interface, and the memory complete communication with each other through the communication bus;
a memory for storing a computer program;
and the processor is used for realizing any video memory allocation method when executing the computer program stored in the memory.
According to a fourth aspect of embodiments of the present disclosure, there is provided a computer-readable storage medium,
the computer readable storage medium has a computer program stored therein, and the computer program is executed by a processor to implement any of the methods for video memory allocation described above.
According to the video memory allocation method and device, the electronic device and the storage medium provided by the embodiment of the application, when the video memory is applied by the current application, the number of the video memory applied by the current application is obtained, and the number of the video memory to be applied is obtained; reading the total distributed video memory quantity and the used video memory quantity in a preset configuration file corresponding to the current application; judging whether the sum of the number of the video memories to be applied and the number of the used video memories is larger than the total distributed video memory number or not; and if the sum of the number of the video memories to be applied and the number of the used video memories is not more than the total distributed number of the video memories, distributing the video memories of the number of the video memories to be applied for the current application. Therefore, the video memory is distributed according to the application request, the situation that the video memory is contended and robbed due to the fact that the quantity of the application video memory exceeds the whole video memory of the GPGPU is prevented under the condition that the video memory of the current application is used is guaranteed, the video memory supply of each application is guaranteed, and the use efficiency of the video memory is improved. Of course, it is not necessary for any product or method of the present application to achieve all of the above-described advantages at the same time.
Drawings
In order to more clearly illustrate the embodiments of the present application or the technical solutions in the prior art, the drawings used in the description of the embodiments or the prior art will be briefly described below, it is obvious that the drawings in the following description are only some embodiments of the present application, and for those skilled in the art, other drawings can be obtained according to the drawings without creative efforts.
Fig. 1 is a flowchart of a video memory allocation method according to an embodiment of the present application.
Fig. 2 is a flowchart of a configuration file creating method according to an embodiment of the present application.
Fig. 3 is another flowchart of a video memory allocation method according to an embodiment of the present application.
Fig. 4 is a flowchart illustrating a portion of a platform hypervisor according to an embodiment of the present application.
Fig. 5 is a diagram illustrating an example of a video memory allocation method according to an embodiment of the present application.
Fig. 6 is a schematic structural diagram of a video memory allocation apparatus according to an embodiment of the present disclosure.
Fig. 7 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
The technical solutions in the embodiments of the present application will be clearly and completely described below with reference to the drawings in the embodiments of the present application, and it is obvious that the described embodiments are only a part of the embodiments of the present application, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present application.
In order to improve the utilization efficiency of the video memory, embodiments of the present application provide a video memory method, an apparatus, an electronic device, and a storage medium, which are described in detail below.
First, terms of art in the embodiments of the present application are explained:
CGroup (Control Group): the kernel function is used for limiting, auditing and isolating the resource use conditions of a processor, a memory, disk IO (input/output of a disk), a network and the like of a process.
GPGPU (General-purpose-graphics computing on graphics processing units, General-purpose graphics processor): a graphics processor capable of performing general purpose computational tasks other than graphics.
CUDA (computer Unified Device Architecture): programming models and software development kits proposed by NVIDIA (england) for parallel general purpose computing on GPUs.
Container operating system layer virtualization technology and software implemented with L inux (an operating system) namespace, CGroup functionality.
Displaying and storing: memory in the GPGPU device.
Fig. 1 is a flowchart of a video memory allocation method according to an embodiment of the present application, including the following steps:
in step S11, when the current application applies for the video memory, the number of the video memory applied by the current application is obtained, so as to obtain the number of the video memory to be applied.
The data acquisition method of the embodiment of the application aims at the video memory in the intelligent terminal device, so that the data acquisition method can be executed through the intelligent terminal device, and specifically, the intelligent terminal device can be a computer or a server and the like.
The application video memory of the current application can be an application for video memory of applications in various forms, for example, an application for model training in a server, a video memory for executing the application before or during model training, and the number of the video memories applied, that is, the number of the video memories to be applied. The current application is any application which is currently carrying out a video memory application in the GPGPU at the current moment, for example, the application for model training.
In step S12, the total allocated video memory amount and the used video memory amount in the preset configuration file corresponding to the current application are read.
The total allocated video memory quantity is the upper limit of the preset video memory quantity allocated to the current application, and the used video memory quantity is the video memory quantity allocated to the current application. For example, the total video memory of the current image processor is 8GB, and if the upper limit of the allocated video memory is set to be 500MB by a preset rule for a certain application in the server, the total allocated video memory is 500 MB.
In step S13, it is determined whether the sum of the number of pending video memories and the number of used video memories is greater than the total allocated video memory number.
And judging whether the sum of the number of the video memories to be applied and the number of the used video memories is greater than the total distributed video memory number or not, namely judging whether the number of the applied video memories and the number of the used video memories which are currently applied are greater than the number of the total video memories set for the current application or not.
In step S14, if the sum of the to-be-applied video memory number and the used video memory number is not greater than the total allocated video memory number, allocating the video memory of the to-be-applied video memory number for the current application.
In step S15, if the sum of the number of pending applications and the number of used video memories is greater than the total allocated video memory number, the video memory shortage information in the specified format is sent to the current application.
And if the sum of the number of the video memories to be applied and the number of the used video memories is greater than the total number of the distributed video memories, sending video memory shortage information in a specified format to the current application. The video memory of the application number can be allocated when the number of the used video memory and the video memory to be applied of the target application is smaller than the preset upper limit, the situation that the video memory is contended and robbed due to the fact that the number of the applied video memory exceeds the total video memory of the GPGPU is prevented, the video memory supply of each application is guaranteed, and the use efficiency of the video memory is improved.
Optionally, when the video memory is applied by the current application, before the number of the video memory applied by the current application is obtained and the number of the video memory to be applied is obtained, the method further includes: starting a current application, and creating a current application configuration file, wherein the configuration file comprises the total allocated video memory quantity and the used video memory quantity, the total allocated video memory quantity is the upper limit of the video memory quantity allocated to the current application, and the value of the used video memory quantity is zero in an initial state; judging whether the total available video memory quantity is larger than the total allocated video memory quantity or not, wherein the total available video memory quantity is the video memory quantity which is not used in the image processor; and if the total available video memory quantity is larger than the total distributed video memory quantity, judging that the current application configuration file configuration is finished.
Optionally, after determining whether the total available video memory amount is greater than the total allocated video memory amount, the method further includes: and if the total available video memory quantity is not more than the total allocated video memory quantity, giving the value of the total available video memory quantity to the total allocated video memory quantity.
Optionally, after allocating the video memory of the number of the video memories to be applied to the current application, the method further includes: and updating the used video memory quantity according to the video memory quantity to be applied.
Optionally, the method further includes: when the current application releases the video memory, acquiring the quantity of the video memory release of the current application to obtain the quantity of the video memory release; and updating the used video memory quantity according to the video memory release quantity.
Therefore, by the video memory allocation method of the embodiment of the application, when the video memory is applied by the current application, the number of the video memories applied by the current application is obtained, and the number of the video memories to be applied is obtained; reading the total distributed video memory quantity and the used video memory quantity in a preset configuration file corresponding to the current application; judging whether the sum of the number of the video memories to be applied and the number of the used video memories is larger than the total distributed video memory number or not; and if the sum of the number of the video memories to be applied and the number of the used video memories is not more than the total distributed number of the video memories, distributing the video memories of the number of the video memories to be applied for the current application. Therefore, the video memory is distributed according to the application request, the situation that the video memory is contended and robbed due to the fact that the quantity of the application video memory exceeds the whole video memory of the GPGPU is prevented under the condition that the video memory of the current application is used is guaranteed, the video memory supply of each application is guaranteed, and the use efficiency of the video memory is improved.
Fig. 2 is a flowchart of a configuration file creating method according to an embodiment of the present application, including the following steps:
in step S21, the current application is launched, creating a current application profile.
The configuration file comprises the total distributed video memory quantity and the used video memory quantity, the total distributed video memory quantity is the upper limit of the video memory quantity distributed to the current application, and the value of the used video memory quantity is zero in the initial state. The configuration file may be a vgpu _ cfg _ s type file.
Before the current application is started and the current application configuration file is created, the method may further include: applying for a storage space, wherein the size of the storage space is a multiple of a specified number of the data size of the current application configuration file, and the specified number is the maximum GPGPU application number allowed by a single machine.
In step S22, it is determined whether the total available memory amount is greater than the total allocated memory amount.
Wherein, the total available video memory number is the video memory number which is not used in the image processor. For example, if the total video memory of a certain image processor is 8GB, and the used video memory is 2GB, the total available video memory of the current image processor is 6 GB. The total distributed video memory quantity can be a preset numerical value, and can also be manually set when the current application is started.
In step S23, if the total available video memory amount is greater than the total allocated video memory amount, it is determined that the current application configuration file configuration is completed.
In step S24, if the total available video memory amount is not greater than the total allocated video memory amount, the total available video memory amount is assigned to the total allocated video memory amount.
The method comprises the steps of judging whether the total available video memory quantity is larger than the total allocated video memory quantity or not, judging that the configuration of the current application configuration file is completed if the total available video memory quantity is larger than the total allocated video memory quantity, and giving the total allocated video memory quantity the value of the total available video memory quantity if the total available video memory quantity is not larger than the total allocated video memory quantity, so that the judgment error when the application video memory is judged can be prevented when the total available video memory quantity is smaller than the total allocated video memory.
And if the total available video memory quantity is not greater than the total allocated video memory quantity, giving the value of the total available video memory quantity to the total allocated video memory quantity. The configuration file of the application can be generated, so that when the current application applies for the video memory, whether the video memory application succeeds or not can be judged by reading the configuration file.
Fig. 3 is another flowchart of a video memory allocation method according to an embodiment of the present application, including the following steps:
in step S11, when the current application applies for the video memory, the number of the video memory applied by the current application is obtained, so as to obtain the number of the video memory to be applied.
In step S12, the total allocated video memory amount and the used video memory amount in the preset configuration file corresponding to the current application are read.
The total allocated video memory quantity is the upper limit of the preset video memory quantity allocated to the current application, and the used video memory quantity is the video memory quantity allocated to the current application.
In step S13, it is determined whether the sum of the number of pending video memories and the number of used video memories is greater than the total allocated video memory number.
In step S14, if the sum of the to-be-applied video memory number and the used video memory number is not greater than the total allocated video memory number, allocating the video memory of the to-be-applied video memory number for the current application.
In step S15, if the sum of the number of pending applications and the number of used video memories is greater than the total allocated video memory number, the video memory shortage information in the specified format is sent to the current application.
The video memory shortage information in the specified format can be information in any format, and if the sum of the number of the video memories to be applied and the number of the used video memories is larger than the total distributed video memory number, the video memory shortage information in the specified format is sent to the current application, and whether the application of the video memory is continued or not can be judged through the application.
Therefore, the display memory is controlled, so that the available display memory searched by the current application is smaller than all the display memories of the GPGPU, when the total number of the display memories applied by the application exceeds a set value, the current application is stopped, the phenomenon of contending for the display memory caused by the fact that the sum of the display memory applied by the current application and the used display memory is larger than the display memory of the GPGPU is prevented, and a plurality of applications can share one GPGPU device.
In step S31, the used video memory amount is updated according to the video memory amount to be applied.
In the above, the used video memory number is updated according to the video memory number to be applied, the number of the video memory to be applied may be added to the applied video memory number, and the updated applied video memory number is obtained through calculation.
Optionally, the method further includes: when the current application releases the video memory, acquiring the quantity of the video memory release of the current application to obtain the quantity of the video memory release; and updating the used video memory quantity according to the video memory release quantity.
Optionally, the method further includes: and correcting the number of the video memories, such as correcting to be zero if the used video memory data becomes negative, so as to deal with design omission of partial drivers.
The CGroup is used to expose three interfaces, mem.max, mem.cur, weight, and non-container cases through CGroup, which can be used by creating CGroup, where CGroup is an operation interface that CGroup is exposed to VFS (L inux virtual file system) layer, where mem.max is used to check and set the total allocated display memory number of the application, mem.cur is used to check the currently used display memory number of the application, weight is reserved for subsequent computing power scheduling, GPU CGroup is added, vgpu _ set and vgpu _ show are used to access vgpu _ cfg _ S, which is not strongly coupled to GPU driver, see fig. 4, which is a flowchart of a platform management part of the embodiment of the present application, and if CGroup is started, CGroup is used to execute a new program, step S41 starts, step S2 receives new application, step S receives CGroup _ cfg _ S, determines whether CGroup _ cfg _ S _ sry is received, step S _ srt is executed, CGroup _ S _ sry is executed, step S _ srt is executed, if GPUs _ cfm _ sru _ sr.
Therefore, by the video memory allocation method of the embodiment of the application, when the video memory is applied by the current application, the number of the video memories applied by the current application is obtained, and the number of the video memories to be applied is obtained; reading the total distributed video memory quantity and the used video memory quantity in a preset configuration file corresponding to the current application; judging whether the sum of the number of the video memories to be applied and the number of the used video memories is larger than the total distributed video memory number or not; and if the sum of the number of the video memories to be applied and the number of the used video memories is not more than the total distributed number of the video memories, distributing the video memories of the number of the video memories to be applied for the current application. The method can send the information of insufficient video memory to the current application when the video memory is insufficient, thereby realizing the distribution of the video memory according to the application request, preventing the situation that the video memory is contended and robbed due to the fact that the quantity of the applied video memory exceeds the whole video memory of the GPGPU under the condition that the video memory of the current application is ensured to be used, ensuring the video memory supply of each application and improving the use efficiency of the video memory.
Fig. 5 is a diagram of an example of a video memory allocation method according to an embodiment of the present application, including the following steps:
s51, reading the maximum application number setting, and initializing a vgpu _ cfg _ S table; s52 starting the GPGPU application; s53 initializing GPGPU context and setting vgpu _ cfg _ S item; s54 inquiring the total video memory; s55, inquiring the actual available video memory, executing S56 when the video memory is allocated more than vgpu _ cfg _ S, and executing S57 when the video memory is allocated for other situations; s56 returns the setting in vgpu _ cfg _ S; s57, returning the actual available video memory; s58, continuing the execution, judging whether the execution is continued, executing S59 when the execution is continued, and executing S60 when the execution is not continued; s59, judging the action, executing S60 when the execution is finished, executing S61 when the video memory is applied, and executing step S63 when the video memory is released; s60 releases the context and resets vgpu _ cfg _ S item; s61, applying for video memory, judging whether the applied video memory exceeds the limit, if so, executing S62, and if not, executing S58; s62, continuing, judging whether to continue execution or not, if so, executing S58, otherwise, executing S60; s63 releasing the video memory, judging whether the video memory is released, executing step S58 when the used video memory is normal, and executing step S64 when the used video memory is negative; s64 resets the used video memory. The used video memory may be displayed as a negative number due to the defect of the conventional GPU driver, and the video memory can be corrected by resetting the used video memory.
Fig. 6 is a schematic structural diagram of a video memory allocation apparatus according to an embodiment of the present application, including the following steps:
the video memory application module 601 is configured to obtain the number of video memories applied by the current application when the current application applies for the video memory, so as to obtain the number of the video memories to be applied.
The video memory reading module 602 is configured to read a total allocated video memory quantity and a used video memory quantity in a preset configuration file corresponding to the current application, where the total allocated video memory quantity is an upper limit of a preset video memory quantity allocated to the current application, and the used video memory quantity is a video memory quantity already allocated to the current application.
The video memory determining module 603 is configured to determine whether the sum of the number of the video memories to be applied and the number of the used video memories is greater than the total allocated video memory number.
The application allocation module 604 is configured to allocate the video memory of the video memory amount to be applied to the current application if the sum of the video memory amount to be applied and the used video memory amount is not greater than the total allocated video memory amount.
The information sending module 605 is configured to send the insufficient video memory information in the specified format to the current application if the sum of the number of the to-be-applied video memories and the number of the used video memories is greater than the total allocated video memory number.
Optionally, the apparatus further comprises:
the file creating module is used for starting the current application and creating a current application configuration file, wherein the configuration file comprises the total allocated video memory quantity and the used video memory quantity, the total allocated video memory quantity is the upper limit of the video memory quantity allocated to the current application, and the value of the used video memory quantity is zero in an initial state;
the quantity judging module is used for judging whether the total available video memory quantity is larger than the total allocated video memory quantity or not, wherein the total available video memory quantity is the video memory quantity which is not used in the image processor;
and the completion judging module is used for judging that the configuration of the current application configuration file is completed if the total available video memory quantity is greater than the total distributed video memory quantity.
Optionally, the apparatus further comprises:
and the video memory assignment module is used for assigning the value of the total available video memory quantity to the total allocated video memory quantity if the total available video memory quantity is not greater than the total allocated video memory quantity.
Optionally, the apparatus further comprises:
and the video memory updating module is used for updating the used video memory quantity according to the video memory quantity to be applied.
Optionally, the apparatus further comprises:
the release information module is used for acquiring the quantity of the video memory release of the current application when the current application releases the video memory, so as to obtain the quantity of the video memory release;
and the quantity updating module is used for updating the quantity of the used video memory according to the quantity of the released video memory.
Therefore, by the video memory allocation device of the embodiment of the application, when the video memory is applied by the current application, the number of the video memories applied by the current application is obtained, and the number of the video memories to be applied is obtained; reading the total distributed video memory quantity and the used video memory quantity in a preset configuration file corresponding to the current application; judging whether the sum of the number of the video memories to be applied and the number of the used video memories is larger than the total distributed video memory number or not; and if the sum of the number of the video memories to be applied and the number of the used video memories is not more than the total distributed number of the video memories, distributing the video memories of the number of the video memories to be applied for the current application. Therefore, the video memory is distributed according to the application request, the situation that the video memory is contended and robbed due to the fact that the quantity of the application video memory exceeds the whole video memory of the GPGPU is prevented under the condition that the video memory of the current application is used is guaranteed, the video memory supply of each application is guaranteed, and the use efficiency of the video memory is improved.
The embodiment of the present application further provides an electronic device, as shown in fig. 7, which includes a processor 701, a communication interface 702, a memory 703 and a communication bus 704, where the processor 701, the communication interface 702, and the memory 703 complete mutual communication through the communication bus 704,
a memory 703 for storing a computer program;
the processor 701 is configured to implement the following steps when executing the program stored in the memory 703:
when the current application applies for the video memory, acquiring the number of the video memory applied by the current application to obtain the number of the video memory to be applied;
reading the total distributed video memory quantity and the used video memory quantity in a preset configuration file corresponding to the current application, wherein the total distributed video memory quantity is the upper limit of the preset video memory quantity distributed to the current application, and the used video memory quantity is the video memory quantity distributed to the current application;
judging whether the sum of the number of the video memories to be applied and the number of the used video memories is larger than the total distributed video memory number or not;
if the sum of the number of the video memories to be applied and the number of the used video memories is not more than the total distributed video memory number, distributing the video memories of the number of the video memories to be applied for the current application;
and if the sum of the number of the video memories to be applied and the number of the used video memories is larger than the total distributed video memory number, sending the video memory shortage information in the specified format to the current application.
Optionally, when the processor is configured to execute the program stored in the memory, any of the video memory allocation methods may also be implemented.
The communication bus mentioned in the electronic device may be a PCI (Peripheral component interconnect) bus, an EISA (Extended Industry standard architecture) bus, or the like. The communication bus may be divided into an address bus, a data bus, a control bus, etc. For ease of illustration, only one thick line is shown, but this does not mean that there is only one bus or one type of bus.
The communication interface is used for communication between the electronic equipment and other equipment.
The Memory may include a RAM (Random Access Memory) or an NVM (Non-Volatile Memory), such as at least one disk Memory. Optionally, the memory may also be at least one memory device located remotely from the processor.
The Processor may be a general-purpose Processor, including a Central Processing Unit (CPU), a Network Processor (NP), and the like; but also a DSP (Digital Signal Processor), an ASIC (Application Specific Integrated Circuit), an FPGA (Field-Programmable Gate Array) or other Programmable logic device, discrete Gate or transistor logic device, discrete hardware component.
An embodiment of the present application further provides a computer-readable storage medium, where a computer program is stored in the computer-readable storage medium, and when the computer program is executed by a processor, the computer program implements the following steps:
when the current application applies for the video memory, acquiring the number of the video memory applied by the current application to obtain the number of the video memory to be applied;
reading the total distributed video memory quantity and the used video memory quantity in a preset configuration file corresponding to the current application, wherein the total distributed video memory quantity is the upper limit of the preset video memory quantity distributed to the current application, and the used video memory quantity is the video memory quantity distributed to the current application;
judging whether the sum of the number of the video memories to be applied and the number of the used video memories is larger than the total distributed video memory number or not;
and if the sum of the number of the video memories to be applied and the number of the used video memories is not more than the total distributed number of the video memories, distributing the video memories of the number of the video memories to be applied for the current application.
Optionally, the computer program can also implement any of the video memory allocation methods described above when executed by a processor.
It is noted that, herein, relational terms such as first and second, and the like may be used solely to distinguish one entity or action from another entity or action without necessarily requiring or implying any actual such relationship or order between such entities or actions. Also, the terms "comprises," "comprising," or any other variation thereof, are intended to cover a non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements does not include only those elements but may include other elements not expressly listed or inherent to such process, method, article, or apparatus. Without further limitation, an element defined by the phrase "comprising an … …" does not exclude the presence of other identical elements in a process, method, article, or apparatus that comprises the element.
All the embodiments in the present specification are described in a related manner, and the same and similar parts among the embodiments may be referred to each other, and each embodiment focuses on the differences from the other embodiments. In particular, for the system embodiment, since it is substantially similar to the method embodiment, the description is simple, and for the relevant points, reference may be made to the partial description of the method embodiment.
The above description is only for the preferred embodiment of the present application, and is not intended to limit the scope of the present application. Any modification, equivalent replacement, improvement and the like made within the spirit and principle of the present application are included in the protection scope of the present application.

Claims (12)

1. A video memory allocation method is characterized by comprising the following steps:
when the current application applies for the video memory, acquiring the quantity of the video memory applied by the current application to obtain the quantity of the video memory to be applied;
reading the total distributed video memory quantity and the used video memory quantity in a preset configuration file corresponding to the current application, wherein the total distributed video memory quantity is the preset upper limit of the video memory quantity distributed to the current application, and the used video memory quantity is the video memory quantity distributed to the current application;
judging whether the sum of the number of the video memories to be applied and the number of the used video memories is larger than the total distributed video memory number or not;
if the sum of the number of the video memories to be applied and the number of the used video memories is not more than the total allocated video memory number, allocating the video memories of the number of the video memories to be applied to the current application;
and if the sum of the number of the video memories to be applied and the number of the used video memories is larger than the total distributed number of the video memories, sending the video memory shortage information in the specified format to the current application.
2. The method according to claim 1, wherein when the current application applies for the video memory, before obtaining the number of the video memory applied by the current application and obtaining the number of the video memory to be applied, the method further comprises:
starting the current application, and creating a current application configuration file, wherein the configuration file comprises a total allocated video memory quantity and a used video memory quantity, the total allocated video memory quantity is an upper limit of the video memory quantity allocated to the current application, and the value of the used video memory quantity is zero in an initial state;
judging whether the total available video memory quantity is larger than the total allocated video memory quantity or not, wherein the total available video memory quantity is the video memory quantity which is not used in the image processor;
and if the total available video memory quantity is larger than the total distributed video memory quantity, judging that the current application configuration file configuration is finished.
3. The method of claim 2, wherein after determining whether the total available video memory amount is greater than the total allocated video memory amount, the method further comprises:
and if the total available video memory quantity is not greater than the total allocated video memory quantity, giving the value of the total available video memory quantity to the total allocated video memory quantity.
4. The method according to claim 1, wherein after allocating the video memory of the amount of the video memory to be applied to the current application, the method further comprises:
and updating the used video memory quantity according to the video memory quantity to be applied.
5. The method of claim 1, further comprising:
when the current application releases the video memory, acquiring the quantity of the video memory release of the current application to obtain the quantity of the video memory release;
and updating the used video memory quantity according to the video memory release quantity.
6. A video memory allocation apparatus, comprising:
the video memory application module is used for acquiring the number of the video memories applied by the current application when the current application applies for the video memories, and acquiring the number of the video memories to be applied;
the video memory reading module is used for reading the total allocated video memory quantity and the used video memory quantity in a preset configuration file corresponding to the current application, wherein the total allocated video memory quantity is the preset upper limit of the video memory quantity allocated to the current application, and the used video memory quantity is the video memory quantity allocated to the current application;
the video memory judging module is used for judging whether the sum of the number of the video memories to be applied and the number of the used video memories is larger than the total distributed video memory number or not;
the application allocation module is used for allocating the video memory of the video memory quantity to be applied for the current application if the sum of the quantity of the video memory to be applied and the quantity of the used video memory is not more than the total allocated video memory quantity;
and the information sending module is used for sending the insufficient video memory information in the specified format to the current application if the sum of the number of the video memories to be applied and the number of the used video memories is greater than the total distributed video memory number.
7. The apparatus of claim 6, further comprising:
a file creating module, configured to start the current application and create a current application configuration file, where the configuration file includes a total allocated video memory amount and a used video memory amount, the total allocated video memory amount is an upper limit of the video memory amount allocated to the current application, and a value of the used video memory amount is zero in an initial state;
the quantity judging module is used for judging whether the total available video memory quantity is larger than the total allocated video memory quantity or not, wherein the total available video memory quantity is the video memory quantity which is not used in the image processor;
and the completion judging module is used for judging that the configuration of the current application configuration file is completed if the total available video memory quantity is greater than the total distributed video memory quantity.
8. The apparatus of claim 7, further comprising:
and the video memory assignment module is used for giving the value of the total available video memory quantity to the total allocated video memory quantity if the total available video memory quantity is not greater than the total allocated video memory quantity.
9. The apparatus of claim 6, further comprising:
and the video memory updating module is used for updating the used video memory quantity according to the video memory quantity to be applied.
10. The apparatus of claim 6, further comprising:
the release information module is used for acquiring the quantity of the video memory release of the current application when the current application releases the video memory, so as to obtain the quantity of the video memory release;
and the quantity updating module is used for updating the used video memory quantity according to the video memory release quantity.
11. An electronic device, comprising a processor, a communication interface, a memory and a communication bus, wherein the processor, the communication interface and the memory complete communication with each other through the communication bus;
a memory for storing a computer program;
a processor for implementing the method steps of any of claims 1-5 when executing the computer program stored in the memory.
12. A computer-readable storage medium, characterized in that a computer program is stored in the computer-readable storage medium, which computer program, when being executed by a processor, carries out the method steps of any one of the claims 1-5.
CN202010144896.6A 2020-03-04 2020-03-04 Video memory allocation method and device, electronic equipment and storage medium Pending CN111400035A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202010144896.6A CN111400035A (en) 2020-03-04 2020-03-04 Video memory allocation method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202010144896.6A CN111400035A (en) 2020-03-04 2020-03-04 Video memory allocation method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN111400035A true CN111400035A (en) 2020-07-10

Family

ID=71434510

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202010144896.6A Pending CN111400035A (en) 2020-03-04 2020-03-04 Video memory allocation method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN111400035A (en)

Cited By (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112052083A (en) * 2020-09-15 2020-12-08 浙江智慧视频安防创新中心有限公司 Video memory scheduling method and device of cloud GPU, electronic equipment and storage medium
CN113467958A (en) * 2021-09-02 2021-10-01 腾讯科技(深圳)有限公司 Data processing method, device, equipment and readable storage medium

Citations (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN103761139A (en) * 2014-01-25 2014-04-30 湖南大学 General purpose computation virtualization implementation method based on dynamic library interception
CN104216781A (en) * 2013-05-29 2014-12-17 上海联影医疗科技有限公司 Video memory allocating method and system
CN104243743A (en) * 2013-06-06 2014-12-24 佳能株式会社 Image processing apparatus and control method thereof
CN107168782A (en) * 2017-04-24 2017-09-15 复旦大学 A kind of concurrent computational system based on Spark and GPU
CN109582425A (en) * 2018-12-04 2019-04-05 中山大学 A kind of GPU service redirection system and method merged based on cloud with terminal GPU
US20190155660A1 (en) * 2017-09-20 2019-05-23 Algorithmia, Inc. Scheduling system for computational work on heterogeneous hardware
US20190220383A1 (en) * 2018-01-17 2019-07-18 Microsoft Technology Licensing, Llc Techniques for tracking graphics processing resource utilization
CN110413408A (en) * 2019-06-29 2019-11-05 苏州浪潮智能科技有限公司 A kind of video memory control method, equipment and the storage medium of deep learning frame
CN110471766A (en) * 2019-08-06 2019-11-19 北京华恒盛世科技有限公司 A kind of GPU resource scheduling system and method based on CUDA
CN110532071A (en) * 2019-07-12 2019-12-03 上海大学 A kind of more application schedules system and method based on GPU
CN110688218A (en) * 2019-09-05 2020-01-14 广东浪潮大数据研究有限公司 Resource scheduling method and device

Patent Citations (11)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN104216781A (en) * 2013-05-29 2014-12-17 上海联影医疗科技有限公司 Video memory allocating method and system
CN104243743A (en) * 2013-06-06 2014-12-24 佳能株式会社 Image processing apparatus and control method thereof
CN103761139A (en) * 2014-01-25 2014-04-30 湖南大学 General purpose computation virtualization implementation method based on dynamic library interception
CN107168782A (en) * 2017-04-24 2017-09-15 复旦大学 A kind of concurrent computational system based on Spark and GPU
US20190155660A1 (en) * 2017-09-20 2019-05-23 Algorithmia, Inc. Scheduling system for computational work on heterogeneous hardware
US20190220383A1 (en) * 2018-01-17 2019-07-18 Microsoft Technology Licensing, Llc Techniques for tracking graphics processing resource utilization
CN109582425A (en) * 2018-12-04 2019-04-05 中山大学 A kind of GPU service redirection system and method merged based on cloud with terminal GPU
CN110413408A (en) * 2019-06-29 2019-11-05 苏州浪潮智能科技有限公司 A kind of video memory control method, equipment and the storage medium of deep learning frame
CN110532071A (en) * 2019-07-12 2019-12-03 上海大学 A kind of more application schedules system and method based on GPU
CN110471766A (en) * 2019-08-06 2019-11-19 北京华恒盛世科技有限公司 A kind of GPU resource scheduling system and method based on CUDA
CN110688218A (en) * 2019-09-05 2020-01-14 广东浪潮大数据研究有限公司 Resource scheduling method and device

Cited By (3)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN112052083A (en) * 2020-09-15 2020-12-08 浙江智慧视频安防创新中心有限公司 Video memory scheduling method and device of cloud GPU, electronic equipment and storage medium
CN113467958A (en) * 2021-09-02 2021-10-01 腾讯科技(深圳)有限公司 Data processing method, device, equipment and readable storage medium
CN113467958B (en) * 2021-09-02 2021-12-14 腾讯科技(深圳)有限公司 Data processing method, device, equipment and readable storage medium

Similar Documents

Publication Publication Date Title
CN109144710B (en) Resource scheduling method, device and computer readable storage medium
CN108063784B (en) Method, device and system for distributing application cluster resources in cloud environment
WO2023000673A1 (en) Hardware accelerator device management method and apparatus, and electronic device and storage medium
CN114416352A (en) Computing resource allocation method and device, electronic equipment and storage medium
CN111861412A (en) Completion time optimization-oriented scientific workflow scheduling method and system
CN111400035A (en) Video memory allocation method and device, electronic equipment and storage medium
CN113037794A (en) Computing resource allocation scheduling method, device and system
CN112445615A (en) Thread scheduling system, computer equipment and storage medium
CN110580195B (en) Memory allocation method and device based on memory hot plug
CN107077376B (en) Frame buffer implementation method and device, electronic equipment and computer program product
CN113515382A (en) Cloud resource allocation method and device, electronic equipment and program product
CN111104219A (en) Binding method, device, equipment and storage medium of virtual core and physical core
US20200034209A1 (en) Information processing system and resource allocation method
CN115586961A (en) AI platform computing resource task scheduling method, device and medium
CN107992351B (en) Hardware resource allocation method and device and electronic equipment
CN113535087A (en) Data processing method, server and storage system in data migration process
CN117311990B (en) Resource adjustment method and device, electronic equipment, storage medium and training platform
CN116483546B (en) Distributed training task scheduling method, device, equipment and storage medium
CN116483740B (en) Memory data migration method and device, storage medium and electronic device
CN111813541B (en) Task scheduling method, device, medium and equipment
CN115080242A (en) Method, device and medium for unified scheduling of PCI equipment resources
CN103164338A (en) Analogy method and analogy device of concurrent processing system
CN115564635A (en) GPU resource scheduling method and device, electronic equipment and storage medium
CN110825502A (en) Neural network processor and task scheduling method for neural network processor
CN110955644A (en) IO control method, device, equipment and storage medium of storage system

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination