{"id":33890,"date":"2021-06-04T16:03:05","date_gmt":"2021-06-04T16:03:05","guid":{"rendered":"https:\/\/ubuntuhandbook.org\/?p=33890"},"modified":"2022-05-07T17:01:30","modified_gmt":"2022-05-07T17:01:30","slug":"install-nvidia-driver-switch-between-intel-nvidia-ubuntu","status":"publish","type":"post","link":"https:\/\/ubuntuhandbook.org\/index.php\/2021\/06\/install-nvidia-driver-switch-between-intel-nvidia-ubuntu\/","title":{"rendered":"Install NVIDIA Driver &#038; Switch Between Intel and NVIDIA in Ubuntu 22.04"},"content":{"rendered":"<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/06\/nvidia-logo.webp\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/06\/nvidia-logo-250x250.webp\" alt=\"\" width=\"250\" height=\"250\" class=\"alignleft size-thumbnail wp-image-38385\" 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 simple tutorial shows how to install the NVIDIA proprietary driver in <b>Ubuntu 22.04<\/b> and switch between dedicated and integrated GPU.<\/p>\n<p>Since Ubuntu provides the proprietary driver packages via its restricted repositories, user may install NVIDIA driver as easy as a few clicks.<\/p>\n<h3>Install NVIDIA Driver<\/h3>\n<p>1.) Firstly, click on top-left corner &#8216;<i>Activities<\/i>&#8216;, and then search for and open &#8216;Softwre &#038; Updates&#8217; utility.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/06\/open-softwareupdates.webp\" alt=\"\" width=\"530\" height=\"268\" class=\"aligncenter size-full wp-image-38386\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/06\/open-softwareupdates.webp 530w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/06\/open-softwareupdates-300x152.webp 300w\" sizes=\"auto, (max-width: 530px) 100vw, 530px\" \/><\/p>\n<p>When the tool opens, make sure the &#8220;<i>Proprietary drives for devices (restricted)<\/i>&#8221; is enabled.<\/p>\n<div id=\"attachment_38387\" style=\"width: 610px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-38387\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/06\/enable-restricted-600x314.webp\" alt=\"\" width=\"600\" height=\"314\" class=\"size-large wp-image-38387\" 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\" \/><p id=\"caption-attachment-38387\" class=\"wp-caption-text\">Make sure &#8216;restricted&#8217; repository enabled<\/p><\/div>\n<p>2.) Next, navigate to &#8216;<i><b>Additional Drivers<\/b><\/i>&#8216; tab. There it should list all available graphics drivers.<\/p>\n<p><i>If it shows nothing, press <b>Ctrl+Alt+T<\/b> to open terminal and run command <code>sudo apt update<\/code> to refresh package cache. Then re-launch the &#8216;Software &#038; Updates&#8217; utility.<\/i><\/p>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/06\/install-nvidia.webp\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/06\/install-nvidia-600x384.webp\" alt=\"\" width=\"600\" height=\"384\" class=\"aligncenter size-large wp-image-38388\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/06\/install-nvidia-600x384.webp 600w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/06\/install-nvidia-300x192.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/06\/install-nvidia-768x491.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/06\/install-nvidia.webp 1009w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<p>Choose one of the drivers from the list and click on &#8216;<b>Apply Changes<\/b>&#8216; to install it. There will be a little bar indicates the installing process. When done, restart your computer!<\/p>\n<h3>Switch between NVIDIA and Intel Graphics:<\/h3>\n<p>After restart, your machine will be on performance mode with the dedicated GPU. To switch GPU mode, search for and open &#8216;<b>NVIDIA X Server Settings<\/b>&#8216;.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/06\/launch-nvidiasettings-600x303.webp\" alt=\"\" width=\"600\" height=\"303\" class=\"aligncenter size-large wp-image-38389\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/06\/launch-nvidiasettings-600x303.webp 600w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/06\/launch-nvidiasettings-300x152.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/06\/launch-nvidiasettings.webp 625w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/p>\n<p>When the app opens, navigate to &#8216;<b>PRIME Profiles<\/b>&#8216;. Then you&#8217;ll see three options available in the right:<\/p>\n<ul>\n<li><b>NVIDIA (Performance Mode)<\/b> &#8211; use dedicated NVIDIA GPU to render Ubuntu desktop.<\/li>\n<li><b>NVIDIA On-Demand<\/b> &#8211; use integrated graphics to render desktop, but possible to offload specific apps via dedicated GPU.<\/li>\n<li><b>Intel (Power Saving Mode)<\/b> &#8211; use integrated graphics to render Ubuntu desktop.<\/li>\n<\/ul>\n<p>In my case, the &#8220;Intel (Power Saving Mode)&#8221; is somehow grayed out. As a workaround, choose Intel graphics card by running <code>sudo prime-select intel<\/code> in terminal.<\/p>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/06\/switch-gpu.webp\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/06\/switch-gpu-600x303.webp\" alt=\"\" width=\"600\" height=\"303\" class=\"aligncenter size-large wp-image-38390\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/06\/switch-gpu-600x303.webp 600w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/06\/switch-gpu-300x151.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/06\/switch-gpu-768x388.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/06\/switch-gpu.webp 957w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<p>Changing GPU mode however needs log out and back in to apply changes.<\/p>\n<h3>Run certain apps via NVIDIA GPU while rendering desktop via integrated graphics<\/h3>\n<p>By setting GPU mode to &#8220;NVIDIA On-Demand&#8221;, you may run certain apps via NVIDIA GPU, while others handled by the integrated GPU.<\/p>\n<p>1.) For CUDA apps, you need to run command in terminal (Ctrl+Alt+T) to install the <code>nvidia-cuda-toolkit<\/code> package.<\/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, just use the following 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>You can do this by launching apps from command line. For example, launch SuperTuxkart (a kart racing game) via command:<\/p>\n<pre>__NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia supertuxkart<\/pre>\n<p>Or, edit the application&#8217;s <code>.desktop<\/code> file which is usually under &#8220;\/user\/share\/applications&#8221; directory. And, change the line of &#8216;Exec&#8217; to:<\/p>\n<pre>Exec=env __NV_PRIME_RENDER_OFFLOAD=1 __GLX_VENDOR_LIBRARY_NAME=nvidia supertuxkart<\/pre>\n<h3>Add System Menu option to Switch CPU<\/h3>\n<p>To make it easy to switch between your GPUs, there&#8217;s a Gnome Extension available to add options into system tray menu.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/06\/gpu-profiles.png\" alt=\"\" width=\"319\" height=\"533\" class=\"aligncenter size-full wp-image-39520\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/06\/gpu-profiles.png 319w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/06\/gpu-profiles-180x300.png 180w\" sizes=\"auto, (max-width: 319px) 100vw, 319px\" \/><\/p>\n<p>1.) To get the menu option, you need to first install the open-source <a href=\"https:\/\/github.com\/geminis3\/envycontrol\" rel=\"noopener\" target=\"_blank\">EnvyControl<\/a> tool. Press <b>Ctrl+Alt+T<\/b> on keyboard to open terminal, and run the command below one by one:<\/p>\n<ul>\n<li>Use git command to grab the source:\n<pre>git clone https:\/\/github.com\/geminis3\/envycontrol.git<\/pre>\n<\/li>\n<li>Navigate to the source folder, and install it for global use via pip package manager:\n<pre>cd envycontrol && sudo pip3 install .<\/pre>\n<\/li>\n<\/ul>\n<p>If the pip3 command does not exist, run <code>sudo apt install python3-pip<\/code> command to install it.<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/06\/install-envycontrol-600x407.webp\" alt=\"\" width=\"600\" height=\"407\" class=\"alignnone size-large wp-image-39523\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/06\/install-envycontrol-600x407.webp 600w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/06\/install-envycontrol-300x203.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/06\/install-envycontrol-768x521.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/06\/install-envycontrol.webp 786w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/p>\n<p>As the project page mentioned, users have to run the following 2 commands one by one to prevent Ubuntu&#8217;s own gpu-manager from interfering:<\/p>\n<pre>sudo prime-select on-demand<\/pre>\n<pre>sudo systemctl disable gpu-manager.service<\/pre>\n<p>2.) Next, run command to make sure you have the agent packages installed for installing Gnome Extensions:<\/p>\n<pre>sudo apt install chrome-gnome-shell gnome-shell-extension-prefs<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/04\/apt-chrome-shell-600x403.webp\" alt=\"\" width=\"600\" height=\"403\" class=\"aligncenter size-large wp-image-39006\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/04\/apt-chrome-shell-600x403.webp 600w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/04\/apt-chrome-shell-300x201.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2022\/04\/apt-chrome-shell.webp 764w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/p>\n<p>3.) Finally, go to the extension page and turn on the slider icon to install it:<\/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:\/\/extensions.gnome.org\/extension\/5009\/gpu-profile-selector\/\" target=\"_blank\" rel=\"noreferrer noopener\">GPU Profile Selector Extension<\/a><\/div>\n<\/div>\n<p>NOTE 1: The pre-installed Firefox does not support this stuff so far! Use another browser, or install back <a href=\"https:\/\/ubuntuhandbook.org\/index.php\/2022\/04\/install-firefox-deb-ubuntu-22-04\/\" rel=\"noopener\" target=\"_blank\">Firefox as classic deb package<\/a>.<\/p>\n<p>NOTE 2: If you don&#8217;t see the on\/off switch in that page, click the &#8216;<i>click here to install browser extension<\/i>&#8216; to install extension for your web browser and refresh the page.<\/p>\n<p><a href=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/06\/install-gpu-profiles.webp\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/06\/install-gpu-profiles-600x322.webp\" alt=\"\" width=\"600\" height=\"322\" class=\"aligncenter size-large wp-image-39524\" srcset=\"https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/06\/install-gpu-profiles-600x322.webp 600w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/06\/install-gpu-profiles-300x161.webp 300w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/06\/install-gpu-profiles-768x412.webp 768w, https:\/\/ubuntuhandbook.org\/wp-content\/uploads\/2021\/06\/install-gpu-profiles.webp 1114w\" sizes=\"auto, (max-width: 600px) 100vw, 600px\" \/><\/a><\/p>\n<p>The menu option should appear immediately after successfully installed the extension. If not, press <i>Windows<\/i> (<i>Super<\/i>) key on keyboard or click &#8220;Activities&#8221; on top panel, and then search for and open the &#8220;<b>Gnome Extensions<\/b>&#8221; app to manage your extension.<\/p>","protected":false},"excerpt":{"rendered":"<p>This simple tutorial shows how to install the NVIDIA proprietary driver in Ubuntu 22.04 and switch between dedicated and integrated GPU. Since Ubuntu provides the proprietary driver packages via its restricted repositories, user may install NVIDIA driver as easy as a few clicks. Install NVIDIA Driver 1.) Firstly, click on top-left corner &#8216;Activities&#8216;, and then [&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-33890","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\/33890","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=33890"}],"version-history":[{"count":0,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/posts\/33890\/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=33890"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/categories?post=33890"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ubuntuhandbook.org\/index.php\/wp-json\/wp\/v2\/tags?post=33890"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}