Skip to content

Instantly share code, notes, and snippets.

@abenson
Created March 4, 2020 23:16
Show Gist options
  • Save abenson/a5264836c4e6bf22c8c8415bb616204a to your computer and use it in GitHub Desktop.
Save abenson/a5264836c4e6bf22c8c8415bb616204a to your computer and use it in GitHub Desktop.
#!/bin/bash
export __NV_PRIME_RENDER_OFFLOAD=1
export __GLX_VENDOR_LIBRARY_NAME=nvidia
export __VK_LAYER_NV_optimus=NVIDIA_only
export VK_ICD_FILENAMES=/usr/share/vulkan/icd.d/nvidia_icd.json
exec "$@"
@AdolfRoxler
Copy link

11/10 should be included as part of nvidia and nvidia-dkms in most distros

@v1rbox
Copy link

v1rbox commented Nov 26, 2023

Splendid.

@azaslavskis
Copy link

azaslavskis commented Mar 13, 2024

legend! thanks!

if you are to lazy to download and install it manually

wget https://gist.githubusercontent.com/abenson/a5264836c4e6bf22c8c8415bb616204a/raw/5f65679690075547938ed808d1e665f93eb9f2fd/prime-run 
sudo cp prime-run /usr/local/bin/prime-run
sudo chmod +x /usr/local/bin/prime-run 

check before run!

@Justuser3310
Copy link

Thank you!

@yonatan8070
Copy link

wget https://gist.githubusercontent.com/abenson/a5264836c4e6bf22c8c8415bb616204a/raw/5f65679690075547938ed808d1e665f93eb9f2fd/prime-run 
sudo cp prime-run /usr/bin/prime-run
sudo chmod +x /usr/bin/prime-run 

I just want to note, the correct location for files that aren't controlled by the package manager is /usr/local/.
If someone installs this, and a while later their distribution decides to add it to their NVIDIA packages (such as Arch's nvidia-prime package), they would get a conflict error from the package manager.

@azaslavskis
Copy link

wget https://gist.githubusercontent.com/abenson/a5264836c4e6bf22c8c8415bb616204a/raw/5f65679690075547938ed808d1e665f93eb9f2fd/prime-run 
sudo cp prime-run /usr/bin/prime-run
sudo chmod +x /usr/bin/prime-run 

I just want to note, the correct location for files that aren't controlled by the package manager is /usr/local/. If someone installs this, and a while later their distribution decides to add it to their NVIDIA packages (such as Arch's nvidia-prime package), they would get a conflict error from the package manager.

Thanks fixed it! You right.

@KnownBlackHat
Copy link

KnownBlackHat commented Nov 8, 2024

is this only for wayland? what about x11??

image

@abenson
Copy link
Author

abenson commented Nov 8, 2024 via email

@yonatan8070
Copy link

I can confirm that it also works on Wayland

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment