GPU-based user container processing method, device, equipment and medium

By automatically allocating GPU resources in secure containers, it solves the problem of low efficiency and high cost of manual configuration of GPU resources by users, and achieves efficient and accurate GPU resource configuration and use.

CN118426912BActive Publication Date: 2024-09-03ALIBABA CLOUD COMPUTING CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202410888850.3
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2024-07-04
Publication Date
2024-09-03
Estimated Expiration
2044-07-04

AI Technical Summary

Technical Problem

When using a machine learning platform, users need to manually configure GPU resources, resulting in low efficiency and accuracy and high labor costs.

Method used

By automatically allocating GPU resources in secure containers, creating GPU nodes and mounting the GPU user-mode driver library, the GPU is directly connected to the user container, and GPU resources are automatically configured to reduce manual participation.

Benefits of technology

It improves the efficiency and accuracy of GPU resource configuration, reduces labor costs and requirements for tenants' professional level, and realizes automated GPU usage.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN118426912B
    Figure CN118426912B
Patent Text Reader

Abstract

The embodiment of the present application provides a GPU-based user container processing method, device, equipment and medium, which relates to the field of data processing. The method includes: first, according to the task to be executed using the GPU, the GPU is assigned to the secure container in a direct manner. Afterwards, according to the task to be executed, a GPU node corresponding to the GPU is created in the secure container, and the GPU node and the GPU user-mode driver library are mounted to the target user container corresponding to the task to be executed. Finally, the task to be executed is executed in the target user container through the GPU node and the GPU user-mode driver library mounted in the target user container, and an execution result is generated. Among them, the secure container is used to run the user container, and the secure container runs on the host machine corresponding to the GPU. In this technical solution, the efficiency and accuracy of the configuration process are improved, and the labor cost and the requirements for the professional level of the tenant are effectively reduced.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application relates to the field of computer technology, and in particular to a GPU-based user container processing method, device, equipment, and medium. Background Art

[0002] At present, the calculation of machine learning or deep learning algorithms is mainly based on the computing power provided by the Graphics Processing Unit (GPU). The machine learning platform provided by cloud vendors provides users with a set of data storage, data cleaning, model development and deployment services based on GPU computing clusters.

[0003] However, when users use the services of the machine learning platform, they need to manually configure the relevant GPU resources, which has low efficiency and accuracy and high labor costs. Summary of the invention

[0004] Multiple aspects of the present application provide a GPU-based user container processing method, device, equipment and medium to solve the problems of low efficiency and accuracy and high labor cost in the manual configuration process.

[0005] In a first aspect, an embodiment of the present application provides a GPU-based user container processing method, including:

[0006] According to the tasks to be executed using the GPU as needed, the GPU is directly allocated to the secure container, the secure container is used to run the user container, and the secure container runs on the host machine corresponding to the GPU;

[0007] According to the task to be executed, create a GPU node corresponding to the GPU in the secure container;

[0008] Mounting the GPU node and the GPU user-mode driver library to the target user container corresponding to the task to be executed;

[0009] The task to be executed is executed in the target user container through the GPU node and the GPU user-mode driver library mounted in the target user container, and an execution result is generated.

[0010] In a possible implementation, creating a GPU node corresponding to the GPU in the secure container according to the task to be executed includes:

[0011] Determining a target kernel state driver of the GPU according to the task to be executed;

[0012] Loading the target kernel-mode driver into the virtual machine kernel of the secure container;

[0013] According to the target kernel-mode driver, the GPU node is created in the secure container.

[0014] In a possible implementation, determining a target kernel-mode driver of the GPU according to the task to be executed includes:

[0015] Determine the identifier and version number of the target kernel-mode driver carried in the task to be executed;

[0016] According to the identifier and the version number, a target kernel-mode driver corresponding to the identifier and the version number is obtained from a kernel-mode driver library.

[0017] In a possible implementation, the GPU user-state driver library includes a GPU query program, a dynamic library, and a soft link of the dynamic library, and the GPU node and the GPU user-state driver library mounted in the target user container are used to execute the task to be executed in the target user container to generate an execution result, including:

[0018] In the target user container, updating the soft link of the dynamic library to obtain the updated soft link;

[0019] Check the usage of the GPU through the GPU query program;

[0020] When it is determined according to the usage that the GPU is capable of executing the task to be executed, the GPU is called to execute the task to be executed through the GPU node, the dynamic library, the updated soft link, and the target kernel-mode driver to generate the execution result.

[0021] In a possible implementation, the method further includes:

[0022] According to the task to be executed, a user container corresponding to the task to be executed is created in the security container.

[0023] In a possible implementation, after executing the task to be executed in the target user container through the GPU node and the GPU user mode driver library mounted in the target user container and generating an execution result, the method further includes:

[0024] Uninstalling the GPU node and the GPU user-mode driver library mounted in the target user container;

[0025] Destroy the target user container.

[0026] In a possible implementation, after executing the task to be executed in the target user container through the GPU node and the GPU user mode driver library mounted in the target user container and generating an execution result, the method further includes:

[0027] Deleting the GPU node in the secure container;

[0028] Uninstalling the target kernel-mode driver in the virtual machine kernel;

[0029] Unbind the GPU from the secure container.

[0030] In a second aspect, an embodiment of the present application provides a GPU-based user container processing method, which is applied to a host machine, including:

[0031] According to a task execution request sent by a terminal device used by the tenant, a GPU required for the task execution request is directly allocated to a secure container, where the secure container is used to run a user container and the secure container runs on the host machine;

[0032] According to the task execution request, loading the target kernel state driver corresponding to the GPU into the virtual machine kernel of the secure container;

[0033] According to the target kernel state driver, a GPU user state driver library and a GPU node corresponding to the target kernel state driver are mounted to a target user container corresponding to the task execution request;

[0034] Execute the task execution request in the target user container through the GPU node and the GPU user mode driver library mounted in the target user container to generate an execution result;

[0035] The execution result is sent to the terminal device.

[0036] In a third aspect, an embodiment of the present application provides a GPU-based user container processing device, including:

[0037] An allocation module, used to allocate the GPU to a secure container in a direct manner according to the needs of using the tasks to be executed by the GPU, where the secure container is used to run the user container, and the secure container runs on a host machine corresponding to the GPU;

[0038] A creation module, used to create a GPU node corresponding to the GPU in the secure container according to the task to be executed;

[0039] A mounting module, used to mount the GPU node and the GPU user-mode driver library to the target user container corresponding to the task to be executed;

[0040] An execution module is used to execute the task to be executed in the target user container through the GPU node and the GPU user-mode driver library mounted in the target user container, and generate an execution result.

[0041] In a possible implementation, the creation module is specifically used to:

[0042] Determining a target kernel state driver of the GPU according to the task to be executed;

[0043] Loading the target kernel-mode driver into the virtual machine kernel of the secure container;

[0044] According to the target kernel-mode driver, the GPU node is created in the secure container.

[0045] In a possible implementation, the creation module is specifically used to:

[0046] Determine the identifier and version number of the target kernel-mode driver carried in the task to be executed;

[0047] According to the identifier and the version number, a target kernel-mode driver corresponding to the identifier and the version number is obtained from a kernel-mode driver library.

[0048] In a possible implementation, the creation module is specifically used to:

