|
8 | 8 | "fmt" |
9 | 9 | "io" |
10 | 10 | "os" |
| 11 | + "path/filepath" |
11 | 12 | "strconv" |
12 | 13 | "strings" |
13 | 14 | "time" |
@@ -272,6 +273,32 @@ func CreateControllerContainer(ctx context.Context, dockerClient *client.Client, |
272 | 273 | hostConfig.DeviceRequests = []container.DeviceRequest{{Count: -1, Capabilities: [][]string{{"gpu"}}}} |
273 | 274 | } |
274 | 275 |
|
| 276 | + // devicePaths contains glob patterns for common AI accelerator device files. |
| 277 | + // Enable access to AI accelerator devices if they exist |
| 278 | + devicePaths = []string{ |
| 279 | + "/dev/dri", // Direct Rendering Infrastructure (used by Vulkan, Mesa, Intel/AMD GPUs) |
| 280 | + "/dev/kfd", // AMD Kernel Fusion Driver (for ROCm) |
| 281 | + "/dev/accel", // Intel accelerator devices |
| 282 | + "/dev/davinci*", // TI DaVinci video processors |
| 283 | + "/dev/devmm_svm", // Huawei Ascend NPU |
| 284 | + "/dev/hisi_hdc", // Huawei Ascend NPU |
| 285 | + } |
| 286 | + |
| 287 | + for _, path := range devicePaths { |
| 288 | + devices, err := filepath.Glob(path) |
| 289 | + if err != nil { |
| 290 | + // Skip on glob error, don't fail container creation |
| 291 | + continue |
| 292 | + } |
| 293 | + for _, device := range devices { |
| 294 | + hostConfig.Devices = append(hostConfig.Devices, container.DeviceMapping{ |
| 295 | + PathOnHost: device, |
| 296 | + PathInContainer: device, |
| 297 | + CgroupPermissions: "rwm", |
| 298 | + }) |
| 299 | + } |
| 300 | + } |
| 301 | + |
275 | 302 | // Create the container. If we detect that a concurrent installation is in |
276 | 303 | // progress (as indicated by a conflicting container name (which should have |
277 | 304 | // been detected just before installation)), then we'll allow the error to |
|
0 commit comments