Resource allocation method, device, equipment and storage medium
By calculating the weight value of the GPU card in Kubernetes and dynamically allocating GPU resources, the low usage rate problem caused by traditional random allocation is solved, and efficient utilization and reasonable allocation of GPU resources are achieved.
Patent Information
- Application Number
- CN202110270221.0
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-03-12
- Publication Date
- 2024-12-31
- Estimated Expiration
- 2041-03-12
AI Technical Summary
Traditional Kubernetes randomly allocates GPU cards during GPU scheduling, resulting in low overall GPU usage and waste of resources.
By obtaining the number of GPU resources required for the task request and the topology of available GPU nodes, the weight value of each GPU card is calculated, and the most suitable GPU node and GPU card are allocated according to the weight value, so as to achieve dynamic adjustment of resource allocation.
It improves the utilization rate of GPU resources, ensures the rational use of resources, meets task requests with greater demand, and reduces resource waste.
Smart Images

Figure CN112988383B_ABST
Abstract
Description
Technical Field
[0001] The present application belongs to the field of computer technology, and in particular, relates to a resource allocation method, a resource allocation device, a resource allocation equipment and a storage medium. Background Art
[0002] With the development of various industries, it is necessary to build machine learning applications for various scenarios. In order to train machine learning models with better performance using massive data, it is necessary to efficiently call and manage large-scale graphics processing units (GPUs). In response to such needs, cloud native technology based on Kubernetes came into being.
[0003] Kubernetes, or K8s for short, is an abbreviation formed by replacing the eight characters "ubernete" with "8". It is an open source containerized application management framework for multiple hosts in a cloud platform. The goal of Kubernetes is to make the deployment of containerized applications simple and efficient. Kubernetes provides a mechanism for application deployment, planning, updating, and maintenance.
[0004] However, the current Kubernetes usually randomly allocates GPU cards when scheduling GPUs, resulting in low overall GPU utilization and waste of resources. Summary of the invention
[0005] In view of this, embodiments of the present application provide a resource allocation method, a resource allocation apparatus, a resource allocation device, and a storage medium to solve the problem that the traditional resource allocation method randomly allocates GPU cards, resulting in low overall GPU utilization and waste of resources.
[0006] A first aspect of an embodiment of the present application provides a resource allocation method, including:
[0007] When a task request that requires scheduling GPU resources is obtained, available GPU nodes and the number of used GPU cards in each available GPU node are obtained; the task request carries the number of GPU resources required to complete the task request;
[0008] Determine a weight value corresponding to each idle GPU card in each available GPU node based on the available GPU nodes, the number of the GPU cards, and the topological structure corresponding to each GPU card;
[0009] Determine the allocation result corresponding to the task request based on the required number of GPU resources and the weight value corresponding to each idle GPU card;
[0010] A GPU card is allocated to the task request based on the allocation result.
[0011] A second aspect of an embodiment of the present application provides a resource allocation device, including:
[0012] An acquisition unit, configured to acquire available GPU nodes and the number of used GPU cards in each available GPU node when a task request requiring scheduling of GPU resources is acquired; the task request carries the number of GPU resources required to complete the task request;
[0013] A first determining unit is used to determine a weight value corresponding to each idle GPU card in each available GPU node based on the available GPU nodes, the number of the GPU cards, and a topological structure corresponding to each GPU card;
[0014] A second determining unit, configured to determine an allocation result corresponding to the task request based on the required number of GPU resources and a weight value corresponding to each idle GPU card;
[0015] An allocating unit is used to allocate a GPU card to the task request based on the allocation result.
[0016] A third aspect of an embodiment of the present application provides a resource allocation device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor implements the steps of the resource allocation method described in the first aspect when executing the computer program.
[0017] A fourth aspect of an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the resource allocation method described in the first aspect above are implemented.
[0018] A fifth aspect of the embodiments of the present application provides a computer program product. When the computer program product runs on a resource allocation device, the resource allocation device executes the steps of the resource allocation method described in the first aspect.
[0019] The resource allocation method, resource allocation apparatus, resource allocation device and storage medium provided in the embodiments of the present application have the following beneficial effects:
[0020] In the resource allocation method provided in the present application, when a task request that requires scheduling GPU resources is obtained, the available GPU nodes and the number of GPU cards used in each available GPU node are obtained; the task request carries the number of GPU resources required to complete the task request; based on the available GPU nodes, the number of GPU cards and the topological structure corresponding to each GPU card, the weight value corresponding to each idle GPU card in each available GPU node is determined; based on the required number of GPU resources and the weight value corresponding to each idle GPU card, the allocation result corresponding to the task request is determined, and the GPU card is allocated to the task request based on the allocation result. In the above method, the resource allocation device determines the weight value corresponding to each available GPU card according to the topological structure and usage corresponding to each GPU card, and allocates the most suitable GPU node and GPU card to the task request based on the weight value and the different requirements of the task request. This method of dynamically adjusting the weight to allocate GPU resources allows GPU cards to be more compactly allocated to different task requests, so that idle GPU resources can better serve task requests with greater demand, fully and reasonably utilize GPU resources, and maximize the utilization rate of GPU resources. BRIEF DESCRIPTION OF THE DRAWINGS
[0021] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art will be briefly introduced below. Obviously, the drawings described below are only some embodiments of the present application. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative labor.
[0022] Figure 1 is a schematic flow chart of a resource allocation method provided in an embodiment of the present application;
[0023] Figure 2 is a schematic flow chart of a resource allocation method provided in another embodiment of the present application;
[0024] Figure 3 is a schematic flow chart of a resource allocation method provided in yet another embodiment of the present application;
[0025] Figure 4 is a schematic flow chart of a resource allocation method provided in another embodiment of the present application;
[0026] Figure 5 is a schematic diagram of a resource allocation device provided by an embodiment of the present application;
[0027] Figure 6 It is a schematic diagram of a resource allocation device provided in another embodiment of the present application. DETAILED DESCRIPTION
[0028] In order to make the purpose, technical solution and advantages of the present application more clearly understood, the present application is further described in detail below in conjunction with the accompanying drawings and embodiments. It should be understood that the specific embodiments described herein are only used to explain the present application and are not used to limit the present application.
[0029] The traditional resource allocation method randomly allocates GPU cards, resulting in low overall GPU utilization and waste of resources. In view of this, the present application provides a resource allocation method, in which, when a task request that requires scheduling GPU resources is obtained, the available GPU nodes and the number of GPU cards used in each available GPU node are obtained; the task request carries the number of GPU resources required to complete the task request; based on the available GPU nodes, the number of GPU cards and the topological structure corresponding to each GPU card, the weight value corresponding to each idle GPU card in each available GPU node is determined; based on the required number of GPU resources and the weight value corresponding to each idle GPU card, the allocation result corresponding to the task request is determined, and the GPU card is allocated to the task request based on the allocation result. In the above method, the resource allocation device determines the weight value corresponding to each available GPU card according to the topological structure and usage corresponding to each GPU card, and allocates the most suitable GPU node and GPU card to the task request based on the weight value and the different requirements of the task request. This method of dynamically adjusting the weight to allocate GPU resources allows GPU cards to be more compactly allocated to different task requests, so that idle GPU resources can better serve task requests with greater demand, fully and reasonably utilize GPU resources, and maximize the utilization rate of GPU resources.
[0030] See also Figure 1 , Figure 1 : is a schematic flow chart of the resource allocation method provided in the embodiment of the present application. The execution subject of the resource allocation method in this embodiment is a resource allocation device, and the resource allocation device includes but is not limited to an independent server, a distributed server, a server cluster, a cloud server, a smart phone, a tablet computer, a computer, a personal digital assistant (PDA), a laptop computer, an ultra-mobile personal computer (UMPC), etc. Figure 1 The resource allocation method shown may include S101 to S104, and the specific implementation principle of each step is as follows.
[0031] S101: When a task request requiring scheduling of GPU resources is obtained, available GPU nodes and the number of used GPU cards in each available GPU node are obtained; the task request carries the number of GPU resources required to complete the task request.
[0032] When an application needs to schedule GPU resources, it will initiate a task request that requires scheduling GPU resources. The resource allocation device receives the task request and obtains the available GPU nodes and the number of GPU cards used in each available GPU node. The task request carries the number of GPU resources required to complete the task request. It can also be that the resource allocation device monitors whether there is a task request that needs to schedule GPU resources. When the task request is monitored, the task request is obtained. Among them, the number of GPU resources required to complete the task request carried in the task request can be understood as the number of GPU cards required to complete the task request.
[0033] For ease of understanding, some terms involved in this embodiment are explained illustratively.
[0034] GPU: Graphics Processing Unit.
[0035] Kubernetes: A system for running and coordinating containerized applications on resource allocation devices, providing mechanisms for application deployment, planning, updating and maintenance.
[0036] Pod: It is the basic unit of the Kubernetes system. It is the smallest component created or deployed by the user. It is a combination of one or more containers and a resource object for running containerized applications on the Kubernetes system.
[0037] Api server: A component in kubernetes through which other components can share state and interact.
[0038] PCI-Express (PCI-E): is the latest bus and interface standard, which can include display interface and various application interfaces.
[0039] Kubelet: A component in kubernetes. Its main function is to obtain the running information of GPU nodes from somewhere regularly and report it to the API server regularly.
[0040] For example, kubernetes is deployed and run in the resource allocation device in advance. A task request that requires scheduling GPU resources can be received through Apiserver. When the task request is received, a Pod object is created accordingly. Among them, one Pod object corresponds to one task request, which can be understood as creating a Pod object for each task request received.
[0041] The resource allocation device parses the encapsulated information through the API server to obtain the identification information corresponding to all current GPU nodes, the used GPU cards and idle GPU cards corresponding to each GPU node in all current GPU nodes, the identification information corresponding to each GPU card, and the topological structure corresponding to each GPU card.
[0042] Based on the number of GPU resources required to complete the task request carried in the task request, the available GPU nodes and the number of used GPU cards in each available GPU node are determined among all current GPU nodes and all GPU cards. Exemplarily, the number of used GPU cards and the number of free GPU cards corresponding to each GPU node can be determined based on the used GPU cards and free GPU cards corresponding to each GPU node. A GPU node whose number of free GPU cards in the GPU node is greater than or equal to the required number of GPU resources is selected as an available GPU node. The number of used GPU cards in these available GPU nodes is obtained.
[0043] Optionally, when there are multiple PCI-Es set in the GPU node, obtaining the number of used GPU cards in the available GPU node includes obtaining the number of all used GPU cards in the GPU node and obtaining the number of used GPU cards installed in the same PCI-E. For example, when there are two PCI-Es set in the GPU node, the number of all used GPU cards in the GPU node is obtained, and the number of used GPU cards in each PCI-E is obtained.
[0044] Optionally, before S101, it may also include collecting the topological structure corresponding to each GPU card on each GPU node in all GPU nodes, the identification information corresponding to each GPU node, the identification information corresponding to each GPU card, the usage of each GPU card, etc. based on the preset plug-in, and encapsulating this information in the form of extended resources. That is, the obtained information is encoded and converted into data that can be understood by the computer. The Kubelet process obtains the packaged information according to the preset period and uploads the information to the Api server. The preset period is set by the user and is not limited to this. For example, the Kubelet process obtains the latest packaged information every 10 seconds and uploads the information to the Api server.
[0045] Among them, the preset plug-in is mainly used to collect information corresponding to each GPU card on each GPU node, and the preset plug-in can be a custom device-plugin plug-in. The topological structure corresponding to the GPU card is used to represent the physical layout of the GPU card in the resource allocation device. For example, two PCI-E and 8 GPU cards are provided in the resource allocation device, and every four GPU cards are installed on one PCI-E according to a preset order. For any one of the GPU cards, the relationship between the GPU card and the two PCI-E and the remaining 7 GPU cards is the physical layout corresponding to the GPU card, that is, the topological structure corresponding to the GPU card.
[0046] In an embodiment of the present application, the resource allocation device can timely and accurately obtain the identification information corresponding to all current GPU nodes, as well as the topological structure and identification information corresponding to each GPU card, so that the subsequent resource allocation device can timely and reasonably allocate GPU resources for task requests.
[0047] like Figure 2 As shown, Figure 2 is a schematic flow chart of a resource allocation method provided by another embodiment of the present application. Optionally, in a possible implementation, the above S101 includes S1011 to S1013, which are specifically as follows:
[0048] S1011: Obtain the GPU nodes in the logged-in state and the number of idle GPU cards in each GPU node.
[0049] Obtaining the logged-in GPU nodes can also be understood as obtaining the currently available GPU nodes. Specifically, the resource allocation device parses the packaged information through the API server to obtain all current GPU nodes and the used GPU cards and idle GPU cards corresponding to each GPU node in all current GPU nodes. Based on this, the number of idle GPU cards in each GPU node in all current GPU nodes is counted.
[0050] S1012: Determine available GPU nodes based on the number of idle GPU cards in each GPU node and the required number of GPU resources.
[0051] The resource allocation device can filter out GPU nodes whose number of idle GPU cards does not meet the number of GPU resources required by the task request in advance among all GPU nodes. These filtered-out GPU nodes will not enter the subsequent allocation process, thereby improving the speed and accuracy of subsequent GPU resource allocation.
[0052] The resource allocation device can also mark the GPU nodes whose number of idle GPU cards in the GPU nodes is greater than or equal to the required number of GPU resources as available GPU nodes. Similarly, only the GPU nodes marked as available can enter the subsequent allocation process, thereby improving the speed and accuracy of subsequent GPU resource allocation.
[0053] For example, the task request that needs to schedule GPU resources carries the number of GPU resources required to complete the task request, which is 3. The number of idle GPU cards on all GPU nodes is obtained, and the GPU nodes with the number of idle GPU cards greater than or equal to 3 are retained, and the GPU nodes with the number of idle GPU cards less than 3 are filtered out. Exemplarily, if the number of idle GPU cards on a GPU node is 1, the GPU node is filtered out; if the number of idle GPU cards on a GPU node is 2, the GPU node is filtered out; if the number of idle GPU cards on a GPU node is 4, the GPU node is retained; if the number of idle GPU cards on a GPU node is 3, the GPU node is also retained. These reserved GPU nodes are available GPU nodes, and these GPU nodes and the GPU cards on these GPU nodes will enter the subsequent allocation process.
[0054] S1013: Obtain the number of used GPU cards in each available GPU node.
[0055] The available GPU nodes here can be understood as GPU nodes that can be subsequently allocated for the task request, or can be understood as GPU nodes corresponding to GPU cards that can be subsequently allocated for the task request. After determining the available GPU nodes, the number of used GPU cards on each available GPU node is obtained respectively, so as to facilitate the subsequent determination of the weight value corresponding to each idle GPU card in each available GPU node.
[0056] S102: Based on the number of available GPU nodes and GPU cards and the topological structure corresponding to each GPU card, determine a weight value corresponding to each idle GPU card in each available GPU node.
[0057] The resource allocation device determines the weight value corresponding to each idle GPU card in each available GPU node based on the available GPU nodes, the number of used GPU cards in each available GPU node, and the topological structure corresponding to each used GPU card in the available GPU nodes. Exemplarily, after determining each available GPU node, the number of used GPU cards and the number of idle GPU cards on each available GPU node are counted to obtain the topological structure corresponding to each used GPU card on each available GPU node. The number of used GPU cards on each available GPU node includes the number of all used GPU cards in each GPU node and the number of used GPU cards installed in the same PCI-E.
[0058] The weight value corresponding to each idle GPU card in each available GPU node is determined by a preset formula. The preset formula is as follows:
[0059]
[0060] In the above formula (1), g represents the weight value corresponding to the idle GPU card, constant is a constant that can be adjusted according to the topological structure corresponding to each GPU card; all1 represents the number of all GPU cards in the GPU node; all2 represents the number of GPU cards installed on the same PCI-E; used1 represents the number of all used GPU cards in the GPU node; used2 represents the number of used GPU cards installed on the same PCI-E; requested represents the number of GPU resources required for the task request.
[0061] Exemplarily, the preset formula can be divided into three parts. The first part is a constant 100, which is used to represent the initial weight value assigned to each GPU card. Here, 100 is only for exemplary explanation and is not limited to this.
[0062] The second part is This part is used to update the weight value based on the topology of each GPU card. Under the current topology, the fewer idle GPU cards are left, the higher the weight value is, and the more idle GPU cards are left, the lower the weight value is. It can be understood that the fewer idle GPU cards are left, the more priority they will be allocated. For example, a GPU node is set with 2 PCI-E and 8 GPU cards, and every 4 GPU cards are installed on a PCI-E in a preset order. Among them, two GPU cards installed in sequence on the first PCI-E are in use. At this time, constant can be 120, all1 can be 8, and used1 can be 2.
[0063] The third part is If the weight value corresponding to the third idle GPU card on the first PCI-E is calculated, the number of GPU resources required for the task request is 2. At this time, all2 takes 4, and the values of used2 and requested are set to 2 respectively. The third part considers the integrity of the number of GPU cards, and gives priority to allocating the complete topology structure to the task request to improve the efficiency of data processing by the task request. As in the above example, the number of GPU resources required for the task request is 2. According to the calculation result of the weight value, the resource allocation device can allocate the remaining two idle GPU cards on the same PCI-E to the task request, which ensures the maximum utilization of GPU card resources on the one hand; on the other hand, the GPU card on the same PCI-E is allocated to the task request, which facilitates the data interaction within the task request and improves the speed of data processing by the task request; on the other hand, for another PCI-E, it still has 4 idle GPU cards. When the new task request requires 3 GPU cards or 4 GPU cards, the GPU card in another PCI-E can be directly allocated without the task request waiting.
[0064] It should be noted that if the third part of the formula is calculated to be a negative value, the calculation result of this part will be discarded.
[0065] S103: Determine an allocation result corresponding to the task request based on the required number of GPU resources and the weight value corresponding to each idle GPU card.
[0066] The allocation result includes first identification information and second identification information; wherein, the first identification information is used to identify the target GPU node to be allocated to the task request, and the second identification information is used to identify the target GPU card to be allocated to the task request. The target GPU node is the GPU node selected from the available GPU nodes to be allocated to the task request, and the target GPU card is the GPU card selected from the target GPU node to be allocated to the task request. It is worth noting that the number of first identification information and second identification information is not limited. For example, when there are multiple GPU cards that need to be allocated to the task request, there are multiple second identification information accordingly, and each second identification information identifies a target GPU node.
[0067] Based on the weight value corresponding to each idle GPU card, a GPU card with a larger weight value and the same number of required GPU resources can be selected as the target GPU card to be allocated, and the GPU node corresponding to the target GPU card is obtained as the target GPU node. The first identification information corresponding to the target GPU node and the second identification information corresponding to the target GPU card are obtained and used as the allocation result.
[0068] Optionally, in a possible implementation, the above S103 may include S1031 to S1032, which are specifically as follows:
[0069] S1031: Sort the weight values to obtain a sorting result.
[0070] Exemplarily, the GPU cards may be sorted in descending order of weight values to obtain one sorting result, or the GPU cards may be sorted in descending order of weight values to obtain another sorting result.
[0071] S1032: Determine the allocation result based on the sorting result and the required number of GPU resources; the allocation result includes first identification information and second identification information; wherein the first identification information is used to identify the target GPU node to be allocated to the task request, and the second identification information is used to identify the target GPU card to be allocated to the task request.
[0072] When the GPU cards are sorted in descending order based on the weight values, several GPU cards that match the number of GPU resources required in the task request are selected from the sorting result in a front-to-back order, and the selected GPU cards are used as the target GPU cards to be assigned to the task request. At the same time, the target GPU node corresponding to the target GPU card is obtained. When the GPU cards are sorted in descending order based on the weight values, several GPU cards that match the number of GPU resources required in the task request are selected from the sorting result in a back-to-front order, and the selected GPU cards are used as the target GPU cards to be assigned to the task request. At the same time, the target GPU node corresponding to the target GPU card is obtained. If there are GPU cards with the same weight values, they can be selected in the order of precedence in the sorting result, or randomly selected from the GPU cards with the same weight values, and there is no limitation on this.
[0073] The first identification information corresponding to the target GPU node and the second identification information corresponding to the target GPU card are obtained, and used as the allocation result.
[0074] Exemplarily, the order of GPU cards according to the weight value from large to small is used as an example for explanation. If the number of GPU resources required to complete the task request carried in the task request is 3, then the top 3 GPU cards are selected in the sorting result, and the second identification information corresponding to each of the 3 GPU cards and the first identification information of the GPU node corresponding to any one of the GPU cards are obtained. The first identification information and the 3 second identification information are used as the allocation result corresponding to the task request. The resource allocation device will allocate the corresponding GPU node and GPU card to the task request according to the allocation result.
[0075] S104: Allocate a GPU card for the task request based on the allocation result.
[0076] Specifically, the target GPU node may be searched in the available GPU nodes by using the first identification information, the target GPU card may be searched in the target GPU node based on the second identification information, and the found target GPU card may be allocated to the task request.
[0077] Optionally, in a possible implementation, the above S104 may include S1041 to S1042, which are specifically as follows:
[0078] S1041: Search for a target GPU node among available GPU nodes based on the first identification information.
[0079] The first identification information can uniquely identify a GPU node, and the resource allocation device can find the target GPU node among the available GPU nodes according to the first identification information.
[0080] S1042: Searching for a target GPU card in the target GPU node based on the second identification information, and allocating the target GPU card to the task request.
[0081] Each second identification information can uniquely identify a GPU card. In the searched target GPU node, the target GPU card is further searched according to the second identification information, and the target GPU card is allocated to the task request.
[0082] Exemplarily, the allocation result can be stored in the annotation information of the Pod. Kubelet obtains the allocation result in the Pod corresponding to the current task request, and according to the first identification information and the second identification information contained in the allocation result, retrieves the corresponding target GPU node and target GPU card, and sets them to the environment variables of the Pod, thereby realizing the GPU resource allocation for the task request.
[0083] In the embodiment of the present application, the resource allocation device determines the weight value corresponding to each available GPU card according to the topological structure and usage of each GPU card, and allocates the most suitable GPU node and GPU card to the task request based on the weight value and the different requirements of the task request. This method of dynamically adjusting the weight to allocate GPU resources allows GPU cards to be more compactly allocated to different task requests, so that idle GPU resources can better serve task requests with greater demand, fully and reasonably utilize GPU resources, and maximize the utilization rate of GPU resources.
[0084] like Figure 3 As shown, Figure 3 is a schematic flow chart of a resource allocation method provided in another embodiment of the present application. Optionally, in a possible implementation, Figure 3 The resource allocation method shown may include S201 to S206. Figure 3The steps S201 to S204 shown can refer to the above description of S101 to S104, and will not be described here for brevity. Steps S205 to S206 will be described in detail below.
[0085] S205: Update available GPU nodes based on the target GPU node.
[0086] Update the available GPU nodes in real time based on the target GPU node. For example, the target GPU node is the GPU node that has been assigned to the task request, and the usage status of the target GPU node needs to be recorded as a reference for determining the allocation result of the next task request.
[0087] S206: Update the number of used GPU cards in each available GPU node based on the target GPU card.
[0088] The number of used GPU cards in each available GPU node is updated in real time based on the target GPU card. Exemplarily, the use status of the target GPU card in the target GPU node is recorded, and the number of used GPU cards and the number of idle GPU cards in the target GPU node are re-determined. For example, the state of the target GPU card is updated to be in use, which is conducive to accurately allocating the corresponding GPU node and GPU card for the next task request.
[0089] In this embodiment, the available GPU nodes and the number of used GPU cards in each available GPU node are updated in real time, which can ensure that the corresponding GPU node and GPU card are accurately allocated to the next task request, and at the same time, maximize the utilization of GPU resources.
[0090] like Figure 4 As shown, Figure 4 is a schematic flow chart of a resource allocation method provided by another embodiment of the present application. Optionally, in a possible implementation, Figure 4 The resource allocation method shown may include S301 to S303. Figure 4 The steps S301 to S302 shown can refer to the above description of S101 to S102, and will not be described here for brevity. The following will specifically describe step S303.
[0091] S303: When the allocation result corresponding to the task request is not determined based on the required number of GPU resources and the weight value corresponding to each idle GPU card, randomly allocate a GPU card to the task request.
[0092] When the allocation result corresponding to the task request is not determined based on the required number of GPU resources and the weight value corresponding to each idle GPU card, that is, when the appropriate GPU node and GPU card to be allocated to the task request cannot be selected, the currently idle GPU card is randomly selected and allocated to the task request.
[0093] Exemplarily, Kubelet searches for the allocation result in the annotation information of the Pod corresponding to the current task request. If no allocation result matching the task request is found, it proves that the allocation result corresponding to the task request cannot be determined. At this time, the identification information corresponding to the currently idle GPU card is randomly selected, and the GPU node corresponding to the GPU card is selected. The selected GPU card and GPU node are set to the environment variables of the Pod corresponding to the current task request, thereby realizing the GPU resource allocation for the current task request.
[0094] In the embodiment of the present application, when there is no suitable GPU resource for allocating to the task request, or the allocation result corresponding to the task request cannot be determined in time due to a freeze in the resource allocation device, etc., the corresponding GPU resource can be randomly allocated to the task request to ensure that the task corresponding to the task request can be successfully completed.
[0095] In the prior art, a GPU node (which can be understood as a server) is provided with two PCI-Es and eight GPU cards. Four GPU cards with identification information of 0, 1, 2, and 3 are installed on one PCI-E in a preset order, and four GPU cards with identification information of 4, 5, 6, and 7 are installed on another PCI-E in a preset order. If the two GPU cards with identification information of 0 and 1 have been used at this time, the number of GPU resources required to complete the task request is 2. The practice in the prior art will allocate the GPU card on another PCI-E to the task request. The resource allocation method provided in the present application determines the weight value corresponding to the idle GPU card based on the topological structure and usage of these GPU cards, and the weight value of the GPU card with the calculated identification information of 2 and 3 is greater than the weight value of other GPU cards, so the GPU card with the identification information of 2 and 3 on the previous PCI-E will be allocated to the task request. When there is another task request with the number of GPU resources required of 3 or 4, the GPU card on another PCI-E can be allocated to the new task request, while the GPU resource allocation can only be performed after the previous task is completed in the prior art. The method of dynamically adjusting weight values to allocate GPU resources provided in the present application enables GPU cards to be more compactly allocated to different task requests, so that idle GPU resources can better serve task requests with greater demand, fully and reasonably utilizing GPU resources and maximizing GPU resource utilization.
[0096] See also Figure 5 , Figure 5 Schematic diagram of a resource allocation device provided in one embodiment of the present application. The resource allocation device includes units for executing Figure 1 , Figure 2 , Figure 3 , Figure 4 For details, please refer to the steps in the corresponding embodiment. Figure 1 , Figure 2 , Figure 3 , Figure 4 For the convenience of explanation, only the parts related to this embodiment are shown. Figure 5 ,include:
[0097] The acquisition unit 410 is used to acquire available GPU nodes and the number of used GPU cards in each available GPU node when acquiring a task request that requires scheduling GPU resources; the task request carries the number of GPU resources required to complete the task request;
[0098] A first determining unit 420 is used to determine a weight value corresponding to each idle GPU card in each available GPU node based on the available GPU nodes, the number of the GPU cards, and a topological structure corresponding to each GPU card;
[0099] A second determining unit 430 is used to determine an allocation result corresponding to the task request based on the required number of GPU resources and a weight value corresponding to each idle GPU card;
[0100] The allocation unit 440 is configured to allocate a GPU card to the task request based on the allocation result.
[0101] Optionally, the acquiring unit 410 is specifically configured to:
[0102] Get the GPU nodes in the logged-in state and the number of idle GPU cards in each GPU node;
[0103] Determine the available GPU nodes based on the number of idle GPU cards in each GPU node and the required number of GPU resources;
[0104] Get the number of used GPU cards in each available GPU node.
[0105] Optionally, the second determining unit 430 is specifically configured to:
[0106] Sorting the weight values to obtain a sorting result;
[0107] The allocation result is determined based on the sorting result and the required number of GPU resources; the allocation result includes first identification information and second identification information; wherein the first identification information is used to identify the target GPU node to be allocated to the task request, and the second identification information is used to identify the target GPU card to be allocated to the task request.
[0108] Optionally, the allocating unit 440 is specifically configured to:
[0109] Searching for the target GPU node in the available GPU nodes based on the first identification information;
[0110] The target GPU card is searched in the target GPU node based on the second identification information, and the target GPU card is allocated to the task request.
[0111] Optionally, the resource allocation device further includes:
[0112] A first updating unit, configured to update the available GPU node based on the target GPU node;
[0113] The second updating unit is used to update the number of used GPU cards in each available GPU node based on the target GPU card.
[0114] Optionally, the resource allocation device further includes:
[0115] The random allocation unit is used to randomly allocate a GPU card to the task request when the allocation result corresponding to the task request is not determined based on the required number of GPU resources and the weight value corresponding to each idle GPU card.
[0116] See also Figure 6 , Figure 6 FIG. 1 is a schematic diagram of a resource allocation device provided by another embodiment of the present application. Figure 6 As shown, the resource allocation device 5 of this embodiment includes: a processor 50, a memory 51, and a computer-readable instruction 52 stored in the memory 51 and executable on the processor 50. When the processor 50 executes the computer-readable instruction 52, the steps in the above-mentioned various processing resource allocation method embodiments are implemented, such as Figure 1 Alternatively, when the processor 50 executes the computer-readable instructions 52, the functions of each unit in the above embodiments are realized, for example, Figure 5 The functions of units 410 to 440 are shown.
[0117] Exemplarily, the computer-readable instructions 52 may be divided into one or more units, which are stored in the memory 51 and executed by the processor 50 to complete the present application. The one or more units may be a series of computer-readable instruction segments capable of completing specific functions, which are used to describe the execution process of the computer-readable instructions 52 in the resource allocation device 5. For example, the computer-readable instructions 52 may be divided into an acquisition unit, a first determination unit, a second determination unit, and an allocation unit, and the specific functions of each unit are as described above.
[0118] The resource allocation device may include, but is not limited to, a processor 50 and a memory 51. Those skilled in the art will appreciate that Figure 6 It is only an example of the resource allocation device 5 and does not constitute a limitation of the resource allocation device. It may include more or fewer components than shown in the figure, or a combination of certain components, or different components. For example, the resource allocation device may also include input and output terminals, network access terminals, buses, etc.
[0119] The processor 50 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.
[0120] The memory 51 may be an internal storage unit of the resource allocation device, such as a hard disk or memory of the resource allocation device. The memory 51 may also be an external storage terminal of the resource allocation device, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the resource allocation device. Further, the memory 51 may also include both an internal storage unit of the resource allocation device and an external storage terminal. The memory 51 is used to store the computer-readable instructions and other programs and data required by the terminal. The memory 51 may also be used to temporarily store data that has been output or is to be output.
[0121] The embodiments described above are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments can still be modified, or some of the technical features can be replaced by equivalents. These modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.
Claims
1. A resource allocation method, characterized in that: include: When a task request that requires scheduling GPU resources is obtained, available GPU nodes and the number of used GPU cards in each available GPU node are obtained; the task request carries the number of GPU resources required to complete the task request; Based on the available GPU nodes, the number of GPU cards, the topological structure corresponding to each GPU card, and a preset formula, a weight value corresponding to each idle GPU card in each available GPU node is determined; the preset formula is as follows: Among them, g represents the weight value corresponding to the idle GPU card, constant is a constant, and the constant is adjusted according to the topological structure corresponding to each GPU card; all1 represents the number of all GPU cards in the GPU node; all2 represents the number of GPU cards installed on the same PCI-E; used1 represents the number of all used GPU cards in the GPU node; used2 represents the number of used GPU cards installed on the same PCI-E; requested represents the number of GPU resources required for the task request; Determine the allocation result corresponding to the task request based on the required number of GPU resources and the weight value corresponding to each idle GPU card; A GPU card is allocated to the task request based on the allocation result.
2. The resource allocation method according to claim 1, characterized in that: When a task request requiring scheduling of GPU resources is obtained, available GPU nodes and the number of used GPU cards in each available GPU node are obtained, including: Get the GPU nodes in the logged-in state and the number of idle GPU cards in each GPU node; Determine the available GPU nodes based on the number of idle GPU cards in each GPU node and the required number of GPU resources; Get the number of used GPU cards in each available GPU node.
3. The resource allocation method according to claim 1, characterized in that: The determining the allocation result corresponding to the task request based on the required number of GPU resources and the weight value corresponding to each idle GPU card includes: Sorting the weight values to obtain a sorting result; The allocation result is determined based on the sorting result and the required number of GPU resources; the allocation result includes first identification information and second identification information; wherein the first identification information is used to identify the target GPU node to be allocated to the task request, and the second identification information is used to identify the target GPU card to be allocated to the task request.
4. The resource allocation method according to claim 3, characterized in that: The allocating a GPU card to the task request based on the allocation result includes: Searching for the target GPU node in the available GPU nodes based on the first identification information; The target GPU card is searched in the target GPU node based on the second identification information, and the target GPU card is allocated to the task request.
5. The resource allocation method according to claim 3, characterized in that: After allocating a GPU card to the task request based on the allocation result, the resource allocation method further includes: Updating the available GPU nodes based on the target GPU node; The number of used GPU cards in each available GPU node is updated based on the target GPU card.
6. The resource allocation method according to any one of claims 1 to 5, characterized in that: When the allocation result corresponding to the task request is not determined based on the required number of GPU resources and the weight value corresponding to each idle GPU card, a GPU card is randomly allocated to the task request.
7. A resource allocation device, characterized in that: include: An acquisition unit, configured to acquire available GPU nodes and the number of used GPU cards in each available GPU node when a task request requiring scheduling of GPU resources is acquired; the task request carries the number of GPU resources required to complete the task request; The first determining unit is used to determine the weight value corresponding to each idle GPU card in each available GPU node based on the available GPU nodes, the number of the GPU cards, the topological structure corresponding to each GPU card, and a preset formula; the preset formula is as follows: Among them, g represents the weight value corresponding to the idle GPU card, constant is a constant, and the constant is adjusted according to the topological structure corresponding to each GPU card; all1 represents the number of all GPU cards in the GPU node; all2 represents the number of GPU cards installed on the same PCI-E; used1 represents the number of all used GPU cards in the GPU node; used2 represents the number of used GPU cards installed on the same PCI-E; requested represents the number of GPU resources required for the task request; A second determining unit, configured to determine an allocation result corresponding to the task request based on the required number of GPU resources and a weight value corresponding to each idle GPU card; An allocating unit is used to allocate a GPU card to the task request based on the allocation result.
8. The resource allocation device according to claim 7, characterized in that: The acquisition unit is specifically used for: Get the GPU nodes in the logged-in state and the number of idle GPU cards in each GPU node; Determine the available GPU nodes based on the number of idle GPU cards in each GPU node and the required number of GPU resources; Get the number of used GPU cards in each available GPU node.
9. A resource allocation device, comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the resource allocation method according to any one of claims 1 to 6 is implemented.
10. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the resource allocation method according to any one of claims 1 to 6 is implemented.