[0049] In the target user container, updating the soft link of the dynamic library to obtain the updated soft link;

[0050] Check the usage of the GPU through the GPU query program;

[0051] When it is determined according to the usage that the GPU is capable of executing the task to be executed, the GPU is called to execute the task to be executed through the GPU node, the dynamic library, the updated soft link, and the target kernel-mode driver to generate the execution result.

[0052] In a possible implementation, the creation module is further used to:

[0053] According to the task to be executed, a user container corresponding to the task to be executed is created in the security container.

[0054] In a possible implementation, after executing the task to be executed in the target user container through the GPU node and the GPU user mode driver library mounted in the target user container and generating an execution result, the GPU-based user container processing device further includes:

[0055] An uninstallation module, used to uninstall the GPU node and the GPU user-mode driver library mounted in the target user container;

[0056] A destroying module is used to destroy the user container.

[0057] In a possible implementation, after executing the task to be executed in the target user container through the GPU node and the GPU user mode driver library mounted in the target user container and generating an execution result, the GPU-based user container processing device further includes:

[0058] A deletion module, used to delete the GPU node in the secure container;

[0059] The uninstall module is further used to uninstall the target kernel-mode driver in the virtual machine kernel;

[0060] An unbinding module is used to unbind the GPU of the secure container.

[0061] In a fourth aspect, an embodiment of the present application provides a GPU-based user container processing device, which is applied to a host machine, and the device includes:

[0062] A receiving module, configured to allocate a GPU required for a task execution request in a direct manner to a secure container according to a task execution request sent by a terminal device used by a tenant, wherein the secure container is used to run a user container and the secure container runs on the host machine;

[0063] A loading module, used to load the target kernel state driver corresponding to the GPU into the virtual machine kernel of the secure container according to the task execution request;

[0064] A mounting module, used for mounting a GPU user state driver library and a GPU node corresponding to the target kernel state driver to a target user container corresponding to the task execution request according to the target kernel state driver;

[0065] An execution module, configured to execute the task execution request in the target user container through the GPU node and the GPU user state driver library mounted in the target user container, and generate an execution result;

[0066] A sending module is used to send the execution result to the terminal device.

[0067] In a fifth aspect, an embodiment of the present application provides an electronic device, including: a memory and a processor;

[0068] The memory stores computer-executable instructions;

[0069] The processor executes the computer-executable instructions stored in the memory, so that the processor performs the methods shown in the first aspect, the second aspect and various possible implementations.

[0070] In a sixth aspect, an embodiment of the present application provides a computer-readable storage medium, in which computer execution instructions are stored. When the computer execution instructions are executed by a processor, they are used to implement the methods shown in the first aspect, the second aspect and various possible implementations.

[0071] In a seventh aspect, an embodiment of the present application provides a computer program product, including a computer program, which, when executed by a processor, is used to implement the methods shown in the first aspect, the second aspect, and various possible implementations.

[0072] The GPU-based user container processing method, device, equipment and medium provided in the embodiment of the present application include: first, according to the task to be executed using the GPU as needed, the GPU is allocated to the secure container in a direct manner. Afterwards, according to the task to be executed, a GPU node corresponding to the GPU is created in the secure container, and the GPU node and the GPU user state driver library are mounted to the target user container corresponding to the task to be executed. Finally, the task to be executed is executed in the target user container through the GPU node and the GPU user state driver library mounted in the target user container, and the execution result is generated. Among them, the secure container is used to run the user container, and the secure container runs on the host machine corresponding to the GPU. The technical solution provides a solution for automatically using the GPU in the secure container scenario based on GPU direct pass. After the GPU is directly passed to the secure container, a GPU node can be automatically created in the secure container, and the GPU node and the GPU user state driver library can be mounted to the target user container to achieve the purpose of automatically configuring GPU resources for the target user container, so that the GPU can be automatically used inside the secure container. The whole process does not require manual participation, which improves the efficiency and accuracy of the configuration process, and effectively reduces the labor cost and the requirements for the professional level of the tenant. BRIEF DESCRIPTION OF THE DRAWINGS

[0073] The drawings described herein are used to provide a further understanding of the present application and constitute a part of the present application. The illustrative embodiments of the present application and their descriptions are used to explain the present application and do not constitute an improper limitation on the present application. In the drawings:

[0074] Figure 1 A schematic diagram of a scenario of a GPU-based user container processing method provided in an embodiment of the present application;

[0075] Figure 2 A flowchart of a first embodiment of a method for processing a user container based on a GPU provided in an embodiment of the present application;

[0076] Figure 3 A flowchart of a second embodiment of a GPU-based user container processing method provided in an embodiment of the present application;

[0077] Figure 4 A flowchart of a third embodiment of a method for processing a user container based on a GPU provided in an embodiment of the present application;

[0078] Figure 5 A flowchart of a fourth embodiment of a method for processing a user container based on a GPU provided in an embodiment of the present application;

[0079] Figure 6 A flowchart of a fifth embodiment of a method for processing a user container based on a GPU provided in an embodiment of the present application;

[0080] Figure 7 A schematic diagram of the structure of a first embodiment of a GPU-based user container processing device provided in an embodiment of the present application;

[0081] Figure 8 A schematic diagram of the structure of a second embodiment of a GPU-based user container processing device provided in an embodiment of the present application;

[0082] Fig. 9 A schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0083] In order to make the purpose, technical solutions and advantages of the present application clearer, the technical solutions of the present application will be clearly and completely described below in combination with the specific embodiments of the present application and the corresponding drawings. Obviously, the described embodiments are only part of the embodiments of the present application, not all of them. Based on the embodiments in the present application, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of this application. The user information (including but not limited to user device information, user personal information, etc.) and data (including but not limited to data for analysis, stored data, displayed data, etc.) involved in this application are all information and data authorized by the user or fully authorized by all parties, and the collection, use and processing of relevant data need to comply with relevant laws, regulations and standards, and provide corresponding operation entrances for users to choose to authorize or refuse.

[0084] First, the terms involved in the embodiments of the present application are explained:

[0085] Host: A physical server that provides computing resources, storage, and network connections, and runs virtualization software to support a virtualized environment. Suppose there is a cloud vendor that provides virtual private server (VPS) services. In this case, the host refers to the physical server that the cloud vendor uses to host tenant VPS instances. These hosts use virtualization software (such as Kernel-based Virtual Machine (KVM)) to divide physical resources into multiple virtual machines. Each virtual machine is a VPS instance, and they share the computing resources of the host.

[0086] Secure container: A lightweight virtual machine that runs a user container, providing an independent unit that includes the operating environment and required applications, allowing applications to be packaged, distributed, and deployed in a unified environment and run effectively in the user container, thereby simplifying the software development, deployment, and operation and maintenance process.

[0087] User container: A container that runs user business, which usually contains the applications, dependencies, and configurations required by the user, and provides the advantages of isolation, portability, and scalability.

[0088] Graphics Processing Unit (GPU): A processor specifically designed to process graphics and image data. It was originally designed to accelerate computer graphics rendering, but is now also widely used in scientific computing, artificial intelligence, deep learning and other fields. Compared with the traditional central processing unit (CPU), GPU has a large number of cores and high parallel computing capabilities, which can process large-scale data and perform a large number of computing tasks at the same time. This makes GPU perform well when processing workloads that require large amounts of data parallel computing. For example, in deep learning, the parallel computing capabilities of GPU can speed up the training of neural network models.

