Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to analyze NVIDIA and k8s-device-plugin source code

2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)05/31 Report--

How to carry out NVIDIA and k8s-device-plugin source code analysis, in view of this problem, this article introduces the corresponding analysis and answers in detail, hoping to help more partners who want to solve this problem to find a more simple and easy way.

K8s-device-plugin internal implementation schematic diagram

In how Kubernetes uses NVIDIA GPU through Device Plugins, this paper makes an in-depth analysis of the working principle of NVIDIA/k8s-device-plugin, in order to facilitate us to post its internal implementation schematic diagram again:

PreStartContainer and GetDevicePluginOptions interfaces, which can be ignored in NVIDIA/k8s-device-plugin, can be considered empty implementations. We focus on the implementation of ListAndWatch and Allocate.

Start

It all starts with the main function! The core code is as follows:

Func main () {log.Println ("Loading NVML") if err: = nvml.Init (); err! = nil {select {}}. Log.Println ("Fetching devices.") If len (getDevices ()) = 0 {select {}} log.Println ("Starting FS watcher.") Watcher, err: = newFSWatcher (pluginapi.DevicePluginPath) if err! = nil {os.Exit (1)}. Log.Println ("Starting OS watcher.") Sigs: = newOSWatcher (syscall.SIGHUP, syscall.SIGINT, syscall.SIGTERM Syscall.SIGQUIT) restart: = true var devicePlugin * NvidiaDevicePluginL: for {if restart {if devicePlugin! = nil {devicePlugin.Stop ()} devicePlugin = NewNvidiaDevicePlugin () if err: = devicePlugin.Serve () Err! = nil {...} else {restart = false}} select {case event: =

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report