A task allocation method, device, equipment, storage medium and program product
By obtaining server cluster processor status information and automatically assigning tasks, the problem of insufficient support for large models in distributed inference is solved, and the automatic distributed inference task allocation of the latest models is realized, which reduces the learning and deployment costs.
Patent Information
- Application Number
- CN202410781699.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-18
- Publication Date
- 2024-11-15
- Estimated Expiration
- 2044-06-18
AI Technical Summary
The lack of effective support for distributed inference by the latest big models has led developers to learn distributed inference frameworks, increasing learning and time costs, especially in time-critical tasks.
By obtaining the status information of the server cluster processor, determining the idle processor and automatically assigning inference tasks, the automatic allocation of distributed inference tasks is realized and the dependence on the distributed framework is reduced.
Automatic distributed inference task allocation for the latest models is realized, reducing the learning cost of distributed frameworks and the deployment time cost of task allocation for developers.
Smart Images

Figure CN118349367B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of computer application technology, and in particular to a task allocation method, device, equipment, storage medium and program product. Background Art
[0002] When a large model is performing task reasoning (i.e., executing reasoning tasks), when the amount of data is relatively large, distributed reasoning is often adopted to perform reasoning operations of the deep learning model simultaneously on multiple computing nodes or devices to accelerate the reasoning process and process large-scale data.
[0003] For some popular open source models, their communities will provide a relatively complete distributed reasoning solution, which can be deployed to perform large-scale task reasoning immediately. For example, the CodeGeeX (multi-language code generation model) model can use Megatron (a deep learning library for training extremely large-scale models) for distributed task reasoning. The CodeGeeX code repository can be downloaded from github (a hosting platform for open source and private software projects). Based on the code repository, the computing resources of the distributed system can be utilized to process large-scale data sets.
[0004] However, the latest large models or some large models mainly used for research and learning do not support distributed reasoning enough, and their communities do not provide distributed reasoning solutions. In this case, developers need to learn some distributed reasoning frameworks and adapt them to these models. The learning cost and time cost here will be relatively high, and these costs may not be acceptable for some tasks with time requirements.
[0005] In summary, how to effectively solve problems such as the distributed allocation of reasoning tasks of the model is a technical problem that technical personnel in this field urgently need to solve. Summary of the invention
[0006] The purpose of the present invention is to provide a task allocation method, device, equipment, storage medium and program product, which can automatically realize the distributed reasoning task allocation of the model.
[0007] In order to solve the above technical problems, the present invention provides the following technical solutions:
[0008] A task allocation method, comprising:
[0009] Acquire status information of processors in the server cluster, and write idle processor identifiers determined using the status information into a target record;
[0010] When the target record is not empty, the idle processor identifier is sequentially read from the target record and the data set path is sequentially read from the input file until no pair of idle processor identifiers and data set paths can be read; wherein one of the data set paths corresponds to one inference task in the model usage;
[0011] Determine an idle processor identifier and a data set path obtained by reading as a pair of allocation information, and respectively splice a task command according to each pair of the allocation information;
[0012] Writing the concatenated task commands into an output file, and deleting the data set paths that have been read and used in the input file;
[0013] Based on the output file, the inference task is allocated to idle processors in the server cluster.
[0014] Preferably, obtaining status information of processors in the server cluster and writing idle processor identifiers determined using the status information into a target record includes:
[0015] Acquire status information of processors in the server cluster, and write identifiers of idle processors determined using the status information into a first record;
[0016] After a specified time interval, obtaining status information of processors in the server cluster, and writing the idle processor identifier determined by using the status information into a second record;
[0017] An intersection of the first record and the second record is determined as the target record.
[0018] Preferably, the status information includes processor usage, and obtaining the status information of the processors in the server cluster and writing the idle processor identifier determined by using the status information into the target record includes:
[0019] Use the parallel distributed operation and maintenance tool to call the processor status check command line tool to obtain the processor usage rate;
[0020] determining a processor whose processor usage is lower than a preset threshold as an idle processor;
[0021] Determine the IP address and number of the idle processor as the information in the idle processor identifier;
[0022] The idle processor identification is written into the target record.
[0023] Preferably, writing the idle processor identifier into the target record comprises:
[0024] The IP address and number in the idle processor identifier are written into the target record in the form of a key-value pair.
[0025] Preferably, after using the parallel distributed operation and maintenance tool to call the processor status check command line tool, the method further includes:
[0026] When the processor usage rate is not obtained, a prompt message of capturing an exception is output.
[0027] Preferably, the IP address and number in the idle processor identifier are written into the target record in the form of a key-value pair, including:
[0028] Using the IP address and number of the idle processor as a key and the number of the idle processor as a value;
[0029] The key and the value are written into the target record according to a preset key-value pair format; wherein the IP address corresponds to the node to which the idle processor belongs.
[0030] Preferably, when the target record is not empty, the idle processor identifier is sequentially read from the target record and the data set path is sequentially read from the input file until no paired idle processor identifier and data set path can be read, including:
[0031] Determine whether the target record is empty;
[0032] If yes, then output the prompt message of reasoning task allocation failure;
[0033] If not, then each time an idle processor identifier is read from the target record, the data set path is read from the input file until no pairs of idle processor identifiers and data set paths can be read.
[0034] Preferably, obtaining status information of processors in a server cluster includes:
[0035] Regularly obtaining status information of processors in the server cluster;
[0036] or, in case of obtaining the input file, obtaining the status information of the processors in the server cluster;
[0037] Or, when the input file is not empty, obtaining status information of processors in the server cluster.
[0038] Preferably, the plurality of task commands obtained by splicing are written into an output file, and the paths of the data sets that have been read and used in the input file are deleted, including:
[0039] In the output file, write a number of the task commands in sequence;
[0040] The dataset path that has been read and used for splicing in the task command is deleted from the input file.
[0041] Preferably, allocating the inference task to idle processors in the server cluster based on the output file comprises:
[0042] The reasoning tasks are allocated to idle processors in the server cluster by executing the task commands in the output file.
[0043] Preferably, it also includes:
[0044] Using the idle processor assigned to the task, read the data set corresponding to the data set path, perform data processing and reasoning on the read data set, obtain the result summary and output;
[0045] After outputting the results, clean up the resources of the processor that has completed the task.
[0046] Preferably, an idle processor identifier and a data set path obtained by reading are determined as a pair of allocation information, and a task command is respectively spliced according to each pair of the allocation information;
[0047] In a reading order, an idle processor identifier and a data set path read at the same time are determined as a pair of allocation information;
[0048] According to the standard format of the preset command line, each pair of the allocation information is spliced respectively to obtain a plurality of the task commands.
[0049] A task allocation device, comprising:
[0050] A status acquisition module, used to acquire status information of processors in the server cluster, and write the idle processor identifier determined by using the status information into a target record;
[0051] An information reading module, used for, when the target record is not empty, sequentially reading idle processor identifiers from the target record and sequentially reading data set paths from the input file until no pairs of idle processor identifiers and data set paths can be read; wherein one of the data set paths corresponds to one inference task in the model use;
[0052] A task command determination module is used to determine an idle processor identifier and a data set path obtained by reading as a pair of allocation information, and to respectively assemble a task command according to each pair of the allocation information;
[0053] An output file determination module, used to write the concatenated task commands into an output file, and delete the data set paths that have been read and used in the input file;
[0054] A task allocation module is used to allocate the reasoning tasks to idle processors in the server cluster based on the output file.
[0055] An electronic device, comprising:
[0056] Memory for storing computer programs;
[0057] A processor is used to implement the steps of the above-mentioned task allocation method when executing the computer program.
[0058] A readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the above-mentioned task allocation method are implemented.
[0059] A computer program product includes a computer program / instruction, which implements the steps of the above-mentioned task allocation method when executed by a processor.
[0060] The method provided by the embodiment of the present invention is applied to obtain the status information of the processors in the server cluster, and write the idle processor identifiers determined by using the status information into the target record; when the target record is not empty, read the idle processor identifiers from the target record in sequence and read the data set paths from the input file in sequence until no pairs of idle processor identifiers and data set paths can be read; wherein, a data set path corresponds to an inference task in the use of the model; determine the idle processor identifier and the data set path obtained by reading as a pair of allocation information, and splice a task command according to each pair of allocation information; write the spliced several task commands into the output file, and delete the data set paths that have been read and used in the input file; based on the output file, assign inference tasks to the idle processors in the server cluster.
[0061] In the present invention, first, the state information of the processor in the server cluster that can realize the distributed execution of a certain model can be obtained, and then the idle processor can be determined based on the state information, and the idle processor can be written into the target record. Then, when the target record is not empty, the idle processor identifier is read from the target record, and at the same time, the data set path is read from the input file in sequence until the paired idle processor identifier and data and path cannot be read. That is, the data set path and the idle processor identifier read in the present invention are read in pairs, and one data set path corresponds to one reasoning task in the model test. In order to effectively complete the reasoning task allocation, an idle processor identifier and a data path are determined as a pair of allocation information, and then each allocation information is spliced respectively, so as to obtain multiple task commands. That is, a task command corresponds to which idle processor processes the reasoning task corresponding to which data set path. Several task commands are all written into the output file, and the data set path that has been read and used in the output file is deleted. In this way, the reasoning task can be allocated to the idle processors in the server cluster based on the output file.
[0062] Technical effect: The present invention relates to distributed task delivery, which can automatically distribute inference tasks to server clusters for the latest models or models with incomplete community support, thereby reducing developers' learning costs for distributed frameworks and the time cost of task allocation and deployment.
[0063] Correspondingly, the embodiments of the present invention also provide a task allocation device, equipment, readable storage medium and computer program product corresponding to the above-mentioned task allocation method, which have the above-mentioned technical effects and are not described in detail here. BRIEF DESCRIPTION OF THE DRAWINGS
[0064] In order to more clearly illustrate the technical solutions in the embodiments of the present invention or related technologies, the drawings required for use in the embodiments or related technical descriptions are briefly introduced below. Obviously, the drawings described below are only some embodiments of the present invention. For ordinary technicians in this field, other drawings can be obtained based on these drawings without paying creative work.
[0065] Figure 1 is an implementation flow chart of a task allocation method in an embodiment of the present invention;
[0066] Figure 2 A schematic diagram of a process for determining an output file in an embodiment of the present invention;
[0067] Figure 3 A specific implementation flow chart of a task allocation method in an embodiment of the present invention;
[0068] Figure 4A schematic diagram of the structure of a task allocation device in an embodiment of the present invention;
[0069] Figure 5 This is a schematic diagram of the structure of an electronic device in an embodiment of the present invention;
[0070] Figure 6 The figure is a schematic diagram of a specific structure of an electronic device in an embodiment of the present invention. DETAILED DESCRIPTION
[0071] In order to enable those skilled in the art to better understand the scheme of the present invention, the present invention is further described in detail below in conjunction with the accompanying drawings and specific implementation methods. Obviously, the described embodiments are only part of the embodiments of the present invention, rather than all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without making creative work are within the scope of protection of the present invention.
[0072] Please refer to Figure 1 , Figure 1 This is a flowchart of a task allocation method in an embodiment of the present invention, the method comprising the following steps:
[0073] S101. Acquire status information of processors in a server cluster, and write idle processor identifiers determined using the status information into a target record.
[0074] The server cluster may include multiple nodes, each of which may include several processors, and the processors may be processors such as GPUs and CPUs.
[0075] In the present invention, the status information of each processor in the server cluster can be obtained by executing commands or using relevant tools, and the processors in each server cluster can be set to report their status information automatically.
[0076] The status information may specifically be information indicating whether it has an assigned task, or information indicating whether it is executing a related task, or may be a related performance indicator of the processor, such as memory usage, etc. In other words, as long as the status information can clearly identify which processors are idle. It should be noted that in the embodiment of the present invention, an idle processor refers to a processor to which an inference task can be assigned at this time.
[0077] In one embodiment of the present invention, obtaining status information of processors in a server cluster includes:
[0078] Regularly obtain status information of processors in the server cluster;
[0079] or, obtaining the status information of the processors in the server cluster when the input file is obtained;
[0080] Or, if the input file is not empty, obtain the status information of the processors in the server cluster.
[0081] That is to say, in this embodiment, the timing to obtain the status information of the processors in the server cluster can be through regular acquisition, or by triggering the acquisition when the input file is obtained; or it can be triggered to obtain the status of the processors in the server cluster when the input file is not empty. These three situations can be used interchangeably in practical applications. For example, after reaching the stage of regularly acquiring the status information of the processors in the server cluster, first clarify whether there is an input file and whether the input file is not empty. If so, obtain the status information, otherwise the current round of acquisition will not be executed.
[0082] In one embodiment of the present invention, the status information includes processor usage, obtaining the status information of the processors in the server cluster, and writing the idle processor identifier determined by using the status information into the target record, including:
[0083] Use the parallel distributed operation and maintenance tool to call the processor status check command line tool to obtain the processor usage rate;
[0084] determining a processor whose processor usage is lower than a preset threshold as an idle processor;
[0085] Determine the IP address and number of the idle processor as information in the idle processor identifier;
[0086] Writes the idle processor ID to the target record.
[0087] For ease of description, the above steps are combined for explanation below.
[0088] In this embodiment, the status information may specifically include the processor usage of each processor in the server cluster. A threshold may be pre-set, and if the processor usage is lower than the threshold, the corresponding processor may be determined to be an idle processor. For example, the threshold may be set to 0, or may be set to other values lower than the threshold to indicate that the processor is in an idle state and can be assigned an inference task according to actual needs.
[0089] After the idle processor is determined, the IP address and number of the idle processor can be determined as the information in the idle processor identifier, and then the idle processor identifier is written into the target record. In this way, by reading the target record, it is possible to determine which idle processors are currently available.
[0090] In one embodiment of the present invention, the processing of the status information includes:
[0091] Execute to obtain status information and obtain output results; the output results include the IP address and number of the idle processor;
[0092] Assign the output result to a temporary variable;
[0093] The output results are processed based on temporary variables to obtain output results in list form.
[0094] Specifically, you can predefine a command to be executed, which uses pdsh to execute the nvidia-smi command on the specified host, query the GPU index and used memory, and filter out the idle GPUs. Execute the predefined command and assign the output result to a temporary variable. Process the output result and modify its format to a list form so that it can be further processed based on the list form.
[0095] In one embodiment of the present invention, writing the idle processor identifier into the target record includes:
[0096] Write the IP address and number in the idle processor identifier into the target record in the form of a key-value pair.
[0097] Set the key-value pair to record the idle processor identifier. The dictionary key can be used as the name of the subsequent log file, such as 127.0.0.1_0.log. In this way, the execution status of each GPU of each node on the task can be well distinguished.
[0098] In one embodiment of the present invention, the IP address and number in the idle processor identifier are written into the target record in the form of a key-value pair, including:
[0099] Use the IP address and number of the idle processor as the key and the number of the idle processor as the value;
[0100] The key and value are written into the target record in a preset key-value pair format, wherein the IP address corresponds to the node to which the idle processor belongs.
[0101] That is, in this embodiment, the processor is a GPU, and the processing of the state information includes:
[0102] Traverse the output list corresponding to the idle processors and extract the IP address and number of each GPU;
[0103] Extract the IP address and number of each GPU and add them to the dictionary as a key-value pair. The key-value pair format of the dictionary is {'GPU IP address and number': 'GPU number'}.
[0104] Specifically, the output result of obtaining the status information can be processed and its format can be changed to a list form. By traversing the output list, the IP address and number of each GPU are extracted and added to the dictionary as a key-value pair. The key-value pair format of the dictionary is {'GPU IP address and number': 'GPU number'}, such as {'127.0.0.1_0':'0', '127.0.0.1_1':'1', '127.0.0.1_2':'2'}, which means that the server IP is 127.0.0.1, and the idle GPUs are card 0, card 1, and card 2 of the current server.
[0105] In this way, the dictionary key can be used as the name of the subsequent log file, such as 127.0.0.1_0.log, which can well distinguish the execution status of each GPU of each node on the task; the GPU number is to facilitate the splicing of the inference task command. In addition, the dictionary key-value pair is designed in this way to avoid the processing complexity of the subsequent processing of the idle processor identifier.
[0106] Since the dictionary keys cannot be named repeatedly and each node corresponds to multiple GPUs; based on the above two points, if you only use IP as the key, the dictionary format will be {'127.0.0.1':'[0,1,2]'}, that is, cards 0, 1, and 2 of 127.0.0.1 are idle.
[0107] In order to ensure that the inference task allocation does not conflict, it is simpler to compare and analyze the idle state processor identifiers. Of course, it is also possible to directly use the list as the returned data structure, but the list is not conducive to the subsequent data expansion. In terms of dictionaries, other information will be added to the value later. In summary, it is recommended that the data structure used here is a dictionary, and the format of the dictionary is {'GPU IP address and number': 'GPU number'}.
[0108] In a specific implementation of the present invention, after the processor status check command line tool is called using the parallel distributed operation and maintenance tool, a prompt message of capturing an exception is output when the processor usage rate is not obtained. In other words, for the robustness of the program, exception capture is added. If an error occurs when executing a command, the exception is captured and the error message is printed to facilitate subsequent problem location.
[0109] S102: When the target record is not empty, read the idle processor identifiers from the target record and read the data set paths from the input file in sequence until no paired idle processor identifiers and data set paths can be read.
[0110] Among them, a dataset path corresponds to an inference task in model usage.
[0111] Specifically, one data set corresponds to one reasoning task, and one data set path corresponds to one data set. Therefore, one data set path also corresponds to one reasoning task.
[0112] When the target record is not empty, the idle processor identifier can be read from the target record, and the data set path can be read from the input file in sequence. Since an inference task needs to be assigned to a processor for processing, and a processor can only process one inference task in the same allocation cycle, that is, the inference task needs to correspond to the processor one by one.
[0113] In order to achieve a one-to-one correspondence between reasoning tasks and processors, firstly, this embodiment reads the target record and input file only when the target record is not empty; secondly, the reading can be terminated when a pair of idle processor identifiers and data set paths cannot be read.
[0114] That is to say, the idle processor identifier obtained by reading always appears in pairs with the data set path. That is to say, each time an idle processor identifier is read, a data set path is read.
[0115] For example, if there are 2 idle processor identifiers in the target record and there are 4 data set paths in the input file, the reading is terminated after reading 2 idle processor identifiers from the target record and 2 data set paths from the input file.
[0116] When there are three idle processor identifiers in the target record, if there is one data set path in the input file, the reading is terminated after one idle processor identifier is read from the target record and one data set path is read from the input file;
[0117] In the case where there are 3 idle processor identifiers in the target record, if there are 3 data set paths in the input file, the reading is terminated after the 3 idle processor identifiers are read from the target record and the 3 data set paths are read from the input file;
[0118] When there are three idle processor identifiers in the target record, if the input file itself does not exist or the data set path does not exist in the input file, no reading is performed.
[0119] In actual implementation, the number of idle processor identifiers A in the target record and the number of data set paths B in the input file can be clearly read first. When both A and B are not 0, the minimum value is determined from A and B, and the number of times the minimum value is read from the target record and the input file respectively, thereby obtaining the minimum number of idle processor identifiers and data set paths. Of course, a read can also be defined in the read file, which is to read a data set path from the input file and an idle processor identifier from the target record. If the read cannot be satisfied once, the reading is stopped; if the read can be satisfied once, the reading is continuously looped until the condition for a read is not satisfied once.
[0120] In the input file, one line of information can correspond to one data set path. Therefore, when reading the input file, one or more lines of information can be read each time.
[0121] In one embodiment of the present invention, when the target record is not empty, the idle processor identifier is sequentially read from the target record and the data set path is sequentially read from the input file until no pair of idle processor identifiers and data set paths can be read, including:
[0122] Determine whether the target record is empty;
[0123] If yes, then output the prompt message of reasoning task allocation failure;
[0124] If not, then each time an idle processor identifier is read from the target record, the data set path is read from the input file until no pairs of idle processor identifiers and data set paths can be read.
[0125] Specifically, when the target record is empty, the inference task allocation failure prompt message is directly output; when the target record is not empty, each time an idle processor identifier is read from the target record, the data set path is read from the input file until no pairs of idle processor identifiers and data set paths can be read. At the same time, traversal reading can be implemented to iterate according to the shortest input sequence, that is, iterative reading is performed according to the shortest input file line number and target record length.
[0126] S103: Determine an idle processor identifier and a data set path obtained by reading as a pair of allocation information, and respectively assemble a task command according to each pair of allocation information.
[0127] Since one inference task and one idle processor need to correspond one to one, in this embodiment, an idle processor identifier and a data set path obtained by reading are determined as a pair of allocation information, and one day's task commands are spliced according to each pair of allocation information.
[0128] That is to say, a task command is obtained by splicing a pair of allocation information, and a task command can specify that an inference task should be assigned to an idle processor.
[0129] In one embodiment of the present invention, an idle processor identifier and a data set path obtained by reading are determined as a pair of allocation information, and a task command is spliced according to each pair of allocation information;
[0130] According to the reading order, an idle processor identifier and a data set path read at the same time are determined as a pair of allocation information;
[0131] According to the standard format of the preset command line, each pair of allocation information is spliced separately to obtain a plurality of task commands.
[0132] For ease of description, the above steps are combined for explanation below.
[0133] In this embodiment, an idle processor identifier and a data set path read each time can be determined as a pair of allocation information according to the reading order. Then, each pair of allocation information is spliced according to the preset standard format of the command line, so as to obtain a plurality of task commands. That is, the number of task commands is the same as the number of pairs of allocation information.
[0134] The task command is to allocate the reasoning task corresponding to the data set path in the allocation information to the idle processor corresponding to the idle processor identifier in the allocation information. In practical applications, the preset command line identifier format can be specifically capable of allocating the reasoning task to the idle processor based on the data set path.
[0135] In one embodiment of the present invention, the processor is a GPU, and the idle processor identifier includes the IP address and number of the GPU; each pair of allocation information is spliced according to the standard format of the preset command line to obtain a plurality of task commands, including:
[0136] Write the absolute address in each pair of allocation information and the IP and number of the idle GPU into the corresponding position of the standard format of the preset command line to obtain a number of task commands;
[0137] The standard format of the preset command line is: pdsh -w TARGET_IP –R ssh –f PORT " CUDA_VISIBLE_DEVICES=gpu_num python infer.py --input_file inputfile.txt --output_file outputfile.txt 2>&1 | tee . / log / TARGET_IP.log" &;
[0138] Pdsh stands for Parallel Distributed Operation and Maintenance Tool;
[0139] -w TARGET_IP, indicates the target server IP;
[0140] -R ssh, specifies the use of the secure shell protocol;
[0141] -f, which means executing the remote command of the secure shell protocol in the background;
[0142] PORT, indicating the port number for secure shell protocol access;
[0143] The quotation marks contain the command that the parallel distributed operation and maintenance tool executes on the target server:
[0144] CUDA_VISIBLE_DEVICES=gpu_num, specifies the GPU number of the current server;
[0145] python infer.py is the model inference script for execution;
[0146] --input_file, is the input file;
[0147] --output_file, output file;
[0148] inputfile.txt is the output file list;
[0149] 2>&1 | tee . / log / log.log, print the log on the screen and write it into the . / log / TARGET_IP.log file;
[0150] &, puts the current command into the background for execution.
[0151] For example, if the processor identifier in the allocation information is {'127.0.0.1_0':'0'}, and the data set path is: / home / 1.txt, the following task command is obtained by splicing based on the standard format of the above preset command line:
[0152] pdsh -w 127.0.0.1 -R ssh -f 500 "CUDA_VISIBLE_DEVICES=0 pythoninfer.py --input_file / home / 1.txt --output_file / home / 1.txt_res 2>&1 | tee . / log / 127_0_0_1_0.log" &.
[0153] Accordingly, if there are multiple pairs of allocation information, there are multiple corresponding task commands.
[0154] S104, writing the concatenated task commands into an output file, and deleting the dataset paths that have been read and used in the input file.
[0155] After completing the splicing of task commands, you can write the task commands into the input file. To avoid repeated allocation of inference tasks, you need to delete the dataset path of the spliced task commands that have been read and used from the input file.
[0156] In one embodiment of the present invention, the plurality of task commands obtained by splicing are written into the output file, and the paths of the data sets that have been read and used in the input file are deleted, including:
[0157] In the output file, write several task commands in sequence;
[0158] Delete the dataset paths that have been read and used in the task command splicing from the input file.
[0159] That is to say, the task commands generated by the splicing can be written into the output file one by one. Then, the dataset paths in the input file that have been read and used for the task command splicing can be deleted.
[0160] S105. Allocate inference tasks to idle processors in the server cluster based on the output file.
[0161] The output file contains task commands. Through the output file, it is possible to allocate inference tasks to idle processors in the server cluster, thereby realizing the distributed inference application of the model.
[0162] In one embodiment of the present invention, allocating inference tasks to idle processors in a server cluster based on an output file includes:
[0163] By executing the task command in the output file, the inference task is assigned to the idle processors in the server cluster. In other words, by executing the task command, the distributed deployment of the inference task is realized, that is, the idle processor performs the task inference processing of the data set corresponding to the corresponding data set path.
[0164] In one embodiment of the present invention, it also includes:
[0165] Using the idle processor assigned to the task, read the data set corresponding to the data set path, perform data processing and reasoning on the read data set, obtain the result summary and output;
[0166] After outputting the results, clean up the resources of the processor that has completed the task.
[0167] That is to say, the idle processor assigned with the task can read the data set of the corresponding data set path, and perform data processing and reasoning on the data set to obtain the summary, combination and output.
[0168] After outputting the results, the resources of the processor that has completed the task can be cleaned up so that it can be assigned new reasoning tasks during subsequent task allocation.
[0169] It should be noted that after each task is completed, the GPU resources will be released for subsequent GPU status detection, so the model will be reloaded after each task assignment; the model loading time is about 1 minute. Among them, resource cleaning records the output file, such as recording it in the record.txt file, and then deletes the output file; clears the model information loaded on the GPU, etc.
[0170] The method provided by the embodiment of the present invention is applied to obtain the status information of the processors in the server cluster, and write the idle processor identifiers determined by using the status information into the target record; when the target record is not empty, read the idle processor identifiers from the target record in sequence and read the data set paths from the input file in sequence until no pairs of idle processor identifiers and data set paths can be read; wherein, a data set path corresponds to an inference task in the use of the model; determine the idle processor identifier and the data set path obtained by reading as a pair of allocation information, and splice a task command according to each pair of allocation information; write the spliced several task commands into the output file, and delete the data set paths that have been read and used in the input file; based on the output file, assign inference tasks to the idle processors in the server cluster.
[0171] In the present invention, first, the state information of the processor in the server cluster that can realize the distributed execution of a certain model can be obtained, and then the idle processor can be determined based on the state information, and the idle processor can be written into the target record. Then, when the target record is not empty, the idle processor identifier is read from the target record, and at the same time, the data set path is read from the input file in sequence until the paired idle processor identifier and data and path cannot be read. That is, the data set path and the idle processor identifier read in the present invention are read in pairs, and one data set path corresponds to one reasoning task in the model test. In order to effectively complete the reasoning task allocation, an idle processor identifier and a data path are determined as a pair of allocation information, and then each allocation information is spliced respectively, so as to obtain multiple task commands. That is, a task command corresponds to which idle processor processes the reasoning task corresponding to which data set path. Several task commands are all written into the output file, and the data set path that has been read and used in the output file is deleted. In this way, the reasoning task can be allocated to the idle processors in the server cluster based on the output file.
[0172] Technical effect: The present invention relates to distributed task distribution. For the latest models or models with incomplete community support, it can automatically distribute inference tasks to server clusters, reducing the learning cost of developers for distributed frameworks and the time cost of task distribution and deployment.
[0173] It should be noted that, based on the above embodiments, the embodiments of the present invention also provide corresponding improved solutions. In the preferred / improved embodiments, the same steps or corresponding steps as those in the above embodiments can be referenced to each other, and the corresponding beneficial effects can also be referenced to each other, which will not be described one by one in the preferred / improved embodiments of this article.
[0174] In one embodiment of the present invention, obtaining status information of processors in a server cluster and writing an idle processor identifier determined using the status information into a target record includes:
[0175] Acquire status information of processors in the server cluster, and write an idle processor identifier determined using the status information into a first record;
[0176] After a specified time interval, obtain the status information of the processors in the server cluster, and write the idle processor identifier determined by using the status information into the second record;
[0177] An intersection of the first record and the second record is determined as a target record.
[0178] For ease of description, the above steps are combined for explanation below.
[0179] The first and second in the first record and the second record are only used to indicate records acquired at different periods.
[0180] For the convenience of explanation, the first record is represented by record 1, the second record is represented by record 2, and the target record is represented by record 3.
[0181] If a task is assigned to a GPU and the GPU is loading a model when obtaining its status information, the status information may be incorrect, causing it to be mistakenly identified as an idle GPU.
[0182] In order to avoid such a situation, in this embodiment, it is proposed to obtain the status information twice, and generate record 1 and record 2, and then take the intersection of the two, that is, record 3, as the basis for subsequent task allocation.
[0183] According to the speed of GPU loading the model, if the GPU is loading the model, 5 minutes is enough for the GPU status to no longer show idle. In other words, the specified time can be set to 5 minutes. Of course, in actual applications, the specified time can also be set to other time values.
[0184] Specifically, in actual applications, the idle GPU information can be obtained and the returned result can be saved in a dictionary, named record 1. If no idle GPU is found (that is, record 1 is empty), it means that all current GPUs have tasks executing and new tasks cannot be executed, and the program will be exited.
[0185] After waiting for 5 minutes (300 seconds), get the idle GPU information again and save the returned result in a dictionary named record 2. If no idle GPU is found (that is, record 2 is empty), exit the program.
[0186] Create an empty dictionary and name it record 3. Traverse each key-value pair in record 2 (i.e. {'GPU IP address and number': 'GPU number'}). If 'GPU IP address and number' also exists in record 1, it means that the GPU of the node is idle after two consecutive queries, then add the key-value pair to record 3. The purpose of calling the first module twice in a row and comparing the results returned twice is: a GPU card has just completed the previous task and is executing the initialization of the next task. At this time, the GPU may still be idle, but in fact the task has been sent to the GPU, avoiding task execution failure due to resource competition.
[0187] In one embodiment of the present invention, the above-mentioned task allocation method is implemented, including:
[0188] Execute the auto_write_bash_script.py script regularly. The auto_write_bash_script.py script is a program that monitors idle GPUs and generates corresponding command scripts.
[0189] Determine whether new new_bash.sh is generated; new new_bash.sh is the output file;
[0190] If yes, after executing new new_bash.sh, record new new_bash.sh in record.txt, and after completing the record, delete new new_bash.sh.
[0191] If no, exit the program.
[0192] You can query the idle GPUs by combining the pdsh and nvidia-smi commands, and then generate an execution script. The script content is the command of the distributed inference task that needs to be executed. Finally, use a shell script to regularly execute the above task allocation method to complete the distribution and execution of distributed tasks.
[0193] The specific implementation process includes:
[0194] 1. Write a program to monitor idle GPUs and generate corresponding command scripts, named auto_write_bash_script.py (see the flowchart below) Figure 2 ), there are only two modules in the script, one module is to monitor the idle GPU status, and the other module is used to generate command script files to use the idle GPU for task calculations.
[0195] Functional description for the first module (named: monitor_idle_gpu):
[0196] ①. Define the command to be executed, which uses pdsh to execute the nvidia-smi command on the specified host, query the GPU index and used memory, and filter out idle GPUs.
[0197] ②. Execute the command defined in step ① and assign the output result to a temporary variable.
[0198] ③. Process the output results and change their format to a list. The purpose of changing the format is to facilitate the processing of the second module.
[0199] ④. Traverse the output list, extract the IP address and number of each GPU, and add them as key-value pairs to the dictionary. The key-value pair format of the dictionary is {'GPU IP address and number': 'GPU number'}, such as {'127.0.0.1_0':'0', '127.0.0.1_1':'1', '127.0.0.1_2':'2'} means that the server IP is 127.0.0.1, and the idle GPUs are cards 0, 1, and 2 of the current server;
[0200] In this way, the key of the dictionary can be used as the name of the subsequent log file, such as 127.0.0.1_0.log, which can well distinguish the execution status of each GPU of each node on the task; the GPU number is to facilitate the splicing of the inference task commands. In addition, the key-value pairs of the dictionary are designed in this way to avoid the processing complexity of the second module. Since the naming of the dictionary keys cannot be repeated, and each node corresponds to multiple GPUs. The data structure used here is a dictionary, and the format of the dictionary is {'GPU IP address and number': 'GPU number'};
[0201] ⑤. For the robustness of the program, add exception capture. If an error occurs when executing a command, the exception is captured and the error message is printed to facilitate subsequent problem location.
[0202] ⑥ Return the recorded idle GPU information, that is, return a dictionary, such as {'127.0.0.1_0':'0', '127.0.0.1_1':'1', '127.0.0.2_3':'3', '127.0.0.5_7':'7'}. This result shows that cards 0 and 1 of the 127.0.0.1 server are idle, card 3 of 127.0.2 is idle, and card 7 of 127.0.5 is idle.
[0203] Function description for the second module (named: get_real_idle_gpu_info):
[0204] ①. Call the first module to obtain the idle GPU information and save the returned result in a dictionary named record 1. If no idle GPU is found (that is, record 1 is empty), it means that all GPUs are currently executing tasks and new tasks cannot be executed, then exit the program.
[0205] ② The program waits for 5 minutes (300 seconds). 5 minutes is an empirical time. According to the speed at which the GPU loads the model, if the GPU is loading the model, 5 minutes is enough for the GPU status to no longer show idle.
[0206] ③. Call the first module again to obtain the idle GPU information and save the returned result in a dictionary named record 2. If no idle GPU is found (that is, record 2 is empty), exit the program.
[0207] ④. Create an empty dictionary and name it record 3. Traverse each key-value pair in record 2 (i.e. {'GPU IP address and number': 'GPU number'}). If 'GPU IP address and number' also exists in record 1, it means that the GPU of the node is idle after two consecutive queries. Then add the key-value pair to record 3. The purpose of calling the first module twice in a row and comparing the results returned twice is: a GPU card has just completed the previous task and is executing the initialization of the next task. At this time, the GPU may still be idle, but in fact the task has been sent to the GPU, avoiding task execution failure due to resource competition;
[0208] ⑤. Open the input file and output file; the input file is a txt file, each line is the absolute path of a data set. The output file is named: new_bash.sh.
[0209] ⑥. Traverse each line of the input file and record 3 at the same time, and splice the command of the inference task according to the dataset path of the input file and the node IP and GPU information in record 3. The purpose of simultaneous traversal is to iterate according to the shortest input sequence, that is, iterate according to the shortest one of the number of lines in the input file and the length of record 3. After traversal, if an output file is generated, the used information is deleted from the input file. Among them, it is assumed that infer.py is the script that actually performs the inference task.
[0210] Example 1:
[0211] The content of the input file is as follows:
[0212] / home / 1.txt;
[0213] / home / 2.txt;
[0214] / home / 3.txt;
[0215] The data content of record 3 is as follows:
[0216] {'127.0.0.1_0':'0'};
[0217] Process the key value of record 3, and then splice the input file information. The output file content after splicing is as follows:
[0218] pdsh -w 127.0.0.1 -R ssh -f 500 "CUDA_VISIBLE_DEVICES=0 pythoninfer.py --input_file / home / 1.txt --output_file / home / 1.txt_res 2>&1 | tee . / log / 127_0_0_1_0.log" &.
[0219] After the loop ends, the content of the input file is:
[0220] / home / 2.txt;
[0221] / home / 3.txt;
[0222] Example 2:
[0223] The content of the input file is as follows:
[0224] / home / 1.txt;
[0225] / home / 2.txt;
[0226] / home / 3.txt;
[0227] The data content of record 3 is as follows:
[0228] {'127.0.0.1_0':'0', '127.0.0.1_1':'1', '127.0.0.1_2':'2', '127.0.0.1_3':'3'};
[0229] Process the key value of record 3, and then splice the input file information. The output file content after splicing is as follows:
[0230] pdsh -w 127.0.0.1 -R ssh -f 500 "CUDA_VISIBLE_DEVICES=0 pythoninfer.py --input_file / home / 1.txt --output_file / home / 1.txt_res 2>&1 | tee . / log / 127_0_0_1_0.log" &;
[0231] pdsh -w 127.0.0.1 -R ssh -f 500 "CUDA_VISIBLE_DEVICES=1 pythoninfer.py --input_file / home / 2.txt --output_file / home / 2.txt_res 2>&1 | tee . / log / 127_0_0_1_1.log" &;
[0232] pdsh -w 127.0.0.1 -R ssh -f 500 "CUDA_VISIBLE_DEVICES=2 pythoninfer.py --input_file / home / 3.txt --output_file / home / 3.txt_res 2>&1 | tee . / log / 127_0_0_1_2.log" &;
[0233] After the loop ends, the input file content is empty, and GPU card No. 3 at 127.0.0.1 is still idle.
[0234] Example 3:
[0235] The content of the input file is as follows:
[0236] / home / 1.txt;
[0237] / home / 2.txt;
[0238] / home / 3.txt;
[0239] The data content of record 3 is as follows:
[0240] {'':''};
[0241] There is no output file at this time, that is, there is no new_bash.sh;
[0242] After the loop ends, the content of the input file is:
[0243] / home / 1.txt;
[0244] / home / 2.txt;
[0245] / home / 3.txt;
[0246] 2. Write a shell script named auto_submit.sh (see the flowchart Figure 3 ). This script is a scheduled execution script, which is executed once every minute. The execution content is:
[0247] ①. First execute auto_write_bash_script.py;
[0248] ② Check whether the new_bash.sh file is generated. If the file is generated, execute the new_bash.sh script directly and record the content of the file in a record file, such as recorded.txt, to facilitate later problem location; after recording, delete the new_bash.sh file, and then exit the auto_submit.sh script and wait for the next execution;
[0249] ③. If the new_bash.sh file is not generated, the auto_submit.sh script exits and waits for the next execution;
[0250] For example: Qwen1.5 is a test version of the model, and its peripheral supporting facilities are basically zero, so it is impossible to perform multi-node reasoning tasks, and the model does not provide the use of distributed frameworks such as Megatron. Under the task requirements of evaluating the model, due to the tight GPU resources and short window period, the reasoning task needs to be completed within a specific short time. Using the task allocation method provided by the present invention, there is no need to adapt the model or learn any distributed framework. The model can be directly loaded with data for distributed reasoning tasks. It can effectively reduce the learning cost of developers for distributed frameworks and the related time cost.
[0251] Corresponding to the above method embodiment, the embodiment of the present invention further provides a task allocation device. The task allocation device described below and the task allocation method described above can be referred to each other.
[0252] See also Figure 4 As shown, the device includes the following modules:
[0253] A state acquisition module 101 is used to acquire state information of processors in a server cluster and write an idle processor identifier determined by using the state information into a target record;
[0254] The information reading module 102 is used to read the idle processor identifier from the target record and the data set path from the input file in sequence when the target record is not empty, until no pair of idle processor identifiers and data set paths can be read; wherein one data set path corresponds to one inference task in the model use;
[0255] The task command determination module 103 is used to determine an idle processor identifier and a data set path obtained by reading as a pair of allocation information, and to splice a task command according to each pair of allocation information;
[0256] The output file determination module 104 is used to write the concatenated task commands into the output file and delete the data set paths that have been read and used in the input file;
[0257] The task allocation module 105 is used to allocate reasoning tasks to idle processors in the server cluster based on the output file.
[0258] The device provided by the embodiment of the present invention is used to obtain status information of processors in a server cluster, and write an idle processor identifier determined by using the status information into a target record; when the target record is not empty, the idle processor identifiers are read from the target record in sequence and the data set paths are read from the input file in sequence until no pairs of idle processor identifiers and data set paths can be read; wherein a data set path corresponds to an inference task in model use; an idle processor identifier and a data set path obtained by reading are determined as a pair of allocation information, and a task command is spliced according to each pair of allocation information; several task commands obtained by splicing are written into an output file, and the data set paths that have been read and used in the input file are deleted; based on the output file, inference tasks are allocated to idle processors in the server cluster.
[0259] In the present invention, first, the state information of the processor in the server cluster that can realize the distributed execution of a certain model can be obtained, and then the idle processor can be determined based on the state information, and the idle processor can be written into the target record. Then, when the target record is not empty, the idle processor identifier is read from the target record, and at the same time, the data set path is read from the input file in sequence until the paired idle processor identifier and data and path cannot be read. That is, the data set path and the idle processor identifier read in the present invention are read in pairs, and one data set path corresponds to one reasoning task in the model test. In order to effectively complete the reasoning task allocation, an idle processor identifier and a data path are determined as a pair of allocation information, and then each allocation information is spliced respectively, so as to obtain multiple task commands. That is, a task command corresponds to which idle processor processes the reasoning task corresponding to which data set path. Several task commands are all written into the output file, and the data set path that has been read and used in the output file is deleted. In this way, the reasoning task can be allocated to the idle processors in the server cluster based on the output file.
[0260] Technical effect: The present invention relates to distributed task delivery, which can automatically distribute inference tasks to server clusters for the latest models or models with incomplete community support, thereby reducing developers' learning costs for distributed frameworks and the time cost of task allocation and deployment.
[0261] In a specific implementation of the present invention, the state acquisition module is specifically used to acquire the state information of the processors in the server cluster, and write the idle processor identifier determined by using the state information into the first record;
[0262] After a specified time interval, the status information of the processors in the server cluster is obtained, and the idle processor identifier determined by using the status information is written into the second record;
[0263] An intersection of the first record and the second record is determined as a target record.
[0264] In a specific implementation of the present invention, the status information includes processor usage, and the status acquisition module is specifically used to use a parallel distributed operation and maintenance tool to call a processor status check command line tool to obtain the processor usage;
[0265] determining a processor whose processor usage is lower than a preset threshold as an idle processor;
[0266] Determine the IP address and number of the idle processor as information in the idle processor identifier;
[0267] Writes the idle processor ID to the target record.
[0268] In a specific implementation of the present invention, the state acquisition module is specifically used to write the IP address and number in the idle processor identifier into the target record in the form of a key-value pair.
[0269] In a specific implementation of the present invention, the status acquisition module is also used to output a prompt message of capturing an exception when the processor usage rate is not obtained after the processor status check command line tool is called using the parallel distributed operation and maintenance tool.
[0270] In a specific embodiment of the present invention, the state acquisition module is specifically used to use the IP address and number of the idle processor as a key and the number of the idle processor as a value;
[0271] The key and value are written into the target record in a preset key-value pair format, wherein the IP address corresponds to the node to which the idle processor belongs.
[0272] In a specific implementation of the present invention, the information reading module is specifically used to determine whether the target record is empty;
[0273] If yes, then output the prompt message of reasoning task allocation failure;
[0274] If not, then each time an idle processor identifier is read from the target record, the data set path is read from the input file until no pairs of idle processor identifiers and data set paths can be read.
[0275] In a specific implementation of the present invention, the status acquisition module is specifically used to periodically acquire status information of processors in the server cluster;
[0276] or, obtaining the status information of the processors in the server cluster when the input file is obtained;
[0277] Or, if the input file is not empty, obtain the status information of the processors in the server cluster.
[0278] In a specific implementation of the present invention, the output file determination module is specifically used to write a plurality of task commands in sequence into the output file;
[0279] Delete the dataset paths that have been read and used in the task command splicing from the input file.
[0280] In a specific implementation of the present invention, the task allocation module is specifically used to allocate reasoning tasks to idle processors in the server cluster by executing task commands in the output file.
[0281] In a specific embodiment of the present invention, it also includes:
[0282] The resource cleaning module is used to use the idle processors assigned to the task to read the data set corresponding to the data set path, and perform data processing and reasoning on the read data set to obtain the result summary and output;
[0283] After outputting the results, clean up the resources of the processor that has completed the task.
[0284] In a specific implementation of the present invention, the task command determination module is specifically used to determine an idle processor identifier and a data set path read at the same time as a pair of allocation information according to the reading order;
[0285] According to the standard format of the preset command line, each pair of allocation information is spliced separately to obtain a plurality of task commands.
[0286] In a specific embodiment of the present invention, the processor is a GPU, and the idle processor identifier includes the IP address and number of the GPU; the task command determination module is specifically used to write the absolute address in each pair of allocation information and the IP and number of the idle GPU into the corresponding position of the standard format of the preset command line, and obtain a plurality of task commands;
[0287] The standard format of the preset command line is: pdsh -w TARGET_IP –R ssh –f PORT " CUDA_VISIBLE_DEVICES=gpu_num python infer.py --input_file inputfile.txt --output_file outputfile.txt 2>&1 | tee . / log / TARGET_IP.log" &;
[0288] Pdsh stands for Parallel Distributed Operation and Maintenance Tool;
[0289] -w TARGET_IP, indicates the target server IP;
[0290] -R ssh, specifies the use of the secure shell protocol;
[0291] -f, which means executing the remote command of the secure shell protocol in the background;
[0292] PORT, indicating the port number for secure shell protocol access;
[0293] The quotation marks contain the command that the parallel distributed operation and maintenance tool executes on the target server:
[0294] CUDA_VISIBLE_DEVICES=gpu_num, specifies the GPU number of the current server;
[0295] python infer.py is the model inference script for execution;
[0296] --input_file, is the input file;
[0297] --output_file, output file;
[0298] inputfile.txt is the output file list;
[0299] 2>&1 | tee . / log / log.log, print the log on the screen and write it into the . / log / TARGET_IP.log file;
[0300] &, put the current command into the background for execution.
[0301] Corresponding to the above method embodiment, an embodiment of the present invention further provides an electronic device. The electronic device described below and the task allocation method described above can refer to each other.
[0302] See also Figure 5 As shown, the electronic device includes:
[0303] A memory 332, for storing computer programs;
[0304] The processor 322 is used to implement the steps of the task allocation method of the above method embodiment when executing a computer program.
[0305] For details, please refer to Figure 6 , Figure 6 A schematic diagram of the specific structure of an electronic device provided for this embodiment, which may have relatively large differences due to different configurations or performances, may include one or more processors (central processing units, CPU) (for example, one or more processors) and a memory 332, and the memory 332 stores one or more computer programs 342 or data 344. Among them, the memory 332 can be a temporary storage or a permanent storage. The program stored in the memory 332 may include one or more modules (not shown in the figure), and each module may include a series of instruction operations in the data processing device. Furthermore, the processor 322 can be configured to communicate with the memory 332 to execute a series of instruction operations in the memory 332 on the electronic device 301.
[0306] The electronic device 301 may further include one or more power supplies 326 , one or more wired or wireless network interfaces 350 , one or more input and output interfaces 358 , and / or one or more operating systems 341 .
[0307] The steps in the task allocation method described above can be implemented by the structure of an electronic device.
[0308] Corresponding to the above method embodiment, the embodiment of the present invention further provides a readable storage medium. The readable storage medium described below and the task allocation method described above can refer to each other.
[0309] A readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the task allocation method of the above method embodiment are implemented.
[0310] The readable storage medium may specifically be a U disk, a mobile hard disk, a read-only memory (ROM), a random access memory (RAM), a magnetic disk or an optical disk, or other readable storage medium that can store program codes.
[0311] Corresponding to the above method embodiment, the embodiment of the present invention further provides a computer program product. The computer program product described below and the task allocation method described above can be referred to in correspondence with each other.
[0312] A computer program product includes a computer program / instruction. When the computer program / instruction is executed by a processor, the steps of the above-mentioned task allocation method are implemented.
[0313] In this specification, each embodiment is described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the embodiments can be referred to each other. For the device disclosed in the embodiment, since it corresponds to the method disclosed in the embodiment, the description is relatively simple, and the relevant parts can be referred to the method part.
[0314] Those skilled in the art may further appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of the two. In order to clearly illustrate the interchangeability of hardware and software, the composition and steps of each example have been generally described in the above description according to function. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art may use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of the present invention.
[0315] The steps of the method or algorithm described in conjunction with the embodiments disclosed herein may be implemented directly using hardware, a software module executed by a processor, or a combination of the two. The software module may be placed in a random access memory (RAM), a memory, a read-only memory (ROM), an electrically programmable ROM, an electrically erasable programmable ROM, a register, a hard disk, a removable disk, a CD-ROM, or any other form of storage medium known in the art.
[0316] Finally, it should be noted that, in this article, relationships such as first and second, etc. are used only to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms include, include or any other variations are intended to cover non-exclusive inclusion, so that a process, method, article or device that includes a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device.
[0317] Specific examples are used herein to illustrate the principles and implementation methods of the present invention. The description of the above embodiments is only used to help understand the method of the present invention and its core idea. At the same time, for those skilled in the art, according to the idea of the present invention, there will be changes in the specific implementation methods and application scope. In summary, the content of this specification should not be understood as a limitation on the present invention.
Claims
1. A task allocation method, characterized in that: include: Acquire status information of processors in the server cluster, and write idle processor identifiers determined using the status information into a target record; When the target record is not empty, the idle processor identifier is sequentially read from the target record and the data set path is sequentially read from the input file until no pair of idle processor identifiers and data set paths can be read; wherein one data set path corresponds to one inference task in the model use; and in the input file, one line of information corresponds to one data set path; Determine an idle processor identifier and a data set path obtained by reading as a pair of allocation information, and respectively splice a task command according to each pair of the allocation information; Writing the concatenated task commands into an output file, and deleting the data set paths that have been read and used in the input file; Based on the output file, allocating the inference task to idle processors in the server cluster; Wherein, when the target record is not empty, the idle processor identifier is sequentially read from the target record and the data set path is sequentially read from the input file until no paired idle processor identifier and data set path can be read, including: Determine whether the target record is empty; If yes, then output the prompt message of reasoning task allocation failure; If not, then each time an idle processor identifier is read from the target record, the data set path is read from the input file until no pairs of idle processor identifiers and data set paths can be read.
2. The method according to claim 1, characterized in that Acquiring status information of processors in a server cluster and writing idle processor identifiers determined using the status information into a target record includes: Acquire status information of processors in the server cluster, and write identifiers of idle processors determined using the status information into a first record; After a specified time interval, obtaining status information of processors in the server cluster, and writing the idle processor identifier determined by using the status information into a second record; An intersection of the first record and the second record is determined as the target record.
3. The method according to claim 1, characterized in that The state information includes a processor usage rate, and the state information of the processors in the server cluster is obtained, and the idle processor identifier determined by using the state information is written into the target record, including: Use the parallel distributed operation and maintenance tool to call the processor status check command line tool to obtain the processor usage rate; determining a processor whose processor usage is lower than a preset threshold as an idle processor; Determine the IP address and number of the idle processor as the information in the idle processor identifier; The idle processor identification is written into the target record.
4. The method according to claim 3, characterized in that Writing the idle processor identifier into the target record includes: The IP address and number in the idle processor identifier are written into the target record in the form of a key-value pair.
5. The method according to claim 4, characterized in that After using the parallel distributed operation and maintenance tool to call the processor status check command line tool, it also includes: When the processor usage rate is not obtained, a prompt message of capturing an exception is output.
6. The method according to claim 4, characterized in that The IP address and number in the idle processor identifier are written into the target record in the form of a key-value pair, including: Using the IP address and number of the idle processor as a key and the number of the idle processor as a value; The key and the value are written into the target record according to a preset key-value pair format; wherein the IP address corresponds to the node to which the idle processor belongs.
7. The method according to claim 1, characterized in that Get the status information of the processors in the server cluster, including: Regularly obtaining status information of processors in the server cluster; or, in case of obtaining the input file, obtaining the status information of the processors in the server cluster; Or, when the input file is not empty, obtaining status information of processors in the server cluster.
8. The method according to claim 1, characterized in that Write the concatenated task commands into the output file, and delete the dataset paths that have been read and used in the input file, including: In the output file, write a number of the task commands in sequence; The dataset path that has been read and used for splicing in the task command is deleted from the input file.
9. The method according to claim 1, characterized in that: Based on the output file, allocating the inference task to idle processors in the server cluster includes: The reasoning tasks are allocated to idle processors in the server cluster by executing the task commands in the output file.
10. The method according to claim 9, characterized in that Also includes: Using the idle processor assigned to the task, read the data set corresponding to the data set path, perform data processing and reasoning on the read data set, obtain the result summary and output; After outputting the results, clean up the resources of the processor that has completed the task.
11. A task allocation device, characterized in that: include: A status acquisition module, used to acquire status information of processors in the server cluster, and write the idle processor identifier determined by using the status information into a target record; An information reading module, used for, when the target record is not empty, sequentially reading idle processor identifiers from the target record and sequentially reading data set paths from the input file until no pairs of idle processor identifiers and data set paths can be read; wherein one data set path corresponds to one inference task in the model use; and in the input file, one line of information corresponds to one data set path; A task command determination module is used to determine an idle processor identifier and a data set path obtained by reading as a pair of allocation information, and to respectively assemble a task command according to each pair of the allocation information; An output file determination module, used to write the concatenated task commands into an output file, and delete the data set paths that have been read and used in the input file; A task allocation module, used for allocating the reasoning tasks to idle processors in the server cluster based on the output file; Among them, the information reading module is specifically used to determine whether the target record is empty; if so, output a prompt message that the reasoning task allocation failed; if not, each time an idle processor identifier is read from the target record, the data set path is read from the input file until no paired idle processor identifier and data set path can be read.
12. An electronic device, characterized in that: include: Memory for storing computer programs; A processor, configured to implement the steps of the task allocation method according to any one of claims 1 to 10 when executing the computer program.
13. A readable storage medium, characterized in that: The readable storage medium stores a computer program, and when the computer program is executed by a processor, the steps of the task allocation method according to any one of claims 1 to 10 are implemented.
14. A computer program product comprising a computer program / instructions, characterized in that When the computer program / instruction is executed by a processor, the steps of the task allocation method described in any one of claims 1 to 10 are implemented.