[0089] RunC: A container runtime tool responsible for managing and executing the lifecycle of containers. It implements the Open Container Initiative (OCI) specification, which is an open standard for container runtimes and image formats, which means that containers created by RunC can interoperate with other container tools that follow the OCI standard. RunC provides a set of command-line tools for creating, starting, stopping, and destroying containers, as well as managing various runtime parameters of containers. It interacts with the Linux kernel interface and uses Linux namespaces, control groups (cgroups), and other features to achieve container isolation and resource restrictions.

[0090] Next, the scenarios involved in the embodiments of the present application are introduced:

[0091] Current machine learning and deep learning algorithms obtain an initial model by modeling the research problem, and train the initial model based on a large amount of training data, thereby learning the training parameters and generating a trained model. In practical applications, data can be predicted and analyzed based on the trained model to obtain the processing results output by the trained model. In the above process, the entire model training and application process is mainly based on the computing power provided by the GPU card.

[0092] In the field of cloud computing, major cloud vendors have launched machine learning platforms based on GPU computing clusters, which provide tenants with the necessary services, such as data storage, data cleaning, model development and deployment, etc. Through these machine learning platforms, tenants can efficiently perform data preprocessing and feature engineering, optimize model structure and conduct training, and ultimately achieve accurate prediction and in-depth analysis of data.

[0093] In addition, machine learning platforms also provide tenants with flexible resource configuration and management functions, which can dynamically adjust the allocation of computing resources according to demand to meet the needs of tasks of different scales and complexities. At the same time, machine learning platforms usually also provide a rich algorithm library and development tools to help tenants quickly build and deploy various machine learning models and accelerate the launch and implementation of projects.

[0094] In cloud computing, a physical machine is usually shared by multiple tenants. If a task or container of one tenant launches a malicious attack on the host kernel, it may affect the normal operation of other tenants' tasks, causing security issues and resource competition.

[0095] To solve this problem, cloud vendors usually use virtualization technology, such as virtual machines, to isolate different tenants. Each tenant's tasks or containers can run inside their own virtual machines, which are isolated from each other and do not share kernel and host resources. This approach provides stronger security, thereby meeting the strong isolation requirements of multi-tenancy and ensuring that problems with one tenant will not have a negative impact on other tenants. RunC containers usually run inside virtual machines to achieve lighter application deployment. RunC containers isolate multiple tasks based on cgroups, and multiple RunC containers share the host machine's kernel.

[0096] Among them, the secure container is a streamlined virtual machine, in which the user container runs. The RunC container has the nvidia-docker component to meet the user's use of the GPU. However, before using the user container, the user container needs to be configured, and the configuration process needs to be implemented by the tenants themselves, which has high requirements on the tenants' operation level. In addition, since the manual processing process also takes a lot of time and cannot guarantee the accuracy of the processing, there are problems such as low efficiency and accuracy, and high labor costs.

[0097] Based on the above technical problems, the technical concept of this application is: because the existing technology cannot guarantee the rigor of manual processing, the efficiency and accuracy of the existing technology are low. Based on this, this application provides a GPU-based user container processing method. After the GPU is directly connected to the secure container, it can automatically load the kernel state driver, create a GPU node, mount the GPU node to the user container, and mount the user state driver library to the user container, so as to achieve the purpose of automatically using the GPU inside the virtual machine without manual participation, effectively improve the efficiency and accuracy of the processing, and reduce labor costs.

[0098] Figure 1 A schematic diagram of a scenario of a GPU-based user container processing method provided in an embodiment of the present application. Figure 1 As shown, the scenario includes a terminal device 11 and a machine learning platform 12. The machine learning platform 12 includes multiple host machines, such as Figure 1 In the host machines 121, 122, and 123, a secure container runs in each host machine, which is used to run a user container, and the user container is used to process task execution requests sent by the tenant through the terminal device 11.

[0099] Optionally, each host machine in the machine learning platform 12 can communicate with the terminal device 11 via wired or wireless means.

[0100] In actual applications, when a tenant needs to use the machine learning platform 12 to perform tasks that require GPU-based tasks such as model training or model application, the tenant can send a task execution request to the machine learning platform 12 through the terminal device 11. After receiving the task execution request sent by the terminal device 11, the machine learning platform 12 can allocate a host machine for the task execution request to process it.

[0101] It should be understood that the machine learning platform 12 can assign the task execution request to any host machine in an idle state, can assign the task execution request to a host machine pre-configured for the terminal device 11, and can also assign it to a host machine pre-configured for the type of the task execution request. The specific allocation method can be determined based on actual conditions, and the embodiments of the present application do not impose specific restrictions on this.

[0102] Figure 1 Taking the machine learning platform 12 assigning a task execution request to the host machine 122 as an example for explanation, the host machine 122 creates a user container corresponding to the task execution request in the secure container according to the task execution request to process the task execution request, and automatically loads the kernel state driver in the secure container, creates a GPU node, and mounts the GPU node and the user state driver library to the user container, so that the user container can process the task execution request through the GPU of the host machine 122.

[0103] Furthermore, after the user container completes processing the task execution request, an execution result is generated, and the host machine 122 sends the execution result to the terminal device 11 for the tenant to review and further process.

[0104] It should be understood that the specific processing process of the host machine 122 will be specifically explained in the following embodiments and will not be repeated here.

[0105] It should be understood that in actual applications, the number of user containers running in the secure container can be determined based on actual conditions. Figure 1 Only one example is used for explanation and description, and the embodiments of the present application do not impose any specific limitation on this.

[0106] The technical solution shown in the present application is described in detail below through specific embodiments. It should be noted that the following embodiments can exist independently or in combination with each other, and the same or similar contents will not be described repeatedly in different embodiments.

[0107] Figure 2 This is a flow chart of the first embodiment of the GPU-based user container processing method provided in the present application. Figure 2 As shown, the GPU-based user container processing method can be implemented by the following steps:

[0108] S21. As required, the GPU is allocated to the secure container in a direct manner according to the tasks to be executed using the GPU.

[0109] The execution subject of the embodiment of the present application is an electronic device, which can be a terminal device, such as a laptop computer, a desktop computer, a tablet computer, etc., or a server, such as Figure 1The host machine of the machine learning platform 12 in the embodiment. In practical applications, whether the electronic device is a terminal device or a server can be determined according to actual conditions, and the embodiment of the present application does not impose specific restrictions on this.

[0110] In this embodiment, in order to prevent different tasks from interfering with each other or grabbing resources, it is necessary to provide a complete virtualized environment for task execution through a secure container, and to isolate different tasks through user containers running in the secure container. Since the task to be executed requires the use of GPU computing power, before processing the task to be executed, it is necessary to configure the secure container and the user container so that the user container can call GPU resources.

[0111] In this step, the task to be executed can be a task generated by the electronic device itself, or a task obtained from other devices, and there is no specific limitation on this. Since the GPU needs to be accessed when executing the task to be executed, the GPU needs to be allocated to the secure container in a direct manner.

