Data acquisition method, device, storage medium and electronic device
By processing call requests in GPU-free terminals and using the function of the virtual GPU and the physical GPU function library with the same name, GPU task execution on GPU-free devices is realized, resource waste and programming complexity problems are solved, and user experience is improved.
Patent Information
- Application Number
- CN202210256039.4
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-03-15
- Publication Date
- 2025-09-05
- Estimated Expiration
- 2042-03-15
AI Technical Summary
In the prior art, GPU resources are limited and costly, resulting in wasted device resources, and code modification is required when completing GPU tasks on devices without GPUs, increasing programming complexity and possibility of errors.
By obtaining the call request on the terminal without the physical GPU installed, processing the call request as a remote terminal, and using the function library of the virtual GPU with the same name as the native function library of the physical GPU for processing, the execution of remote GPU tasks is realized and the consistency of programming habits is maintained.
Complete GPU tasks on GPU-free devices reduces resource waste, reduces user programming complexity and error rate, and improves program transparency.
Smart Images

Figure CN114595065B_ABST
Abstract
Description
Technical Field
[0001] The present disclosure relates to the field of computer technology, and in particular to a data acquisition method, device, storage medium, and electronic device. Background Art
[0002] Currently, GPU (graphics processing unit) resources are limited and expensive. Directly using devices with locally installed GPUs to complete GPU tasks will cause the GPUs to be idle most of the time, resulting in serious resource waste. In addition, it is not practical to install a GPU locally on every device.
[0003] In the related art, there is a solution that sends local GPU tasks to the GPU of a remote device for execution, thereby completing the GPU tasks through the GPU of the remote device. In this way, the function of completing GPU tasks can be achieved even on a local device without a GPU. However, the solution in the related art usually requires code modification when writing GPU tasks. Summary of the Invention
[0004] This summary is provided to briefly introduce concepts that will be described in detail in the detailed description below. This summary is not intended to identify key features or essential features of the claimed technical solution, nor is it intended to limit the scope of the claimed technical solution.
[0005] In a first aspect, the present disclosure provides a data acquisition method, applied to a first terminal, the method comprising:
[0006] Obtaining a first call request for invoking the virtual GPU installed by the first terminal, where the first call request carries an identifier corresponding to the first function;
[0007] Processing the first call request through the first function to obtain a second call request, and sending the second call request to a second terminal through the first function, so that the second terminal calls a second function in a native function library of the physical GPU according to the second call request, and calls a physical GPU installed in the second terminal for processing according to the second function to obtain target data corresponding to the second call request, where the first function is a function in the function library of the first terminal with the same name as the second function;
[0008] Receive the target data returned by the second terminal.
[0009] In a second aspect, the present disclosure provides a data acquisition device, applied to a first terminal, the device comprising:
[0010] A first call request obtaining module, configured to obtain a first call request for invoking the virtual GPU installed by the first terminal, wherein the first call request carries an identifier corresponding to the first function;
[0011] a second call request generating module, configured to process the first call request through the first function to obtain a second call request, and send the second call request to a second terminal through the first function, so that the second terminal calls a second function in a native function library of the physical GPU according to the second call request, and calls a physical GPU installed in the second terminal for processing according to the second function to obtain target data corresponding to the second call request, where the first function is a function in the function library of the first terminal with the same name as the second function;
[0012] The target data receiving module is configured to receive the target data returned by the second terminal.
[0013] In a third aspect, the present disclosure provides a computer-readable storage medium having a computer program stored thereon, which implements the steps of the method described in the first aspect when executed by a processing device.
[0014] In a fourth aspect, the present disclosure provides an electronic device, comprising:
[0015] a storage device having at least one computer program stored thereon;
[0016] At least one processing device, configured to execute the at least one computer program in the storage device to implement the steps of the method of the first aspect.
[0017] Based on the above technical solution, when a first terminal without a physical GPU installed obtains a first call request, the first call request can be processed to obtain a second call request, and then the second call request can be processed by the physical GPU of the remote second terminal, and the processed target data is returned to the first terminal, thereby realizing the function of completing GPU tasks even when the first terminal does not have a GPU. In addition, since a virtual GPU is installed in the first terminal, and the first function in the function library of the first terminal corresponding to the virtual GPU has the same name as the second function in the native function library of the physical GPU, when programming GPU tasks, the user can program according to the same programming habits as when there is a physical GPU in the first terminal, avoiding the user from modifying the code when writing GPU tasks, making the user program more transparent, and reducing the possibility of user programming errors.
[0018] Other features and advantages of the present disclosure will be described in detail in the following detailed description. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] The above and other features, advantages and aspects of the various embodiments of the present disclosure will become more apparent with reference to the following detailed description in conjunction with the accompanying drawings. Throughout the drawings, the same or similar reference numerals represent the same or similar elements. It should be understood that the drawings are schematic and that the originals and elements are not necessarily drawn to scale. In the drawings:
[0020] Figure 1 is a schematic diagram of an application environment provided according to an exemplary embodiment;
[0021] Figure 2 is a flow chart of a data acquisition method provided according to an exemplary embodiment;
[0022] Figure 3 is a schematic diagram of another application environment provided according to an exemplary embodiment;
[0023] Figure 4 is a module connection diagram of a data acquisition device provided according to an exemplary embodiment;
[0024] Figure 5 It is a schematic structural diagram of an electronic device provided according to an exemplary embodiment. DETAILED DESCRIPTION
[0025] The following describes embodiments of the present disclosure in more detail with reference to the accompanying drawings. Although certain embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be construed as limited to the embodiments described herein. Rather, these embodiments are provided to provide a more thorough and complete understanding of the present disclosure. It should be understood that the drawings and embodiments of the present disclosure are for illustrative purposes only and are not intended to limit the scope of protection of the present disclosure.
[0026] It should be understood that the various steps described in the method embodiments of the present disclosure may be performed in different orders and / or in parallel. In addition, the method embodiments may include additional steps and / or omit the steps shown. The scope of the present disclosure is not limited in this respect.
[0027] As used herein, the term "including" and its variations are open-ended, i.e., "including but not limited to." The term "based on" means "based, at least in part, on." The term "one embodiment" means "at least one embodiment," the term "another embodiment" means "at least one additional embodiment," and the term "some embodiments" means "at least some embodiments." Other terms are defined in the following description.
[0028] It should be noted that the concepts of "first" and "second" mentioned in this disclosure are only used to distinguish different devices, modules or units, and are not used to limit the order or interdependence of the functions performed by these devices, modules or units.
[0029] It should be noted that the modifications of "one" and "multiple" mentioned in the present disclosure are illustrative rather than restrictive, and those skilled in the art should understand that unless otherwise clearly indicated in the context, they should be understood as "one or more".
[0030] The names of the messages or information exchanged between multiple devices in the embodiments of the present disclosure are only used for illustrative purposes and are not used to limit the scope of these messages or information.
[0031] In related technologies, some frameworks, such as TensorFlow and PyTorch, can submit GPU tasks to remote machines for execution. However, when using these frameworks, users are aware that they are using the GPU on the remote machine, and they need to add additional code to the GPU task code when programming the GPU task. GPU tasks can include developing, debugging, and running GPU programs, and when executing GPU tasks, the GPU is called for processing.
[0032] For example, tf requires explicitly calling the tf.config.experimental_connect_to_cluster method. Another example is that Torch usually needs to be compiled with xla and requires adding some code to the code that originally ran on a single machine, such as xm.mark_step().
[0033] The need to add additional code complicates the entire GPU task programming process and makes it opaque to user programs. Furthermore, this differs from traditional programming practices for devices with locally installed GPUs, increasing the likelihood of user programming errors.
[0034] In response to the above technical problems, the embodiments of the present disclosure provide a data acquisition method, device, storage medium, and electronic device. When a first call request is obtained at a first terminal without a physical GPU installed, the first call request is processed to obtain a second call request, and then the second call request is processed by the physical GPU of the remote second terminal, and the processed target data is returned to the first terminal. This achieves the function of completing GPU tasks even when the first terminal does not have a GPU. In addition, by installing a virtual GPU at the first terminal, and the first function in the function library of the first terminal corresponding to the virtual GPU has the same name as the second function in the native function library of the physical GPU, when programming GPU tasks, the user can program according to the same programming habits as if there is a physical GPU at the first terminal, avoiding the user from modifying the code when writing GPU tasks, making the user program more transparent, and reducing the possibility of user programming errors.
[0035] In order to facilitate the detailed description of the present application, an application environment in an embodiment of the present application is first introduced below with reference to the accompanying drawings.
[0036] In some embodiments, see Figure 1 , Figure 1 The figure shows a schematic diagram of an application environment provided by an embodiment of the present disclosure. It includes a first terminal and a second terminal, wherein the first terminal and the second terminal are connected via a network. The first terminal can send a call request from a local GPU program to a virtual GPU to the second terminal via a first function in a virtual function library, so that the second terminal calls a second function with the same name as the first function in the native function library of its own physical GPU, and calls its own installed physical GPU for processing according to the second function. This supports users to develop, debug, and run GPU programs on machines without GPU devices, and the entire process is transparent to the user program, as if the GPU device is local to the first terminal.
[0037] A data acquisition method, device, storage medium, and electronic device proposed in an embodiment of the present disclosure will be described in detail below with reference to the accompanying drawings.
[0038] Figure 2 This is a flow chart of a data acquisition method provided according to an exemplary embodiment. The data acquisition method provided by the embodiment of the present disclosure can be Figure 1 The first terminal shown in FIG. 1 can be executed specifically by a data acquisition device, which can be implemented in software and / or hardware and is configured at Figure 1 In the first terminal shown. Figure 2 The data acquisition method provided by the embodiment of the present disclosure may include the following steps:
[0039] S210: Obtain a first calling request for calling a virtual GPU installed in the first terminal, where the first calling request carries an identifier corresponding to a first function.
[0040] The virtual GPU can be understood as a GPU virtualized locally on the first terminal. Unlike a real physical GPU, the virtual GPU cannot perform calculations.
[0041] In some embodiments, a driver device can be created and mounted on the / dev / remotegpu path. The driver device can be a Linux driver device. The driver device can create configuration information of the remote physical GPU in the proc file system, such as / proc / driver / bytedance / remotegpu0 and / proc / driver / bytedance / remotegpu1. Each file stores information about the remote real physical GPU. For example, the virtual GPU device points to the GPU device on the remote second terminal with an IP address of 192.0.0.1 and a UUID of GPU-5a0622d3-66c6-4f39-30fd-d31ab6401071. This process completes the creation of the virtual GPU, and the first terminal can subsequently access the second terminal via Ethernet.
[0042] It is understandable that since calling the GPU to perform calculations is achieved by calling a corresponding function, the first calling request carries an identifier corresponding to the first function.
[0043] The first call request may be initiated by any GPU program of the first terminal, for example, a game or drawing software that needs to call the GPU for processing.
[0044] S220, processing the first call request through the first function to obtain a second call request, and sending the second call request to the second terminal through the first function, so that the second terminal calls the second function in the native function library of the physical GPU according to the second call request, and calls the physical GPU installed by itself for processing according to the second function to obtain target data corresponding to the second call request, where the first function is a function in the function library of the first terminal with the same name as the second function.
[0045] In the embodiment of the present disclosure, after obtaining the first call request, the first terminal can parse the first call request to obtain the identifier corresponding to the first function included therein, and then call the corresponding first function for processing according to the identifier. Since the GPU of the first terminal is a virtual GPU and cannot perform calculations, the first function will not call the virtual GPU to calculate the first call request, but will repackage the first call request to obtain a second call request, and send the second call request to the second terminal.
[0046] In some embodiments, the functions performed by the first function mainly include two parts, and the functions of these two parts can be completed by corresponding sub-functions respectively, for example, the first sub-function and the second sub-function, wherein the first sub-function completes the function of repackaging the first call request to obtain the second call request, and the second sub-function completes the function of sending the second call request to the second terminal.
[0047] After sending the second call request to the second terminal, the second terminal can call the second function with the same name as the first function in the native function library of the physical GPU according to the second call request, and call the physical GPU installed on itself for processing according to the second function to obtain the target data corresponding to the second call request.
[0048] It can be understood that the native function library of the physical GPU may include a native cuda function library and a native nvidia function library. In the embodiment of the present disclosure, the function library where the first function is located may be a custom cuda function library and a custom nvidia function library. After calling the custom cuda function library and the custom nvidia function library, the physical GPU will not be directly operated for calculation.
[0049] S230: Receive target data returned by the second terminal.
[0050] In the embodiment of the present disclosure, after the second terminal calls its own installed physical GPU to process the second call request and obtains the target data, it can return the target data to the first terminal, so that the first terminal can receive the target data returned by the second terminal.
[0051] In some implementations, after receiving the target data returned by the second terminal, the first terminal may return the target data to the corresponding upper-layer application.
[0052] By adopting the above method, when a first terminal without a physical GPU installed obtains a first call request, the first call request can be processed to obtain a second call request, and then the second call request is processed by the physical GPU of the remote second terminal, and the processed target data is returned to the first terminal, thereby realizing the function of completing GPU tasks even when the first terminal does not have a GPU. In addition, since a virtual GPU is installed in the first terminal, and the first function in the function library of the first terminal corresponding to the virtual GPU has the same name as the second function in the native function library of the physical GPU, when programming GPU tasks, the user can program according to the same programming habits as if there is a physical GPU in the first terminal, so as to avoid the user from modifying the code when writing GPU tasks, making the user program more transparent and reducing the possibility of user programming errors.
[0053] It is understandable that the physical GPU has a corresponding video memory address in the second terminal. In addition, in order to minimize changes to the programming code and be transparent to the user program, the virtual GPU may also have a corresponding video memory address in the first terminal, wherein the video memory address of the virtual GPU in the first terminal may be virtual.
[0054] In the embodiment of the present disclosure, the GPU task executed locally on the first terminal is sent to the remote second terminal for execution. Therefore, the corresponding GPU tasks in the first terminal and the second terminal remain unchanged. In other words, the request type included in the call request remains unchanged. In some embodiments, both the first call request and the second call request are computing sub-requests for invoking the GPU for computing. In this case, the second call request may specifically include a computing sub-request for invoking the physical GPU for computing. In this case, processing the first call request by the first function to obtain the second call request includes the following steps:
[0055] In a case where the second call request includes a calculation sub-request for calling a physical GPU for calculation, an identifier corresponding to the first function, configuration information of the physical GPU, calculation parameters, and a target video memory address are obtained through the first function; and a calculation sub-request is generated through the first function based on the identifier corresponding to the first function, configuration information of the physical GPU, calculation parameters, and target video memory address.
[0056] Since the corresponding GPU functions completed in the first terminal and the second terminal remain unchanged, when generating the second call request, the called function is the same and the calculation parameters are also the same. In addition, since the configuration information of the virtual GPU points to the configuration information of the real physical GPU, the configuration information of the virtual GPU is the same as the configuration information of the physical GPU. However, considering that the video memory address in the first terminal and the video memory address in the second terminal may not correspond, when generating the second call request, it is also necessary to obtain the actual video memory address corresponding to the calculation of the physical GPU in the second terminal, that is, the target video memory address.
[0057] Therefore, in the embodiment of the present disclosure, the identifier corresponding to the first function, the configuration information of the physical GPU, the calculation parameters and the target memory address can be obtained through the first function, and then the calculation sub-request can be generated through the first function based on the identifier corresponding to the first function, the configuration information of the physical GPU, the calculation parameters and the target memory address.
[0058] Exemplarily, when the first calling request and the second calling request are both computing sub-requests for calling a GPU to perform computing, the first function may be a cuLaunchKernel function.
[0059] In some implementations, obtaining the target video memory address may include the following steps:
[0060] Obtain an original video memory address of the first terminal used when the virtual GPU performs calculations; and determine a target video memory address in the second terminal corresponding to the original video memory address based on a mapping relationship between the video memory address in the first terminal and the video memory address in the second terminal.
[0061] In an embodiment of the present disclosure, in the first terminal, the first call request can be parsed through the first function to obtain the identifier corresponding to the first function, the configuration information of the physical GPU, the calculation parameters, and the original video memory address of the first terminal used by the virtual GPU. After obtaining the original video memory address of the first terminal used when the virtual GPU performs calculations, the target video memory address in the second terminal corresponding to the original video memory address can be determined based on the mapping relationship between the video memory address in the first terminal and the video memory address in the second terminal.
[0062] Furthermore, in some embodiments, after receiving the first call request, the first terminal may also forward the first call request directly to the second terminal via the first function. The second terminal then parses the first call request, obtains the identifier corresponding to the first function, the configuration information of the physical GPU, the calculation parameters, and the target video memory address, and generates a calculation sub-request based on the identifier corresponding to the first function, the configuration information of the physical GPU, the calculation parameters, and the target video memory address. In this case, the mapping relationship between the video memory address in the first terminal and the video memory address in the second terminal may also be stored in the second terminal.
[0063] In other embodiments, the first call request and the second call request are both change sub-requests for calling a GPU to change video memory. In this case, the second call request may specifically include a change sub-request for calling a physical GPU to change video memory, and the target data includes a first changed video memory address after the physical GPU changes the video memory. In this case, after obtaining the target data, the data acquisition method of the embodiment of the present disclosure further includes the following steps:
[0064] A second changed video memory address and the first changed video memory address after the virtual GPU changes the video memory are obtained; and a mapping relationship is updated based on the first changed video memory address and the second changed video memory address.
[0065] Based on the foregoing, it can be seen that the physical GPU has a corresponding video memory address in the second terminal, and the virtual GPU has a corresponding video memory address in the first terminal. Therefore, after the first terminal obtains the first call request, the virtual GPU can also change the video memory address in the first terminal to obtain a changed second changed video memory address. Furthermore, in order to ensure the accurate completion of subsequent GPU tasks, after obtaining the target data, the first changed video memory address can be mapped to the changed second changed video memory address to update the mapping relationship.
[0066] In some embodiments, a change subrequest for modifying video memory may include a video memory allocation subrequest and a video memory release subrequest. For example, when both the first call request and the second call request are change subrequests for invoking a GPU to modify video memory, the first function may be the cuMemAlloc function.
[0067] In addition, considering that the function library where the first function is located is not the native function library of the physical GPU, it cannot be directly installed and deployed in the deployment location of the native function library of the physical GPU, for example, it cannot be directly deployed in the / usr / lib / x86_64-linux-gnu / libnvidia-ml.so.1 path or the / usr / lib / x86_64-linux-gnu / libcuda.so.1 path. In this case, in order to further reduce the user's code modification when writing GPU tasks and be more transparent to the user program, in some embodiments, the data acquisition method of the embodiment of the present disclosure may further include the following steps:
[0068] The actual installation location of the function library of the first terminal is obtained; and the actual installation location is soft-connected to the universal installation location of the native function library of the physical GPU on the first terminal.
[0069] A soft link, also known as a symbolic link, can be thought of as an alias for a file that contains the pathname of another file. This file can be any file or directory, and can link to files on different file systems. Soft links allow us to use the same file in different directories without having to place a copy of the file in each directory. We can simply place the file in a specific directory and then link to it in other directories.
[0070] For example, assuming that the function library corresponding to the first function is installed and deployed in the / usr / lib / x86_64-linux-gnu / libcuda.so path, it can be soft-linked to the / usr / lib / x86_64-linux-gnu / libcuda.so.1 path, or assuming that the function library corresponding to the first function is installed and deployed in the / usr / lib / x86_64-linux-gnu / libnvidia.so path, it can be soft-linked to the / usr / lib / x86_64-linux-gnu / libnvidia.so.1 path.
[0071] By soft-connecting the actual installation location of the function library of the first terminal to the general installation location of the native function library of the physical GPU on the first terminal, it is possible to reduce the user's code modifications when writing GPU tasks even if it is inconvenient to install the first function library at the general installation location of the native function library, making it more transparent to the user program.
[0072] In some embodiments, the first terminal and the second terminal can communicate via a remote call protocol. For example, a remote call server can be deployed on the second terminal, and a remote call client (i.e., a first function) can be deployed on the first terminal, so that the client and the server can communicate via the remote call protocol. In this case, the first function can send a second call request to the second terminal based on the remote call protocol, and receive target data returned by the second terminal via the remote call protocol.
[0073] Furthermore, considering that some terminals are equipped with remote direct data access network cards, in this case, network acceleration can be achieved through remote direct data access technology. Therefore, in other embodiments, the first terminal and the second terminal can communicate via a remote call protocol and a remote direct data access network. Thus, the data packet type corresponding to the second call request can be subdivided into a control transmission data packet and a data transmission data packet, and the data packet type corresponding to the target data can be subdivided into a control transmission data packet and a data transmission data packet. In this case, sending the second call request to the second terminal through the first function can include the following steps:
[0074] The control transmission data packet corresponding to the second call request is sent to the second terminal based on the remote call protocol through the first function; and / or the data transmission data packet corresponding to the second call request is sent to the second terminal based on the remote direct data access network through the first function.
[0075] Similarly, receiving the target data returned by the second terminal may include the following steps:
[0076] Receive a control transmission data packet corresponding to the target data via a remote call protocol; and / or receive a data transmission data packet corresponding to the target data via a remote direct data access network.
[0077] The remote procedure call protocol is referred to as RPC (Remote Procedure Call Protocol) and remote direct data access is referred to as RDMA (Remote Direct Memory Access).
[0078] That is, in the embodiment of the present disclosure, when the second call request includes a control transmission data packet, the control transmission data packet corresponding to the second call request can be sent to the second terminal based on the remote call protocol, and when the second call request includes a data transmission data packet, the data transmission data packet corresponding to the second call request can be sent to the second terminal based on the remote direct data access network. When the target data includes a control transmission data packet, the control transmission data packet corresponding to the target data can be received through the remote call protocol, and when the target data includes a data transmission data packet, the data transmission data packet corresponding to the target data can be received through the remote direct data access network.
[0079] In addition, in some embodiments, the first function includes an MPI_Send function and an MPI_Recv function. In this case, sending the data transmission data packet corresponding to the second call request to the second terminal based on the remote direct data access network through the first function includes: calling the MPI_Send function to send the data transmission data packet corresponding to the second call request to the second terminal based on the remote direct data access network.
[0080] Receiving a data transmission data packet corresponding to the target data through the remote direct data access network, including: calling the MPI_Recv function to copy the data transmission data packet corresponding to the target data through the remote direct data access network
[0081] In an embodiment of the present disclosure, when a first terminal sends a data transmission data packet to a second terminal, such as when calling the cuMemcpyHtoD function to send a data packet, the MPI_Send function can be called to send the data transmission data packet to the second terminal through a remote direct data access network to achieve network acceleration when the first terminal sends data to the second terminal.
[0082] When the first terminal copies data from the second terminal, such as calling the cuMemcpyDtoH function to copy a data packet, the MPI_Recv function can be called to copy the data transmission data packet from the second terminal through the remote direct data access network. For example, the GPU memory data is copied from the second terminal to achieve network acceleration when the first terminal copies data from the second terminal.
[0083] See also Figure 3 , Figure 3The figure shows a schematic diagram of another application environment involved in an embodiment of the present disclosure. It includes a first terminal and a second terminal. The first terminal and the second terminal can be connected via the RPC protocol and the RDMA network. The first terminal can send a local control transmission data packet to the RPC server of the second terminal based on the RPC protocol through the first function in the virtual function library, and receive a control transmission data packet from the RPC server through the RPC protocol. The first terminal can also send a local data transmission data packet to the second terminal based on the RDMA network through the first function in the virtual function library, and receive a data transmission data packet from the second terminal through the RDMA network.
[0084] Figure 4 FIG. 1 is a schematic diagram of module connections of a data acquisition device according to an exemplary embodiment. Figure 4 As shown, an embodiment of the present disclosure provides a data acquisition device, which is applied to a first terminal pole. The device 400 may include:
[0085] A first call request obtaining module 410 is configured to obtain a first call request for invoking the virtual GPU installed by the first terminal, where the first call request carries an identifier corresponding to the first function;
[0086] a second call request generating module 420 configured to process the first call request through the first function to obtain a second call request, and to send the second call request to a second terminal through the first function, so that the second terminal calls a second function in a native function library of the physical GPU according to the second call request, and calls a physical GPU installed in the second terminal for processing according to the second function to obtain target data corresponding to the second call request, where the first function is a function in the function library of the first terminal with the same name as the second function;
[0087] The target data receiving module 430 is configured to receive the target data returned by the second terminal.
[0088] Optionally, the second call request generating module 420 includes:
[0089] an acquisition submodule, configured to, when the second call request includes a calculation subrequest for calling the physical GPU to perform calculations, obtain, through the first function, an identifier corresponding to the first function, configuration information of the physical GPU, calculation parameters, and a target video memory address;
[0090] The computing sub-request generating sub-module is configured to generate the computing sub-request through the first function based on an identifier corresponding to the first function, configuration information of the physical GPU, the computing parameters, and the target video memory address.
[0091] Optionally, the acquisition submodule is also used to obtain the original video memory address of the first terminal used by the virtual GPU for calculation; based on the mapping relationship between the video memory address in the first terminal and the video memory address in the second terminal, determine the target video memory address in the second terminal corresponding to the original video memory address.
[0092] Optionally, when the second calling request is a change sub-request for calling the physical GPU to change the video memory, the target data includes a first changed video memory address after the physical GPU changes the video memory. In this case, the apparatus 400 further includes:
[0093] a changed video memory address acquisition module, configured to acquire a second changed video memory address after the virtual GPU changes the video memory, and the first changed video memory address;
[0094] A mapping relationship updating module is configured to update the mapping relationship based on the first changed video memory address and the second changed video memory address.
[0095] Optionally, the apparatus 400 further includes:
[0096] an actual installation location acquisition module, configured to acquire the actual installation location of the function library of the first terminal;
[0097] The soft connection module is used to soft-connect the actual installation location to the general installation location of the native function library of the physical GPU on the first terminal.
[0098] Optionally, the data packet types corresponding to the second call request include control transmission data packets and data transmission data packets, and the data packet types corresponding to the target data include control transmission data packets and data transmission data packets. The second call request generating module 420 includes:
[0099] A first sending submodule, configured to send a control transmission data packet corresponding to the second call request to the second terminal based on a remote call protocol through the first function;
[0100] The second sending submodule is configured to send the data transmission data packet corresponding to the second call request to the second terminal based on the remote direct data access network through the first function.
[0101] The target data receiving module 430 includes:
[0102] A first receiving submodule is configured to receive a control transmission data packet corresponding to the target data through a remote call protocol;
[0103] The second receiving submodule is configured to receive a data transmission data packet corresponding to the target data via a remote direct data access network.
[0104] Optionally, the first function includes an MPI_Send function and an MPI_Recv function, and the second sending submodule is further configured to call the MPI_Send function to send the data transmission packet corresponding to the second call request to the second terminal via the remote direct data access network. The second receiving submodule is further configured to call the MPI_Recv function to copy the data transmission packet corresponding to the target data via the remote direct data access network.
[0105] The specific implementation of each functional module of the device in the above embodiment has been described in detail in the part about the method, and will not be repeated here.
[0106] Reference below Figure 5 , which shows a schematic structural diagram of an electronic device 500 suitable for implementing the embodiments of the present disclosure. The terminal devices in the embodiments of the present disclosure may include, but are not limited to, mobile terminals such as mobile phones, laptop computers, digital broadcast receivers, PDAs (personal digital assistants), PADs (tablet computers), PMPs (portable multimedia players), in-vehicle terminals (e.g., in-vehicle navigation terminals), and fixed terminals such as digital TVs and desktop computers. Figure 5 The electronic device shown is only an example and should not limit the functions and scope of use of the embodiments of the present disclosure.
[0107] like Figure 5 As shown, the electronic device 500 may include a processing device (e.g., a central processing unit, a graphics processing unit, etc.) 501, which can perform various appropriate actions and processes according to a program stored in a read-only memory (ROM) 502 or a program loaded from a storage device 508 into a random access memory (RAM) 503. Various programs and data required for the operation of the electronic device 500 are also stored in the RAM 503. The processing device 501, the ROM 502, and the RAM 503 are connected to each other via a bus 504. An input / output (I / O) interface 505 is also connected to the bus 504.
[0108] Typically, the following devices may be connected to the I / O interface 505: an input device 506 including, for example, a touch screen, a touchpad, a keyboard, a mouse, a camera, a microphone, an accelerometer, a gyroscope, etc.; an output device 507 including, for example, a liquid crystal display (LCD), a speaker, a vibrator, etc.; a storage device 508 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 509. The communication device 509 may allow the electronic device 500 to communicate with other devices wirelessly or by wire to exchange data. Although Figure 5The electronic device 500 is shown with various devices, but it should be understood that it is not required to implement or possess all of the devices shown. More or fewer devices may be implemented or possessed instead.
[0109] In particular, according to an embodiment of the present disclosure, the process described above with reference to the flowchart can be implemented as a computer software program. For example, an embodiment of the present disclosure includes a computer program product, which includes a computer program carried on a non-transitory computer-readable medium, and the computer program includes a program code for executing the method shown in the flowchart. In such an embodiment, the computer program can be downloaded and installed from the network through the communication device 509, or installed from the storage device 508, or installed from the ROM 502. When the computer program is executed by the processing device 501, the above-mentioned functions defined in the method of the embodiment of the present disclosure are performed.
[0110] It should be noted that the computer-readable medium mentioned above in the present disclosure may be a computer-readable signal medium or a computer-readable storage medium, or any combination of the two. A computer-readable storage medium may be, for example, but not limited to, an electrical, magnetic, optical, electromagnetic, infrared, or semiconductor system, device, or component, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: an electrical connection with one or more wires, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the above. In the present disclosure, a computer-readable storage medium may be any tangible medium that contains or stores a program that can be used by or in conjunction with an instruction execution system, device, or component. In the present disclosure, a computer-readable signal medium may include a data signal propagated in baseband or as part of a carrier wave, which carries computer-readable program code. Such a propagated data signal may take a variety of forms, including but not limited to electromagnetic signals, optical signals, or any suitable combination of the above. A computer-readable signal medium may also be any computer-readable medium other than a computer-readable storage medium that can transmit, propagate, or transport a program for use by or in conjunction with an instruction execution system, apparatus, or device. The program code contained on the computer-readable medium may be transmitted using any suitable medium, including but not limited to wires, optical cables, RF (radio frequency), etc., or any suitable combination thereof.
[0111] In some embodiments, the electronic devices can communicate using any currently known or future developed network protocol, such as HTTP (HyperText Transfer Protocol), and can be interconnected with any form or medium of digital data communication (e.g., a communication network). Examples of communication networks include a local area network ("LAN"), a wide area network ("WAN"), an internet (e.g., the Internet), and a peer-to-peer network (e.g., an ad hoc peer-to-peer network), as well as any currently known or future developed network.
[0112] The computer-readable medium may be included in the electronic device, or may exist independently without being incorporated into the electronic device.
[0113] The computer-readable medium carries one or more programs. When the one or more programs are executed by the electronic device, the electronic device: obtains the current process priority of the hosted application; adjusts the process priority of the target process of the host application corresponding to the hosted application to be consistent with the current process priority, and the target process is a process required for the host application to create a virtual operating environment for running the hosted application; wherein there is a dependency relationship between the process priority of the host application and the process priority of the target process, and the dependency relationship is used to make the process priority of the target process change in accordance with the change of the process priority of the host application.
[0114] Computer program code for performing the operations of the present disclosure may be written in one or more programming languages, or a combination thereof, including, but not limited to, object-oriented programming languages such as Java, Smalltalk, C++, and conventional procedural programming languages such as "C" or similar programming languages. The program code may be executed entirely on the user's computer, partially on the user's computer, as a stand-alone software package, partially on the user's computer and partially on a remote computer, or entirely on the remote computer or server. In cases involving a remote computer, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or may be connected to an external computer (e.g., through the Internet using an Internet service provider).
[0115] The flowcharts and block diagrams in the accompanying drawings illustrate the possible implementation architecture, functions and operations of the systems, methods and computer program products according to various embodiments of the present disclosure. In this regard, each box in the flowchart or block diagram can represent a module, program segment, or a part of code, and the module, program segment, or a part of code contains one or more executable instructions for realizing the specified logical function. It should also be noted that in some alternative implementations, the functions marked in the box can also occur in a different order than that marked in the accompanying drawings. For example, two boxes represented in succession can actually be executed substantially in parallel, and they can sometimes be executed in the opposite order, depending on the functions involved. It should also be noted that each box in the block diagram and / or flowchart, and the combination of the boxes in the block diagram and / or flowchart, can be implemented with a dedicated hardware-based system that performs the specified function or operation, or can be implemented with a combination of dedicated hardware and computer instructions.
[0116] The modules described in the embodiments of the present disclosure may be implemented in software or hardware, wherein the name of a module does not necessarily limit the module itself.
[0117] The functions described above herein may be performed, at least in part, by one or more hardware logic components. For example, and without limitation, exemplary types of hardware logic components that may be used include: field programmable gate arrays (FPGAs), application specific integrated circuits (ASICs), application specific standard products (ASSPs), systems on chip (SOCs), complex programmable logic devices (CPLDs), and the like.
[0118] In the context of the present disclosure, a machine-readable medium can be a tangible medium that can contain or store a program for use by or in conjunction with an instruction execution system, device or equipment. A machine-readable medium can be a machine-readable signal medium or a machine-readable storage medium. A machine-readable medium can include, but is not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, device or equipment, or any suitable combination of the foregoing. A more specific example of a machine-readable storage medium can include an electrical connection based on one or more lines, a portable computer disk, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or flash memory), an optical fiber, a portable compact disk read-only memory (CD-ROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing.
[0119] According to one or more embodiments of the present disclosure, Example 1 provides a data acquisition method, applied to a first terminal, the method including:
[0120] Obtaining a first call request for invoking the virtual GPU installed by the first terminal, where the first call request carries an identifier corresponding to the first function;
[0121] Processing the first call request through the first function to obtain a second call request, and sending the second call request to a second terminal through the first function, so that the second terminal calls a second function in a native function library of the physical GPU according to the second call request, and calls a physical GPU installed in the second terminal for processing according to the second function to obtain target data corresponding to the second call request, where the first function is a function in the function library of the first terminal with the same name as the second function;
[0122] Receive the target data returned by the second terminal.
[0123] According to one or more embodiments of the present disclosure, Example 2 provides the method of Example 1, wherein processing the first call request by the first function to obtain a second call request includes:
[0124] When the second call request includes a calculation subrequest for calling the physical GPU to perform calculations, obtaining, through the first function, an identifier corresponding to the first function, configuration information of the physical GPU, calculation parameters, and a target video memory address;
[0125] The computing sub-request is generated by the first function based on the identifier corresponding to the first function, the configuration information of the physical GPU, the computing parameters, and the target video memory address.
[0126] According to one or more embodiments of the present disclosure, Example 3 provides the method of Example 2, which obtains the target video memory address, including:
[0127] Obtaining an original video memory address of the first terminal used by the virtual GPU for calculation;
[0128] Based on the mapping relationship between the video memory address in the first terminal and the video memory address in the second terminal, a target video memory address in the second terminal corresponding to the original video memory address is determined.
[0129] According to one or more embodiments of the present disclosure, Example 4 provides the method of Example 3, wherein, when the second call request is a change sub-request for calling the physical GPU to change the video memory, the target data includes a first changed video memory address after the physical GPU changes the video memory. After obtaining the target data, the method further includes:
[0130] Obtaining a second changed video memory address after the virtual GPU changes the video memory, and the first changed video memory address;
[0131] The mapping relationship is updated based on the first changed video memory address and the second changed video memory address.
[0132] According to one or more embodiments of the present disclosure, Example 5 provides the method of Example 1, further comprising:
[0133] Obtaining an actual installation location of the function library of the first terminal;
[0134] The actual installation location is soft-connected to the general installation location of the native function library of the physical GPU on the first terminal.
[0135] According to one or more embodiments of the present disclosure, Example 6 provides the method of any one of Examples 1-5, wherein the data packet type corresponding to the second call request includes a control transmission data packet and a data transmission data packet, the data packet type corresponding to the target data includes a control transmission data packet and a data transmission data packet, and sending the second call request to the second terminal through the first function includes:
[0136] Sending a control transmission data packet corresponding to the second call request to the second terminal based on a remote call protocol through the first function; and / or
[0137] Sending the data transmission data packet corresponding to the second call request to the second terminal based on the remote direct data access network through the first function;
[0138] The receiving the target data returned by the second terminal includes:
[0139] Receive a control transmission data packet corresponding to the target data via a remote call protocol; and / or
[0140] A data transmission data packet corresponding to the target data is received through a remote direct data access network.
[0141] According to one or more embodiments of the present disclosure, Example 7 provides the method of Example 6, wherein the first function includes an MPI_Send function and an MPI_Recv function, and sending the data transmission packet corresponding to the second call request to the second terminal based on the remote direct data access network by the first function includes:
[0142] Calling the MPI_Send function to send the data transmission data packet corresponding to the second call request to the second terminal based on the remote direct data access network;
[0143] The receiving of a data transmission data packet corresponding to the target data through a remote direct data access network includes:
[0144] The MPI_Recv function is called to copy the data transmission data packet corresponding to the target data through the remote direct data access network.
[0145] According to one or more embodiments of the present disclosure, Example 8 provides a data acquisition device, applied to a first terminal, the device including:
[0146] A first call request obtaining module, configured to obtain a first call request for invoking the virtual GPU installed by the first terminal, wherein the first call request carries an identifier corresponding to the first function;
[0147] a second call request generating module, configured to process the first call request through the first function to obtain a second call request, and send the second call request to a second terminal through the first function, so that the second terminal calls a second function in a native function library of the physical GPU according to the second call request, and calls a physical GPU installed in the second terminal for processing according to the second function to obtain target data corresponding to the second call request, where the first function is a function in the function library of the first terminal with the same name as the second function;
[0148] The target data receiving module is configured to receive the target data returned by the second terminal.
[0149] According to one or more embodiments of the present disclosure, Example 9 provides the apparatus of Example 8, wherein the second call request generating module includes:
[0150] an acquisition submodule, configured to, when the second call request includes a calculation subrequest for calling the physical GPU to perform calculations, obtain, through the first function, an identifier corresponding to the first function, configuration information of the physical GPU, calculation parameters, and a target video memory address;
[0151] The computing sub-request generating sub-module is configured to generate the computing sub-request through the first function based on an identifier corresponding to the first function, configuration information of the physical GPU, the computing parameters, and the target video memory address.
[0152] According to one or more embodiments of the present disclosure, Example 10 provides the apparatus of Example 9, wherein the acquisition submodule is further used to obtain the original video memory address of the first terminal used by the virtual GPU for calculation; based on the mapping relationship between the video memory address in the first terminal and the video memory address in the second terminal, determine the target video memory address in the second terminal corresponding to the original video memory address.
[0153] According to one or more embodiments of the present disclosure, Example 11 provides the apparatus of Example 10, wherein, when the second call request is a change sub-request for calling the physical GPU to change the video memory, the target data includes a first changed video memory address after the physical GPU changes the video memory. In this case, the apparatus further includes:
[0154] a changed video memory address acquisition module, configured to acquire a second changed video memory address after the virtual GPU changes the video memory, and the first changed video memory address;
[0155] A mapping relationship updating module is configured to update the mapping relationship based on the first changed video memory address and the second changed video memory address.
[0156] According to one or more embodiments of the present disclosure, Example 12 provides the apparatus of Example 8, wherein the apparatus further includes:
[0157] an actual installation location acquisition module, configured to acquire the actual installation location of the function library of the first terminal;
[0158] The soft connection module is used to soft-connect the actual installation location to the general installation location of the native function library of the physical GPU on the first terminal.
[0159] According to one or more embodiments of the present disclosure, Example 13 provides the apparatus of any one of Examples 8-12, wherein the data packet types corresponding to the second call request include control transmission data packets and data transmission data packets, the data packet types corresponding to the target data include control transmission data packets and data transmission data packets, and the second call request generating module includes:
[0160] A first sending submodule, configured to send a control transmission data packet corresponding to the second call request to the second terminal based on a remote call protocol through the first function;
[0161] a second sending submodule, configured to send the data transmission data packet corresponding to the second call request to the second terminal based on a remote direct data access network through the first function;
[0162] The target data receiving module includes:
[0163] A first receiving submodule is configured to receive a control transmission data packet corresponding to the target data through a remote call protocol;
[0164] The second receiving submodule is configured to receive a data transmission data packet corresponding to the target data via a remote direct data access network.
[0165] According to one or more embodiments of the present disclosure, Example 14 provides the apparatus of Example 13, wherein the first function includes an MPI_Send function and an MPI_Recv function, and the second sending submodule is further configured to call the MPI_Send function to send a data transmission packet corresponding to the second call request to the second terminal over a remote direct data access network. The second receiving submodule is further configured to call the MPI_Recv function to copy the data transmission packet corresponding to the target data over the remote direct data access network.
[0166] According to one or more embodiments of the present disclosure, Example 15 provides a computer-readable medium having a computer program stored thereon, which implements the steps of any one of the methods described in Examples 1-7 when executed by a processing device.
[0167] According to one or more embodiments of the present disclosure, Example 16 provides an electronic device, including:
[0168] a storage device having a computer program stored thereon;
[0169] A processing device is used to execute the computer program in the storage device to implement the steps of the method described in any one of Examples 1-7.
[0170] The above description is merely a preferred embodiment of the present disclosure and an illustration of the technical principles employed. Those skilled in the art should understand that the scope of disclosure involved in the present disclosure is not limited to the technical solutions formed by the specific combination of the above-mentioned technical features, but also includes other technical solutions formed by any combination of the above-mentioned technical features or their equivalents without departing from the above-mentioned disclosed concepts. For example, a technical solution formed by replacing the above-mentioned features with (but not limited to) technical features with similar functions disclosed in this disclosure.
[0171] In addition, although each operation is described in a specific order, this should not be understood as requiring these operations to be performed in the specific order shown or in a sequential order. Under certain circumstances, multitasking and parallel processing may be advantageous. Similarly, although some specific implementation details have been included in the above discussion, these should not be interpreted as limiting the scope of the present disclosure. Some features described in the context of a separate embodiment can also be implemented in a single embodiment in combination. On the contrary, the various features described in the context of a single embodiment can also be implemented in multiple embodiments individually or in any suitable sub-combination mode.
[0172] Although the subject matter has been described using language specific to structural features and / or methodological logical acts, it should be understood that the subject matter defined in the appended claims is not necessarily limited to the specific features or acts described above. Rather, the specific features and acts described above are merely example forms of implementing the claims. Regarding the apparatus in the above-described embodiments, the specific manner in which each module performs operations has been described in detail in the embodiments related to the method and will not be elaborated upon here.
Claims
1. A data acquisition method, characterized in that: Applied to a first terminal, the method includes: Obtaining a first call request for invoking the virtual GPU installed by the first terminal, where the first call request carries an identifier corresponding to the first function; encapsulating the first call request through the first function to obtain a second call request, and sending the second call request to a second terminal through the first function, so that the second terminal calls a second function in a native function library of the physical GPU according to the second call request, and calls a physical GPU installed in the second terminal for processing according to the second function to obtain target data corresponding to the second call request, where the first function is a function in the function library of the first terminal with the same name as the second function; Receive the target data returned by the second terminal.
2. The data acquisition method according to claim 1, characterized in that: The encapsulating the first call request by the first function to obtain a second call request includes: When the second call request includes a calculation subrequest for calling the physical GPU to perform calculations, obtaining, through the first function, an identifier corresponding to the first function, configuration information of the physical GPU, calculation parameters, and a target video memory address; The computing sub-request is generated by the first function based on the identifier corresponding to the first function, the configuration information of the physical GPU, the computing parameters, and the target video memory address.
3. The data acquisition method according to claim 2, characterized in that: Obtaining the target video memory address includes: Obtaining an original video memory address of the first terminal used by the virtual GPU for calculation; Based on the mapping relationship between the video memory address in the first terminal and the video memory address in the second terminal, a target video memory address in the second terminal corresponding to the original video memory address is determined.
4. The data acquisition method according to claim 3, characterized in that: In a case where the second call request is a change sub-request for calling the physical GPU to change the video memory, the target data includes a first changed video memory address after the physical GPU changes the video memory. After obtaining the target data, the method further includes: Obtaining a second changed video memory address after the virtual GPU changes the video memory, and the first changed video memory address; The mapping relationship is updated based on the first changed video memory address and the second changed video memory address.
5. The data acquisition method according to claim 1, characterized in that: The method further comprises: Obtaining an actual installation location of the function library of the first terminal; The actual installation location is soft-connected to the general installation location of the native function library of the physical GPU on the first terminal.
6. The data acquisition method according to any one of claims 1 to 5, characterized in that: The data packet types corresponding to the second call request include control transmission data packets and data transmission data packets, the data packet types corresponding to the target data include control transmission data packets and data transmission data packets, and sending the second call request to the second terminal through the first function includes: Sending a control transmission data packet corresponding to the second call request to the second terminal based on a remote call protocol through the first function; and / or Sending the data transmission data packet corresponding to the second call request to the second terminal based on the remote direct data access network through the first function; The receiving the target data returned by the second terminal includes: Receive a control transmission data packet corresponding to the target data via a remote call protocol; and / or A data transmission data packet corresponding to the target data is received through a remote direct data access network.
7. The data acquisition method according to claim 6, characterized in that: The first function includes an MPI_Send function and an MPI_Recv function, and sending the data transmission data packet corresponding to the second call request to the second terminal based on the remote direct data access network through the first function includes: Calling the MPI_Send function to send the data transmission data packet corresponding to the second call request to the second terminal based on the remote direct data access network; The receiving of a data transmission data packet corresponding to the target data through a remote direct data access network includes: The MPI_Recv function is called to copy the data transmission data packet corresponding to the target data through the remote direct data access network.
8. A data acquisition device, characterized in that: Applied to a first terminal, the apparatus includes: A first call request obtaining module, configured to obtain a first call request for invoking the virtual GPU installed by the first terminal, wherein the first call request carries an identifier corresponding to the first function; a second call request generating module, configured to encapsulate the first call request through the first function to obtain a second call request, and send the second call request to a second terminal through the first function, so that the second terminal calls a second function in a native function library of the physical GPU according to the second call request, and calls a physical GPU installed on the second terminal for processing according to the second function to obtain target data corresponding to the second call request, where the first function is a function in the function library of the first terminal with the same name as the second function; The target data receiving module is configured to receive the target data returned by the second terminal.
9. A computer-readable medium having a computer program stored thereon, characterized in that: When the program is executed by a processing device, the steps of the method according to any one of claims 1 to 7 are implemented.
10. An electronic device, characterized in that: include: a storage device having at least one computer program stored thereon; At least one processing device, configured to execute the at least one computer program in the storage device to implement the steps of the method according to any one of claims 1 to 7.
Citation Information
Patent Citations
Program debugging method and device
CN111400172A