Skip to content
This repository was archived by the owner on Oct 6, 2025. It is now read-only.

Commit 2ffd27c

Browse files
committed
Add AI accelerator device mounting support in CreateControllerContainer
Need this to talk to device via Vulkan, ROCm, etc. Signed-off-by: Eric Curtin <[email protected]>
1 parent a224872 commit 2ffd27c

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

pkg/standalone/containers.go

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import (
88
"fmt"
99
"io"
1010
"os"
11+
"path/filepath"
1112
"strconv"
1213
"strings"
1314
"time"
@@ -272,6 +273,32 @@ func CreateControllerContainer(ctx context.Context, dockerClient *client.Client,
272273
hostConfig.DeviceRequests = []container.DeviceRequest{{Count: -1, Capabilities: [][]string{{"gpu"}}}}
273274
}
274275

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+
275302
// Create the container. If we detect that a concurrent installation is in
276303
// progress (as indicated by a conflicting container name (which should have
277304
// been detected just before installation)), then we'll allow the error to

0 commit comments

Comments
 (0)