[0112] It should be understood that the secure container is used to run the user container. The secure container runs on the host machine corresponding to the GPU. The relationship between the secure container, user container and host machine can be referred to in Figure 1 The embodiments shown will not be described in detail here.

[0113] Optionally, the task to be executed may carry a GPU identifier, and the GPU corresponding to the GPU identifier is directly assigned to the secure container. The electronic device may also determine the corresponding GPU according to the type of the task to be executed, and assign the GPU to the secure container in a direct manner.

[0114] In a possible implementation, the GPU can be bound to a vfio-pci driver and then assigned to a secure container in a direct manner. Specifically, the GPU can be bound to the vfio-pci driver by first loading the vfio-pci module, then determining the peripheral component interconnect (PCI) address of the GPU, and finally writing the PCI address of the GPU into the device binding file of the vfio-pci driver to bind it to the vfio-pci driver.

[0115] By first binding the GPU to the vfio-pci driver and then passing it directly to the secure container, the vfio-pci driver can correctly manage the GPU status and reset operations, provide direct access to the GPU, and prevent untrusted code from making unauthorized access to the GPU, effectively improving the GPU security, stability, and performance.

[0116] Exemplarily, the tasks to be performed that require the use of a GPU usually involve work that requires large-scale computing, parallel processing, and graphics rendering, such as scientific computing, machine learning and deep learning, data analysis and big data processing, and image and video processing. For example, for scientific computing, the tasks to be performed may be astronomy simulation tasks, climate simulation tasks, quantum chemistry calculation tasks, etc.; for machine learning and deep learning, the tasks to be performed may be model training tasks and model reasoning tasks; for data analysis and big data processing, the tasks to be performed may be image processing tasks, signal processing tasks, matrix operation tasks, etc.; for image and video processing, the tasks to be performed may be video editing tasks, special effects processing tasks, game scene rendering tasks, etc.

[0117] Optionally, since the user container will occupy system resources during operation, and in order to ensure that the environment for each task operation is consistent, the user container needs to be destroyed after each task is completed, and a new user container is created when the next task needs to be executed. In other words, a user container corresponding to the task to be executed can also be created in the security container according to the task to be executed, so that the task to be executed can be processed later through the user container.

[0118] For example, you can create a user container through Kata Containers. Specifically, first configure the container management system (such as Docker or Kubernetes) to use Kata Containers as the runtime, and then use the command line tool of the container management system to create the user container. Furthermore, after creating the user container, you can also verify whether the user container is running with Kata Containers by viewing the log or entering the shell (English full name: Shell Command Language) of the user container.

[0119] S22. Create a GPU node corresponding to the GPU in the secure container according to the task to be executed.

[0120] In this step, since the user container usually runs in the isolated environment of the secure container, it can only access the resources provided by the secure container in which it is located. The GPU is directly connected to the secure container and is not exposed to the user container. Therefore, if the user container wants to use the GPU later, it is necessary to create a GPU node corresponding to the GPU in the secure container and mount the GPU node to the user container so that the user container can call GPU resources through the GPU node. Therefore, it is necessary to first create a GPU node corresponding to the GPU in the secure container.

[0121] It should be understood that at this point the secure container has been assigned a GPU.

[0122] In one possible implementation, the target kernel-state driver corresponding to the GPU can be first loaded into the virtual machine kernel of the secure container, and a GPU node corresponding to the GPU can be created in the secure container according to the target kernel-state driver.

[0123] It should be understood that the specific implementation process and principle of this step will be Figure 3 The detailed description is given in the illustrated embodiment and will not be repeated here.

[0124] S23. Mount the GPU node and the GPU user-mode driver library to the target user container corresponding to the task to be executed.

[0125] In this step, since the GPU user-state driver library is the interface between the user container and the GPU, and manages the allocation and release of GPU resources, the application in the user container sends the task to be executed to the GPU through the GPU user-state driver library. Therefore, it is necessary to mount the GPU node and the GPU user-state driver library to the user container corresponding to the task to be executed, so that the task to be executed can be executed later through the GPU node and the GPU user-state driver library.

[0126] In one possible implementation, the GPU node file and the soft link of the dynamic library in the GPU user-mode driver library can be determined first, and then the GPU node file is mounted to the first instruction directory of the user container, and the soft link of the dynamic library is mounted to the second instruction directory of the user container, and the relevant parameters are configured so that the user container can call the GPU node and the GPU user-mode driver library.

[0127] In another possible implementation, the GPU node and the GPU user mode driver library may be mounted through nvidia-docker.

[0128] Compared with directly copying the GPU user-state driver library to the user container, the resource sharing between the target user container and the secure container can be achieved through mounting, ensuring that the GPU resources in the secure container and the target user container are consistent, avoiding version mismatches or compatibility issues. Furthermore, if the GPU user-state driver library is subsequently updated or changed, only the GPU user-state driver library on the secure container needs to be updated, without modifying the content in the target user container, reducing maintenance costs and complexity. Finally, since the copying process takes a lot of time and requires additional storage space in the user container, mounting can effectively improve processing efficiency and save disk space.

[0129] S24. Execute the task to be executed in the target user container through the GPU node and GPU user-mode driver library mounted in the target user container to generate an execution result.

[0130] In this step, after the target user container has mounted the GPU node and the GPU user-mode driver library, it can directly access the GPU resources. Therefore, the GPU node and the GPU user-mode driver library in the target user container can be used to execute the task to be executed in the target user container using the GPU to obtain the execution result.

[0131] In a possible implementation, the GPU user-mode driver library includes a GPU query program, a dynamic library, and a soft link of the dynamic library. The soft link of the dynamic library can be updated in the target user container to obtain the updated soft link. Afterwards, the GPU query program is used to check the usage of the GPU. When it is determined that the GPU can execute the task to be executed based on the usage, the GPU is called to execute the task to be executed through the GPU node, the dynamic library, the updated soft link, and the target kernel-mode driver to generate an execution result.

[0132] Optionally, the GPU query program may be a binary program in a GPU user-mode driver library.

[0133] Optionally, GPU usage generally refers to GPU load, including GPU utilization, temperature, power consumption, memory usage, fan speed, and other indicators. In actual applications, it can be determined whether various indicators of the GPU meet expectations based on the GPU usage, such as whether the GPU utilization is less than 80%, to determine whether the GPU can execute the task to be executed.

[0134] In one possible implementation, calling the GPU to execute the task to be executed can be achieved through the following steps through the GPU node, dynamic library, updated soft link, and target kernel state driver: when it is determined that the GPU is able to execute the task to be executed, executing the GPU computing task execution program, calling the updated soft link through the GPU computing task execution program, thereby calling the dynamic library, and calling the GPU node to operate the target kernel state driver through the dynamic library, so that the GPU executes the task to be executed.

[0135] In another possible implementation, calling the GPU to execute the task to be executed can be implemented through the following steps through the GPU node, dynamic library, updated soft link, and target kernel-state driver: when it is determined that the GPU can execute the task to be executed, execute the GPU computing task execution program, find and call the dynamic library through the updated soft link, and call the GPU node according to the application programming interface (Application Programming Interface, API) contained in the dynamic library that can interact with the GPU. The API will handle operations such as memory allocation, data transmission, and instruction sending to ensure that the task to be executed can be correctly sent to the GPU. In the process of interacting with the GPU node, the dynamic library will communicate with the target kernel-state driver through a system call. After receiving the instruction from the dynamic library, the target kernel-state driver configures the GPU to start executing the task to be executed. After the GPU completes the task to be executed, it will return the execution result to the dynamic library.

[0136] The GPU-based user container processing method provided in the embodiment of the present application first uses the tasks to be executed by the GPU as needed, and assigns the GPU to the secure container in a direct manner. Afterwards, according to the tasks to be executed, a GPU node corresponding to the GPU is created in the secure container, and the GPU node and the GPU user state driver library are mounted to the target user container corresponding to the tasks to be executed. Finally, the tasks to be executed are executed in the target user container through the GPU node and the GPU user state driver library mounted in the target user container, and the execution result is generated. Among them, the secure container is used to run the user container, and the secure container runs on the host machine corresponding to the GPU. The technical solution provides a solution for automatically using the GPU in the secure container scenario based on GPU direct pass. After the GPU is directly passed to the secure container, a GPU node can be automatically created in the secure container, and the GPU node and the GPU user state driver library can be mounted to the target user container to achieve the purpose of automatically configuring GPU resources for the target user container, so that the GPU can be automatically used inside the secure container. The whole process does not require manual participation, which improves the efficiency and accuracy of the configuration process, and effectively reduces the labor cost and the requirements for the professional level of the tenant.

[0137] based on Figure 2 The embodiment shown, the implementation process of S22 is explained below through a specific embodiment.

[0138] Figure 3 The flowchart of the second embodiment of the GPU-based user container processing method provided in the embodiment of the present application is as follows. Figure 3 As shown, S22 can be implemented by the following steps:

[0139] S31. Determine the target kernel-mode driver of the GPU according to the task to be executed.

[0140] In this step, the task to be executed carries the identification of the target kernel-state driver, and the corresponding target kernel-state driver can be determined according to the identification of the target kernel-state driver.

[0141] In actual applications, since each GPU has its own special design and functions, it is used to handle specific types of tasks. For example, some GPUs may be more suitable for graphics processing (such as game rendering, video editing, etc.), while other GPUs are more suitable for computing-intensive tasks (such as deep learning, scientific computing, etc.). Therefore, in order to improve processing efficiency, when a tenant needs to perform operations based on the GPU of an electronic device, the electronic device can determine the corresponding multiple GPUs according to the type of task to be performed, and then determine the identification of the kernel-state driver corresponding to each GPU, and display it through the display of the terminal device used by the tenant, so that the user can determine the identification of the target kernel-state driver from it.

[0142] Optionally, after determining the identifier of the kernel-state driver corresponding to each GPU, the electronic device can directly select one from the identifiers of the kernel-state drivers corresponding to the multiple GPUs as the identifier of the target kernel-state driver. Exemplarily, the identifier of the kernel-state driver of the GPU with the lowest utilization rate can be determined as the identifier of the target kernel-state driver, the identifier of the kernel-state driver of the GPU with the highest priority can be determined as the identifier of the target kernel-state driver, or one can be randomly selected from the identifiers of the kernel-state drivers of the GPUs as the identifier of the target kernel-state driver, or a default GPU can be pre-configured for different types of tasks, and the identifier of the kernel-state driver of the default GPU corresponding to the type can be determined as the identifier of the target kernel-state driver.

[0143] In a possible implementation, the identification and version number of the target kernel-mode driver carried in the task to be executed may be determined, and then, based on the identification and version number, the target kernel-mode driver corresponding to the identification and version number is obtained from the kernel-mode driver library.

[0144] For example, assuming that a tenant uses the GPU of an electronic device to perform an inference job for generating an image through his own terminal device, the electronic device will determine the multiple GPUs corresponding to the inference job for generating the image, as well as the multiple versions corresponding to each GPU, and display them through the tenant's terminal device, so that the user can determine the identification and version number of the target kernel-state driver according to his own production job computing framework.

[0145] Exemplarily, gpu-prestart-hook may be called to identify the identifier and version number of the target kernel-mode driver specified in the task to be executed.

[0146] Optionally, in addition to being determined by the user, the electronic device can also determine the target kernel mode driver's identification and version number by itself. For example, the target GPU identification and version can be determined by usage, priority, default, etc., or randomly determined.

[0147] S32. Load the target kernel-state driver into the virtual machine kernel of the secure container.

[0148] In this step, the target kernel state driver plays a key role in the operating system, responsible for communicating with the GPU and providing corresponding functional and performance support. Therefore, in order for the secure container and the user container running in the secure container to use GPU resources, it is necessary to ensure that the GPU is correctly identified and initialized, so the target kernel state driver also needs to be loaded into the virtual machine kernel of the secure container.

[0149] S33. Create a GPU node in the secure container according to the target kernel state driver.

[0150] In this step, after the target kernel-state driver is loaded into the virtual machine kernel of the secure container, a GPU node can be created based on the target kernel-state driver so that the GPU can be accessed through the target kernel-state driver based on the GPU node later.

[0151] In a possible implementation, it is possible to first detect whether the GPU has been correctly identified and initialized by the secure container. If it has been identified and initialized, a GPU node is created in the secure container; if it has not been identified / initialized, the target kernel state driver is reloaded into the virtual machine kernel of the secure container.

[0152] Optionally, you can use the mknod command to create a GPU node corresponding to the GPU.

[0153] Optionally, after creating a GPU node in the secure container, it is also possible to verify whether the GPU node is successfully associated with the GPU and can communicate with the GPU. If it cannot communicate with the GPU, the GPU node is destroyed and a new GPU node is created in the secure container.

[0154] In an embodiment of the present application, first, the target kernel state driver of the GPU is determined according to the task to be executed. After that, the target kernel state driver is loaded into the virtual machine kernel of the secure container. Finally, a GPU node is created in the secure container according to the target kernel state driver. In this technical solution, the electronic device can recommend optional kernel state drivers to tenants based on the type of task to be executed, so that the tenant can determine the target kernel state driver from it according to the actual situation. In the prior art, tenants need to judge the target kernel state driver corresponding to the GPU by themselves and download the target kernel state driver from the official website. In comparison, the manual processing process is time-consuming and labor-intensive, and the accuracy and rigor of the processing cannot be guaranteed. The technical solution can actively provide tenants with optional kernel state drivers, and tenants only need to determine them. The manual participation part is less, which greatly improves the accuracy and efficiency of the configuration process and reduces the operating threshold of tenants.

[0155] Based on any of the above embodiments, since the user container will occupy system resources during operation, and in order to ensure that the environment for each task operation is consistent, the user container needs to be destroyed after each task is completed. Specifically, after the execution result is generated, the GPU node and GPU user-mode driver library mounted in the target user container can be uninstalled, and finally the user container can be destroyed.

[0156] By releasing the resources occupied by the target user container and destroying the target user container, the waste of resources can be avoided. At the same time, since the target user container may have vulnerabilities or be attacked, timely destruction of the target user container can reduce the risk of attack. Finally, creating a target user container before each task starts and destroying the target user container after the task ends can ensure that each task can use a brand new container, ensure that the environment in which the task runs is consistent, and reduce unpredictable problems.

