Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add better support for nvidia gpus #146

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions config/nvidia-primary-gpu.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
Section "OutputClass"
Identifier "nvidia"
MatchDriver "nvidia-drm"
Driver "nvidia"
Option "AllowEmptyInitialConfiguration"
ModulePath "/nvidia/xorg"
Option "PrimaryGPU" "yes"
EndSection
16 changes: 15 additions & 1 deletion run-gow
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,20 @@ xorg_driver[debian]=$(cat - <<END
END
)

# Get a line suitable for inserting into an `volumes:` list in a docker
# compose file that will load whatever extra paths is necessary.
get_xorg_driver() {
local os_type_re="$(os_type)"
if [ "${os_type_re}" = "ubuntu" ] &&
[ -f /usr/lib/xorg/modules/drivers/nvidia_drv.so ] &&
[ -f /usr/lib/xorg/modules/extensions/libglxserver_nvidia.so ]; then
echo "${xorg_driver["debian"]}"
else
echo "${xorg_driver[${os_type_re}]}"
fi
echo "- ./config/nvidia-primary-gpu.conf:/usr/share/X11/xorg.conf.d/01-primary-gpu.conf:ro"
}

# Iterate through the given file and insert environment files and volume mounts
# as needed for the desired setup (headless, gpu type, etc)
transform_file() {
Expand All @@ -377,7 +391,7 @@ transform_file() {
if [[ $line =~ $gpu_env_re ]]; then
pad_lines "$(get_gpu_env)" "${BASH_REMATCH[1]}"
elif [ "$gpu_type" = "nvidia" ] && [[ $line =~ $xorg_driver_re ]]; then
pad_lines "${xorg_driver[$(os_type)]}" "${BASH_REMATCH[1]}"
pad_lines "$(get_xorg_driver)" "${BASH_REMATCH[1]}"
else
echo "$line"
fi
Expand Down