Equipment collaboration method and device, electronic equipment and computer readable storage medium
By automatically obtaining the Internet protocol address and port number, the problem of long-time multi-GPU collaborative training and port number conflict in deep learning model training is solved, and efficient multi-GPU collaborative training is achieved.
Patent Information
- Application Number
- CN202310458000.5
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-04-24
- Publication Date
- 2024-10-25
AI Technical Summary
During the training process of deep learning models, a single computer device can only support a limited graphics processing unit (GPU), causing the training of large-scale data and parameter models to take too long, and existing multi-GPU collaborative training methods require manual specification of Internet protocols. Address and port number, it is easy to cause training failure due to port number conflict.
Provides a device collaboration method that automatically obtains the Internet protocol address and idle port number of the host device, establishes a communication connection between the host device and the collaborative device, reduces operational complexity and avoids port number conflicts.
It realizes automated communication connection settings in multi-GPU collaborative training, reduces operational complexity, avoids training failures caused by port number conflicts, and improves training efficiency.
Smart Images

Figure CN118839784A_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of artificial intelligence technology, and in particular to a device collaboration method, apparatus, electronic device, and computer-readable storage medium. Background Art
[0002] In the process of deep learning model training, ultra-large-scale data and / or large-scale parameters are generally used to train the model. If a single computer device is used to train the deep learning model, since a single computer device often only supports 8 graphics processing units (GPUs), and these large-scale data and / or large-scale parameter models often require far more than 8 GPU cards, the training of the deep learning model will take too much time. Summary of the invention
[0003] In order to overcome the problems existing in the related art, the present disclosure provides a device collaboration method, apparatus, electronic device and computer-readable storage medium.
[0004] According to a first aspect of an embodiment of the present disclosure, a device coordination method is provided, the method comprising:
[0005] Determining a plurality of target devices, the plurality of target devices comprising a host device and at least one collaborative device;
[0006] Determine the same idle external port number of the plurality of target devices, and determine the target external port number according to the same idle external port number of the plurality of target devices;
[0007] The Internet Protocol address of the host device is determined, and a communication connection is established between the host device and each of the collaborative devices based on the Internet Protocol address and the target external port number.
[0008] Optionally, determining a plurality of target devices includes:
[0009] Obtain a configuration file, where the configuration file is used to record host device identification information and the number of graphics processors;
[0010] Determining the host device according to the host device identification information in the configuration file;
[0011] According to a preset device selection rule and the number of the graphics processors in the configuration file, a target number of collaborative devices is determined from a preset plurality of devices, wherein at least one of the graphics processors is configured in the preset plurality of devices, and the number of idle graphics processors included in the target number of collaborative devices is not less than the number of the graphics processors in the configuration file.
[0012] Optionally, determining the same idle external port number of the multiple target devices includes:
[0013] Acquire a first public file, where the first public file is used to characterize the correspondence between identification information of each target device, an external port number of each target device, and a used external port number of each target device;
[0014] According to the first public file, the same idle external port number of the multiple target devices is determined.
[0015] Optionally, the first public file is obtained in the following manner:
[0016] Determine the external port information and the used external port information of each of the target devices;
[0017] For the external port information of each of the target devices, determine the external port number of each of the target devices, and for the used external port information of each of the target devices, process each line of information in the used external port information by a preset regular expression to obtain multiple lines of intermediate information separated by a preset identifier, and use the preset identifier as a segmentation point to segment each line of the intermediate information to obtain multiple data fields, determine a target data field containing a target preset identifier in the multiple data fields, use the target preset identifier as a segmentation point to segment the target data field to obtain the used external port number of each of the target devices;
[0018] Generate a correspondence between the identification information of each target device, the external port number of each target device, and the used external port number of each target device, and save the correspondence of each target device as the first public file.
[0019] Optionally, determining the same idle external port numbers of the multiple target devices according to the first public file includes:
[0020] Determine, according to the first public file, a used external port number of each of the target devices and a starting port number and an ending port number of each of the target devices' external ports;
[0021] Determine the same external port number of the plurality of target devices according to the starting port number and the ending port number of each of the target devices;
[0022] According to the common external port numbers of the plurality of target devices and the used external port number of each of the target devices, the common idle external port numbers of the plurality of target devices are determined.
[0023] Optionally, determining the same external port number of a plurality of target devices according to the starting port number and the ending port number of each target device includes:
[0024] Determine the largest starting port number among the multiple target devices as the target starting port number;
[0025] Determine the smallest termination port number among the plurality of target devices as the target termination port number;
[0026] According to the port number range corresponding to the target start port number and the target end port number, the same external port number of the plurality of target devices is determined.
[0027] Optionally, determining the Internet Protocol address of the host device includes:
[0028] Obtaining Internet Protocol address information of the host device;
[0029] Matching the Internet Protocol address information according to a preset protocol identifier to obtain target protocol address information;
[0030] Determine the digital text according to the target protocol address information, and determine the format information of the digital text;
[0031] Determine whether the format information is the same as the preset format information, and if the format information is the same as the preset format information, determine that the digital text is the Internet Protocol address of the host device.
[0032] Optionally, establishing a communication connection between the host device and each of the collaborative devices according to the Internet Protocol address and the target external port number includes:
[0033] Periodically detecting whether a second public file exists, wherein the second public file is generated according to the Internet Protocol address and the target external port number;
[0034] When the existence of the second public file is detected, a communication connection is established between the host device and each of the collaborative devices.
[0035] According to a second aspect of an embodiment of the present disclosure, there is provided a device coordination apparatus, including:
[0036] A first determination module is configured to determine a plurality of target devices, wherein the plurality of target devices include a host device and at least one collaborative device;
[0037] A second determination module is configured to determine the same idle external port numbers of the multiple target devices, and determine the target external port number according to the same idle external port numbers of the multiple target devices;
[0038] The communication module is configured to determine the Internet Protocol address of the host device and establish a communication connection between the host device and each of the collaborative devices based on the Internet Protocol address and the target external port number.
[0039] Optionally, the first determining module is further configured to:
[0040] Obtain a configuration file, where the configuration file is used to record host device identification information and the number of graphics processors;
[0041] Determining the host device according to the host device identification information in the configuration file;
[0042] According to a preset device selection rule and the number of the graphics processors in the configuration file, a target number of collaborative devices is determined from a preset plurality of devices, wherein at least one of the graphics processors is configured in the preset plurality of devices, and the number of idle graphics processors included in the target number of collaborative devices is not less than the number of the graphics processors in the configuration file.
[0043] Optionally, the second determining module is further configured to:
[0044] Acquire a first public file, where the first public file is used to characterize the correspondence between identification information of each target device, an external port number of each target device, and a used external port number of each target device;
[0045] According to the first public file, the same idle external port number of the multiple target devices is determined.
[0046] Optionally, the first public file is obtained in the following manner:
[0047] Determine the external port information and the used external port information of each of the target devices;
[0048] For the external port information of each of the target devices, determine the external port number of each of the target devices, and for the used external port information of each of the target devices, process each line of information in the used external port information by a preset regular expression to obtain multiple lines of intermediate information separated by a preset identifier, and use the preset identifier as a segmentation point to segment each line of the intermediate information to obtain multiple data fields, determine a target data field containing a target preset identifier in the multiple data fields, use the target preset identifier as a segmentation point to segment the target data field to obtain the used external port number of each of the target devices;
[0049] Generate a correspondence between the identification information of each target device, the external port number of each target device, and the used external port number of each target device, and save the correspondence of each target device as the first public file.
[0050] Optionally, the second determining module is further configured to:
[0051] Determine, according to the first public file, a used external port number of each of the target devices and a starting port number and an ending port number of each of the target devices' external ports;
[0052] Determine the same external port number of the plurality of target devices according to the starting port number and the ending port number of each of the target devices;
[0053] According to the common external port numbers of the plurality of target devices and the used external port number of each of the target devices, the common idle external port numbers of the plurality of target devices are determined.
[0054] Optionally, the second determining module is further configured to:
[0055] Determine the largest starting port number among the multiple target devices as the target starting port number;
[0056] Determine the smallest termination port number among the plurality of target devices as the target termination port number;
[0057] According to the port number range corresponding to the target start port number and the target end port number, the same external port number of the plurality of target devices is determined.
[0058] Optionally, the communication module is further configured to:
[0059] Obtaining Internet Protocol address information of the host device;
[0060] Matching the Internet Protocol address information according to a preset protocol identifier to obtain target protocol address information;
[0061] Determine the digital text according to the target protocol address information, and determine the format information of the digital text;
[0062] Determine whether the format information is the same as the preset format information, and if the format information is the same as the preset format information, determine that the digital text is the Internet Protocol address of the host device.
[0063] Optionally, the communication module is further configured to:
[0064] Periodically detecting whether a second public file exists, wherein the second public file is generated according to the Internet Protocol address and the target external port number;
[0065] When the existence of the second public file is detected, a communication connection is established between the host device and each of the collaborative devices.
[0066] According to a third aspect of an embodiment of the present disclosure, there is provided an electronic device, including:
[0067] processor;
[0068] a memory for storing processor-executable instructions;
[0069] Wherein, the processor is configured to:
[0070] Execute the steps of any one of the methods described in the first aspect of the present disclosure.
[0071] According to a fourth aspect of an embodiment of the present disclosure, a computer-readable storage medium is provided, on which computer program instructions are stored. When the program instructions are executed by a processor, the steps of any one of the methods described in the first aspect of the present disclosure are implemented.
[0072] The technical solution provided by the embodiments of the present disclosure may have the following beneficial effects:
[0073] In the multi-GPU collaborative training method based on the socket mode, the Internet Protocol address of the host device and the target external port number for establishing a communication connection can be automatically obtained, and a communication connection between the host device and each collaborative device can be established based on the Internet Protocol address and the target external port number. Compared with the multi-GPU collaborative training method based on the socket mode in the related art, there is no need to manually check the Internet Protocol address of the host device and the idle external port number of each target device. On the one hand, it reduces the operational complexity of the multi-GPU collaborative training method, and on the other hand, it avoids the problem of failure of deep learning model training due to mutual interference when multiple people start deep learning model training in a computer cluster at the same time.
[0074] It is to be understood that the foregoing general description and the following detailed description are exemplary and explanatory only and are not restrictive of the present disclosure. BRIEF DESCRIPTION OF THE DRAWINGS
[0075] The accompanying drawings, which are incorporated in and constitute a part of this specification, illustrate embodiments consistent with the present disclosure and, together with the description, serve to explain the principles of the present disclosure.
[0076] Figure 1 is a flowchart of a multi-GPU collaborative training method based on a shared file mode according to an exemplary embodiment;
[0077] Figure 2 is a flowchart of a multi-GPU collaborative training method based on manually configured socket mode according to an exemplary embodiment;
[0078] Figure 3 is a flowchart of a multi-GPU collaborative training method based on automatic configuration socket mode according to an exemplary embodiment;
[0079] Figure 4 is a flow chart of a device collaboration method according to an exemplary embodiment;
[0080] Figure 5 is a block diagram of a device coordination apparatus according to an exemplary embodiment;
[0081] Figure 6 It is a block diagram of an apparatus for device collaboration according to an exemplary embodiment. DETAILED DESCRIPTION
[0082] Exemplary embodiments will be described in detail herein, examples of which are shown in the accompanying drawings. When the following description refers to the drawings, the same numbers in different drawings represent the same or similar elements unless otherwise indicated. The embodiments described in the following exemplary embodiments do not represent all embodiments consistent with the present disclosure. Instead, they are merely examples of devices and methods consistent with some aspects of the present disclosure as detailed in the appended claims.
[0083] As mentioned in the background technology, in the multi-GPU collaborative training method, there are two modes: shared file mode and socket mode. Among them, the shared file mode requires the computer device to be equipped with NFS and specify the shared files that the computer device can access, so that the computer device can complete the communication connection by accessing the shared file, that is, handshake, and then perform collaborative training of the deep learning model. Specifically, Figure 1 As shown, first you need to configure NFS on all computer devices in the computer cluster, share the same storage space on the network for each computer device, and create a shared file in the storage space; then after submitting the model training task, start a process for each target GPU (GPU used for collaborative training of deep learning models) in the required computer device, read the shared file and establish a handshake through each process, and when the process of each target GPU has established a handshake through the shared file, multi-GPU collaborative training of the deep learning model can begin.
[0084] The socket mode requires manually specifying the host device's Internet Protocol address and the target port number for establishing a handshake in the computer cluster, so that the remaining computer devices can complete the handshake with the host device based on the Internet Protocol address and the target port number to perform collaborative training of the deep learning model. Specifically, Figure 2 As shown, before the collaborative training of the deep learning model is started, on the one hand, it is necessary to manually specify the computer device as the host device and query the Internet Protocol address of the host device; on the other hand, it is also necessary to manually log in to each computer device used for training and manually query the idle external port number of each computer device used for training to determine the target port number used to establish a communication connection. After the Internet Protocol address and the target port number are determined, the Internet Protocol address and the target port number are manually saved as a public file, so that when the collaborative training of the deep learning model is started, each computer device used for training can obtain the Internet Protocol address and the target port number by reading the public file, thereby completing the handshake according to the Internet Protocol address and the target port, so as to perform multi-GPU collaborative training of the deep learning model.
[0085] In the above two modes, the multi-GPU collaborative training method based on the shared file mode requires that all computer devices in the computer cluster are equipped with NFS, and each computer device needs to set up the same storage space and share it on the network so that other computers in the computer cluster can access the shared space of this computer. In this mode, if any of the computer devices used for training does not share the shared space, multi-GPU collaborative training cannot be achieved. Therefore, when implementing multi-GPU collaborative training based on this file sharing mode, it is necessary to configure NFS for each computer device in the computer cluster, which increases the training complexity of the deep learning model. In addition, since NFS is not very stable, even if each computer device in the computer cluster is configured with NFS, there will be a problem that some computer devices used for training do not share after loading the storage space, and this problem cannot be discovered in time, which in turn affects the multi-GPU collaborative training of the deep learning model. Although the multi-GPU collaborative training method based on the socket mode can overcome the shortcomings of the multi-GPU collaborative training method in the shared file mode, the multi-GPU collaborative training method in the socket mode requires manual specification of the Internet Protocol address of the host device and the target port number used to establish a handshake. When multiple people submit deep learning model training tasks in a computer cluster at the same time, it is easy to cause the target port number to be occupied by others, resulting in the failure of deep learning model training. Although in some scenarios, the problem of multiple users using one port number at the same time can be overcome by pre-configuring the port number usage table, that is, by pre-assigning a different port number to each user to overcome the problem of multiple users using one port number at the same time. However, when new users join and old users leave, the port number usage table needs to be maintained in time, which is also troublesome to operate.
[0086] In view of this, the embodiments of the present disclosure provide a device collaboration method, apparatus, electronic device, and computer-readable storage medium, which can automatically obtain the Internet Protocol address of the host device and the target external port number for establishing a communication connection in a multi-GPU collaborative training method in socket mode. Specifically, Figure 3As shown, before the collaborative training of the deep learning model is started, the number of GPUs used for training and the computer device as the host device can be specified first, and the computer device used for training, that is, the collaborative device, is determined according to the number of GPUs used for training. When the collaborative training of the deep learning model is started, the Internet Protocol address of the computer device as the host device is automatically obtained, thereby obtaining the Internet Protocol address of the host device; at the same time, the idle external port number of each computer device used for training is automatically obtained, and the intersection of the idle external port numbers of each computer device used for training is automatically obtained to generate the same idle external port number of each computer device used for training, and a target external port number for establishing a handshake is obtained by selecting an idle external port number therefrom.
[0087] The embodiments of the present disclosure are further explained below with reference to the accompanying drawings.
[0088] Figure 4 is a flow chart of a device collaboration method according to an exemplary embodiment. Figure 4 As shown, the device collaboration method may include steps S401-S403.
[0089] In step S401, a plurality of target devices are determined, wherein the plurality of target devices include a host device and at least one collaborative device.
[0090] It should be understood that in the multi-GPU collaborative training method, 16 GPUs, 32 GPUs, 64 GPUs, 128 GPUs or 256 GPUs are generally required, and multiple GPUs can generally be configured in a computer device. Therefore, when determining multiple target devices from a computer cluster, it can be determined based on the GPU usage of each computer device in the computer cluster. That is, in one possible implementation, some of the GPUs required for training the deep learning model are located in the same computer device, and the remaining GPUs are located in different computer devices. In another possible implementation, each GPU required for training the deep learning model is located in a different computer device. Which specific implementation method is used can be determined based on the scheduling rules of the resource scheduling system in the computer cluster or the preset device selection rules, and the embodiments of the present disclosure do not impose any restrictions on this.
[0091] In addition, it should be understood that when training a deep learning model based on the socket mode, a host device is required to establish a communication connection with the remaining collaborative devices. Therefore, the number of target devices in the embodiment of the present disclosure should be at least two, that is, at least one host device and one collaborative device. At the same time, in order to avoid determining the host device as a collaborative device when determining the collaborative device, in a possible implementation, a computer device as a host device can be pre-specified, and then at least one collaborative device can be determined in the computer cluster based on the GPU usage of each computer device in the computer cluster and / or a preset device selection rule.
[0092] It is worth noting that when a computer device is pre-designated as a host device, any computer device in the computer device cluster can be selected as the host device. Alternatively, a computer device can be selected from the computer cluster as the host device according to the GPU usage of each computer device in the computer cluster, and the embodiments of the present disclosure do not impose any restrictions on this.
[0093] In addition, the device selection rule can also be set according to actual conditions, and the embodiment of the present disclosure does not impose any restrictions on this. In a possible implementation, the device selection rule can be selected based on the number of available GPUs / available GPU resources in a single computer device. That is, first obtain the number of available GPUs / available GPU resources of computer devices other than the host device in the computer cluster, and then select the computer device with the largest number of available GPUs / available GPU resources as the collaborative device. In another possible implementation, a configuration file for recording the host device identification information and the required number of GPUs can be generated first, and then the resource scheduling system in the computer cluster is used to determine the corresponding collaborative device and host device according to the configuration file. For example, after generating the configuration file, SGE (Sun Grid Engine, a distributed resource management and scheduling system from SUN Microsystem, which is used to optimize the use of software and hardware resources in a UNIX-based computing environment) or SLURM (Simple Linux Utility for Resource Management, a highly scalable and fault-tolerant cluster manager and job scheduling system that can be used for large computing node clusters) is used to submit to the computer cluster according to one GPU and one process, so as to filter out the host device and the collaborative device according to the scheduling rules of SGE or SLURM (i.e., the preset device selection rules). That is, according to an embodiment of the present disclosure, determining a plurality of target devices may include:
[0094] Obtain a configuration file, wherein the configuration file is used to record host device identification information and the number of graphics processors; determine the host device according to the host device identification information in the configuration file; and determine a target number of collaborative devices from a plurality of preset devices according to a preset device selection rule and the number of graphics processors in the configuration file, wherein at least one of the plurality of preset devices is configured with the graphics processor, and the number of idle graphics processors included in the target number of collaborative devices is not less than the number of graphics processors in the configuration file.
[0095] The host device identification information may be an identifier of a computer device, or a number of a computer device, or an identifier of a GPU or a number of a GPU, and the embodiments of the present disclosure do not impose any limitation on this.
[0096] In step S402, the same idle external port numbers of the plurality of target devices are determined, and the target external port number is determined according to the same idle external port numbers of the plurality of target devices.
[0097] It should be understood that in the Transmission Control Protocol (TCP) or Internet Protocol (IP), the port number is numbered by 16 bits, which means that the maximum number of port numbers is 2. 16 That is, 65536 port numbers. However, due to the use and reservation of each computer device, not all port numbers can be used externally. Therefore, in order to obtain the same idle external port number for multiple target devices, it is necessary to first obtain the external port number of each target device, and then determine which external ports of each target device are occupied by querying, so as to obtain the used external port number of each target device, and then determine the same idle external port number for multiple target devices according to the external port number of each target device and the used external port number of each target device.
[0098] In addition, it should be understood that the external port number and the used external port number of each computer device may be different. Therefore, in order to obtain the external port number and the used external port number of each target device, the external port number and the used external port number of each target device need to be saved in a public file, so that the host device can obtain the external port number and the used external port number of each target device by accessing the public file, and determine the same external port number of multiple target devices according to the external port number of each target device, and determine the same idle external port number of multiple target devices according to the same external port number of multiple target devices and the used external port number of each target device. In order to achieve the above process, in a possible implementation, when each target device obtains the external port number and the used external port number, the corresponding relationship between the identification information of each target device, the external port number of each target device and the used external port number of each target device can be generated, and the corresponding relationship of each target device can be saved in a public file, so that the host device can obtain the corresponding relationship of each target device by accessing the public file, and determine the same idle external port number of multiple target devices by parsing the corresponding relationship of each target device. That is, according to an embodiment of the present disclosure, determining the same idle external port numbers of the multiple target devices may include:
[0099] Obtain a first public file, wherein the first public file is used to characterize the correspondence between the identification information of each of the target devices, the external port number of each of the target devices, and the used external port number of each of the target devices; and determine the same idle external port number of the multiple target devices based on the first public file.
[0100] Illustratively, the first public file may be represented as shown in Table 1, wherein GPU in Table 1 represents the file name of the first public file, and each row in Table 1 represents a corresponding relationship of a target device.
[0101] Table 1 First public document
[0102]
[0103] The host device obtains the external port number and the used external port number of itself and the collaborative device by accessing the public file, and determines the same external port number of itself and the collaborative device based on the external port number of itself and the collaborative device, and determines the same idle external port number of itself and the collaborative device based on the same external port number of itself and the collaborative device and the used external port number of itself and the collaborative device.
[0104] It is worth noting that the representation of public files here is for illustration only. In actual use, it can be set according to actual conditions, and the embodiments of the present disclosure do not impose any restrictions on this.
[0105] In addition, it is worth noting that since the first public file stores the identification information of each target device, the external port number of each target device, and the correspondence between the used external port number of each target device, it is necessary to obtain the external port number and the used external port number of each target device before generating the first public file. In the related art, the used external port information of the computer device is viewed based on the instruction "netstat -tnlp", so as to determine the used external port number based on the used external port information. Some of the used external port information of the computer device can be as follows:
[0106]
[0107] Among them, each row represents the used external port information of a used external port number, and according to the used external port information of a used external port number, it can be seen that a used external port information includes not only the used external port number, but also some other redundant information. Therefore, in the related art, after obtaining the used external port information, it is necessary to manually extract the used external port number from it. However, since this solution needs to automatically obtain the target external port number, after obtaining the used external port information, a computer device is also required to filter the used external port information to obtain the used external port number.
[0108] In order to realize the automatic acquisition of the used external port number by the computer device, the inventor observed the used external port information and found that each used external port information includes 6 data fields, namely, data field Proto, data field Recv-Q, data field Send-Q Local Address, data field Foreign Address, data field state and data field PID / Program name. There are multiple space identifiers between adjacent data fields, and the used external port number is after the colon identifier. Therefore, in a possible implementation method, in order to reduce the number of splits, the space identifiers between adjacent data fields in each used external port information can be first deduplicated to obtain the target external port information, and then the space identifier is used as a split point to split the target external port information to obtain multiple data fields in the used external port information, and finally the target data field containing the colon identifier is determined from the multiple data fields, and the colon identifier is used as a split point to split the target data field to obtain the used external port number.
[0109] After obtaining the used external port number of each target device through filtering, the corresponding relationship of each target device can be generated according to the identification information of each target device, the external port number of each target device and the used external port number of each target device, and the corresponding relationship of each target device is saved in a public file. That is, according to an embodiment of the present disclosure, the first public file can be obtained by:
[0110] Determine the external port information and used external port information of each target device; determine the external port number of each target device for the external port information of each target device, and process each line of information in the used external port information of each target device through a preset regular expression to obtain multiple lines of intermediate information separated by a preset identifier, and use the preset identifier as a segmentation point to segment each line of the intermediate information to obtain multiple data fields, determine a target data field containing a target preset identifier in the multiple data fields, use the target preset identifier as a segmentation point to segment the target data field to obtain the used external port number of each target device; generate a correspondence between the identification information of each target device, the external port number of each target device, and the used external port number of each target device, and save the correspondence of each target device as the first public file.
[0111] It is worth noting that it is a prior art for a computer device to determine an external port number based on external port information, so this embodiment of the present disclosure will not be elaborated on.
[0112] It should be understood that when establishing a communication connection between computer devices, the port number used to establish the communication connection should be consistent. Therefore, when determining the target external port number, it is necessary to first obtain the same external port number among multiple target devices, then filter out the used external port number of each target device, obtain the same idle external port number among multiple target devices, and finally determine the target external port number used to establish the communication connection from the same idle external port number.
[0113] Since the external port number and the used external port number of each target device are stored in the first public file, in a possible implementation, the external port number and the used external port number of each target device can be obtained by accessing the first public file, and then the same external port number among multiple target devices is determined based on the external port number of each target device, and finally the used port number is filtered out from the same external port number to obtain the same idle external port number among multiple target devices. That is, according to an embodiment of the present disclosure, determining the same idle external port number of the multiple target devices based on the first public file may include:
[0114] According to the first public file, the used external port number of each of the target devices and the starting port number and the ending port number of each of the target devices' external ports are determined; according to the starting port number and the ending port number of each of the target devices, the same external port number of the multiple target devices is determined; according to the same external port number of the multiple target devices and the used external port number of each of the target devices, the same idle external port number of the multiple target devices is determined.
[0115] Among them, according to the starting port number and the ending port number of each target device, the same external port number of multiple target devices is determined, that is, according to the starting port number and the ending port number of each target device, the intersection of the external port numbers of multiple target devices is obtained. In a possible implementation, the same external port number range of multiple target devices can be obtained by comparing the size of the starting port number of each target device and selecting the largest starting port number as the starting point of the intersection; and by comparing the size of the ending port number of each target device and selecting the smallest ending port number as the end point of the intersection. In other words, the starting port number and the ending port number of the same external port number range can be obtained by the following formula:
[0116]
[0117]
[0118] Among them, F s represents the starting port number in the same external port number range, F(i) represents the i-th target device, and M represents the number of target devices; F e Indicates the end port number in the same external port number range. [0] indicates the start port number, and [1] indicates the end port number.
[0119] Through the above formula, the same external port number range of multiple target devices can be determined, and then the same idle external port number of multiple target devices can be determined based on the same external port number range and the used external port number of each target device. That is, according to an embodiment of the present disclosure, the same external port number of multiple target devices can be determined based on the starting port number and the ending port number of each target device, which may include:
[0120] The largest starting port number among the multiple target devices is determined as the target starting port number; the smallest ending port number among the multiple target devices is determined as the target ending port number; and the same external port number of the multiple target devices is determined based on the port number range corresponding to the target starting port number and the target ending port number.
[0121] After determining the same external port number of multiple target devices, any port number can be selected from the same external port numbers as the target external port number. In a possible implementation, any port number can be selected from the same external port numbers by a random function as the target external port number. That is, the target external port number can be determined by the following formula:
[0122] P u =hu({F e -s}- a );
[0123] Among them, P u Indicates the target external port number, sh indicates a random function, and F e Indicates the end port number in the same external port number range, F s Indicates the disclosed port number in the same external port number range, P a Indicates the used external port number of each target device.
[0124] In step S403, the Internet Protocol address of the host device is determined, and a communication connection is established between the host device and each of the collaborative devices based on the Internet Protocol address and the target external port number.
[0125] In a possible implementation, a communication connection is established between the host device and each collaborative device, so that the host device and each collaborative device can train a deep learning model according to the communication connection. The deep learning model can be an existing model in the relevant technology, such as residual networks (Residual Networks, ResNets), regional convolutional neural networks (Region-CNN, R-CNN) or deep neural networks (Deep Neural Networks, DNN), or it can be an improved model of an existing model in the relevant technology, and the embodiments of the present disclosure do not impose any restrictions on this.
[0126] It should be understood that in the related art, the Internet Protocol address information of a computer device can be queried by querying the command "ifconfig eth0". The queried Internet Protocol address information includes not only the Internet Protocol address but also some redundant information. Therefore, in order to automatically obtain the Internet Protocol address from the Internet Protocol address information, it is also necessary to filter the redundant information in the Internet Protocol address information to obtain the Internet Protocol address.
[0127] In a possible implementation, determining the Internet Protocol address of the host device may include:
[0128] Acquire Internet Protocol address information of the host device; match the Internet Protocol address information according to a preset protocol identifier to obtain target protocol address information; determine digital text according to the target protocol address information, and determine format information of the digital text; determine whether the format information is the same as the preset format information, and if the format information is the same as the preset format information, determine that the digital text is the Internet Protocol address of the host device.
[0129] Schematically, an Internet Protocol address information is represented as:
[0130] eth0: flags = 4163<up,BROADCAST,RUNNING,MULTICAST> mtu 1500
[0131] inet 10.38.21.1netmask 255.255.252.0broadcast 10.38.25.255
[0132] Ether 0c:42:a1:e9:e0:10txqueuelen 1000(Ethernet)
[0133] RX packets 408075736157bytes 517846245828662(470.9TiB)
[0134] RX errors 0dropped 2548overruns 0frame 0
[0135] TX packets 301416894586bytes 351950730555022(320.0TiB)
[0136] TX errors 0dropped 0overruns 0carrier 0collisions 0
[0137] When obtaining the Internet Protocol address based on the Internet Protocol address information, you can first match the Internet Protocol address information according to the preset protocol identifier "netmask" to obtain the target protocol address information containing the Internet Protocol address information, namely: inet 10.38.21.1netmask255.255.252.0broadcast 10.38.25.255; then determine the digital text and the format information of the digital text in the target protocol address information. There are three digital texts, namely 10.38.21.1, 255.255.252.0 and 10.38.25.255, and the format information corresponding to the three digital texts are **.**.**.*, ***.***.***.* and **.**.**.***; and the format information of the Internet Protocol address is generally ***.***.***.*. Therefore, by setting the preset format information to ***.***.***.* and comparing them with the format information corresponding to the three digital texts respectively, the Internet Protocol address, i.e. 255.255.252.0, can be filtered out from the three digital texts.
[0138] It is worth noting that, in order to reduce the amount of data processing by the computer device, in a possible implementation, only the host device checks the Internet Protocol address. Specifically, each target device determines whether it is a host device by checking its own device identifier and the host device identifier recorded in the configuration file, and only checks its own Internet Protocol address after determining that it is a host device.
[0139] In addition, after determining the target external port number and the Internet Protocol address of the host device, it is necessary to inform each collaborative device of the target external port number and the Internet Protocol address of the host device, so that each collaborative device can initiate a communication connection establishment request to the host device according to the target external port number and the Internet Protocol address of the host device, and the host device responds to the communication connection request initiated by each collaborative device until a communication connection is established between the host device and each collaborative device. Among them, since each collaborative device needs to obtain the Internet Protocol address of the host device and the target external port number for establishing a communication connection, if the target external port number and the Internet Protocol address are sent to each collaborative device separately by the host device, it will undoubtedly increase the data processing capacity of the host device. Therefore, in a possible implementation method, the target external port number and the Internet Protocol address of the host device can be saved as a public file, and each collaborative device obtains the target external port number and the Internet Protocol address of the host device by accessing the public file, and then establishes a communication connection with the host device according to the target external port number and the Internet Protocol address of the host device. That is, according to one embodiment of the present disclosure, the establishment of a communication connection between the host device and each of the collaborative devices according to the Internet Protocol address and the target external port number may include:
[0140] Periodically detect whether a second public file exists, wherein the second public file is generated according to the Internet Protocol address and the target external port number; when the existence of the second public file is detected, establish a communication connection between the host device and each of the collaborative devices.
[0141] It should be understood that the detection period for periodically detecting whether the second public file exists can be set according to actual conditions. For example, the detection period can be set to 2 seconds, 10 seconds or 1 minute.
[0142] In addition, after detecting the second public file, in order to ensure that each collaborative device has established a communication connection with the host device, in a possible implementation, it is also possible to periodically detect whether the host device has established a communication connection with each collaborative device. When it is detected that the host device has not established a communication connection with each collaborative device, the target collaborative device that has not established a communication connection with the host device is determined, and the communication connection between the target collaborative device and the host device is re-established.
[0143] In a possible implementation, it is possible to determine whether each collaborative device has established a communication connection with the host device by periodically detecting the communication flag of each collaborative device. The communication flag has two expressions: true and false, and true indicates that the host device has established a communication connection with the collaborative device, and false indicates that the host device has not established a communication connection with the collaborative device. In a specific implementation, the host device can detect the communication flag of each collaborative device, and when it is detected that the communication flag of a collaborative device is false, the communication connection with the collaborative device is reestablished.
[0144] In addition, since the communication connection between the collaborative device and the host device rarely fails, in order to reduce the host device's detection process of the communication flag and improve the processing performance of the host device, in a possible implementation, it is also possible to determine whether the host device has established a communication connection with each collaborative device by periodically detecting the number of trues. That is, if the host device detects that the number of trues is less than the number of pre-configured collaborative devices, it is determined that the host device has not established a communication connection with each collaborative device. At this time, the target collaborative device that has not established a communication connection with the host device is determined by identifying false, and the communication connection between the target collaborative device and the host device is re-established; if the host device detects that the number of trues is equal to the number of pre-configured collaborative devices, it is determined that the host device has established a communication connection with each collaborative device.
[0145] In addition, in order to avoid the target collaborative device being unable to establish a communication connection with the host device due to problems such as computer equipment failure or network failure, in a possible implementation method, a communication establishment time threshold can be pre-set. Within the communication establishment time threshold, if the communication connection between the target collaborative device and the host device fails to be established, an error is reported to prompt relevant personnel to handle it in time.
[0146] In summary, through the above-mentioned device collaboration method, the Internet Protocol address of the host device and the target external port number for establishing a communication connection can be automatically obtained in the multi-GPU collaborative training method based on the socket mode, and the communication connection between the host device and each collaborative device can be established according to the Internet Protocol address and the target external port number. Compared with the multi-GPU collaborative training method based on the socket mode in the related art, there is no need to manually check the Internet Protocol address of the host device and the idle external port number of each target device. On the one hand, it reduces the operational complexity of the multi-GPU collaborative training method, and on the other hand, it avoids the problem of failure of deep learning model training due to mutual interference when multiple people start deep learning model training in a computer cluster at the same time. At the same time, it also avoids the maintenance problem of the port number usage table caused by the mutual agreement on the port number that each user can use.
[0147] Based on the same concept, the embodiment of the present disclosure also provides a device coordination device, such as Figure 5 As shown, the device collaboration apparatus 500 may include a first determination module 501, a second determination module 502 and a communication module 503, wherein:
[0148] The first determination module 501 may be configured to determine a plurality of target devices, wherein the plurality of target devices include a host device and at least one collaborative device;
[0149] The second determination module 502 may be configured to determine the same idle external port numbers of the multiple target devices, and determine the target external port number according to the same idle external port numbers of the multiple target devices;
[0150] The communication module 503 may be configured to determine the Internet Protocol address of the host device, and establish a communication connection between the host device and each of the collaborative devices according to the Internet Protocol address and the target external port number.
[0151] In a possible implementation manner, the first determining module 501 may also be configured as follows:
[0152] Obtain a configuration file, where the configuration file is used to record host device identification information and the number of graphics processors;
[0153] Determining the host device according to the host device identification information in the configuration file;
[0154] According to a preset device selection rule and the number of the graphics processors in the configuration file, a target number of collaborative devices is determined from a preset plurality of devices, wherein at least one of the graphics processors is configured in the preset plurality of devices, and the number of idle graphics processors included in the target number of collaborative devices is not less than the number of the graphics processors in the configuration file.
[0155] In a possible implementation manner, the second determining module 502 may also be configured as follows:
[0156] Acquire a first public file, where the first public file is used to characterize the correspondence between identification information of each target device, an external port number of each target device, and a used external port number of each target device;
[0157] According to the first public file, the same idle external port number of the multiple target devices is determined.
[0158] In a possible implementation manner, the first public file can be obtained in the following manner:
[0159] Determine the external port information and the used external port information of each of the target devices;
[0160] For the external port information of each of the target devices, determine the external port number of each of the target devices, and for the used external port information of each of the target devices, process each line of information in the used external port information by a preset regular expression to obtain multiple lines of intermediate information separated by a preset identifier, and use the preset identifier as a segmentation point to segment each line of the intermediate information to obtain multiple data fields, determine a target data field containing a target preset identifier in the multiple data fields, use the target preset identifier as a segmentation point to segment the target data field to obtain the used external port number of each of the target devices;
[0161] Generate a correspondence between the identification information of each target device, the external port number of each target device, and the used external port number of each target device, and save the correspondence of each target device as the first public file.
[0162] In a possible implementation manner, the second determining module 502 may also be configured as follows:
[0163] Determine, according to the first public file, a used external port number of each of the target devices and a starting port number and an ending port number of each of the target devices' external ports;
[0164] Determine the same external port number of the plurality of target devices according to the starting port number and the ending port number of each of the target devices;
[0165] According to the common external port numbers of the plurality of target devices and the used external port number of each of the target devices, the common idle external port numbers of the plurality of target devices are determined.
[0166] In a possible implementation manner, the second determining module 502 may also be configured as follows:
[0167] Determine the largest starting port number among the multiple target devices as the target starting port number;
[0168] Determine the smallest termination port number among the plurality of target devices as the target termination port number;
[0169] According to the port number range corresponding to the target start port number and the target end port number, the same external port number of the plurality of target devices is determined.
[0170] In a possible implementation, the communication module 503 may also be configured as:
[0171] Obtaining Internet Protocol address information of the host device;
[0172] Matching the Internet Protocol address information according to a preset protocol identifier to obtain target protocol address information;
[0173] Determine the digital text according to the target protocol address information, and determine the format information of the digital text;
[0174] Determine whether the format information is the same as the preset format information, and if the format information is the same as the preset format information, determine that the digital text is the Internet Protocol address of the host device.
[0175] In a possible implementation, the communication module 503 may also be configured as:
[0176] Periodically detecting whether a second public file exists, wherein the second public file is generated according to the Internet Protocol address and the target external port number;
[0177] When the existence of the second public file is detected, a communication connection is established between the host device and each of the collaborative devices.
[0178] In summary, through the above-mentioned device collaboration device, the Internet Protocol address of the host device and the target external port number for establishing a communication connection can be automatically obtained in the multi-GPU collaborative training method based on the socket mode, and the communication connection between the host device and each collaborative device can be established according to the Internet Protocol address and the target external port number. Compared with the multi-GPU collaborative training method based on the socket mode in the related art, there is no need to manually check the Internet Protocol address of the host device and the idle external port number of each target device. On the one hand, it reduces the operational complexity of the multi-GPU collaborative training method, and on the other hand, it avoids the problem of failure of deep learning model training due to mutual interference when multiple people start deep learning model training in a computer cluster at the same time. At the same time, it also avoids the maintenance problem of the port number usage table caused by the mutual agreement on the port number that each user can use.
[0179] Regarding the device in the above embodiment, the specific manner in which each module performs operations has been described in detail in the embodiment of the method, and will not be elaborated here.
[0180] The embodiment of the present disclosure also provides a computer-readable storage medium having computer program instructions stored thereon, which, when executed by a processor, implement the steps of the device coordination method provided by the present disclosure.
[0181] The embodiment of the present disclosure also provides a computer program product, which includes a computer program that can be executed by a programmable device, and the computer program has a code portion for executing the above-mentioned device coordination method when executed by the programmable device.
[0182] The present disclosure also provides an electronic device, including:
[0183] processor;
[0184] a memory for storing processor-executable instructions;
[0185] Wherein, the processor is configured to:
[0186] Execute the steps of the device coordination method provided by the present disclosure.
[0187] Figure 6 600 is a block diagram of an apparatus for device collaboration according to an exemplary embodiment. For example, the apparatus 600 may be provided as a server. Figure 6 The apparatus 600 includes a processing component 622, which further includes one or more processors, and a memory resource represented by a memory 632 for storing instructions, such as applications, that can be executed by the processing component 622. The application stored in the memory 632 may include one or more modules, each corresponding to a set of instructions. In addition, the processing component 622 is configured to execute instructions to perform the above-mentioned device coordination method.
[0188] The device 600 may also include a power supply component 626 configured to perform power management of the device 600, a wired or wireless network interface 650 configured to connect the device 600 to a network, and an input / output interface 658. The device 600 may operate based on an operating system stored in the memory 632, such as Windows Server 2000. TM , Mac OS X TM , Unix TM , Linux TM , FreeBSD TM or similar.
[0189] Those skilled in the art will readily appreciate other embodiments of the present disclosure after considering the specification and practicing the present disclosure. The present disclosure is intended to cover any variations, uses or adaptations of the present disclosure that follow the general principles of the present disclosure and include common knowledge or customary techniques in the art that are not disclosed in the present disclosure. The description and examples are to be considered as exemplary only, and the true scope and spirit of the present disclosure are indicated by the following claims.
[0190] It should be understood that the present disclosure is not limited to the exact structures that have been described above and shown in the drawings, and that various modifications and changes may be made without departing from the scope thereof. The scope of the present disclosure is limited only by the appended claims.
Claims
1. A device collaboration method, characterized in that: The method comprises: Determining a plurality of target devices, the plurality of target devices comprising a host device and at least one collaborative device; Determine the same idle external port number of the plurality of target devices, and determine the target external port number according to the same idle external port number of the plurality of target devices; The Internet Protocol address of the host device is determined, and a communication connection is established between the host device and each of the collaborative devices based on the Internet Protocol address and the target external port number.
2. The method according to claim 1, characterized in that The determining of multiple target devices comprises: Obtain a configuration file, where the configuration file is used to record host device identification information and the number of graphics processors; Determining the host device according to the host device identification information in the configuration file; According to a preset device selection rule and the number of the graphics processors in the configuration file, a target number of collaborative devices is determined from a preset plurality of devices, wherein at least one of the graphics processors is configured in the preset plurality of devices, and the number of idle graphics processors included in the target number of collaborative devices is not less than the number of the graphics processors in the configuration file.
3. The method according to claim 1 or 2, characterized in that: The determining the same idle external port number of the multiple target devices includes: Acquire a first public file, where the first public file is used to characterize the correspondence between identification information of each target device, an external port number of each target device, and a used external port number of each target device; According to the first public file, the same idle external port numbers of the multiple target devices are determined.
4. The method according to claim 3, characterized in that The first public file is obtained in the following manner: Determine the external port information and the used external port information of each of the target devices; For the external port information of each of the target devices, determine the external port number of each of the target devices, and for the used external port information of each of the target devices, process each line of information in the used external port information by a preset regular expression to obtain multiple lines of intermediate information separated by a preset identifier, and use the preset identifier as a segmentation point to segment each line of the intermediate information to obtain multiple data fields, determine a target data field containing a target preset identifier in the multiple data fields, use the target preset identifier as a segmentation point to segment the target data field to obtain the used external port number of each of the target devices; Generate a correspondence between the identification information of each target device, the external port number of each target device, and the used external port number of each target device, and save the correspondence of each target device as the first public file.
5. The method according to claim 3, characterized in that: The determining, according to the first public file, the same idle external port numbers of the plurality of target devices comprises: Determine, according to the first public file, the used external port number of each of the target devices and the starting port number and the ending port number of each of the target devices' external ports; Determine the same external port number of the plurality of target devices according to the starting port number and the ending port number of each of the target devices; According to the common external port numbers of the plurality of target devices and the used external port number of each of the target devices, the common idle external port numbers of the plurality of target devices are determined.
6. The method according to claim 5, characterized in that The step of determining the same external port number of a plurality of target devices according to the starting port number and the ending port number of each target device comprises: Determine the largest starting port number among the multiple target devices as the target starting port number; Determine the smallest termination port number among the plurality of target devices as the target termination port number; According to the port number range corresponding to the target start port number and the target end port number, the same external port number of the plurality of target devices is determined.
7. The method according to claim 1 or 2, characterized in that: Determining the Internet Protocol address of the host device includes: Obtaining Internet Protocol address information of the host device; Matching the Internet Protocol address information according to a preset protocol identifier to obtain target protocol address information; Determine the digital text according to the target protocol address information, and determine the format information of the digital text; Determine whether the format information is the same as the preset format information, and if the format information is the same as the preset format information, determine that the digital text is the Internet Protocol address of the host device.
8. The method according to claim 1 or 2, characterized in that: The step of establishing a communication connection between the host device and each of the collaborative devices according to the Internet Protocol address and the target external port number includes: Periodically detecting whether a second public file exists, wherein the second public file is generated according to the Internet Protocol address and the target external port number; When the existence of the second public file is detected, a communication connection is established between the host device and each of the collaborative devices.
9. A device coordination apparatus, characterized in that: include: A first determination module is configured to determine a plurality of target devices, wherein the plurality of target devices include a host device and at least one collaborative device; A second determination module is configured to determine the same idle external port numbers of the multiple target devices, and determine the target external port number according to the same idle external port numbers of the multiple target devices; The communication module is configured to determine the Internet Protocol address of the host device and establish a communication connection between the host device and each of the collaborative devices based on the Internet Protocol address and the target external port number.
10. An electronic device, characterized in that: include: processor; a memory for storing processor-executable instructions; Wherein, the processor is configured to: Execute the steps of the method according to any one of claims 1 to 8.
11. A computer-readable storage medium having computer program instructions stored thereon, characterized in that: When the program instructions are executed by a processor, the steps of the method described in any one of claims 1 to 8 are implemented.
Citation Information
Patent Citations
System and method for collaboration of multiple ports of exchanger
CN103812792A
Cooperative work method and device, storage medium and cooperative system
CN112752048A
Port connection system and method and computer equipment
CN114629862A
Bus analyzer
JP2002281051A
Electronic device, wire connection device, and power supply control method
JP2021056797A