[0157] Furthermore, the resources occupied by the secure container can be released. Specifically, after the execution result is generated, the GPU node in the secure container is deleted, the target kernel state driver in the virtual machine kernel is uninstalled, and the GPU of the secure container is unbound, effectively avoiding the waste of resources.

[0158] Next, starting from the interaction process between the host machine, secure container, and user container, the GPU-based user container processing method is explained.

[0159] Figure 4 This is a flow chart of the third embodiment of the GPU-based user container processing method provided in the present application. Figure 4 As shown, the GPU-based user container processing method can be implemented by the following steps:

[0160] S41. The host directly connects the GPU to the secure container.

[0161] In this step, after the host machine receives the pending tasks sent by the terminal device used by the tenant, it can determine the GPU required to execute the pending tasks based on the pending tasks and pass the GPU directly to the secure container.

[0162] S42. The secure container loads the GPU kernel state driver.

[0163] In this step, the secure container can load the GPU kernel state driver corresponding to the identifier and version of the GPU kernel state driver carried by the task to be executed into the virtual machine kernel.

[0164] S43. The secure container creates a GPU node.

[0165] S44. The secure container mounts the GPU node to the target user container.

[0166] The target user container is the user container corresponding to the task to be executed.

[0167] S45. After detecting that the GPU node is mounted successfully, the target user container notifies the security container that the GPU node is mounted successfully.

[0168] S46. The secure container mounts the GPU user state library into the target user container.

[0169] S47. After detecting that the GPU user state library is mounted successfully, the target user container notifies the secure container that the GPU user state library is mounted successfully.

[0170] In this step, after the target user container successfully mounts the GPU node and the GPU user state library, it executes the task to be executed through the GPU node and the GPU user state library.

[0171] S48. After the pending task is completed, the security container is released.

[0172] In summary, after the GPU is bound to the vfio-pci driver, it is directly connected to the secure container, and the GPU can be seen in the secure container. At the same time, the target user container corresponding to the task to be executed is built in the secure container, and the target user container is started after the construction is completed. After the GPU is directly connected to the secure container, the kernel state driver of the GPU is loaded into the virtual machine kernel of the secure container. Then a GPU node is created in the secure container. After the GPU node is successfully created, the GPU can be read and written through the GPU node.

[0173] Furthermore, the secure container mounts the created GPU node to the target user container, and the processes in the target user container can directly access the GPU through the GPU node. After that, the GPU user-mode driver library pre-mounted from the host to the secure container is mounted to the target user container. The user-mode driver library contains binary executable programs (including the above Figure 1 The GPU query program in the illustrated embodiment), as well as the dynamic library and the soft link of the dynamic library, will perform an update soft link action after the mounting is completed.

[0174] Finally, the task to be executed is executed through the target user container, and the secure container is released after the task process of the target user container is completed.

[0175] Combination Figure 1 Next, we will use a more intuitive way to Figure 4 The process is described in detail below.

[0176] Figure 5 This is a flow chart of the fourth embodiment of the GPU-based user container processing method provided in the present application. Figure 5 As shown, the GPU-based user container processing method can be implemented by the following steps:

[0177] Step 1: The host directly connects the GPU to the secure container.

[0178] Step 2: The secure container loads the GPU kernel state driver into the virtual machine kernel.

[0179] Step 3: Create a GPU node in the secure container.

[0180] Step 4: The secure container mounts the GPU node to the target user container.

[0181] Step 5: The secure container mounts the GPU user state library to the target user container.

[0182] In the above embodiment, the GPU hardware card and the GPU user-mode driver library are both on the host machine, the secure container runs on the host machine, and the target user container runs in the secure container. The secure container is a virtual machine with a kernel module (virtual machine kernel). After the GPU is directly connected to the secure container, the GPU kernel-mode driver needs to be loaded. The target user container is an ordinary RunC container. If you want to use the GPU, you need a GPU node and a GPU user-mode driver library. Therefore, the GPU node and the GPU user-mode library are mounted in the target user container.

[0183] Next, starting from the interaction process between the terminal device used by the tenant and the host machine, the GPU-based user container processing method is described in detail.

[0184] Figure 6 This is a flow chart of Embodiment 5 of the GPU-based user container processing method provided in the present application. Figure 6 As shown, the GPU-based user container processing method can be implemented by the following steps:

[0185] S61. The terminal device used by the tenant sends a task execution request to the host machine.

[0186] In an embodiment, the terminal device used by the tenant can communicate with the host machine via wired or wireless means, so that related operations can be performed through the GPU computing power of the host machine.

[0187] In this step, when the tenant needs to use the GPU computing power provided by the host machine, the tenant can send a task execution request to the host machine to request that the task to be executed carried in the task execution request be executed through the GPU of the host machine to obtain the execution result.

[0188] In a specific implementation, the tenant may determine the task to be executed through the terminal device, and determine the identifier of the GPU that the host needs to use to execute the task to be executed, and the identifier and version number of the target kernel-mode driver corresponding to the GPU.

[0189] Correspondingly, the host machine receives the task execution request sent by the terminal device.

[0190] S62. The host machine allocates the GPU required for the task execution request to the secure container in a direct manner according to the task execution request sent by the terminal device used by the tenant.

[0191] In this step, the task execution request can carry the identifier of the GPU to be used for the task to be executed, and the host machine can directly allocate the GPU corresponding to the GPU identifier to the secure container; the host machine can also directly allocate the GPU corresponding to the type of task to be executed to the secure container.

[0192] Among them, the secure container is used to run user containers, and the secure container runs on the host machine.

[0193] S63. The host machine loads the target kernel-state driver corresponding to the GPU into the virtual machine kernel of the secure container according to the task execution request.

[0194] In this step, the task execution request includes the task to be executed that requires the use of the GPU, the identifier and version number of the target kernel state driver. The target kernel state driver of the GPU is determined according to the identifier and version number of the target kernel state driver, and then the host loads the target kernel state driver into the virtual machine kernel of the secure container.

[0195] S64. According to the target kernel-state driver, the GPU user-state driver library and the GPU node corresponding to the target kernel-state driver are mounted to the target user container corresponding to the task execution request.

[0196] In this step, the host creates a GPU node in the secure container based on the target kernel-mode driver. Further, the host creates a target user container corresponding to the task to be executed in the secure container based on the task to be executed. Finally, the host mounts the GPU node and the GPU user-mode driver library to the target user container corresponding to the task to be executed.

[0197] S65. The host executes the task execution request in the target user container through the GPU node and the GPU user mode driver library mounted in the target user container, and generates an execution result.

[0198] S66. The host machine sends the execution result to the terminal device.

[0199] Correspondingly, the terminal device receives the execution result sent by the host machine.

[0200] Optionally, after the execution result is generated, the target user container may be destroyed and the resources of the secure container may be released. The specific implementation process may refer to the relevant contents in the above embodiment, which will not be described here.

[0201] The following is an embodiment of the device of the present application, which can be used to execute the embodiment of the method of the present application. For details not disclosed in the embodiment of the device of the present application, please refer to the embodiment of the method of the present application.

[0202] Figure 7 For a structural diagram of the first embodiment of the GPU-based user container processing device provided in the present application, see Figure 7 , the GPU-based user container processing device 70 includes:

