
In this article, we will explore how to select a GPU (Graphics Processing Unit) for each application on Ubuntu when using NVIDIA hybrid graphics. Hybrid graphics technology allows you to switch between integrated and dedicated GPUs, depending on the task at hand. This can be beneficial for power saving and performance enhancement.
To choose which GPU to use for each application on Ubuntu with NVIDIA hybrid graphics, you have three options: Bumblebee, NVIDIA Prime, and the DRI_PRIME environment variable. Bumblebee is a project that provides support for NVIDIA Optimus laptops, while NVIDIA Prime allows you to switch between the integrated and dedicated GPUs. The DRI_PRIME environment variable is another method to select a GPU for each application. Experiment with these options to find the best solution for your needs.
Understanding Hybrid Graphics
Hybrid graphics systems contain two GPUs: an integrated GPU (iGPU), which is less powerful but energy-efficient, and a dedicated GPU (dGPU), which is more powerful but consumes more energy. NVIDIA Optimus technology is an example of hybrid graphics.
Options for GPU Selection in Ubuntu
There are three primary methods for choosing a GPU for each application on Ubuntu with NVIDIA hybrid graphics:
- Bumblebee
- NVIDIA Prime
- DRI_PRIME environment variable
1. Using Bumblebee
Bumblebee is a project that aims to provide support for NVIDIA Optimus laptops for GNU/Linux distributions.
Installation
To install Bumblebee, follow the instructions in this guide.
Configuration
Open the Bumblebee Application Settings program and set the desired applications to run on Performance Mode. This will use the NVIDIA GPU for those applications.
Note: Some users have reported issues with Bumblebee on Ubuntu 14.04 and higher versions.
2. Using NVIDIA Prime
NVIDIA Prime is a technology that allows you to switch between your iGPU and dGPU.
Installation
- Open the “Additional Drivers” program and select the NVIDIA binary (331.xx) driver to install the NVIDIA driver.
- Remove Bumblebee by running the command:
sudo apt-get purge bumblebee*
. This command removes all packages related to Bumblebee. - Install NVIDIA Prime by running the command:
sudo apt-get install nvidia-prime
. This command installs NVIDIA Prime.
Configuration
After restarting your computer, open the NVIDIA X Server Settings program and choose between the Intel and NVIDIA graphics driver. Logout and log back in to apply the changes.
3. Using the DRI_PRIME Environment Variable
The DRI_PRIME environment variable is another method to select a GPU for each application.
Configuration
- Set the integrated Intel GPU as the default GPU using NVIDIA Prime for power-saving benefits.
- To run a specific application with the NVIDIA GPU, use the
DRI_PRIME=1
environment variable before the application command. For example, to run Inkscape with the NVIDIA GPU, use the command:DRI_PRIME=1 inkscape
. - You can modify the application’s .desktop file to always run with
DRI_PRIME=1
by adding the lineExec=DRI_PRIME=1 /usr/bin/application
to the file.
The DRI_PRIME=1
command forces the system to use the dGPU for that specific application.
Checking GPU Usage
It’s important to check the system settings to ensure the correct GPU is being used. If the Graphics in System Settings > Details shows Intel Haswell instead of NVIDIA, there may be an issue with the GPU configuration.
Conclusion
The ability to choose the GPU for each application provides flexibility and control over your system’s performance and power consumption. Whether you prefer Bumblebee, NVIDIA Prime, or the DRI_PRIME environment variable, each method has its own advantages. Experiment to find which works best for you and your specific needs.
Hybrid graphics technology allows you to switch between integrated and dedicated GPUs, depending on the task at hand, providing a balance between power saving and performance enhancement.
The three primary methods are Bumblebee, NVIDIA Prime, and the DRI_PRIME environment variable.
To install Bumblebee, you can follow the instructions provided in the guide mentioned in the article.
Some users have reported issues with Bumblebee on Ubuntu 14.04 and higher versions. It is recommended to check the latest information and user experiences before deciding to use Bumblebee.
To install NVIDIA Prime, you can open the "Additional Drivers" program, select the NVIDIA binary (331.xx) driver, remove Bumblebee, and then install NVIDIA Prime using the provided command.
After installing NVIDIA Prime, you can open the NVIDIA X Server Settings program, choose between the Intel and NVIDIA graphics driver, and then log out and log back in to apply the changes.
The DRI_PRIME environment variable is used to select a GPU for each application. By setting the variable to 1 before the application command, you can force the system to use the dedicated GPU for that specific application.
To modify an application’s .desktop file, you can add the line "Exec=DRI_PRIME=1 /usr/bin/application" to the file. This ensures that the application always runs with the NVIDIA GPU.
You can check the Graphics section in System Settings > Details to see which GPU is being used. If it shows Intel Haswell instead of NVIDIA, there may be an issue with the GPU configuration.
The choice between Bumblebee, NVIDIA Prime, or the DRI_PRIME environment variable depends on your specific needs and preferences. It is recommended to experiment with each method to determine which works best for you.