(serverId?: string)
| 125 | }; |
| 126 | |
| 127 | const checkSwarmResources = async (serverId?: string) => { |
| 128 | let swarmEnabled = false; |
| 129 | let gpuResources = 0; |
| 130 | |
| 131 | try { |
| 132 | const nodeCommand = |
| 133 | "docker node inspect self --format '{{json .Description.Resources.GenericResources}}'"; |
| 134 | const { stdout: resources } = serverId |
| 135 | ? await execAsyncRemote(serverId, nodeCommand) |
| 136 | : await execAsync(nodeCommand); |
| 137 | |
| 138 | if (resources && resources !== "null") { |
| 139 | const genericResources = JSON.parse(resources); |
| 140 | for (const resource of genericResources) { |
| 141 | if ( |
| 142 | resource.DiscreteResourceSpec && |
| 143 | (resource.DiscreteResourceSpec.Kind === "GPU" || |
| 144 | resource.DiscreteResourceSpec.Kind === "gpu") |
| 145 | ) { |
| 146 | gpuResources = resource.DiscreteResourceSpec.Value; |
| 147 | swarmEnabled = true; |
| 148 | break; |
| 149 | } |
| 150 | } |
| 151 | } |
| 152 | } catch (error) { |
| 153 | console.debug("Swarm resource check:", error); |
| 154 | } |
| 155 | |
| 156 | return { swarmEnabled, gpuResources }; |
| 157 | }; |
| 158 | |
| 159 | const checkGpuInfo = async (serverId?: string) => { |
| 160 | let gpuModel: string | undefined; |
no test coverage detected