{"id":1307,"date":"2020-10-08T15:21:59","date_gmt":"2020-10-08T06:21:59","guid":{"rendered":"https:\/\/ahnbk.com\/?p=1307"},"modified":"2020-10-08T15:26:30","modified_gmt":"2020-10-08T06:26:30","slug":"install-cuda-cudnn-nvidia-driver-on-ubuntu-20-04-for-tensorflow2","status":"publish","type":"post","link":"https:\/\/ahnbk.com\/?p=1307","title":{"rendered":"Install CUDA, cuDNN, Nvidia Driver on Ubuntu 20.04 for Tensorflow2"},"content":{"rendered":"\n<p>\uae30\uc874\uc5d0 \uc124\uce58\ub418\uc5b4 \uc788\ub294 \uac83\ub4e4 \uc81c\uac70. Ubuntu 20.04\uc5d0\ub294 \uae30\ubcf8\uc73c\ub85c Nvidia Driver\uac00 \uc124\uce58\ub418\uc5b4 \uc788\uc73c\ubbc0\ub85c \uc774\ub97c \uc9c0\uc6cc\uc8fc\uc5b4\uc57c \ud568.<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo apt-get purge nvidia*<br>$ sudo apt-get autoremove<br>$ sudo apt-get autoclean<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">CUDA \uc124\uce58<\/h3>\n\n\n\n<p>1. \ub808\ud3ec\uc9c0\ud1a0\ub9ac \ud0a4 \ub4f1\ub85d<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo apt-key adv --fetch-keys http:\/\/developer.download.nvidia.com\/compute\/cuda\/repos\/ubuntu2004\/x86_64\/7fa2af80.pub<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p>2. apt\uc5d0 \ub808\ud3ec\uc9c0\ud1a0\ub9ac \uc8fc\uc18c \ub4f1\ub85d<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo bash -c 'echo \"deb http:\/\/developer.download.nvidia.com\/compute\/cuda\/repos\/ubuntu2004\/x86_64 \/\" &gt;&gt; \/etc\/apt\/sources.list.d\/cuda.list'<br>$ sudo bash -c 'echo \"deb http:\/\/developer.download.nvidia.com\/compute\/cuda\/repos\/ubuntu1804\/x86_64 \/\" &gt;&gt; \/etc\/apt\/sources.list.d\/cuda.list'<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p>3. CUDA, Nvidia Driver \uc124\uce58 (CUDA\ub97c \uc124\uce58\ud558\uba74 \uc790\ub3d9\uc73c\ub85c \uc774\uc5d0 \uc758\uc874\ub41c \ub4dc\ub77c\uc774\ubc84 \uc790\ub3d9\uc73c\ub85c \uc124\uce58)<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo apt update<br>$ sudo apt install cuda<br>$ sudo apt install cuda-10-1<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p>4. cuDNN \uc124\uce58\ub97c \uc704\ud55c repo \ud328\ud0a4\uc9c0 \uc124\uce58<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ wget http:\/\/developer.download.nvidia.com\/compute\/machine-learning\/repos\/ubuntu2004\/x86_64\/nvidia-machine-learning-repo-ubuntu2004_1.0.0-1_amd64.deb<br>$ sudo dpkg -i nvidia-machine-learning-repo-ubuntu2004_1.0.0-1_amd64.deb<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p>5. cuDNN \ub808\ud3ec\uc9c0\ud1a0\ub9ac \ucd94\uac00<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo bash -c 'echo \"deb http:\/\/developer.download.nvidia.com\/compute\/machine-learning\/repos\/ubuntu1804\/x86_64 \/\" &gt;&gt; \/etc\/apt\/sources.list.d\/nvidia-machine-learning.list'<\/code><\/pre>\n\n\n\n<p>6. cuDNN \uc124\uce58 (CUDA \ubc84\uc804\uc5d0 \ub9de\ub294 \ubc84\uc804\uc73c\ub85c \uc124\uce58\ud574\uc57c \ud568)<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo apt install libcudnn7-dev=7.6.5.32-1+cuda10.1 libcudnn7=7.6.5.32-1+cuda10.1<\/code><\/pre>\n\n\n\n<p>\ucd94\ud6c4 \uc5c5\ub370\uc774\ud2b8\uc2dc \ucd5c\uc2e0\ubc84\uc804\uc73c\ub85c \uc5c5\ub370\uc774\ud2b8 \ub418\ub294 \uac83\uc744 \ubc29\uc9c0<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo apt-mark hold libcudnn7 libcudnn7-dev<br>libcudnn7 set on hold.<br>libcudnn7-dev set on hold.<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p>\uc774\uc640 \uac19\uc774 \uc124\uce58\ub97c \uc644\ub8cc\ud558\uace0, \uc7ac\ubd80\ud305\ud55c \ub2e4\uc74c&#8230; \ub4dc\ub77c\uc774\ubc84\uac00 \uc798 \uc124\uce58\ub418\uc5b4 \uc788\ub294\uc9c0 \ud655\uc778<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ nvidia-smi<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large is-resized\"><img data-attachment-id=\"1309\" data-permalink=\"https:\/\/ahnbk.com\/?attachment_id=1309\" data-orig-file=\"https:\/\/i0.wp.com\/ahnbk.com\/wp-content\/uploads\/2020\/10\/image.png?fit=1114%2C814&amp;ssl=1\" data-orig-size=\"1114,814\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"image\" data-image-description=\"\" data-image-caption=\"\" data-medium-file=\"https:\/\/i0.wp.com\/ahnbk.com\/wp-content\/uploads\/2020\/10\/image.png?fit=1000%2C731&amp;ssl=1\" data-large-file=\"https:\/\/i0.wp.com\/ahnbk.com\/wp-content\/uploads\/2020\/10\/image.png?fit=525%2C384&amp;ssl=1\" decoding=\"async\" loading=\"lazy\" src=\"https:\/\/i0.wp.com\/ahnbk.com\/wp-content\/uploads\/2020\/10\/image.png?resize=525%2C383&#038;ssl=1\" alt=\"\" class=\"wp-image-1309\" width=\"525\" height=\"383\" srcset=\"https:\/\/i0.wp.com\/ahnbk.com\/wp-content\/uploads\/2020\/10\/image.png?w=1114&amp;ssl=1 1114w, https:\/\/i0.wp.com\/ahnbk.com\/wp-content\/uploads\/2020\/10\/image.png?resize=1000%2C731&amp;ssl=1 1000w, https:\/\/i0.wp.com\/ahnbk.com\/wp-content\/uploads\/2020\/10\/image.png?resize=768%2C561&amp;ssl=1 768w, https:\/\/i0.wp.com\/ahnbk.com\/wp-content\/uploads\/2020\/10\/image.png?w=1050&amp;ssl=1 1050w\" sizes=\"(max-width: 525px) 100vw, 525px\" data-recalc-dims=\"1\" \/><\/figure>\n\n\n\n<p><\/p>\n\n\n\n<hr class=\"wp-block-separator is-style-wide\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">TensorFlow2 \uc124\uce58<\/h3>\n\n\n\n<pre class=\"wp-block-code\"><code>$ sudo apt install python3-pip<br>$ sudo pip3 install -U tensorflow-gpu<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p>\ud658\uacbd\ubcc0\uc218 \uc14b\uc5c5<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ echo 'export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:\/usr\/local\/cuda-11.1\/lib64:\/usr\/local\/cuda-10.2\/lib64:\/usr\/local\/cuda-10.1\/lib64' &gt;&gt; ~\/.bashrc<br>$ source ~\/.bashrc<\/code><\/pre>\n\n\n\n<p><\/p>\n\n\n\n<p>\uc2e4\ud589 \ubc0f \uc124\uce58 \ud655\uc778<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>$ python3<br>Python 3.8.5 (default, Jul 28 2020, 12:59:40)<br>&#91;GCC 9.3.0] on linux<br>Type \"help\", \"copyright\", \"credits\" or \"license\" for more information.<br>import tensorflow as tf<br>2020-10-08 15:02:50.803732: I tensorflow\/stream_executor\/platform\/default\/dso_loader.cc:48] Successfully opened dynamic library libcudart.so.10.1<br>tf.config.list_physical_devices('GPU')<br>2020-10-08 15:03:01.717511: I tensorflow\/stream_executor\/platform\/default\/dso_loader.cc:48] Successfully opened dynamic library libcuda.so.1<br>2020-10-08 15:03:01.733336: I tensorflow\/stream_executor\/cuda\/cuda_gpu_executor.cc:982] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero<br>2020-10-08 15:03:01.733585: I tensorflow\/core\/common_runtime\/gpu\/gpu_device.cc:1716] Found device 0 with properties:<br>pciBusID: 0000:01:00.0 name: GeForce GTX 1650 computeCapability: 7.5<br>coreClock: 1.56GHz coreCount: 16 deviceMemorySize: 3.82GiB deviceMemoryBandwidth: 119.24GiB\/s<br>2020-10-08 15:03:01.733603: I tensorflow\/stream_executor\/platform\/default\/dso_loader.cc:48] Successfully opened dynamic library libcudart.so.10.1<br>2020-10-08 15:03:01.734679: I tensorflow\/stream_executor\/platform\/default\/dso_loader.cc:48] Successfully opened dynamic library libcublas.so.10<br>2020-10-08 15:03:01.735901: I tensorflow\/stream_executor\/platform\/default\/dso_loader.cc:48] Successfully opened dynamic library libcufft.so.10<br>2020-10-08 15:03:01.736061: I tensorflow\/stream_executor\/platform\/default\/dso_loader.cc:48] Successfully opened dynamic library libcurand.so.10<br>2020-10-08 15:03:01.737163: I tensorflow\/stream_executor\/platform\/default\/dso_loader.cc:48] Successfully opened dynamic library libcusolver.so.10<br>2020-10-08 15:03:01.737773: I tensorflow\/stream_executor\/platform\/default\/dso_loader.cc:48] Successfully opened dynamic library libcusparse.so.10<br>2020-10-08 15:03:01.740221: I tensorflow\/stream_executor\/platform\/default\/dso_loader.cc:48] Successfully opened dynamic library libcudnn.so.7<br>2020-10-08 15:03:01.740295: I tensorflow\/stream_executor\/cuda\/cuda_gpu_executor.cc:982] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero<br>2020-10-08 15:03:01.740563: I tensorflow\/stream_executor\/cuda\/cuda_gpu_executor.cc:982] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero<br>2020-10-08 15:03:01.740768: I tensorflow\/core\/common_runtime\/gpu\/gpu_device.cc:1858] Adding visible gpu devices: 0<br>&#91;PhysicalDevice(name='\/physical_device:GPU:0', device_type='GPU')]<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>\uae30\uc874\uc5d0 \uc124\uce58\ub418\uc5b4 \uc788\ub294 \uac83\ub4e4 \uc81c\uac70. Ubuntu 20.04\uc5d0\ub294 \uae30\ubcf8\uc73c\ub85c Nvidia Driver\uac00 \uc124\uce58\ub418\uc5b4 \uc788\uc73c\ubbc0\ub85c \uc774\ub97c \uc9c0\uc6cc\uc8fc\uc5b4\uc57c \ud568. CUDA \uc124\uce58 1. \ub808\ud3ec\uc9c0\ud1a0\ub9ac \ud0a4 \ub4f1\ub85d 2. apt\uc5d0 \ub808\ud3ec\uc9c0\ud1a0\ub9ac \uc8fc\uc18c \ub4f1\ub85d 3. CUDA, Nvidia Driver \uc124\uce58 (CUDA\ub97c \uc124\uce58\ud558\uba74 \uc790\ub3d9\uc73c\ub85c \uc774\uc5d0 \uc758\uc874\ub41c \ub4dc\ub77c\uc774\ubc84 \uc790\ub3d9\uc73c\ub85c \uc124\uce58) 4. cuDNN \uc124\uce58\ub97c \uc704\ud55c repo \ud328\ud0a4\uc9c0 \uc124\uce58 5. cuDNN \ub808\ud3ec\uc9c0\ud1a0\ub9ac \ucd94\uac00 6. cuDNN \uc124\uce58 (CUDA \ubc84\uc804\uc5d0 &hellip; <\/p>\n<p class=\"link-more\"><a href=\"https:\/\/ahnbk.com\/?p=1307\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Install CUDA, cuDNN, Nvidia Driver on Ubuntu 20.04 for Tensorflow2&#8221;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"advanced_seo_description":"","jetpack_seo_html_title":"","jetpack_seo_noindex":false,"jetpack_post_was_ever_published":false,"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"footnotes":"","_jetpack_memberships_contains_paid_content":false},"categories":[62,59],"tags":[20,118,298,297],"jetpack_featured_media_url":"","jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p2wXSW-l5","jetpack-related-posts":[],"jetpack_likes_enabled":false,"_links":{"self":[{"href":"https:\/\/ahnbk.com\/index.php?rest_route=\/wp\/v2\/posts\/1307"}],"collection":[{"href":"https:\/\/ahnbk.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ahnbk.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ahnbk.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ahnbk.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1307"}],"version-history":[{"count":5,"href":"https:\/\/ahnbk.com\/index.php?rest_route=\/wp\/v2\/posts\/1307\/revisions"}],"predecessor-version":[{"id":1314,"href":"https:\/\/ahnbk.com\/index.php?rest_route=\/wp\/v2\/posts\/1307\/revisions\/1314"}],"wp:attachment":[{"href":"https:\/\/ahnbk.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1307"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ahnbk.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1307"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ahnbk.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1307"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}