{"id":1230,"date":"2022-05-18T06:58:56","date_gmt":"2022-05-17T23:58:56","guid":{"rendered":"https:\/\/bigdolphin.com.vn\/?p=1230"},"modified":"2024-03-26T15:25:04","modified_gmt":"2024-03-26T08:25:04","slug":"learning-cuda-installation","status":"publish","type":"post","link":"https:\/\/bigdolphin.com.vn\/?p=1230","title":{"rendered":"Learning CUDA: Step 01: Installation"},"content":{"rendered":"\n<p>This topic shows steps to install NVIDIA driver and Cuda toolkit on Ubuntu.<\/p>\n\n\n\n<p>My card GT630 is old then I have to use Ubuntu 16.04 that have gcc 5 and linux kernel 4. However, the steps are same for newer card and kernel. You must check cuda version before selecting suitable linux version for your card.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">1. Preparation<\/h3>\n\n\n\n<ul><li>Hardware: PC with NVidia Card, GT630 is used in this series (driver 384, cuda 8.0 GA2, gcc 5)<\/li><li>OS: Ubuntu 16.04<\/li><\/ul>\n\n\n\n<h3 class=\"wp-block-heading\">2. Remove existing driver<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash line-numbers\">sudo apt-get remove --purge nvidia*\nsudo apt-get remove --purge \"nvidia*\"<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">3. Install driver<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash line-numbers\">sudo add-apt-repository ppa:graphics-drivers\/ppa\nsudo apt update\nubuntu-drivers devices\nsudo apt install -y nvidia-384 libxmu-dev freeglut3-dev libx11-dev libglu1-mesa libglu1-mesa-dev libfreeimage-dev\nsudo reboot<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">4. Reboot and check<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash line-numbers\">sudo reboot\nnvidia-smi<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash line-numbers\">+-----------------------------------------------------------------------------+\n| NVIDIA-SMI 384.130                Driver Version: 384.130                   |\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 GT 630      Off  | 00000000:03:00.0 N\/A |                  N\/A |\n| 40%   39C    P0    N\/A \/  N\/A |      0MiB \/  1985MiB |     N\/A      Default |\n+-------------------------------+----------------------+----------------------+\n+-----------------------------------------------------------------------------+\n| Processes:                                                       GPU Memory |\n|  GPU       PID   Type   Process name                             Usage      |\n|=============================================================================|\n|    0                    Not Supported                                       |\n+-----------------------------------------------------------------------------+<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">5. Download Cuda and patches<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash line-numbers\">mkdir v8.0_ga2\ncd v8.0_ga2\nwget https:\/\/developer.nvidia.com\/compute\/cuda\/8.0\/Prod2\/local_installers\/cuda_8.0.61_375.26_linux-run\nwget https:\/\/developer.nvidia.com\/compute\/cuda\/8.0\/Prod2\/patches\/2\/cuda_8.0.61.2_linux-run<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">6. Extract packages<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash line-numbers\">chmod +x cuda_8.0.61_375.26_linux-run\nchmod +x cuda_8.0.61.2_linux-run\nmkdir extract\n.\/cuda_8.0.61_375.26_linux-run --extract=$(pwd)\/extract<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">7. Install Cuda only<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash line-numbers\">sudo .\/extract\/cuda-linux64-rel-8.0.61-21551265.run -noprompt\nsudo .\/cuda_8.0.61.2_linux-run --silent --accept-eula\nsudo \/bin\/bash -c 'echo PATH=\\\"\\$PATH:\/usr\/local\/cuda\/bin\\\" >> \/etc\/profile'\nsudo \/bin\/bash -c 'echo \"\/usr\/local\/cuda\/lib64\" >> \/etc\/ld.so.conf'\nsudo ldconfig<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">8. Reboot and check<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash line-numbers\">sudo reboot\nnvcc --version<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash line-numbers\">nvcc: NVIDIA (R) Cuda compiler driver\nCopyright (c) 2005-2016 NVIDIA Corporation\nBuilt on Tue_Jan_10_13:22:03_CST_2017\nCuda compilation tools, release 8.0, V8.0.61<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">9. Install CuDNN<\/h3>\n\n\n\n<p>Go to this link to download CuDNN <a href=\"https:\/\/developer.nvidia.com\/cudnn\">https:\/\/developer.nvidia.com\/cudnn<\/a>, version should >= 7.0<\/p>\n\n\n\n<p>Install to system<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash line-numbers\">sudo dpkg -i cudnn\/libcudnn7_7.1.4.18-1+cuda8.0_amd64.deb\nsudo dpkg -i cudnn\/libcudnn7-dev_7.1.4.18-1+cuda8.0_amd64.deb\nsudo dpkg -i cudnn\/libcudnn7-doc_7.1.4.18-1+cuda8.0_amd64.deb<\/code><\/pre>\n\n\n\n<p>Check version<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash line-numbers\">cat \/usr\/include\/cudnn.h | grep CUDNN_MAJOR -A 2<\/code><\/pre>\n\n\n\n<pre class=\"wp-block-code\"><code lang=\"bash\" class=\"language-bash line-numbers\">#define CUDNN_MAJOR 7\n#define CUDNN_MINOR 1\n#define CUDNN_PATCHLEVEL 4\n#define CUDNN_VERSION    (CUDNN_MAJOR * 1000 + CUDNN_MINOR * 100 + CUDNN_PATCHLEVEL)\n#include \"driver_types.h\"<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>This topic shows steps to install NVIDIA driver and Cuda toolkit on Ubuntu.<\/p>\n","protected":false},"author":2,"featured_media":1233,"comment_status":"open","ping_status":"open","sticky":false,"template":"single-with-sidebar","format":"standard","meta":{"gtb_hide_title":false,"gtb_wrap_title":false,"gtb_class_title":"","gtb_remove_headerfooter":false,"footnotes":""},"categories":[10],"tags":[63,59,61],"_links":{"self":[{"href":"https:\/\/bigdolphin.com.vn\/index.php?rest_route=\/wp\/v2\/posts\/1230"}],"collection":[{"href":"https:\/\/bigdolphin.com.vn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/bigdolphin.com.vn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/bigdolphin.com.vn\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/bigdolphin.com.vn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1230"}],"version-history":[{"count":25,"href":"https:\/\/bigdolphin.com.vn\/index.php?rest_route=\/wp\/v2\/posts\/1230\/revisions"}],"predecessor-version":[{"id":1268,"href":"https:\/\/bigdolphin.com.vn\/index.php?rest_route=\/wp\/v2\/posts\/1230\/revisions\/1268"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/bigdolphin.com.vn\/index.php?rest_route=\/wp\/v2\/media\/1233"}],"wp:attachment":[{"href":"https:\/\/bigdolphin.com.vn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1230"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/bigdolphin.com.vn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1230"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/bigdolphin.com.vn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1230"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}