{"id":416,"date":"2019-04-07T11:12:43","date_gmt":"2019-04-07T18:12:43","guid":{"rendered":"http:\/\/35.243.195.209\/?p=416"},"modified":"2020-04-20T20:48:43","modified_gmt":"2020-04-21T03:48:43","slug":"install-cuda-10-1-and-driver-418","status":"publish","type":"post","link":"https:\/\/nanzhou.cc\/index.php\/2019\/04\/07\/install-cuda-10-1-and-driver-418\/","title":{"rendered":"Install CUDA 10.1 and Driver 418"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">Summary<\/h2>\n\n\n\n<p>In this post, I will introduce how to install the newest CUDA and corresponding Nvidia driver in Ubuntu 16.04.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Details<\/h2>\n\n\n\n<p>I want to use CUDA for neural network inference. But after I compile the executable files and run, it tells me driver not compatible with this version of CUDA.<\/p>\n\n\n\n<p>I have GTX 1060 and CUDA 9.0 in my desktop. I decide to remove them and go through the installation process from scratch to get the newest CUDA 10.1 and driver 418.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">1. Remove the Current CUDA<\/h3>\n\n\n\n<p>We are happy in the folders CUDA provides the uninstall scripts.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">(base) zhoun14@zhoun14:~$ which nvcc\n\/usr\/local\/cuda\/bin\/nvcc\n(base) zhoun14@zhoun14:~$ cd \/usr\/local\/cuda\/bin\/\n(base) zhoun14@zhoun14:\/usr\/local\/cuda\/bin$ ls\nnvcc cuda-uninstaller   ...<\/code><\/pre>\n\n\n\n<p>Run the uninstaller.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">2. Remove the Current Driver<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">sudo apt-get remove --purge '^nvidia-.*'<\/code><\/pre>\n\n\n\n<p>It also helps if you have the following problems.<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>Bad resolution;<\/li><li>Loop login;<\/li><\/ol>\n\n\n\n<p>Alternatively, you can use autoinstaller to firstly avoid loop login,<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">sudo ubuntu-drivers autoinstall<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">3. Install CUDA and Drivers Using the Runfile<\/h3>\n\n\n\n<p>Go to <a href=\"https:\/\/docs.nvidia.com\/cuda\/cuda-installation-guide-linux\/index.html\">the official page<\/a>.<\/p>\n\n\n\n<ol class=\"wp-block-list\"><li>Check the prerequisite;<\/li><li>Download the <a href=\"https:\/\/developer.nvidia.com\/cuda-downloads\">CUDA Toolkit<\/a>; choose your platform and use the runfile format;<\/li><\/ol>\n\n\n\n<p>Then it comes the most important part. Do the following commands.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Reboot to Test Mode<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">sudo reboot nomodeset<\/code><\/pre>\n\n\n\n<p>Press <code>ctrl<\/code> + <code>alt<\/code> + <code>F1<\/code>. It may vary on different machines. Try combinations from <code>F1<\/code> to <code>F12<\/code>.<\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Disabling Nouveau<\/h4>\n\n\n\n<p>See <a href=\"https:\/\/docs.nvidia.com\/cuda\/cuda-installation-guide-linux\/index.html#runfile-nouveau\">here<\/a> for details. But you can just create a file at <code>\/etc\/modprobe.d\/blacklist-nouveau.conf<\/code> with the following contents:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">blacklist nouveau\noptions nouveau modeset=0<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Regenerate the kernel initramfs.<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">sudo update-initramfs -u<\/code><\/pre>\n\n\n\n<h4 class=\"wp-block-heading\">Run the Runfile<\/h4>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">sudo sh cuda_&lt;version>_linux.run<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">4. Verify the Driver<\/h3>\n\n\n\n<p>It verifies the CUDA at the same time.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">(base) zhoun14@zhoun14:~$ nvidia-smi \nSun Apr  7 09:58:49 2019       \n+-----------------------------------------------------------------------------+\n| NVIDIA-SMI 418.56       Driver Version: 418.56       CUDA Version: 10.1     |\n|-------------------------------+----------------------+----------------------+\n| GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |\n| Fan  Temp  Perf  Pwr:Usage\/Cap|         Memory-Usage | GPU-Util  Compute M. |\n|===============================+======================+======================|\n|   0  GeForce GTX 106...  Off  | 00000000:01:00.0  On |                  N\/A |\n| 39%   40C    P8     5W \/ 120W |    424MiB \/  3016MiB |      0%      Default |\n+-------------------------------+----------------------+----------------------+\n\n+-----------------------------------------------------------------------------+\n| Processes:                                                       GPU Memory |\n|  GPU       PID   Type   Process name                             Usage      |\n|=============================================================================|\n|    0       314      G   ...quest-channel-token=6420533192254872401    41MiB |\n|    0      1739      G   \/usr\/lib\/xorg\/Xorg                           232MiB |\n|    0      3175      G   \/opt\/teamviewer\/tv_bin\/TeamViewer              2MiB |\n|    0      3380      G   compiz                                       146MiB |\n+-----------------------------------------------------------------------------+<\/code><\/pre>\n\n\n\n<p>If nothing prints out. You can do step 2 again and reinstall the drivers using <code>apt-get<\/code>.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">sudo apt-get nvidia-418 nvidia-modprobe<\/code><\/pre>\n\n\n\n<p>If the OS tells you it can not locate the package. Please add the repository first.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">sudo add-apt-repository ppa:graphics-drivers\/ppa\nsudo apt upgrade<\/code><\/pre>\n\n\n\n<p>Then you will be prompted to disable Secure Boot. Select Disable. Reboot the machine but <strong>do enter BIOS<\/strong> to disable Secure Boot. Typically you can enter BIOS by hitting F12 rapidly as soon as the system restarts.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">5. Verify the CUDA<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash\">(base) zhoun14@zhoun14:~$ nvcc --version\nnvcc: NVIDIA (R) Cuda compiler driver\nCopyright (c) 2005-2019 NVIDIA Corporation\nBuilt on Fri_Feb__8_19:08:17_PST_2019\nCuda compilation tools, release 10.1, V10.1.105<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Summary In this post, I will introduce how to install the newest CUDA and corresponding Nvidia driver in Ubuntu 16.04. Details I want to use CUDA for neural network inference. But after I compile the executable files and run, it tells me driver not compatible with this version of CUDA. I have GTX 1060 and&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[6,30,29,5],"tags":[],"class_list":["post-416","post","type-post","status-publish","format-standard","hentry","category-c","category-cuda","category-gpu","category-proglang"],"_links":{"self":[{"href":"https:\/\/nanzhou.cc\/index.php\/wp-json\/wp\/v2\/posts\/416","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/nanzhou.cc\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/nanzhou.cc\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/nanzhou.cc\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/nanzhou.cc\/index.php\/wp-json\/wp\/v2\/comments?post=416"}],"version-history":[{"count":10,"href":"https:\/\/nanzhou.cc\/index.php\/wp-json\/wp\/v2\/posts\/416\/revisions"}],"predecessor-version":[{"id":1039,"href":"https:\/\/nanzhou.cc\/index.php\/wp-json\/wp\/v2\/posts\/416\/revisions\/1039"}],"wp:attachment":[{"href":"https:\/\/nanzhou.cc\/index.php\/wp-json\/wp\/v2\/media?parent=416"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/nanzhou.cc\/index.php\/wp-json\/wp\/v2\/categories?post=416"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/nanzhou.cc\/index.php\/wp-json\/wp\/v2\/tags?post=416"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}