Last active
February 27, 2020 23:31
-
-
Save vilkoz/651f4179671bf0ef8e3319449573a1fa to your computer and use it in GitHub Desktop.
Nvidia optimus laptop run Xorg on nvidia gpu by default
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
systemctl --user import-environment DISPLAY | |
xrandr --setprovideroutputsource modesetting NVIDIA-0 | |
xrandr --auto | |
exec i3 | |
#exec startkde |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /etc/X11/xorg.conf.d/20-intel.conf | |
Section "Device" | |
Identifier "intel" | |
Driver "modesetting" | |
Option "AccelMethod" "none" | |
EndSection | |
Section "Screen" | |
Identifier "intel" | |
Device "intel" | |
EndSection |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /etc/X11/xorg.conf.d/20-nvidia.conf | |
Section "Files" | |
ModulePath "/usr/lib/nvidia" | |
ModulePath "/usr/lib32/nvidia" | |
ModulePath "/usr/lib32/nvidia/xorg/modules" | |
ModulePath "/usr/lib32/xorg/modules" | |
ModulePath "/usr/lib64/nvidia/xorg/modules" | |
ModulePath "/usr/lib64/xorg/modules" | |
EndSection | |
Section "ServerLayout" | |
Identifier "layout" | |
Screen 1 "nvidia" 0 0 | |
Inactive "intel" | |
EndSection | |
Section "Device" | |
Identifier "nvidia" | |
Driver "nvidia" | |
BusID "PCI:1:0:0" | |
EndSection | |
Section "Screen" | |
Identifier "nvidia" | |
Device "nvidia" | |
EndSection |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# /usr/local/bin/enable_nvidia_gpu.sh | |
CONTROLLER_BUS_ID=0000:00:01.0 | |
DEVICE_BUS_ID=0000:01:00.0 | |
MODULES_LOAD=(nvidia nvidia_uvm nvidia_modeset "nvidia_drm modeset=1") | |
echo 'Turning the PCIe controller on to allow card rescan' | |
sudo tee /sys/bus/pci/devices/${CONTROLLER_BUS_ID}/power/control <<<on | |
echo 'Waiting 1 second' | |
sleep 1 | |
if [[ ! -d /sys/bus/pci/devices/${DEVICE_BUS_ID} ]]; then | |
echo 'Rescanning PCI devices' | |
tee /sys/bus/pci/rescan <<<1 | |
echo "Waiting 1 second for rescan" | |
sleep 1 | |
fi | |
echo 'Turning the card on' | |
tee /sys/bus/pci/devices/${DEVICE_BUS_ID}/power/control <<<on | |
for module in "${MODULES_LOAD[@]}" | |
do | |
echo "Loading module ${module}" | |
modprobe ${module} | |
done |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description="Turn on Nvidia GPU and load Nvidia modules" | |
[Service] | |
Type=oneshot | |
User=root | |
ExecStart=/usr/local/bin/enable_nvidia_gpu.sh | |
[Install] | |
WantedBy=multi-user.target |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment