Machine learning training resource allocation method based on multiple graphics cards and hardware virtualization
By using a graphics card hardware virtualization resource allocation operator, physical graphics card resources are decomposed into standardized virtual resource units, solving the problem of balancing hardware cost and versatility in multi-graphics card training resource allocation methods, and achieving efficient utilization of graphics card resources and improved training speed.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- CHANGCHUN INST OF TECH
- Filing Date
- 2026-05-07
- Publication Date
- 2026-06-05
AI Technical Summary
Existing multi-GPU training resource allocation methods cannot balance hardware cost and versatility, resulting in high training hardware costs and virtualization resources that cannot adapt to the hardware requirements of different training tasks, affecting the compatibility and versatility of resource allocation.
By establishing a graphics card hardware virtualization resource allocation operator, physical graphics card resources are decomposed into standardized virtual resource units using hardware virtualization technology, and the corresponding number of virtual resources are dynamically allocated to achieve fine-grained management and unified scheduling of graphics card hardware resources, adapting to the hardware requirements of training tasks.
It effectively reduces the hardware cost of multi-GPU training, improves the versatility of virtualization resources and the utilization rate of GPU hardware, ensures that training tasks receive sufficient computing resources, and balances the issues of training hardware cost and versatility.
Smart Images

Figure CN122152544A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of resource allocation technology, and in particular to a method for allocating machine learning training resources based on multiple graphics cards and hardware virtualization. Background Technology
[0002] With the continuous development of machine learning technology, efficiently training a model is a crucial driving force in machine learning. Graphics cards (GPUs) are the primary resource for training machine learning models. Among all methods to accelerate training, multi-GPU parallel training is the easiest to implement and most effective. Therefore, the number and utilization rate of GPUs are important factors affecting training speed.
[0003] Currently, multi-GPU model training primarily employs two methods: The first relies on dedicated hardware to simultaneously utilize multiple GPUs. All GPUs are physically connected via dedicated hardware provided by the GPU manufacturer, and are treated as a single GPU for parallel training. This method, known as the "hardware method," requires all GPUs to be identical, can only train on the host machine with the GPUs installed, and requires additional dedicated connection hardware, resulting in high hardware costs. The second method relies on software to distribute the use of multiple GPUs, with each GPU providing computation independently for the training task. This method, known as the "software method," has lower requirements for GPUs; the GPUs do not need to be identical. If a network connection is available, training can be distributed across different hosts, eliminating the need for all GPUs to be installed on the same host. This method is less difficult and less expensive to implement, but the hardware specifications of virtualizable GPUs are inconsistent, causing virtualizable resources to be unsuitable for the hardware requirements of different training tasks. This affects resource allocation compatibility, ultimately leading to low versatility of virtualizable resources and an inability to meet the resource requirements of training tasks. Therefore, current training resource allocation methods suffer from a failure to balance training hardware cost and versatility. Summary of the Invention
[0004] This invention addresses the problem that existing training resource allocation methods cannot balance training hardware cost and versatility, and proposes a machine learning training resource allocation method based on multiple graphics cards and hardware virtualization.
[0005] Machine learning training resource allocation methods based on multi-GPU and hardware virtualization include:
[0006] S1, Input The information of each graphics card resource is used to form a graphics card resource list GPUResList. GPUResList is used to obtain the virtualizable graphics card resource list GPUVirtResList and the non-virtualizable graphics card resource list GPUNoVirtResList.
[0007] S2. Establish the resource allocation operator AllocTaskCanVirt for virtualizable computing tasks. AllocTaskCanVirt uses the number of virtualizable resources required, ResCountVirt and GPUVirtResList, to obtain the number of virtualizable resources to be allocated, AllocedNumber.
[0008] S3. Establish the resource allocation operator AllocTaskNoVirt for non-virtualizable computing tasks. AllocTaskNoVirt uses the number of non-virtualizable resources required (ResCountNoVirt) and the list of non-virtualizable graphics card resources (GPUNoVirtResList) to obtain the number of graphics cards allocated (AllocedNoVirtNumber).
[0009] S4. Input the training task resource requirements TrainTask, call AllocTaskCanVirt and AllocTaskNoVirt to obtain the final resource expenditure AllocResNumber and allocation result AllocResult.
[0010] Furthermore, the input in S1 The information of each graphics card resource is used to form a graphics card resource list GPUResList. GPUResList is then used to obtain the virtualizable graphics card resource list GPUVirtResList and the non-virtualizable graphics card resource list GPUNoVirtResList. Specifically:
[0011] S101. Input the hardware location and logical location number of each graphics card on the host. Use the hardware location of each graphics card on the host to form a graphics card resource list GPUResList, and temporarily store the logical location number HostNumber on the host.
[0012] S102. Construct a virtualizable graphics card resource list GPUVirtResList and a non-virtualizable graphics card resource list GPUNoVirtResList, and initialize both GPUVirtResList and GPUNoVirtResList to empty lists.
[0013] Both the virtualizable graphics card resource list GPUVirtResList and the non-virtualizable graphics card resource list GPUNoVirtResList include five fields representing: host number, physical graphics card location, logical graphics card number, available resources of the graphics card, and occupancy flag.
[0014] S103. Initialize the GPU resource list counter GPUResListCounter = 0;
[0015] S104. Read the graphics card resource information corresponding to the GPUResListCounter element in GPUResList. If the graphics card resource information corresponding to the GPUResListCounter element in GPUResList is a virtualizable graphics card resource, then go to S105; otherwise, go to S111.
[0016] S105. Calculate and temporarily store the available video memory size: GPUMemSize = available video memory size of the GPUResListCounter-th graphics card resource in GPUResList;
[0017] S106. Use GPUMemSize to obtain the number of virtual graphics cards that can be split into VirtualSize;
[0018] S107. Initialize the virtual graphics card quantity counter VirtSizeCounter=0;
[0019] S108. Add the five fields HostNumber, GPUResListCounter, VirtSizeCounter, 1, and 0 to the end of GPUVirtResList;
[0020] S109. Set VirtSizeCounter = VirtSizeCounter + 1;
[0021] S110. If VirtSizeCounter is less than VirtSize, go to S108; otherwise, go to S114.
[0022] S111, Temporary GPU memory size GPUNoVirtMemSize = Available memory size of the GPUResListCounter-th GPU resource in GPUResList;
[0023] S112. Use GPUNoVirtMemSize to obtain the number of available resource units, GPUNoVirtSize.
[0024] S113. Add the five fields HostNumber, GPUResListCounter, 1, GPUNoVirtSize, and 0 to the end of GPUNoVirtResList;
[0025] S114. Set GPUResListCounter = GPUResListCounter + 1;
[0026] S115. If GPUResListCounter is less than the number of elements in GPUResList, go to S104; otherwise, output the list of virtualizable graphics card resources GPUVirtResList and the list of non-virtualizable graphics card resources GPUNoVirtResList.
[0027] Furthermore,
[0028] The number of virtual graphics cards that can be split in S106 is VirtSize = GPUMemSize ÷ 1073741824.
[0029] Furthermore,
[0030] The number of available resource units in S112 is GPUNoVirtSize = GPUNoVirtMemSize ÷ 1073741824.
[0031] Furthermore, in S2, the resource allocation operator AllocTaskCanVirt for establishing virtualizable computing tasks uses the number of virtualizable resources required, ResCountVirt and GPUVirtResList, to obtain the allocated number of virtualizable resources, AllocedNumbe, specifically:
[0032] S201. Establish the resource allocation operator AllocTaskCanVirt for virtualizable computing tasks, and input the number of virtualizable resources to be used, ResCountVirt.
[0033] S202. Initialize the virtualizable computing task allocation counter AllocTaskVirtCounter=0, and initialize the number of allocated virtualizable resources AllocedNumber=0;
[0034] S203. If the value of the occupancy flag field of the AllocTaskVirtCounter element in GPUVirtResList is 0, then update the value of the occupancy flag field to 1, and set AllocedNumber = AllocedNumber + 1, and then execute S204; otherwise, execute S204 directly.
[0035] S204. If AllocedNumber = ResCountVirt, then go to S207; otherwise, go to S205.
[0036] S205. Set AllocTaskVirtCounter = AllocTaskVirtCounter + 1;
[0037] S206. If AllocTaskVirtCounter = the number of elements in GPUVirtResList, then go to S207; otherwise, go to S203.
[0038] S207, Output the number of virtualizable resources allocated (AllocedNumber).
[0039] Furthermore, in S3, the resource allocation operator AllocTaskNoVirt for establishing non-virtualizable computing tasks uses the number of non-virtualizable resources required (ResCountNoVirt) and the list of non-virtualizable graphics card resources (GPUNoVirtResList) to obtain the number of graphics cards to be allocated (AllocedNoVirtNumber), specifically:
[0040] S301. Establish the resource allocation operator AllocTaskNoVirt for non-virtualizable computing tasks, and input the number of non-virtualizable resources ResCountNoVirt to be used;
[0041] S302. Initialize the non-virtualizable computing task allocation counter AllocTaskNoVirtCounter=0, and initialize the number of allocated graphics cards AllocedNoVirtNumber=0;
[0042] S303, Temporarily store the GPU availability flag AvailableGPU = the occupancy flag value of the AllocTaskNoVirtCounter element in GPUNoVirtResList;
[0043] S304. If AvailableGPU=0, proceed to S305; otherwise, proceed to S309.
[0044] S305, AvailableGPUCount = the value of the available GPU resource count field of the AllocTaskNoVirtCounter element in GPUNoVirtResList;
[0045] S306. Update AllocedNoVirtNumber using AvailableGPUCount;
[0046] S307. Set AvailableGPU to 1, and modify the value of the occupancy flag field of the AllocTaskNoVirtCounter element in GPUNoVirtResList to 1;
[0047] S308. If AllocedNoVirtNumber is greater than or equal to ResCountNoVirt, then go to S311; otherwise, go to S309.
[0048] S309. Set AllocTaskNoVirtCounter = AllocTaskNoVirtCounter + 1;
[0049] S310. If AllocTaskNoVirtCounter = the number of elements in GPUNoVirtResList, then go to S311; otherwise go to S303.
[0050] S311, Number of graphics cards allocated for output (AllocedNoVirtNumber).
[0051] Furthermore, in S306, updating AllocedNoVirtNumber using AvailableGPUCount is specifically: AllocedNoVirtNumber = AllocedNoVirtNumber + AvailableGPUCount.
[0052] Furthermore, in S4, the input training task resource requirement TrainTask calls AllocTaskCanVirt and AllocTaskNoVirt to obtain the final resource expenditure AllocResNumber and allocation result AllocResult, specifically as follows:
[0053] S401. Input the training task resource requirements (TrainTask).
[0054] TrainTask contains the following fields:
[0055] ResNeed: The amount of resources required;
[0056] AllowVirt: Whether to accept virtualized resources. The value of AllowVirt is 0 or 1, where 0 means not to accept and 1 means to accept.
[0057] S402, Temporarily store a snapshot of the list of virtualizable graphics card resources: GPUVirtResListSnapshot = GPUVirtResList;
[0058] Temporarily save a snapshot of the list of non-virtualizable graphics card resources: GPUNoVirtResListSnapshot = GPUNoVirtResList;
[0059] S403. Initialize the final resource consumption quantity AllocResNumber=0, and initialize the allocation result AllocResult=0;
[0060] S404. If TrainTask.AllowVirt=1, then go to S405; otherwise, go to S407.
[0061] Wherein, TrainTask.AllowVirt is the AllowVirt field in TrainTask;
[0062] S405. Call AllocTaskCanVirt, obtain the return value of AllocTaskCanVirt, and update AllocResNumber using the return value of AllocTaskCanVirt;
[0063] S406. If AllocResNumber is greater than or equal to ResNeed, set AllocResult=1 and go to S410; otherwise, go to S407.
[0064] S407. Call AllocTaskNoVirt, obtain the return value of AllocTaskNoVirt, and update AllocResNumber using the return value of AllocTaskNoVirt;
[0065] S408. If AllocResNumber is greater than or equal to ResNeed, set AllocResult=1 and go to S410; otherwise, go to S409.
[0066] S409. Set GPUVirtResList = GPUVirtResListSnapshot;
[0067] Let GPUNoVirtResList=GPUNoVirtResListSnapshot;
[0068] S410 outputs AllocResNumber and AllocResult.
[0069] Furthermore, in S405, updating AllocResNumber using the return value of AllocTaskCanVirt specifically involves setting AllocResNumber = the return value of AllocTaskCanVirt.
[0070] Furthermore, in S407, updating AllocResNumber using the return value of AllocTaskNoVirt is specifically done by setting AllocResNumber = AllocResNumber + the return value of AllocTaskNoVirt.
[0071] The beneficial effects of this invention are as follows:
[0072] This invention provides a method for allocating machine learning training resources based on multiple graphics cards and hardware virtualization. The invention establishes an allocation operator for graphics card hardware virtualization resources, centrally analyzes and abstracts the graphics card hardware resources of different hosts, and decomposes physical graphics card resources into several standardized virtual resources through hardware virtualization technology. This invention does not rely on dedicated interconnect hardware, effectively reducing the hardware cost of multi-graphics card training. Through virtualization abstraction, this invention transforms physical graphics cards with different hardware specifications into standardized virtual resource units, making virtual resources compatible with the hardware requirements of training tasks. This invention uniformly schedules and allocates hardware virtualization resources, avoiding the problem of virtualizable resources not being compatible with the hardware requirements of different training tasks due to differences in graphics card hardware parameters (such as video memory and computing power) of different hosts, thus improving the versatility of virtualizable resources. This invention dynamically allocates a corresponding number of virtual resources, achieving fine-grained management of graphics card hardware resources. This avoids idle and wasted hardware resources, ensures sufficient computing resources for training tasks, maximizes the utilization of graphics card hardware, accelerates the running speed of training tasks, and simultaneously addresses the issues of training hardware cost and versatility. Attached Figure Description
[0073] Figure 1 This is a flowchart of the present invention. Detailed Implementation
[0074] Specific implementation method one: as follows Figure 1 As shown, the specific process of the machine learning training resource allocation method based on multiple graphics cards and hardware virtualization in this embodiment is as follows:
[0075] S1, Input The information of each graphics card resource is used to form a graphics card resource list GPUResList. GPUResList is then used to obtain the virtualizable graphics card resource list GPUVirtResList and the non-virtualizable graphics card resource list GPUNoVirtResList. Specifically:
[0076] S101. Input the hardware location and logical location number of each graphics card on the host. Use the hardware location of each graphics card on the host to form a graphics card resource list GPUResList, and temporarily store the logical location number HostNumber on the host.
[0077] S102. Construct a virtualizable graphics card resource list GPUVirtResList and a non-virtualizable graphics card resource list GPUNoVirtResList, and initialize both GPUVirtResList and GPUNoVirtResList to empty lists.
[0078] Both the virtualizable graphics card resource list GPUVirtResList and the non-virtualizable graphics card resource list GPUNoVirtResList include five fields: host number, physical graphics card location, logical graphics card number, available resources of the graphics card, and occupied flag.
[0079] Among them, the available resource quantity field of the graphics card is greater than or equal to 1; the occupancy flag field is 0 or 1. A value of 0 indicates that the current logical graphics card is available for use, and a value of 1 indicates that the current logical graphics card is in use; the available resource quantity field of GPUVirtResList is always 1, and the logical graphics card number field of GPUNoVirtResList is always 1.
[0080] S103. Initialize the GPU resource list counter GPUResListCounter = 0;
[0081] S104. Read the GPU resource information corresponding to the GPUResListCounter element in GPUResList. If it is a virtualizable GPU resource, go to S105; otherwise, go to S111.
[0082] S105. Calculate and temporarily store the available video memory size: GPUMemSize = available video memory size of the GPUResListCounter-th graphics card resource in GPUResList;
[0083] S106. Calculate and temporarily store the number of virtual graphics cards that can be split: VirtSize = GPUMemSize ÷ 1073741824;
[0084] S107. Initialize the virtual graphics card quantity counter VirtSizeCounter=0;
[0085] S108. Add the five fields HostNumber, GPUResListCounter, VirtSizeCounter, 1, and 0 to the end of GPUVirtResList;
[0086] S109. Set VirtSizeCounter = VirtSizeCounter + 1;
[0087] S110. If VirtSizeCounter is less than VirtSize, go to S108; otherwise, go to S114.
[0088] S111, Temporary GPU memory size GPUNoVirtMemSize = Available memory size of the GPUResListCounter-th GPU resource in GPUResList;
[0089] S112. Calculate and temporarily store the number of available resource copies: GPUNoVirtSize = GPUNoVirtMemSize ÷ 1073741824;
[0090] S113. Add the five fields HostNumber, GPUResListCounter, 1, GPUNoVirtSize, and 0 to the end of GPUNoVirtResList;
[0091] S114. Set GPUResListCounter = GPUResListCounter + 1;
[0092] S115. If GPUResListCounter is less than the number of elements in GPUResList, go to S104; otherwise, output the list of virtualizable graphics card resources GPUVirtResList and the list of non-virtualizable graphics card resources GPUNoVirtResList.
[0093] S2. Establish the resource allocation operator AllocTaskCanVirt for virtualizable computing tasks. AllocTaskCanVirt uses the number of virtualizable resources required, ResCountVirt and GPUVirtResList, to obtain the number of virtualizable resources to be allocated, AllocedNumber, specifically:
[0094] S201. Establish the resource allocation operator AllocTaskCanVirt for virtualizable computing tasks, and input the number of virtualizable resources to be used, ResCountVirt.
[0095] S202. Initialize the virtualizable computing task allocation counter AllocTaskVirtCounter=0, and initialize the number of allocated virtualizable resources AllocedNumber=0;
[0096] S203. If the value of the occupancy flag field of the AllocTaskVirtCounter element in GPUVirtResList is 0, then update the value of the occupancy flag field to 1, and set AllocedNumber = AllocedNumber + 1, and then execute S204; otherwise, execute S204 directly.
[0097] S204. If AllocedNumber = ResCountVirt, then go to S207; otherwise, go to S205.
[0098] S205. Set AllocTaskVirtCounter = AllocTaskVirtCounter + 1;
[0099] S206. If AllocTaskVirtCounter = the number of elements in GPUVirtResList, then go to S207; otherwise, go to S203.
[0100] S207, Output the number of allocated resources (AllocedNumber).
[0101] S3. Establish the resource allocation operator AllocTaskNoVirt for non-virtualizable computing tasks. AllocTaskNoVirt uses the number of non-virtualizable resources required (ResCountNoVirt) and the list of non-virtualizable graphics card resources (GPUNoVirtResList) to obtain the number of graphics cards to be allocated (AllocedNoVirtNumber), specifically:
[0102] S301. Establish the resource allocation operator AllocTaskNoVirt for non-virtualizable computing tasks, and input the number of non-virtualizable resources ResCountNoVirt to be used;
[0103] S302. Initialize the non-virtualizable computing task allocation counter AllocTaskNoVirtCounter=0, and initialize the number of allocated graphics cards AllocedNoVirtNumber=0;
[0104] S303, Temporarily store the GPU availability flag AvailableGPU = the occupancy flag value of the AllocTaskNoVirtCounter element in GPUNoVirtResList;
[0105] S304. If AvailableGPU=0, proceed to S305; otherwise, proceed to S309.
[0106] S305, AvailableGPUCount = the value of the available GPU resource count field of the AllocTaskNoVirtCounter element in GPUNoVirtResList;
[0107] S306. Let AllocedNoVirtNumber=AllocedNoVirtNumber+AvailableGPUCount;
[0108] S307. Set AvailableGPU to 1, and modify the value of the occupancy flag field of the AllocTaskNoVirtCounter element in GPUNoVirtResList to 1;
[0109] S308. If AllocedNoVirtNumber is greater than or equal to ResCountNoVirt, then go to S311; otherwise, go to S309.
[0110] S309. Set AllocTaskNoVirtCounter = AllocTaskNoVirtCounter + 1;
[0111] S310. If AllocTaskNoVirtCounter = the number of elements in GPUNoVirtResList, then go to S311; otherwise go to S303.
[0112] S311. Output AllocedNoVirtNumber as the result of the operator.
[0113] S4. Input the training task resource requirements (TrainTask), call AllocTaskCanVirt and AllocTaskNoVirt to obtain the final resource expenditure (AllocResNumber) and allocation result (AllocResult), specifically:
[0114] S401. Input the training task resource requirements (TrainTask).
[0115] TrainTask contains the following fields:
[0116] ResNeed: The amount of resources required;
[0117] AllowVirt: Whether to accept virtualized resources. The value is 0 or 1, where 0 means not to accept and 1 means to accept. The default value is 1.
[0118] S402, Temporarily store a snapshot of the list of virtualizable graphics card resources: GPUVirtResListSnapshot = GPUVirtResList;
[0119] Temporarily save a snapshot of the list of non-virtualizable graphics card resources: GPUNoVirtResListSnapshot = GPUNoVirtResList;
[0120] S403. Initialize the final resource consumption quantity AllocResNumber=0, and initialize the allocation result AllocResult=0;
[0121] S404. If TrainTask.AllowVirt=1, then go to S405; otherwise, go to S407.
[0122] Wherein, TrainTask.AllowVirt is the AllowVirt field in TrainTask;
[0123] S405. Call AllocTaskCanVirt and assign the return value of AllocTaskCanVirt to AllocResNumber;
[0124] S406. If AllocResNumber is greater than or equal to ResNeed, set AllocResult=1 and go to S410; otherwise, go to S407.
[0125] S407. Call AllocTaskNoVirt, obtain the return value of AllocTaskNoVirt, and set AllocResNumber = AllocResNumber + AllocTaskNoVirt return value;
[0126] S408. If AllocResNumber is greater than or equal to ResNeed, set AllocResult=1 and go to S410; otherwise, go to S409.
[0127] S409. Set GPUVirtResList = GPUVirtResListSnapshot;
[0128] Let GPUNoVirtResList=GPUNoVirtResListSnapshot;
[0129] S410 outputs AllocResNumber and AllocResult.
[0130] Example: To verify the beneficial effects of the present invention, the following experiments were conducted:
[0131] Input three pieces of graphics card resource information to form a graphics card resource list GPUResList, the contents of which are as follows: (1) Node 0: NVIDIA-0-Virt; (2) Node 0: NVIDIA-1-NoVirt; (3) Node 1: AMD-0-NoVirt;
[0132] The virtualization characteristics and resource quantity of the graphics card resource information were calculated sequentially, and the results are as follows:
[0133] (1) NVIDIA-0-Virt: The video memory size is 25,769,803,776, which can be divided into 24 virtual graphics card resources, numbered sequentially as 0-NVIDIA-0-0, 0-NVIDIA-0-1, ..., 0-NVIDIA-0-23, with each graphics card resource being 1 video memory resource;
[0134] (2) NVIDIA-1-NoVirt: The video memory size is 12,884,901,888, which cannot be split. It is numbered 0-NVIDIA-1-0 and contains 12 video memory resources.
[0135] (3) AMD-2-NoVirt: Memory size 12,884,901,888, cannot be split, numbered 1-AMD-0-0, a total of 12 memory resources;
[0136] The list of virtualizable graphics card resources, GPUVirtResList, is shown in Table 1.
[0137] Table 1
[0138] The list of non-virtualizable graphics card resources, GPUNoVirtResList, is shown in Table 2.
[0139] Table 2
[0140]
[0141] Then, the allocation results are obtained using the non-virtualizable graphics card resource list GPUNoVirtResList and the virtualizable graphics card resource list GPUVirtResList.
[0142] Example 1:
[0143] The input training task resource requirements for TrainTask are as follows:
[0144] ResNeed: 20;
[0145] AllowVirt: 1;
[0146] The training task allows virtualization, and the AllocTaskCanVirt operator is used first to allocate virtualization resources. The list of allocated and marked resources is shown in Table 3.
[0147] Table 3
[0148]
[0149] After allocation, AllocResNumber is 20, which is equal to the required number of resources. This allocation task is now complete, and the remaining resource list is shown in Table 4.
[0150] Table 4
[0151]
[0152] Example 2:
[0153] The input training task resource requirements for TrainTask are as follows:
[0154] ResNeed: 20;
[0155] AllowVirt: 0;
[0156] The training task is not allowed to be virtualized. The AllocTaskNoVirt operator can be used to allocate virtualization resources. The list of allocated and marked resources is shown in Table 5.
[0157] Table 5
[0158]
[0159] After allocation, AllocResNumber is 24, which is greater than the required resource quantity, and this allocation task is completed. The remaining resource list is shown in Table 6;
[0160] Table 6
[0161]
[0162] Example 3:
[0163] The input training task resource requirements for TrainTask are as follows:
[0164] ResNeed: 30;
[0165] AllowVirt: 1;
[0166] The training task allows virtualization, and the AllocTaskCanVirt operator is used first to allocate virtualization resources. The list of allocated and marked resources is shown in Table 7.
[0167] Table 7
[0168]
[0169] After the AllocTaskCanVirt operator completes the allocation, AllocResNumber is 24, which is less than the required resource quantity ResNeed. Therefore, the AllocTaskNoVirt operator is used to allocate non-virtualizable resources. The list of allocated and marked resources is shown in Table 8.
[0170] Table 8
[0171]
[0172] After allocation, AllocResNumber is 36, which is greater than the required resource quantity, and this allocation task is completed. The remaining resource list is shown in Table 9;
[0173] Table 9
[0174]
[0175] Example 4:
[0176] The input training task resource requirements for TrainTask are as follows:
[0177] ResNeed: 50;
[0178] AllowVirt: 1;
[0179] The training task allows virtualization, and the AllocTaskCanVirt operator is used first to allocate virtualization resources. The list of allocated and marked resources is shown in Table 10.
[0180] Table 10
[0181]
[0182] After the AllocTaskCanVirt operator completes the allocation, AllocResNumber is 24, which is less than the required resource quantity ResNeed. Therefore, the AllocTaskNoVirt operator is used to allocate non-virtualizable resources. The list of allocated and marked resources is shown in Table 11.
[0183] Table 11
[0184]
[0185] After allocation, AllocResNumber is 48, which is less than the required number of resources. There are no available resources to continue allocating, so the allocation task ends, the allocation task fails, and the original allocation state is restored.
[0186] The above experiments show that the present invention can improve model training efficiency, can carry out parallel computing tasks using graphics card resources, and meet the needs of computing hardware.
Claims
1. A machine learning training resource allocation method based on multiple graphics cards and hardware virtualization, characterized in that: The specific process of the method is as follows: S1, Input The information of each graphics card resource is used to form a graphics card resource list GPUResList. GPUResList is used to obtain the virtualizable graphics card resource list GPUVirtResList and the non-virtualizable graphics card resource list GPUNoVirtResList. S2. Establish the resource allocation operator AllocTaskCanVirt for virtualizable computing tasks. AllocTaskCanVirt uses the number of virtualizable resources required, ResCountVirt and GPUVirtResList, to obtain the number of virtualizable resources to be allocated, AllocedNumber. S3. Establish the resource allocation operator AllocTaskNoVirt for non-virtualizable computing tasks. AllocTaskNoVirt uses the number of non-virtualizable resources required (ResCountNoVirt) and the list of non-virtualizable graphics card resources (GPUNoVirtResList) to obtain the number of graphics cards allocated (AllocedNoVirtNumber). S4. Input the training task resource requirements TrainTask, call AllocTaskCanVirt and AllocTaskNoVirt to obtain the final resource expenditure AllocResNumber and allocation result AllocResult.
2. The machine learning training resource allocation method based on multiple graphics cards and hardware virtualization according to claim 1, characterized in that: The input in S1 The information of each graphics card resource is used to form a graphics card resource list GPUResList. GPUResList is then used to obtain the virtualizable graphics card resource list GPUVirtResList and the non-virtualizable graphics card resource list GPUNoVirtResList. Specifically: S101. Input the hardware location and logical location number of each graphics card on the host. Use the hardware location of each graphics card on the host to form a graphics card resource list GPUResList, and temporarily store the logical location number HostNumber on the host. S102. Construct a virtualizable graphics card resource list GPUVirtResList and a non-virtualizable graphics card resource list GPUNoVirtResList, and initialize both GPUVirtResList and GPUNoVirtResList to empty lists. Both the virtualizable graphics card resource list GPUVirtResList and the non-virtualizable graphics card resource list GPUNoVirtResList include five fields representing: host number, physical graphics card location, logical graphics card number, available resources of the graphics card, and occupancy flag. S103. Initialize the GPU resource list counter GPUResListCounter = 0; S104. Read the graphics card resource information corresponding to the GPUResListCounter element in GPUResList. If the graphics card resource information corresponding to the GPUResListCounter element in GPUResList is a virtualizable graphics card resource, then go to S105; otherwise, go to S111. S105. Calculate and temporarily store the available video memory size: GPUMemSize = available video memory size of the GPUResListCounter-th graphics card resource in GPUResList; S106. Use GPUMemSize to obtain the number of virtual graphics cards that can be split into VirtualSize; S107. Initialize the virtual graphics card quantity counter VirtSizeCounter=0; S108. Add the five fields HostNumber, GPUResListCounter, VirtSizeCounter, 1, and 0 to the end of GPUVirtResList; S109. Set VirtSizeCounter = VirtSizeCounter + 1; S110. If VirtSizeCounter is less than VirtSize, go to S108; otherwise, go to S114. S111, Temporary GPU memory size GPUNoVirtMemSize = Available memory size of the GPUResListCounter-th GPU resource in GPUResList; S112. Use GPUNoVirtMemSize to obtain the number of available resource units, GPUNoVirtSize. S113. Add the five fields HostNumber, GPUResListCounter, 1, GPUNoVirtSize, and 0 to the end of GPUNoVirtResList; S114. Set GPUResListCounter = GPUResListCounter + 1; S115. If GPUResListCounter is less than the number of elements in GPUResList, go to S104; otherwise, output the list of virtualizable graphics card resources GPUVirtResList and the list of non-virtualizable graphics card resources GPUNoVirtResList.
3. The machine learning training resource allocation method based on multiple graphics cards and hardware virtualization according to claim 2, characterized in that: The number of virtual graphics cards that can be split in S106 is VirtSize = GPUMemSize ÷ 1073741824.
4. The machine learning training resource allocation method based on multiple graphics cards and hardware virtualization according to claim 3, characterized in that: The number of available resource units in S112 is GPUNoVirtSize = GPUNoVirtMemSize ÷ 1073741824.
5. The machine learning training resource allocation method based on multiple graphics cards and hardware virtualization according to claim 4, characterized in that: In S2, the resource allocation operator AllocTaskCanVirt for establishing virtualizable computing tasks uses the required number of virtualizable resources, ResCountVirt and GPUVirtResList, to obtain the allocated number of virtualizable resources, AllocedNumber. S201. Establish the resource allocation operator AllocTaskCanVirt for virtualizable computing tasks, and input the number of virtualizable resources to be used, ResCountVirt. S202. Initialize the virtualizable computing task allocation counter AllocTaskVirtCounter=0, and initialize the number of allocated virtualizable resources AllocedNumber=0; S203. If the value of the occupancy flag field of the AllocTaskVirtCounter element in GPUVirtResList is 0, then update the value of the occupancy flag field to 1, and set AllocedNumber = AllocedNumber + 1, and then execute S204; otherwise, execute S204 directly. S204. If AllocedNumber = ResCountVirt, then go to S207; otherwise, go to S205. S205. Set AllocTaskVirtCounter = AllocTaskVirtCounter + 1; S206. If AllocTaskVirtCounter = the number of elements in GPUVirtResList, then go to S207; otherwise, go to S203. S207, Output the number of virtualizable resources allocated (AllocedNumber).
6. The machine learning training resource allocation method based on multiple graphics cards and hardware virtualization according to claim 5, characterized in that: The resource allocation operator AllocTaskNoVirt in S3 for establishing non-virtualizable computing tasks uses the number of non-virtualizable resources required (ResCountNoVirt) and the list of non-virtualizable graphics card resources (GPUNoVirtResList) to obtain the number of graphics cards to be allocated (AllocedNoVirtNumber), specifically: S301. Establish the resource allocation operator AllocTaskNoVirt for non-virtualizable computing tasks, and input the number of non-virtualizable resources ResCountNoVirt to be used; S302. Initialize the non-virtualizable computing task allocation counter AllocTaskNoVirtCounter=0, and initialize the number of allocated graphics cards AllocedNoVirtNumber=0; S303, Temporarily store the GPU availability flag AvailableGPU = the occupancy flag value of the AllocTaskNoVirtCounter element in GPUNoVirtResList; S304. If AvailableGPU=0, proceed to S305; otherwise, proceed to S309. S305, AvailableGPUCount = the value of the available GPU resource count field of the AllocTaskNoVirtCounter element in GPUNoVirtResList; S306. Update AllocedNoVirtNumber using AvailableGPUCount; S307. Set AvailableGPU to 1, and modify the value of the occupancy flag field of the AllocTaskNoVirtCounter element in GPUNoVirtResList to 1; S308. If AllocedNoVirtNumber is greater than or equal to ResCountNoVirt, then go to S311; otherwise, go to S309. S309. Set AllocTaskNoVirtCounter = AllocTaskNoVirtCounter + 1; S310. If AllocTaskNoVirtCounter = the number of elements in GPUNoVirtResList, then go to S311; otherwise go to S303. S311, Number of graphics cards allocated for output (AllocedNoVirtNumber).
7. The machine learning training resource allocation method based on multiple graphics cards and hardware virtualization according to claim 6, characterized in that: In S306, updating AllocedNoVirtNumber using AvailableGPUCount is specifically: AllocedNoVirtNumber = AllocedNoVirtNumber + AvailableGPUCount.
8. The machine learning training resource allocation method based on multiple graphics cards and hardware virtualization according to claim 7, characterized in that: The input training task resource requirement TrainTask in S4 calls AllocTaskCanVirt and AllocTaskNoVirt to obtain the final resource expenditure AllocResNumber and allocation result AllocResult, specifically: S401. Input the training task resource requirements (TrainTask). TrainTask contains the following fields: ResNeed: The amount of resources required; AllowVirt: Whether to accept virtualized resources. The value of AllowVirt is 0 or 1, where 0 means not to accept and 1 means to accept. S402, Temporarily store a snapshot of the list of virtualizable graphics card resources: GPUVirtResListSnapshot = GPUVirtResList; Temporarily save a snapshot of the list of non-virtualizable graphics card resources: GPUNoVirtResListSnapshot = GPUNoVirtResList; S403. Initialize the final resource consumption quantity AllocResNumber=0, and initialize the allocation result AllocResult=0; S404. If TrainTask.AllowVirt=1, then go to S405; otherwise, go to S407. Wherein, TrainTask.AllowVirt is the AllowVirt field in TrainTask; S405. Call AllocTaskCanVirt, obtain the return value of AllocTaskCanVirt, and update AllocResNumber using the return value of AllocTaskCanVirt; S406. If AllocResNumber is greater than or equal to ResNeed, set AllocResult=1 and go to S410; otherwise, go to S407. S407. Call AllocTaskNoVirt, obtain the return value of AllocTaskNoVirt, and update AllocResNumber using the return value of AllocTaskNoVirt; S408. If AllocResNumber is greater than or equal to ResNeed, set AllocResult=1 and go to S410; otherwise, go to S409. S409. Set GPUVirtResList = GPUVirtResListSnapshot; Let GPUNoVirtResList=GPUNoVirtResListSnapshot; S410 outputs AllocResNumber and AllocResult.
9. The machine learning training resource allocation method based on multiple graphics cards and hardware virtualization according to claim 8, characterized in that: In step S405, updating AllocResNumber using the return value of AllocTaskCanVirt specifically involves setting AllocResNumber = the return value of AllocTaskCanVirt.
10. The machine learning training resource allocation method based on multiple graphics cards and hardware virtualization according to claim 9, characterized in that: In S407, updating AllocResNumber using the return value of AllocTaskNoVirt is specifically done by setting AllocResNumber = AllocResNumber + the return value of AllocTaskNoVirt.