Skip to content

Commit 3ade6d4

Browse files
committed
List writable render devices with no render-device.sh args
To help debugging potential kubernetes device usage issues. Signed-off-by: Eero Tamminen <eero.t.tamminen@intel.com>
1 parent 4b39446 commit 3ade6d4

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

cmd/gpu_plugin/render-device.sh

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
# all distro base images. The required tools, and the packages they
2323
# reside in Debian based distros, are:
2424
# - dash: 'sh' (minimal bourne shell)
25-
# - coreutils: 'seq', 'cat', 'echo'
25+
# - coreutils: 'seq', 'cat', 'echo', 'id'
2626
# - sed: 'sed'
2727
#
2828
# But they are also provided by 'busybox' and 'toybox' tool sets.
@@ -35,6 +35,9 @@ usage ()
3535
echo "on standard output, or added to given command line. If device index"
3636
echo "N is given, provides name of Nth available (Intel GPU) render device."
3737
echo
38+
echo "With no arguments, outputs Intel GPU render devices count from sysfs,"
39+
echo "and how many of them are writable in devfs."
40+
echo
3841
echo "Usage:"
3942
echo " $name <device index>"
4043
echo " $name [device index] <media program> [other options] <GPU selection option>"
@@ -48,8 +51,29 @@ usage ()
4851
exit 1
4952
}
5053

54+
intel="0x8086"
5155
if [ $# -eq 0 ]; then
52-
usage "no arguments given"
56+
syscount=0
57+
devcount=0
58+
for i in $(seq 128 255); do
59+
devfile="/dev/dri/renderD$i"
60+
sysfile="/sys/class/drm/renderD$i/device/vendor"
61+
if [ ! -r "$sysfile" ]; then
62+
continue
63+
fi
64+
vendor=$(cat "$sysfile")
65+
if [ "$vendor" != "$intel" ]; then
66+
continue
67+
fi
68+
syscount=$((syscount+1))
69+
if [ -w "$devfile" ]; then
70+
devcount=$((devcount+1))
71+
fi
72+
done
73+
echo "$syscount Intel GPU render device(s) listed in sysfs, $devcount writable one(s) in devfs:"
74+
ls -l /dev/dri/
75+
echo "User: $(id)"
76+
exit 0
5377
fi
5478

5579
# determine required GPU index
@@ -66,7 +90,6 @@ fi
6690
visible=0
6791

6892
vendor=""
69-
intel="0x8086"
7093
# find host index "i" for Nth visible Intel GPU device
7194
for i in $(seq 128 255); do
7295
if [ -w "/dev/dri/renderD$i" ]; then

0 commit comments

Comments
 (0)