How to limit frame rate for all games on Linux Mint?

8,203

NVIDIA-specific solution

Disclaimer: The use of an official driver package from the repository, NOT from a PPA, is recommended by me. You can learn how to install or update your drivers in my other question here: How to install the latest Nvidia drivers on Linux Mint 20


Important Notice

Disclaimer: This solution has been verified and tested only on one Ubuntu 18.04 or 20.04 based system. If you have an older one, DO NOT FOLLOW; use caution on newer versions too.


Solution for Ubuntu 18.04 and 20.04 based systems

This solution utilizes V-Sync (Vertical Synchronization). If you don't like using it, this solution is not for you.

Thank you, Xander, for the comment on enabling V-Sync. With this hint, I was able to find out, that I only need to do the following steps.

  1. Create the following new (if not yet existing) file in your favorite text editor:

    /etc/modprobe.d/nvidia-drm-nomodeset.conf
    
  2. Put this single line in there, save and close the file; in case the file exists already, then ensure this line is there:

    options nvidia-drm modeset=1
    
  3. Update all of your initramfs images with:

    sudo update-initramfs -u -k all
    

    or if you only want to test it, you can update just the latest image with:

    sudo update-initramfs -u
    
  4. Reboot your system.

  5. The V-Sync shall be on now, verify with:

    sudo cat /sys/module/nvidia_drm/parameters/modeset
    

It will say:

  • Y

if V-Sync is On

  • N

if V-Sync is Off


You should be done now, capped to your display refresh rate (usually 60).

In spite, I am satisfied with this solution, feel free to add your own (AMD-specific, Intel-specific, whatever...) to make this question useful for others.

Share:
8,203

Related videos on Youtube

Vlastimil Burián
Author by

Vlastimil Burián

I am passionate about Linux systems in general and POSIX shell scripting in particular.

Updated on September 18, 2022

Comments

  • Vlastimil Burián
    Vlastimil Burián almost 2 years

    Affected OS


    Related Hardware


    Problem

    There are about 200 - 300 FPS while playing any non-GPU-heavy game(s), so I'm thinking there is a lot of power being wasted, and my hardware is overheating if such a game is in the foreground for many hours straight. Additionally, even if I don't pay the electricity bills, I think my hardware is more prone to fault if playing on a maximum frame rate, which in ordinary games can be the above-stated, hardly believable, 200 - 300 FPS.


    Question

    How can I set an FPS limit for all games on my Nvidia-based hardware? If possible even, to name a few such games?

    For example, NOT an advertisement, Hexcells franchise uses so little GPU, and I tested my solution below on these games.