4

I am Ubuntu 14.04 and have NVIDIA graphics card 820m running with driver v331.

On windows we can select which GPU to use to run a application. How can we do it on Ubuntu?

UPDATE:
my question was marked duplicate of this answer, which didnt helped

  1. in Bumblebee Application Setting program, I set few application to be run on Performance Mode but it get reset to Unrecognized after I close the application (see image below) bumblebee applications settings

  2. Previously the Graphic in System Settings > Details used to be Nvidia but it is not Intel Haswell, which means nvidia is not being used :-/

Ubuntu system settings Details

Alex Jones
  • 7,982
  • 9
  • 55
  • 94

3 Answers3

7

COPY-PASTED FROM HERE

The current version of nvidia-prime uses one graphics card for the complete desktop. You either login with nvidia or intel.

I have had problems with bumblebee since 13.10. What works for me now is nvidia-prime. This allows you to choose which graphics driver you want to use in the nvidia control panel. This only works with lightdm (unity). I'm using this myself on Ubuntu 14.04

How to install

1. Use nvidia driver

Open the dash (super/windows key) and type in "drivers". Open "Aditional drivers" Select the nvidia binary (331.xx) driver.

nvidia driver

Click "apply changes". Wait for the driver to be downloaded and installed, and click close.

2. Remove bumblebee and install prime

Open the shell by pressing ctrl-alt-t.

First let's make sure we have the latest software catalog.

sudo apt-get update

Now remove everything bumblebee related.

sudo apt-get purge bumblebee*

Then install prime.

sudo apt-get install nvidia-prime

Now restart your computer.

How to use prime

After your computer has restarted, open the dash and type "nvidia". Open "Nvidia x-server settings".

choose between Intel and nvidia

Here you can choose between the intel and nvidia graphics driver. Choose the intel one for maximum power saving, choose the nvidia one for maximum performance.

After changing graphics card, you'll have to logout and log back in to apply the changes.

Difference between nvidia-prime and bumblebee

The current version of nvidia-prime uses one graphics card for the complete desktop. You either login with nvidia or intel. With bumblebee, you can start individual programs with a specific graphics card, like it is the case on windows.

Sadly, I can't get bumblebee to work on ubuntu 13.10 or higher...

Alex Jones
  • 7,982
  • 9
  • 55
  • 94
  • What is the problem with Bumblebee on 14.04.2? – Fabby Mar 20 '15 at 21:26
  • @Fabby see the first image in question, bumblebee does not work in 14.04 onwards – Alex Jones Mar 20 '15 at 21:28
  • using one GPU per session kinda sucks. Isn't there any way to make it switch dinamically, similar to how it works on windows? – Alex Burdusel Apr 22 '15 at 13:20
  • @Burdu I know on windows its possible, windows has bigger market share than linux, so nvidia spends more money on making better drivers for windows. as i told from 13.10 onwards we have to use prime drivers for linux, if you have battery or heating issue you can use nvidia in power saver mode. – Alex Jones Apr 22 '15 at 13:51
0

If you want to select a specific GPU for the entire session, then selecting it with Prime, logging out and then logging back in will suffice.

However, if you really want to choose which GPU to use for each application, then you must use the DRI_PRIME environment variable for such specific application(s) instead of using the system-wide Prime setting.

Ideally, it's recommended to use the Prime program in order to preset the integrated GPU (graphics processing unit) as the default (system-wide) one, i.e. it's recommended to set the integrated Intel graphics card as the default one, because it saves power, helps keeping your computer operating at a lower temperature et cetera. Then when you decide to run that very demanding 3D appplication, you use DRI_PRIME to tell the system that it must use your Nvidia GPU to run such specific application.

As explained e.g. here and here, once you've used Prime to "tell" the system that your integrated Intel GPU is the default one to be used system-wide, you tell your Nvidia GPU to run the specific application by running the command:

DRI_PRIME=1 specific-application

...where specific-application is e.g. a 3D modelling application or a 3D game or any other program that requires a GPU with more powerful graphics processing capabilities. If e.g. you want your Nvidia GPU to process the graphics of the Inkscape application, just run:

DRI_PRIME=1 inkscape

In order to run Blender using your Nvidia GPU instead of the integrated Intel GPU, just run:

DRI_PRIME=1 blender

Suppose that you want Blender to always use your Nvidia GPU instead of the integrated Intel GPU. In such case, you may use a text editor (such as GEdit, Nano, Mousepad, Leafpad etc.) in order to edit Blender's .desktop file:

sudo gedit /usr/share/applications/blender.desktop

...and then replace this:

Exec=/usr/bin/blender %u

...with this:

Exec=DRI_PRIME=1 /usr/bin/blender %u

...then just save the file, exit the text editor and start Blender by clicking on its icon at the Applications menu. Each one of those application icons at the Applications menu are one .desktop file, so if you modify e.g. blender.desktop you're pretty much modifying the Blender application shortcut at your Applications menu so when you click on such shortcut it runs Blender with DRI_PRIME set as 1 (i.e. use the Nvidia GPU to run Blender).

In case you don't know which is the current default GPU, run this command:

glxinfo | grep "OpenGL renderer"

And in order to see which GPU is activated when you set DRI_PRIME=1, run this command:

DRI_PRIME=1 glxinfo | grep "OpenGL renderer"

If your integrated Intel GPU is already set as the default (system-wide) GPU, then the first command (glxinfo | grep "OpenGL renderer") will inform you that Intel is the GPU ran by glxinfo by default, and the second command (DRI_PRIME=1 glxinfo | grep "OpenGL renderer") will inform you that Nvidia is the GPU ran by DRI_PRIME=1 glxinfo (i.e. Nvidia is not the default / system-wide GPU, but DRI_PRIME=1 successfully set Nvidia as the active GPU for that specific process initiated by DRI_PRIME=1 glxinfo | grep "OpenGL renderer").

0

After some trial and error I discovered that you need to append the following two lines to the .desktop file of the app you want to use the dgpu by default.

PrefersNonDefaultGPU=true
X-KDE-RunOnDiscreteGpu=true

It will then give you the option to launch using the integrated gpu instead of the discrete one. For the command linen run the following command, it will make a script called prime-run which you can call from the command line, for example opening gedit on the dgpu would be prime-run gedit.

Here is the command.

echo "sudo apt-get install -y sed
echo \"#/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 \\\"\\\$@\\\"\" >| /usr/bin/prime-run
sed -i 's%#%#!%' /usr/bin/prime-run " >| script.sh
sudo chmod +x /usr/bin/prime-run
sudo bash script.sh
sudo rm script.sh