1
0

Updated to latest xe-solutions

Signed-off-by: James P. Ketrenos <james.p.ketrenos@intel.com>
This commit is contained in:
James P. Ketrenos 2020-10-15 14:48:51 -07:00
parent 4eabf2ccd3
commit 56da84f3ec

95
scripts/intel-docker Executable file
View File

@ -0,0 +1,95 @@
#!/bin/bash
function fail {
>&2 echo "$*"
exit -1
}
PRE_RUN=()
POST_RUN=()
RUN=
for arg in "${@}"; do
[[ "${arg}" == "run" ]] && {
RUN=1
continue
}
(( ! RUN )) && {
PRE_RUN+=("${arg}")
} || {
POST_RUN+=("${arg}")
}
done
function usage {
cat << EOF
usage: scripts/intel-docker [DOCKER-OPTIONS]
intel-docker adds the following docker parameters to your
DOCKER-OPTIONS, based on the host configuration:
--device=/dev/dri
--group-add \${VIDEO}
--group-add \${RENDER}
The group id used for VIDEO and RENDER is
based on the 'video' and 'render' group definitions used
for ownership of /dev/dri/* entries. Typically card* is
owned by 'video' and render* is owned by 'render'. To
find the group id, 'stat' is used:
VIDEO=\$(stat -c '%g' /dev/dri/card*)
RENDER=\$(stat -c '%g' /dev/dri/render*)
If /dev/dri entries do not exist, no group add lines are added to
the docker option.
EOF
}
if test -e /dev/dri/card*; then
VIDEO=$(stat -c '%g' /dev/dri/card*)
fi
if test -e /dev/dri/render*; then
RENDER=$(stat -c '%g' /dev/dri/render*)
fi
if [ "${RENDER}" == "${VIDEO}" ]; then
unset RENDER
fi
if [ "${RENDER}" == "" ] && [ "${VIDEO}" == "" ]; then
fail "No /dev/dri/* entries found on host. Does your kernel have the GPU driver loaded?"
fi
cat << EOF
-------------------------------------------------------------------------------
Intel Xe graphics container script
EOF
(( RUN )) && {
PRE_RUN+=("run")
POST_RUN=(--device=/dev/dri ${POST_RUN[@]})
[[ "${VIDEO}" != "" ]] || fail "No group ownership of /dev/dri/card* found."
POST_RUN=("--group-add ${VIDEO}" ${POST_RUN[@]})
[[ "${RENDER}" != "" ]] && POST_RUN=("--group-add ${RENDER}" ${POST_RUN[@]})
true
} || {
cat << EOF
NOTE: intel-docker is intended to be executed with the same arguments as you
would pass to docker, including the 'run' command.
EOF
}
cat << EOF
Adding the following options to the docker command line after 'run' and before
user options:
--device=/dev/dri
--group-add ${VIDEO}$( [[ "${RENDER}" != "" ]] && echo -e "\n --group-add ${RENDER}\n" )
-------------------------------------------------------------------------------
EOF
echo -e "Running:\ndocker ${PRE_RUN[@]} ${POST_RUN[@]}"
docker ${PRE_RUN[@]} ${POST_RUN[@]}