{"id":46451,"date":"2024-05-03T02:45:39","date_gmt":"2024-05-03T02:45:39","guid":{"rendered":"https:\/\/ubuntuhandbook.org\/?p=46451"},"modified":"2024-05-03T02:45:39","modified_gmt":"2024-05-03T02:45:39","slug":"install-nvidia-ubuntu-2404","status":"publish","type":"post","link":"https:\/\/ubuntuhandbook.org\/index.php\/2024\/05\/install-nvidia-ubuntu-2404\/","title":{"rendered":"How to Install &#038; Use NVIDIA Driver in Ubuntu 24.04 | 22.04"},"content":{"rendered":"<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/06\/nvidia-logo.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"alignleft size-thumbnail wp-image-38385\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/06\/nvidia-logo-250x250.webp\" alt=\"\" width=\"250\" height=\"250\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/06\/nvidia-logo-250x250.webp 250w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/06\/nvidia-logo-300x300.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/06\/nvidia-logo-600x600.webp 600w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/06\/nvidia-logo-768x768.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/06\/nvidia-logo.webp 1200w\" sizes=\"auto, (max-width: 250px) 100vw, 250px\" \/><\/a><\/p>\n<p>This is a step by step beginner&#8217;s guide shows how to install NVIDIA proprietary driver in Ubuntu. And, how to switch between Intel\/AMD and NVIDIA GPU, run specific app\/game with NVIDIA while leaving others rendered by integrated graphics card.<\/p>\n<p>While installing Ubuntu, the wizard provides an option to install the NVIDIA proprietary driver alongside. If you didn&#8217;t enable that option, then here&#8217;s how to manually install it afterward.<\/p>\n<p><!--more--><\/p>\n<h3>Step 1: Enable Restricted Repository<\/h3>\n<p>The NVIDIA proprietary driver is a non-free software that is available in the <code>restricted<\/code> system repository.<\/p>\n<p>That repository is usually enabled by default. Just in case, you can launch <b>Software &amp; Updates<\/b> and verify by checking &#8220;<i>Proprietary drivers for devices (restricted)<\/i>&#8221; option.<\/p>\n<div id=\"attachment_38387\" style=\"width: 610px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/06\/enable-restricted.webp\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-38387\" class=\"size-large wp-image-38387\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/06\/enable-restricted-600x314.webp\" alt=\"\" width=\"600\" height=\"314\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/06\/enable-restricted-600x314.webp 600w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/06\/enable-restricted-300x157.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/06\/enable-restricted-768x402.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/06\/enable-restricted.webp 998w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><p id=\"caption-attachment-38387\" class=\"wp-caption-text\">Make sure &#8216;restricted&#8217; repository enabled<\/p><\/div>\n<p>After that, it&#8217;s <b>also important<\/b> to install all available updates! Which can be done either by using <b>Software Updater<\/b><\/p>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/software-updater.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-46452\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/software-updater.webp\" alt=\"\" width=\"645\" height=\"207\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/software-updater.webp 645w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/software-updater-300x96.webp 300w\" sizes=\"auto, (max-width: 645px) 100vw, 645px\" \/><\/a><\/p>\n<p>or press <code>Ctrl+Alt+T<\/code> to open terminal and run the command below instead:<\/p>\n<pre>sudo apt update &amp;&amp; sudo apt upgrade -y<\/pre>\n<p>When done, restart your computer to apply updates if prompted!<\/p>\n<h3>Step 2: Install NVIDIA Driver<\/h3>\n<p>Now, search for and launch <b>Additional Drivers<\/b> utility. It will list available drivers for your device. Choose desire one (in my case, I selected nvidia-driver-535), then click &#8220;Apply Changes&#8221;.<\/p>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/install-nvidia.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-46453\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/install-nvidia-700x436.webp\" alt=\"\" width=\"610\" height=\"380\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/install-nvidia-700x436.webp 700w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/install-nvidia-300x187.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/install-nvidia-768x478.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/install-nvidia.webp 1006w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><\/a><\/p>\n<p>There&#8217;ll be a little process bar in bottom of the app window. When done installing the driver, it prompts that &#8220;You need to restart the computer to complete the driver changes&#8221;. Just click on &#8220;Restart&#8221; button to apply.<\/p>\n<h3>Step 3: Switch Between NVIDIA and integrated GPU<\/h3>\n<p>For laptop users with hybrid graphics (Intel + NVIDIA in my case), just search for and launch <b>NVIDIA Settings<\/b> utility.<\/p>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/launch-nvidia-settings.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-46454\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/launch-nvidia-settings.webp\" alt=\"\" width=\"524\" height=\"270\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/launch-nvidia-settings.webp 524w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/launch-nvidia-settings-300x155.webp 300w\" sizes=\"auto, (max-width: 524px) 100vw, 524px\" \/><\/a><\/p>\n<p>When it opens, you can navigate to <b>PRIME Profiles<\/b> tab, for switching between following GPU modes:<\/p>\n<ul>\n<li><b>NVIDIA (Performance)<\/b> &#8211; use NVIDIA only for the Desktop.<\/li>\n<li><b>NVIDIA On-Demand<\/b> &#8211; use integrated GPU (Intel in my case), and only NVIDIA when specified.<\/li>\n<\/ul>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/nvidia-settings-selectgpu.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-full wp-image-46456\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/nvidia-settings-selectgpu.webp\" alt=\"\" width=\"701\" height=\"526\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/nvidia-settings-selectgpu.webp 701w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/nvidia-settings-selectgpu-300x225.webp 300w\" sizes=\"auto, (max-width: 701px) 100vw, 701px\" \/><\/a><\/p>\n<p><b>The Intel (Power Saving Mode)<\/b> mode is grayed out. If you want to choose it, then press <code>Ctrl+Alt+T<\/code> to open up a terminal window, and run command instead:<\/p>\n<pre>sudo prime-select intel<\/pre>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/prime-select-intel.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-46457\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/prime-select-intel-700x218.webp\" alt=\"\" width=\"610\" height=\"190\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/prime-select-intel-700x218.webp 700w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/prime-select-intel-300x94.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/prime-select-intel-768x239.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/prime-select-intel.webp 866w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><\/a><\/p>\n<p>After switching GPU, you need to <b>restart computer<\/b> to apply change!<\/p>\n<p><b>To tell which GPU is currently in use<\/b>, run command:<\/p>\n<pre>glxinfo |grep -E \"OpenGL vendor|OpenGL renderer\"<\/pre>\n<p><i>If command not found, run <code>sudo apt install mesa-utils<\/code> to install<\/i>.<br \/>\n<a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/verify-gpu.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-46458\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/verify-gpu-700x300.webp\" alt=\"\" width=\"610\" height=\"261\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/verify-gpu-700x300.webp 700w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/verify-gpu-300x129.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/verify-gpu-768x329.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/verify-gpu.webp 1006w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><\/a><\/p>\n<p><b>NOTE: In my NVIDIA GeForce 940M with nvidia-driver-535, the performance mode seems NOT being friendly with Wayland. Ubuntu will default to Xorg session when <code>NVIDIA (Performance)<\/code> mode enabled. If select to manually login Wayland, then it automatically falls back to Intel graphics (On-Demand mode).<\/b><\/p>\n<h3>Step 4: (Optional) System Status Menu Options to switch GPU mode<\/h3>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/nvidia-quicksettings.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-46459\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/nvidia-quicksettings-466x700.webp\" alt=\"\" width=\"466\" height=\"700\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/nvidia-quicksettings-466x700.webp 466w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/nvidia-quicksettings-200x300.webp 200w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/nvidia-quicksettings.webp 479w\" sizes=\"auto, (max-width: 466px) 100vw, 466px\" \/><\/a><\/p>\n<p>For the default GNOME Desktop, there&#8217;s an extension adds top-right system status menu option to switch GPU mode.<\/p>\n<p><b>1.<\/b> The extension however needs a free open-source tool called <code>envycontrol<\/code>. To install it, simply download the <b>.deb<\/b> package from its project page:<\/p>\n<div class=\"wp-block-buttons aligncenter\">\n<div class=\"wp-block-button is-style-fill\"><a class=\"wp-block-button__link has-vivid-cyan-blue-to-vivid-purple-gradient-background has-text-color has-background\" href=\"https:\/\/github.com\/bayasdev\/envycontrol\/releases\" target=\"_blank\" rel=\"noreferrer noopener\">Download Envycontrol (under Assets)<\/a><\/div>\n<\/div>\n<p>Then, press <code>Ctrl+Alt+T<\/code> to open up a terminal window, and run command to install the downloaded .deb package:<\/p>\n<pre>sudo apt install ~\/Downloads\/python3-envycontrol_*_all.deb<\/pre>\n<p>If you didn&#8217;t save it in Downloads folder, then drag&#8217;n&#8217;drop file into terminal after typing <code>sudo apt install<\/code> plus a space.<\/p>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/install-envycontrol.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-46460\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/install-envycontrol-700x346.webp\" alt=\"\" width=\"610\" height=\"302\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/install-envycontrol-700x346.webp 700w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/install-envycontrol-300x148.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/install-envycontrol-768x379.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/install-envycontrol.webp 936w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><\/a><\/p>\n<p><b>2.<\/b> Next, search for and install <b>Extension Manager<\/b> from either Ubuntu Software or App Center (filter by Debian package).<\/p>\n<p>Launch <b>Extension Manager<\/b>, navigate to &#8216;browse&#8217; tab, finally search and install &#8220;GPU profile selector&#8221; extension.<\/p>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/gpu-profiler-extension.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-46461\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/gpu-profiler-extension-700x548.webp\" alt=\"\" width=\"610\" height=\"478\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/gpu-profiler-extension-700x548.webp 700w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/gpu-profiler-extension-300x235.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/gpu-profiler-extension-768x601.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/gpu-profiler-extension.webp 922w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><\/a><\/p>\n<p>Once installed, you can go top-right system status menu (aka Quick Settings) for the new menu options.<\/p>\n<h3>Step 5: Run Certain Apps via NVIDIA GPU while others by Intel<\/h3>\n<p>When in <b>NVIDIA On-Demand<\/b>, most things are rendered by integrated GPU (Intel in my case). If you want to run games or some apps using NVIDIA, then this step may help.<\/p>\n<p>1. First, for CUDA apps, just open terminal (Ctrl+Alt+T) and run command:<\/p>\n<pre>sudo apt install nvidia-cuda-toolkit<\/pre>\n<p>Then there&#8217;ll be application-specific menu to tell it which device to use.<\/p>\n<p>2. For other apps or games, just set environment variables.<\/p>\n<p><b><code>__NV_PRIME_RENDER_OFFLOAD=1<\/code><\/b><br \/>\n<b><code>__GLX_VENDOR_LIBRARY_NAME=nvidia<\/code><\/b><\/p>\n<p>For example, run the command below from terminal to launch <b>supertux2<\/b> (the classic jump &amp; run game) and render via NVIDA GPU:<\/p>\n<pre>__NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia supertux2<\/pre>\n<p>And, you can verify by running <code>sudo apt install nvtop<\/code> command, then run <b>nvtop<\/b> to monitor your GPU usage.<\/p>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/run-game-nvidia.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-46462\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/run-game-nvidia-700x394.webp\" alt=\"\" width=\"610\" height=\"343\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/run-game-nvidia-700x394.webp 700w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/run-game-nvidia-300x169.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/run-game-nvidia-768x432.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/run-game-nvidia-1536x864.webp 1536w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/run-game-nvidia-1320x743.webp 1320w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/run-game-nvidia.webp 1920w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><\/a><\/p>\n<p>To make it permanent, just edit the <b>.desktop<\/b> shortcut file for that app or game. Depends on the app package, find it in following locations:<\/p>\n<ul>\n<li><code>\/usr\/share\/applications<\/code> for deb and snap packages.<\/li>\n<li><code>.local\/share\/applications<\/code> for user added or app auto-created shortcuts.<\/li>\n<li><code>\/var\/lib\/flatpak\/exports\/share\/applications<\/code> for flatpak packages.<\/li>\n<\/ul>\n<p>Once you found out the corresponding shortcut file, edit it and change the <b>Exec<\/b> line to look like:<\/p>\n<pre>Exec=env __NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia supertux2<\/pre>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/game-exe-nvidia.webp\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter size-large wp-image-46463\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/game-exe-nvidia-700x486.webp\" alt=\"\" width=\"610\" height=\"424\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/game-exe-nvidia-700x486.webp 700w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/game-exe-nvidia-300x208.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/game-exe-nvidia-768x533.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2024\/05\/game-exe-nvidia.webp 965w\" sizes=\"auto, (max-width: 610px) 100vw, 610px\" \/><\/a><\/p>\n<p>Finally, try launching the app or game from start menu or GNOME app grid, and verify by <code>nvtop<\/code> command.<\/p>\n<h3>Summary:<\/h3>\n<p>In this tutorial, I&#8217;ve showed you how to install NVIDIA driver in Ubuntu. In short, just enable &#8216;restricted&#8217; repository, then select Apply a driver from &#8220;Additional Drivers&#8221; utility.<\/p>\n<p>Next, you can use either NVIDIA Settings or <code>prime-select<\/code> command to switch between integrated and NVIDIA GPUs. And, by settings environment variables you may run certain apps\/games with NVIDIA GPU while leaving others rendered by integrated GPU.<\/p>","protected":false},"excerpt":{"rendered":"<p>This is a step by step beginner&#8217;s guide shows how to install NVIDIA proprietary driver in Ubuntu. And, how to switch between Intel\/AMD and NVIDIA GPU, run specific app\/game with NVIDIA while leaving others rendered by integrated graphics card. While installing Ubuntu, the wizard provides an option to install the NVIDIA proprietary driver alongside. If [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":38385,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[9],"tags":[656],"class_list":["post-46451","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-howtos","tag-nvidia"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts\/46451","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/comments?post=46451"}],"version-history":[{"count":0,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts\/46451\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/media\/38385"}],"wp:attachment":[{"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/media?parent=46451"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/categories?post=46451"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/tags?post=46451"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}