{"id":4181,"date":"2020-02-16T11:22:40","date_gmt":"2020-02-16T11:22:40","guid":{"rendered":"https:\/\/miloserdov.org\/?p=4181"},"modified":"2021-09-28T07:26:16","modified_gmt":"2021-09-28T07:26:16","slug":"how-to-install-nvidia-drivers-cuda-and-bumblebee-on-arch-linux-blackarch","status":"publish","type":"post","link":"https:\/\/miloserdov.org\/?p=4181","title":{"rendered":"How to install NVIDIA drivers, CUDA and Bumblebee on Arch Linux \/ BlackArch"},"content":{"rendered":"<div class=\"0b20205ac99e89c6cabdb919fd9d1a8a\" data-index=\"1\" style=\"float: none; margin:10px 0 10px 0; text-align:center;\">\n<script async src=\"\/\/pagead2.googlesyndication.com\/pagead\/js\/adsbygoogle.js\"><\/script>\r\n<ins class=\"adsbygoogle\"\r\n     style=\"display:block; text-align:center;\"\r\n     data-ad-format=\"fluid\"\r\n     data-ad-layout=\"in-article\"\r\n     data-ad-client=\"ca-pub-7219829351026140\"\r\n     data-ad-slot=\"9942251718\"><\/ins>\r\n<script>\r\n     (adsbygoogle = window.adsbygoogle || []).push({});\r\n<\/script>\r\n\r\n\n<\/div>\n<p style=\"text-align: justify;\">\n\tIn this note we will consider the following topics:\n<\/p>\n<ul>\n<li style=\"text-align: justify;\">\n\t\tHow to check active GPU in Linux\n\t<\/li>\n<li style=\"text-align: justify;\">\n\t\tHow to switch from integrated graphics to a discrete NVidia graphics card\n\t<\/li>\n<li style=\"text-align: justify;\">\n\t\tHow to install and use Bumblebee to automatically switch between integrated and discrete graphics cards (how to enable NVIDIA Optimus on Linux)\n\t<\/li>\n<\/ul>\n<h2 style=\"text-align: justify;\">\n\tHow to check active GPU in Linux<br \/>\n<\/h2>\n<p style=\"text-align: justify;\">\n\tThere are several commands that will show which video card is used:\n<\/p>\n<pre class=\"brush:bash;\">\r\nglxinfo|egrep &quot;OpenGL vendor|OpenGL renderer&quot;<\/pre>\n<p style=\"text-align: justify;\">\n\tOutput Example:\n<\/p>\n<pre class=\"brush:plain;\">\r\nOpenGL vendor string: Intel Open Source Technology Center\r\nOpenGL renderer string: Mesa DRI Intel(R) UHD Graphics 630 (Coffeelake 3x8 GT2)<\/pre>\n<p style=\"text-align: justify;\">\n\tThis is the same command, but launched via <strong>optirun<\/strong> from the <strong>Bumblebee<\/strong> package:\n<\/p>\n<pre class=\"brush:bash;\">\r\noptirun glxinfo|egrep &quot;OpenGL vendor|OpenGL renderer&quot;<\/pre>\n<p style=\"text-align: justify;\">\n\tSample output that shows that an NVIDIA graphics card is active:\n<\/p>\n<pre class=\"brush:plain;\">\r\nOpenGL vendor string: NVIDIA Corporation\r\nOpenGL renderer string: GeForce GTX 1050 Ti\/PCIe\/SSE2<\/pre>\n<p style=\"text-align: justify;\">\n\tMore about optirun and Bumblebee will come later a bit.\n<\/p>\n<p style=\"text-align: justify;\">\n\tAnother command that displays information about the active GPU (and a cool triangle as a bonus):\n<\/p>\n<pre class=\"brush:bash;\">\r\nglxheads<\/pre>\n<p style=\"text-align: justify;\">\n\t<a href=\"https:\/\/miloserdov.org\/wp-content\/uploads\/2020\/02\/glxheads.png\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" class=\"alignnone size-full wp-image-4190\" height=\"643\" src=\"https:\/\/miloserdov.org\/wp-content\/uploads\/2020\/02\/glxheads.png\" width=\"831\" srcset=\"https:\/\/miloserdov.org\/wp-content\/uploads\/2020\/02\/glxheads.png 831w, https:\/\/miloserdov.org\/wp-content\/uploads\/2020\/02\/glxheads-768x594.png 768w\" sizes=\"(max-width: 831px) 100vw, 831px\" \/><\/a>\n<\/p>\n<p style=\"text-align: justify;\">\n\tUsing the <strong>lspci<\/strong> command with certain options, you can display information about the GPU. Any controller with <strong>[VGA controller]<\/strong> at the end is your currently active GPU. The others are switched off. Command to filter data:\n<\/p>\n<pre class=\"brush:bash;\">\r\nlspci -vnnn | perl -lne &#39;print if \/^\\d+\\:.+(\\[\\S+\\:\\S+\\])\/' | grep '\\[VGA controller\\]&#39;<\/pre>\n<p style=\"text-align: justify;\">\n\tOutput Example:\n<\/p>\n<pre class=\"brush:plain;\">\r\n00:02.0 VGA compatible controller [0300]: Intel Corporation UHD Graphics 630 (Mobile) [8086:3e9b] (prog-if 00 [VGA controller])<\/pre>\n<h2 style=\"text-align: justify;\">\n\tHow to check whether an NVIDIA graphics card is active<br \/>\n<\/h2>\n<p style=\"text-align: justify;\">\n\tThe following command will show the processes that the NVIDIA graphics card uses (if there are no processes, then the video adapter is not used):\n<\/p>\n<pre class=\"brush:bash;\">\r\nsudo lsof \/dev\/nvidia*<\/pre>\n<p style=\"text-align: justify;\">\n\tAnother command that shows the processes that consume the resources of an NVIDIA graphics card, as well as its load level, temperature and other metrics:\n<\/p>\n<pre class=\"brush:bash;\">\r\nnvidia-smi<\/pre>\n<h2 style=\"text-align: justify;\">\n\tHow to install NVIDIA video driver on Arch Linux or BlackArch<br \/>\n<\/h2>\n<p style=\"text-align: justify;\">\n\tTo install the NVidia driver in Arch Linux, BlackArch and their derivatives, run the command:\n<\/p>\n<pre class=\"brush:bash;\">\r\nsudo pacman -S nvidia cuda nvidia-settings<\/pre>\n<h2 style=\"text-align: justify;\">\n\tHow to install and use Bumblebee (how to enable NVIDIA Optimus on Arch Linux)<br \/>\n<\/h2>\n<p style=\"text-align: justify;\">\n\tThe Bumblebee package is needed to automatically switch between integrated and discrete graphics cards. Your card must support NVidia Optimus technology, a list of supporting cards can be found on this page: <a href=\"https:\/\/www.geforce.com\/hardware\/technology\/optimus\/supported-gpus\" rel=\"noopener noreferrer\" target=\"_blank\">https:\/\/www.geforce.com\/hardware\/technology\/optimus\/supported-gpus<\/a>\n<\/p>\n<p style=\"text-align: justify;\">\n\tIf your card is there, then proceed to the following commands. You must already have the NVIDIA proprietary driver installed, as shown above.\n<\/p>\n<p style=\"text-align: justify;\">\n\tOn Arch Linux, BlackArch, and their derivatives, run:\n<\/p>\n<pre class=\"brush:bash;\">\r\nsudo pacman -S bumblebee virtualgl bbswitch acpid mesa\r\nsudo systemctl enable bumblebeed.service\r\nsudo systemctl enable acpid.service\r\nsudo usermod -a -G bumblebee $USER<\/pre>\n<h2 style=\"text-align: justify;\">\n\tSystem freezes after installing Bumblebee<br \/>\n<\/h2>\n<p style=\"text-align: justify;\">\n\tI ran into a problem that Bumblebee works, but when using some commands that use CUDA or access kernel modules, the system freezes. To check if you have this problem, run the <strong>lspci<\/strong> command, for example:\n<\/p>\n<pre class=\"brush:bash;\">\r\nlspci -k<\/pre>\n<p style=\"text-align: justify;\">\n\tIf the system freezes completely, reboot and remove the <strong>bbswitch<\/strong> package.\n<\/p>\n<pre class=\"brush:bash;\">\r\nsudo pacman -R bbswitch<\/pre>\n<h2 style=\"text-align: justify;\">\n\tHow to use Bumblebee \/ NVIDIA Optimus on Linux<br \/>\n<\/h2>\n<p style=\"text-align: justify;\">\n\tNow any program that should use the NVIDIA graphics card can be launched with a command of the form:\n<\/p>\n<pre class=\"brush:bash;\">\r\noptirun PROGRAM<\/pre>\n<p style=\"text-align: justify;\">\n\tWhen <strong>optirun<\/strong> is not used, the NVIDIA card must be in the off state, which should save electricity.\n<\/p>\n<h2 style=\"text-align: justify;\">\n\tHow to test Bumblebee \/ NVIDIA Optimus on Linux<br \/>\n<\/h2>\n<p style=\"text-align: justify;\">\n\tRun the GPU performance test with the usual command:\n<\/p>\n<pre class=\"brush:bash;\">\r\nglxgears<\/pre>\n<p style=\"text-align: justify;\">\n\t<a href=\"https:\/\/miloserdov.org\/wp-content\/uploads\/2020\/02\/glxgears.png\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" class=\"alignnone size-full wp-image-4189\" height=\"491\" src=\"https:\/\/miloserdov.org\/wp-content\/uploads\/2020\/02\/glxgears.png\" width=\"818\" srcset=\"https:\/\/miloserdov.org\/wp-content\/uploads\/2020\/02\/glxgears.png 818w, https:\/\/miloserdov.org\/wp-content\/uploads\/2020\/02\/glxgears-768x461.png 768w\" sizes=\"(max-width: 818px) 100vw, 818px\" \/><\/a>\n<\/p>\n<p style=\"text-align: justify;\">\n\tAnd also with <strong>optirun<\/strong>:\n<\/p>\n<pre class=\"brush:bash;\">\r\noptirun glxgears<\/pre>\n<p style=\"text-align: justify;\">\n\t<a href=\"https:\/\/miloserdov.org\/wp-content\/uploads\/2020\/02\/optirun-glxgears.png\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" class=\"alignnone size-full wp-image-4188\" height=\"494\" src=\"https:\/\/miloserdov.org\/wp-content\/uploads\/2020\/02\/optirun-glxgears.png\" width=\"820\" srcset=\"https:\/\/miloserdov.org\/wp-content\/uploads\/2020\/02\/optirun-glxgears.png 820w, https:\/\/miloserdov.org\/wp-content\/uploads\/2020\/02\/optirun-glxgears-768x463.png 768w\" sizes=\"(max-width: 820px) 100vw, 820px\" \/><\/a>\n<\/p>\n<p style=\"text-align: justify;\">\n\tNote that FPS has grown approximately 20 times.\n<\/p>\n<p style=\"text-align: justify;\">\n\tAnother option for a video card test:\n<\/p>\n<pre class=\"brush:bash;\">\r\nglxspheres64<\/pre>\n<p style=\"text-align: justify;\">\n\t<a href=\"https:\/\/miloserdov.org\/wp-content\/uploads\/2020\/02\/glxspheres64.png\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" class=\"alignnone size-full wp-image-4187\" height=\"1021\" src=\"https:\/\/miloserdov.org\/wp-content\/uploads\/2020\/02\/glxspheres64.png\" width=\"1590\" srcset=\"https:\/\/miloserdov.org\/wp-content\/uploads\/2020\/02\/glxspheres64.png 1590w, https:\/\/miloserdov.org\/wp-content\/uploads\/2020\/02\/glxspheres64-1000x642.png 1000w, https:\/\/miloserdov.org\/wp-content\/uploads\/2020\/02\/glxspheres64-1500x963.png 1500w, https:\/\/miloserdov.org\/wp-content\/uploads\/2020\/02\/glxspheres64-768x493.png 768w, https:\/\/miloserdov.org\/wp-content\/uploads\/2020\/02\/glxspheres64-1536x986.png 1536w\" sizes=\"(max-width: 1590px) 100vw, 1590px\" \/><\/a>\n<\/p>\n<p style=\"text-align: justify;\">\n\tAnd also with <strong>optirun<\/strong>:\n<\/p>\n<pre class=\"brush:bash;\">\r\noptirun glxspheres64<\/pre>\n<p style=\"text-align: justify;\">\n\t<a href=\"https:\/\/miloserdov.org\/wp-content\/uploads\/2020\/02\/optirun-glxspheres64.png\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" class=\"alignnone size-full wp-image-4186\" height=\"944\" src=\"https:\/\/miloserdov.org\/wp-content\/uploads\/2020\/02\/optirun-glxspheres64.png\" width=\"1509\" srcset=\"https:\/\/miloserdov.org\/wp-content\/uploads\/2020\/02\/optirun-glxspheres64.png 1509w, https:\/\/miloserdov.org\/wp-content\/uploads\/2020\/02\/optirun-glxspheres64-1000x626.png 1000w, https:\/\/miloserdov.org\/wp-content\/uploads\/2020\/02\/optirun-glxspheres64-1500x938.png 1500w, https:\/\/miloserdov.org\/wp-content\/uploads\/2020\/02\/optirun-glxspheres64-768x480.png 768w\" sizes=\"(max-width: 1509px) 100vw, 1509px\" \/><\/a>\n<\/p>\n<p style=\"text-align: justify;\">\n\tYou should see a performance boost when using <strong>optirun<\/strong>.\n<\/p>\n<p style=\"text-align: justify;\">\n\tWhile these tests are running, run the command:\n<\/p>\n<pre class=\"brush:bash;\">\r\nnvidia-smi<\/pre>\n<p style=\"text-align: justify;\">\n\t<a href=\"https:\/\/miloserdov.org\/wp-content\/uploads\/2020\/02\/nvidia-smi.png\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" class=\"alignnone size-full wp-image-4185\" height=\"493\" src=\"https:\/\/miloserdov.org\/wp-content\/uploads\/2020\/02\/nvidia-smi.png\" width=\"818\" srcset=\"https:\/\/miloserdov.org\/wp-content\/uploads\/2020\/02\/nvidia-smi.png 818w, https:\/\/miloserdov.org\/wp-content\/uploads\/2020\/02\/nvidia-smi-768x463.png 768w\" sizes=\"(max-width: 818px) 100vw, 818px\" \/><\/a>\n<\/p>\n<p style=\"text-align: justify;\">\n\tYou should see processes that use a discrete graphics card.\n<\/p>\n<p style=\"text-align: justify;\">\n\tIf you have the Chromium web browser installed, then launch it in two ways:\n<\/p>\n<pre class=\"brush:bash;\">\r\nchromium\r\noptirun chromium<\/pre>\n<p style=\"text-align: justify;\">\n\tIn both cases, open the tab:\n<\/p>\n<pre class=\"brush:plain;\">\r\nchrome:\/\/gpu\/<\/pre>\n<p style=\"text-align: justify;\">\n\tThere you will see information about the active graphics chip:\n<\/p>\n<p style=\"text-align: justify;\">\n\t<a href=\"https:\/\/miloserdov.org\/wp-content\/uploads\/2020\/02\/chromium.png\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" class=\"alignnone size-full wp-image-4184\" height=\"647\" src=\"https:\/\/miloserdov.org\/wp-content\/uploads\/2020\/02\/chromium.png\" width=\"1489\" srcset=\"https:\/\/miloserdov.org\/wp-content\/uploads\/2020\/02\/chromium.png 1489w, https:\/\/miloserdov.org\/wp-content\/uploads\/2020\/02\/chromium-1000x435.png 1000w, https:\/\/miloserdov.org\/wp-content\/uploads\/2020\/02\/chromium-768x334.png 768w\" sizes=\"(max-width: 1489px) 100vw, 1489px\" \/><\/a>\n<\/p>\n<p style=\"text-align: justify;\">\n\tAnd:\n<\/p>\n<p style=\"text-align: justify;\">\n\t<a href=\"https:\/\/miloserdov.org\/wp-content\/uploads\/2020\/02\/optirun-chromium.png\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" class=\"alignnone size-full wp-image-4183\" height=\"642\" src=\"https:\/\/miloserdov.org\/wp-content\/uploads\/2020\/02\/optirun-chromium.png\" width=\"1483\" srcset=\"https:\/\/miloserdov.org\/wp-content\/uploads\/2020\/02\/optirun-chromium.png 1483w, https:\/\/miloserdov.org\/wp-content\/uploads\/2020\/02\/optirun-chromium-1000x433.png 1000w, https:\/\/miloserdov.org\/wp-content\/uploads\/2020\/02\/optirun-chromium-768x332.png 768w\" sizes=\"(max-width: 1483px) 100vw, 1483px\" \/><\/a><\/p>\n\n<div style=\"font-size: 0px; height: 0px; line-height: 0px; margin: 0; padding: 0; clear: both;\"><\/div>","protected":false},"excerpt":{"rendered":"<p>In this note we will consider the following topics: How to check active GPU in Linux How to switch from integrated graphics to a discrete NVidia graphics card How to install and use Bumblebee to automatically switch between integrated and discrete graphics cards (how to enable NVIDIA Optimus on Linux)<a href=\"https:\/\/miloserdov.org\/?p=4181\" class=\"read-more\">Read More<\/a><\/p>\n","protected":false},"author":1,"featured_media":4186,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[62,15,19],"tags":[171,149,438,437,78,439,79],"class_list":["post-4181","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-hardware","category-password-attacks","category-work-environment","tag-arch-linux","tag-blackarch","tag-bumblebee","tag-cuda","tag-errors","tag-nvidia","tag-problem-solving"],"post_mailing_queue_ids":[],"_links":{"self":[{"href":"https:\/\/miloserdov.org\/index.php?rest_route=\/wp\/v2\/posts\/4181"}],"collection":[{"href":"https:\/\/miloserdov.org\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/miloserdov.org\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/miloserdov.org\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/miloserdov.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4181"}],"version-history":[{"count":7,"href":"https:\/\/miloserdov.org\/index.php?rest_route=\/wp\/v2\/posts\/4181\/revisions"}],"predecessor-version":[{"id":4196,"href":"https:\/\/miloserdov.org\/index.php?rest_route=\/wp\/v2\/posts\/4181\/revisions\/4196"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/miloserdov.org\/index.php?rest_route=\/wp\/v2\/media\/4186"}],"wp:attachment":[{"href":"https:\/\/miloserdov.org\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4181"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/miloserdov.org\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4181"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/miloserdov.org\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4181"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}