[0203] The allocation module 71 is used to allocate the GPU to the secure container in a direct manner according to the tasks to be executed by the GPU as needed. The secure container is used to run the user container, and the secure container runs on the host machine corresponding to the GPU.

[0204] The creation module 72 is used to create a GPU node corresponding to the GPU in the security container according to the task to be executed.

[0205] The mounting module 73 is used to mount the GPU node and the GPU user mode driver library to the target user container corresponding to the task to be executed.

[0206] The execution module 74 is used to execute the task to be executed in the target user container through the GPU node and GPU user mode driver library mounted in the target user container, and generate an execution result.

[0207] In a possible implementation, the creation module 72 is specifically configured to:

[0208] Determine the target kernel-mode driver of the GPU based on the task to be executed.

[0209] Load the target kernel-mode driver into the virtual machine kernel of the secure container.

[0210] Create a GPU node in the secure container based on the target kernel-mode driver.

[0211] In a possible implementation, the creation module 72 is specifically configured to:

[0212] Determine the identifier and version number of the target kernel-mode driver carried in the task to be executed.

[0213] According to the identifier and the version number, a target kernel-mode driver corresponding to the identifier and the version number is obtained from a kernel-mode driver library.

[0214] In a possible implementation, the creation module 72 is specifically configured to:

[0215] In the target user container, update the soft link of the dynamic library and obtain the updated soft link.

[0216] Use the GPU query program to view GPU usage.

[0217] When it is determined based on the usage that the GPU is capable of executing the task to be executed, the GPU is called to execute the task to be executed and generate an execution result through the GPU node, the dynamic library, the updated soft link, and the target kernel state driver.

[0218] In a possible implementation, the creation module 72 is further configured to:

[0219] According to the task to be executed, a user container corresponding to the task to be executed is created in the security container.

[0220] In a possible implementation, after executing the task to be executed in the target user container and generating the execution result through the GPU node and the GPU user state driver library mounted in the target user container, the GPU-based user container processing device 70 further includes:

[0221] The uninstall module is used to uninstall the GPU node and GPU user-mode driver library mounted in the target user container.

[0222] Destroy module, used to destroy user containers.

[0223] In a possible implementation, after executing the task to be executed in the target user container and generating the execution result through the GPU node and the GPU user state driver library mounted in the target user container, the GPU-based user container processing device 70 further includes:

[0224] The deletion module is used to delete GPU nodes in the secure container.

[0225] The uninstall module is also used to uninstall the target kernel-mode driver in the virtual machine kernel.

[0226] Unbinding module, used to unbind the GPU of the secure container.

[0227] The GPU-based user container processing device 70 provided in the embodiment of the present application can execute the technical solution shown in the above method embodiment, and its implementation principle and beneficial effects are similar, which will not be repeated here.

[0228] Figure 8 For a structural diagram of the second embodiment of the GPU-based user container processing device provided in the present application, see Figure 8 The GPU-based user container processing device 80 is applied to the host machine, and the GPU-based user container processing device 80 includes:

[0229] The receiving module 81 is used to allocate the GPU required for the task execution request to the secure container in a direct manner according to the task execution request sent by the terminal device used by the tenant. The secure container is used to run the user container, and the secure container runs on the host machine.

[0230] The loading module 82 is used to load the target kernel state driver corresponding to the GPU into the virtual machine kernel of the secure container according to the task execution request.

[0231] The mounting module 83 is used to mount the GPU user state driver library and the GPU node corresponding to the target kernel state driver to the target user container corresponding to the task execution request according to the target kernel state driver.

[0232] The execution module 84 is used to execute the task execution request in the target user container through the GPU node and GPU user mode driver library mounted in the target user container, and generate an execution result.

[0233] The sending module 85 is used to send the execution result to the terminal device.

[0234] The GPU-based user container processing device 80 provided in the embodiment of the present application can execute the technical solution shown in the above method embodiment, and its implementation principle and beneficial effects are similar, which will not be repeated here.

[0235] It should be noted that it should be understood that the division of the various modules of the above device is only a division of logical functions. In actual implementation, all or part of them can be integrated into one physical entity, or they can be physically separated. And these modules can all be implemented in the form of software called by processing elements. They can also be implemented in the form of hardware. Some modules can also be implemented in the form of software called by processing elements, and some modules can be implemented in the form of hardware. In addition, all or part of these modules can be integrated together or implemented independently. The processing element here can be an integrated circuit with signal processing capabilities. In the implementation process, each step of the above method or each module above can be completed by an integrated logic circuit of hardware in the processor element or instructions in the form of software.

[0236] Fig. 9 For a schematic diagram of the structure of the electronic device provided in the embodiment of the present application, see Fig. 9 The electronic device 90 may include a processor 91 and a memory 92. Exemplarily, the processor 91 and the memory 92 are interconnected via a bus 93.

[0237] Memory 92 stores computer executable instructions.

[0238] The processor 91 executes the computer execution instructions stored in the memory 92, so that the processor 91 executes the GPU-based user container processing method as shown in the above method embodiment.

[0239] Optionally, the above-mentioned components of the electronic device 90 may be connected via a system bus.

[0240] Optionally, the electronic device 90 may also include a transceiver for communicating with the tenant's terminal device. Figure 8 The receiving module 81 and the sending module 85 in the illustrated embodiment correspond to the transceiver in this embodiment.

[0241] It should be understood that the processor 91 may be a CPU, or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), etc. A general-purpose processor may be a microprocessor or the processor may be any conventional processor, etc. The steps of the method disclosed in the present application may be directly embodied as being executed by a hardware processor, or may be executed by a combination of hardware and software modules in the processor.

[0242] The system bus can be a peripheral component interconnect (PCI) bus or an extended industry standard architecture (EISA) bus. The system bus can be divided into an address bus, a data bus, a control bus, etc. For ease of representation, only one thick line is used in the figure, but it does not mean that there is only one bus or one type of bus. The memory may include random access memory (RAM) and may also include non-volatile memory (NVM), such as at least one disk storage.

[0243] Optionally, the electronic device 90 provided in the embodiment of the present application may be implemented as Figure 1 The host machine in .

[0244] The electronic device 90 provided in the embodiment of the present application can be used to execute the GPU-based user container processing method provided in any of the above method embodiments, and its implementation principle and technical effect are similar and will not be repeated here.

[0245] Accordingly, an embodiment of the present application provides a computer-readable storage medium, in which computer-executable instructions are stored. When the computer-executable instructions are executed by a processor, they are used to implement the GPU-based user container processing method of the above method embodiment.

[0246] Accordingly, an embodiment of the present application may also provide a computer program product, including a computer program. When the computer program is executed by a processor, the GPU-based user container processing method shown in the above method embodiment can be implemented.

[0247] It will be appreciated by those skilled in the art that embodiments of the present invention may be provided as methods, systems, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Furthermore, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD-ROM, optical storage, etc.) containing computer-usable program code.

[0248] The present invention is described with reference to flowcharts and / or block diagrams of methods, devices, and computer program products according to embodiments of the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing device to produce a machine, so that the instructions executed by the processor of the computer or other programmable data processing device generate instructions for implementing the process in the flowchart. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.

