GPU


Fixing Display Settings Issue in Ubuntu 24.04: “Changes Cannot Be Applied” Error

Ubuntu 24.04 is a powerful and user-friendly Linux distribution, but like any operating system, it sometimes presents users with challenges that need troubleshooting. One such issue you may encounter when adjusting display settings is the following error message:

“Changes cannot be applied. This could be due to hardware limitations.”

This error typically appears when attempting to modify the screen resolution or switch display configurations, such as external monitors. Despite having the necessary hardware (e.g., an NVIDIA GPU), users find that changes cannot be applied, leaving them limited control over display settings.

In this blog post, we’ll explain a simple solution to resolve this issue and ensure your display works as expected.

The Problem

In some instances, this error is not necessarily due to hardware limitations but rather a misconfiguration or a missing driver that prevents Ubuntu from properly interfacing with your NVIDIA graphics card. While Ubuntu’s open-source Nouveau drivers are functional for basic tasks, they often lack the features needed to fully utilize the power of NVIDIA GPUs, particularly for advanced display settings or multi-monitor setups.

The Solution: Installing Proprietary NVIDIA Drivers

To fix this issue, you must ensure the proprietary NVIDIA drivers are installed and configured correctly. The following steps will guide you through the process.

Step 1: Install NVIDIA Drivers

The first step is to install the appropriate NVIDIA drivers for your GPU. Ubuntu provides a convenient tool for this:

  1. Open a terminal by pressing Ctrl + Alt + T.
  2. Enter the following command to detect and install the best drivers for your system automatically:
   sudo ubuntu-drivers autoinstall

This command will scan your system’s hardware and install the proprietary drivers NVIDIA provides.

Step 2: Restart Your System

Once the drivers are installed, it’s important to reboot your system to ensure that the changes take effect:

sudo reboot

After restarting, Ubuntu should use the new drivers, but we still need to configure the display settings for optimal performance.

Step 3: Configure NVIDIA PRIME Profiles

NVIDIA’s PRIME technology allows systems with integrated graphics (like Intel) and discrete graphics (NVIDIA) to switch between different power modes. In many cases, Ubuntu will default to using the integrated GPU to conserve power, which can limit display capabilities. We need to switch to the NVIDIA GPU for better performance.

  1. Open the NVIDIA Settings application by searching for it in the application menu or running the following command in the terminal:
   nvidia-settings
  1. In the NVIDIA Settings window, navigate to the PRIME Profiles section.
  2. Select the NVIDIA (Performance Mode) option. This setting ensures that the system uses the discrete NVIDIA GPU, which provides better performance and full control over display settings.
  3. Apply the changes and close the application.
https://youtu.be/TSAZPFgFDZM

Step 4: Restart Again

For the changes to fully take effect, you’ll need to reboot your system one more time:

sudo reboot

After this final reboot, your system should now be using the NVIDIA GPU for display rendering, and you should be able to modify the display settings without encountering the “Changes cannot be applied” error.

Conclusion

If you could not change display settings in Ubuntu 24.04 and received the “Changes cannot be applied” error, the issue likely stemmed from a misconfigured or missing NVIDIA driver. You can restore full control over your display settings by installing the proprietary drivers and configuring PRIME profiles to use the NVIDIA GPU.

Following the steps in this guide should resolve the problem, enabling you to adjust your display settings as needed. If you encounter further issues, check the NVIDIA Settings application or verify that your drivers are up to date.

A pirate flag featuring a stylized mouflon head at the center. The flag is black, and the mouflon is depicted in a bold and imaginative style, with exaggerated features and a fierce expression. The colors are vibrant, with the mouflon's features in white, red, and other bold colors, giving it a lively and adventurous look. The design is unique and dynamic, capturing the essence of a pirate flag while avoiding direct references to copyrighted styles.

Compiling ffmpeg with NVIDIA GPU Hardware Acceleration on Ubuntu 20.04LTS

Please note that the following commands were executed on a system that already had CUDA support so we might be missing a step or two to enable NVIDIA CUDA support.

Install necessary packages

sudo apt-get install build-essential yasm cmake libtool libc6 libc6-dev unzip wget libnuma1 libnuma-dev nvidia-cuda-toolkit;

Clone and install ffnvcodec

git clone https://git.videolan.org/git/ffmpeg/nv-codec-headers.git;
cd nv-codec-headers;
sudo make install;
cd -;

Clone and compile FFmpeg’s public GIT repository with NVIDIA GPU hardware acceleration

git clone https://git.ffmpeg.org/ffmpeg.git ffmpeg/;
cd ffmpeg;
./configure --enable-nonfree --enable-cuda-nvcc --enable-libnpp --extra-cflags=-I/usr/local/cuda/include --extra-ldflags=-L/usr/local/cuda/lib64 --disable-static --enable-shared;
make -j 8;
sudo make install;

SUCCESS!

After performing the above steps, we were able to process media using ffmpeg without stressing our CPU! The workload was transferred to the GPU!


How to check if PyTorch is using the GPU?

The following basic code, will import PyTorch into a project and test if GPU capabilities are enabled and available.

import torch

# Should produce "True"
torch.cuda.is_available()

# Should produce the number of available devices, if you have one device it should produce the value "1"
torch.cuda.device_count()

# If there is a device and it is the first one, it should produce the "0"
torch.cuda.current_device()

# Assuming that there is at least one device, with the following two commands we will get some information on the first available device

# Should produce something similar to "<torch.cuda.device object at 0x7f12b1a298d0>"
torch.cuda.device(0)

# Should produce something similar to "'GeForce GTX 1050 Ti'"
torch.cuda.get_device_name(0)

We are using Ubuntu 20.04 LTS and the NVidia drivers were installed automatically during installation.


Quick note on setting up our programming environment for Coursera.org “DeepLearning.AI TensorFlow Developer Professional Certificate” on Ubuntu 18.04LTS

Recently we were working on some local Jupyter notebooks for the “DeepLearning.AI TensorFlow Developer Professional Certificate“.

To prepare for the setup with GPU, we followed the instructions at https://www.tensorflow.org/install/gpu. But as we were going through the notebooks we noticed the following error at the terminal:

W tensorflow/stream_executor/platform/default/dso_loader.cc:59] Could not load dynamic library 'libcublas.so.10'; dlerror: libcublas.so.10: cannot open shared object file: No such file or directory

Even though libcublas.so.10 was installed it was not loading. Using find was saw that it was installed and available at the folder /usr/local/cuda-10.2/targets/x86_64-linux/lib/ but it was ignored.

To fix this, we added a new entry in ~/.profile as follows:

if [ -d "/usr/local/cuda-10.2/targets/x86_64-linux/lib/" ]; then
    export LD_LIBRARY_PATH=/usr/local/cuda-10.2/targets/x86_64-linux/lib/:${LD_LIBRARY_PATH}
fi

And then executed source ~/.profile from the terminal which we would start the jupyter-notebook command.

After this, library was loaded as expected.