(serverId?: string)
| 81 | }; |
| 82 | |
| 83 | const checkRuntime = async (serverId?: string) => { |
| 84 | let runtimeInstalled = false; |
| 85 | let runtimeConfigured = false; |
| 86 | |
| 87 | try { |
| 88 | // First check: Is nvidia-container-runtime installed? |
| 89 | const checkBinaryCommand = "command -v nvidia-container-runtime"; |
| 90 | try { |
| 91 | const { stdout } = serverId |
| 92 | ? await execAsyncRemote(serverId, checkBinaryCommand) |
| 93 | : await execAsync(checkBinaryCommand); |
| 94 | runtimeInstalled = !!stdout.trim(); |
| 95 | } catch (error) { |
| 96 | console.debug("Runtime binary check:", error); |
| 97 | } |
| 98 | |
| 99 | // Second check: Is it configured in Docker? |
| 100 | try { |
| 101 | const runtimeCommand = 'docker info --format "{{json .Runtimes}}"'; |
| 102 | const { stdout: runtimeInfo } = serverId |
| 103 | ? await execAsyncRemote(serverId, runtimeCommand) |
| 104 | : await execAsync(runtimeCommand); |
| 105 | |
| 106 | const defaultCommand = 'docker info --format "{{.DefaultRuntime}}"'; |
| 107 | const { stdout: defaultRuntime } = serverId |
| 108 | ? await execAsyncRemote(serverId, defaultCommand) |
| 109 | : await execAsync(defaultCommand); |
| 110 | |
| 111 | const runtimes = JSON.parse(runtimeInfo); |
| 112 | const hasNvidiaRuntime = "nvidia" in runtimes; |
| 113 | const isDefaultRuntime = defaultRuntime.trim() === "nvidia"; |
| 114 | |
| 115 | // Only set runtimeConfigured if both conditions are met |
| 116 | runtimeConfigured = hasNvidiaRuntime && isDefaultRuntime; |
| 117 | } catch (error) { |
| 118 | console.debug("Runtime configuration check:", error); |
| 119 | } |
| 120 | } catch (error) { |
| 121 | console.debug("Runtime check:", error); |
| 122 | } |
| 123 | |
| 124 | return { runtimeInstalled, runtimeConfigured }; |
| 125 | }; |
| 126 | |
| 127 | const checkSwarmResources = async (serverId?: string) => { |
| 128 | let swarmEnabled = false; |
no test coverage detected