[0249] These computer program instructions may also be stored in a computer-readable memory capable of directing a computer or other programmable data processing device to operate in a specific manner, so that the instructions stored in the computer-readable memory produce an article of manufacture comprising an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.

[0250] These computer program instructions can also be loaded onto a computer or other programmable data processing device so that a series of operating steps are executed on the computer or other programmable device to produce a computer-implemented process, thereby providing instructions for implementing the process. Figure 1 A process or multiple processes and / or boxes Figure 1 A step that specifies a function in one or more boxes.

[0251] In a typical configuration, an electronic device includes one or more processors, input / output interfaces, network interfaces, and memory.

[0252] The memory may include non-permanent storage in a computer-readable medium, random access memory (RAM) and / or non-volatile memory in the form of read-only memory (ROM) or flash RAM. The memory is an example of a computer-readable medium.

[0253] Computer readable media include permanent and non-permanent, removable and non-removable media that can be implemented by any method or technology to store information. Information can be computer readable instructions, data structures, program modules or other data. Examples of computer storage media include, but are not limited to, phase change memory (PRAM), SRAM, dynamic random access memory (DRAM), other types of RAM, read-only memory (ROM), electrically erasable programmable read-only memory (EEPROM), flash memory or other memory technology, compact disk read-only memory (CD-ROM), digital versatile disk (DVD) or other optical storage, magnetic cassettes, magnetic tape magnetic disk storage or other magnetic storage devices or any other non-transmission media that can be used to store information that can be accessed by electronic devices. As defined in this article, computer readable media does not include temporary computer readable media (transitory media), such as modulated data signals and carrier waves.

[0254] It should also be noted that the terms "include", "comprises" or any other variations thereof are intended to cover non-exclusive inclusion, so that a process, method, commodity or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, commodity or device. In the absence of more restrictions, the elements defined by the sentence "comprises a ..." do not exclude the existence of other identical elements in the process, method, commodity or device including the elements.

[0255] The above are only embodiments of the present application and are not intended to limit the present application. For those skilled in the art, the present application may have various changes and variations. Any modification, equivalent replacement, improvement, etc. made within the spirit and principle of the present application should be included within the scope of the claims of the present application.

Claims

1. A GPU-based user container processing method, characterized in that: include: According to the need to use the tasks to be executed by the graphics processing unit GPU, the GPU is directly allocated to the secure container, the secure container is used to run the user container, and the secure container runs on the host machine corresponding to the GPU; According to the task to be executed, create a GPU node corresponding to the GPU in the secure container; Mounting the GPU node and the GPU user-mode driver library to the target user container corresponding to the task to be executed; The task to be executed is executed in the target user container through the GPU node and the GPU user-mode driver library mounted in the target user container, and an execution result is generated.

2. The method according to claim 1, characterized in that The step of creating a GPU node corresponding to the GPU in the secure container according to the task to be executed includes: Determining a target kernel state driver of the GPU according to the task to be executed; Loading the target kernel-mode driver into the virtual machine kernel of the secure container; According to the target kernel-mode driver, the GPU node is created in the secure container.

3. The method according to claim 2, characterized in that Determining a target kernel-mode driver of the GPU according to the task to be executed includes: Determine the identifier and version number of the target kernel-mode driver carried in the task to be executed; According to the identifier and the version number, a target kernel-mode driver corresponding to the identifier and the version number is obtained from a kernel-mode driver library.

4. The method according to claim 2 or 3, characterized in that: The GPU user-mode driver library includes a GPU query program, a dynamic library, and a soft link of the dynamic library. The GPU node and the GPU user-mode driver library mounted in the target user container execute the task to be executed in the target user container to generate an execution result, including: In the target user container, updating the soft link of the dynamic library to obtain the updated soft link; Check the usage of the GPU through the GPU query program; When it is determined according to the usage that the GPU is capable of executing the task to be executed, the GPU is called to execute the task to be executed through the GPU node, the dynamic library, the updated soft link, and the target kernel-mode driver to generate the execution result.

5. The method according to any one of claims 1 to 3, characterized in that: The method further comprises: According to the task to be executed, a user container corresponding to the task to be executed is created in the security container.

6. The method according to claim 5, characterized in that After executing the task to be executed in the target user container through the GPU node and the GPU user mode driver library mounted in the target user container and generating an execution result, the method further includes: Uninstalling the GPU node and the GPU user-mode driver library mounted in the target user container; Destroy the target user container.

7. The method according to claim 2 or 3, characterized in that: After executing the task to be executed in the target user container through the GPU node and the GPU user mode driver library mounted in the target user container and generating an execution result, the method further includes: Deleting the GPU node in the secure container; Uninstalling the target kernel-mode driver in the virtual machine kernel; Unbind the GPU from the secure container.

8. A GPU-based user container processing method, characterized in that: Applied to a host machine, the method includes: According to a task execution request sent by a terminal device used by the tenant, a graphics processing unit (GPU) required for the task execution request is directly allocated to a secure container, where the secure container is used to run a user container and the secure container runs on the host machine; According to the task execution request, loading the target kernel state driver corresponding to the GPU into the virtual machine kernel of the secure container; According to the target kernel state driver, a GPU user state driver library and a GPU node corresponding to the target kernel state driver are mounted to a target user container corresponding to the task execution request; Execute the task execution request in the target user container through the GPU node and the GPU user mode driver library mounted in the target user container to generate an execution result; The execution result is sent to the terminal device.

9. A GPU-based user container processing device, characterized in that: include: An allocation module, used to use the tasks to be executed by the graphics processing unit GPU as needed, and allocate the GPU to the secure container in a direct manner, where the secure container is used to run the user container, and the secure container runs on the host machine corresponding to the GPU; A creation module, used to create a GPU node corresponding to the GPU in the secure container according to the task to be executed; A mounting module, used to mount the GPU node and the GPU user-mode driver library to the target user container corresponding to the task to be executed; An execution module is used to execute the task to be executed in the target user container through the GPU node and the GPU user-mode driver library mounted in the target user container, and generate an execution result.

10. A GPU-based user container processing device, characterized in that: Applied to a host machine, the device comprises: A receiving module, configured to allocate a graphics processing unit (GPU) required for a task execution request in a direct manner to a secure container according to a task execution request sent by a terminal device used by a tenant, wherein the secure container is used to run a user container and the secure container runs on the host machine; A loading module, used to load a target kernel state driver corresponding to the GPU into a virtual machine kernel of a secure container according to the task execution request; A mounting module, used for mounting a GPU user state driver library and a GPU node corresponding to the target kernel state driver to a target user container corresponding to the task execution request according to the target kernel state driver; An execution module, configured to execute the task execution request in the target user container through the GPU node and the GPU user state driver library mounted in the target user container, and generate an execution result; A sending module is used to send the execution result to the terminal device.

11. An electronic device, characterized in that: include: Memory and processor; The memory stores computer-executable instructions; The processor executes the computer-executable instructions stored in the memory, so that the processor performs the method according to any one of claims 1 to 8.

12. A computer-readable storage medium, characterized in that: The computer-readable storage medium stores computer-executable instructions, which are used to implement the method according to any one of claims 1 to 8 when executed by a processor.

13. A computer program product, comprising a computer program, characterized in that When the computer program is executed by a processor, it is used to implement the method according to any one of claims 1 to 8.