{"id":1951,"date":"2018-05-02T17:54:17","date_gmt":"2018-05-02T17:54:17","guid":{"rendered":"http:\/\/fayazrasheed.com\/?p=1951"},"modified":"2018-09-09T02:18:24","modified_gmt":"2018-09-09T02:18:24","slug":"installing-tensorflowgpu-opencv-and-dlib-on-ubuntu-18-04-bionic-beaver","status":"publish","type":"post","link":"https:\/\/fayazrasheed.com\/?p=1951","title":{"rendered":"Installing Tensorflow(GPU), OpenCV and dlib on Ubuntu 18.04 Bionic Beaver"},"content":{"rendered":"<p>Image source: https:\/\/www.tensorflow.org\/<\/p>\n<p>For those who are ready for machine learning and computer vision with the updated versions of OpenCV, dlib, Tensorflow (GPU) on the Bionic Beaver.<\/p>\n<p>Install synaptic and atom from Ubuntu&#8217;s package manager<\/p>\n<p>[code language=&#8221;bash&#8221;]<br \/>\nsudo ubuntu-drivers autoinstall<br \/>\nsudo add-apt-repository ppa:graphics-drivers\/ppa<br \/>\nsudo apt update<br \/>\n[\/code]<\/p>\n<p>search and install nvidia-390 from synaptic<\/p>\n<p>Download CUDA 9.0 (It has to be 9.0 for Tensorflow 1.8):<\/p>\n<p><a href=\"https:\/\/developer.nvidia.com\/cuda-90-download-archive?target_os=Linux&amp;target_arch=x86_64&amp;target_distro=Ubuntu&amp;target_version=1704&amp;target_type=runfilelocal\">https:\/\/developer.nvidia.com\/cuda-90-download-archive?target_os=Linux&amp;target_arch=x86_64&amp;target_distro=Ubuntu&amp;target_version=1704&amp;target_type=runfilelocal<\/a><\/p>\n<p>And Download cuDNN v7.1.3 for CUDA 9.0:<\/p>\n<p><a href=\"https:\/\/developer.nvidia.com\/rdp\/cudnn-download\">https:\/\/developer.nvidia.com\/rdp\/cudnn-download<\/a><\/p>\n<p>[code language=&#8221;bash&#8221;]<br \/>\nsudo chmod +x cuda_9.0.176_384.81_linux.run<br \/>\nsudo chmod +x cuda_9.0.176.1_linux.run<br \/>\nsudo chmod +x cuda_9.0.176.2_linux.run<br \/>\nsudo .\/cuda_9.0.176_384.81_linux.run &#8211;override<br \/>\nsudo .\/cuda_9.0.176.1_linux.run<br \/>\nsudo .\/cuda_9.0.176.2_linux.run<br \/>\n[\/code]<\/p>\n<p>DO NOT INSTALL THE DRIVER AND SAMPLES IN THIS PART! Ignore the fact that they give you a warning for the driver not being installed. This is because the installer cannot detect the installed driver in your system, which we installed earlier through synaptic.<\/p>\n<p>[code language=&#8221;bash&#8221;]<br \/>\nsudo apt-get install cuda-9<br \/>\nsudo apt-get upgrade<br \/>\ntar -zxvf cudnn-9.0-linux-x64-v7.1.tgz<br \/>\nsudo cp -P cuda\/lib64\/* \/usr\/local\/cuda-9.0\/lib64\/<br \/>\nsudo cp  cuda\/include\/* \/usr\/local\/cuda-9.0\/include\/<br \/>\nsudo chmod a+r \/usr\/local\/cuda-9.0\/include\/cudnn.h<br \/>\nsudo apt-get install libcupti-dev<br \/>\nsudo atom ~\/.bashrc<br \/>\n[\/code]<\/p>\n<p>And add these lines:<\/p>\n<p><code>export PATH=\/usr\/local\/cuda-9.0\/bin${PATH:+:${PATH}}<\/code><br \/>\n<code>export LD_LIBRARY_PATH=\/usr\/local\/cuda-9.0\/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}<\/code><\/p>\n<p>[code language=&#8221;bash&#8221;]<br \/>\nsource ~\/.bashrc<br \/>\nsudo apt-get update<br \/>\nsudo apt-get install build-essential cmake libopenblas-dev liblapack-dev libx11-dev libgtk-3-dev python python-dev python-pip python3 python3-dev python3-pip<\/p>\n<p>[\/code]<\/p>\n<p>Download and install Anaconda Python 3.6 (I use 3.6 universally and 2.7 for scientific computations)<\/p>\n<p>Create environment using an environment name (envname)<\/p>\n<p>[code language=&#8221;bash&#8221;]<br \/>\nconda create -n envname python=2.7<br \/>\nsource activate envname<br \/>\npip install numpy pillow lxml jupyter matplotlib dlib protobuf<br \/>\nsudo apt -y install python-opencv<br \/>\nconda install -c conda-forge opencv<br \/>\nsudo snap install protobuf &#8211;classic<br \/>\npip install &#8211;upgrade tensorflow-gpu<br \/>\n[\/code]<\/p>\n<p>To KILL process and clear memory of GPU:<\/p>\n<p>[code language=&#8221;bash&#8221;]<br \/>\nnvidia-smi<br \/>\n[\/code]<\/p>\n<p>and kill the process causing unwanted memory usage<\/p>\n<p>[code language=&#8221;bash&#8221;]<br \/>\nsudo kill -20483 PID.<br \/>\n[\/code]<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Image source: https:\/\/www.tensorflow.org\/ For those who are ready for machine learning and computer vision with the updated versions of OpenCV, dlib, Tensorflow (GPU) on the Bionic Beaver. Install synaptic and atom from Ubuntu&#8217;s package manager [code language=&#8221;bash&#8221;] sudo ubuntu-drivers autoinstall sudo add-apt-repository ppa:graphics-drivers\/ppa sudo apt update [\/code] search&#8230;<\/p>\n","protected":false},"author":1,"featured_media":1974,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,3,4,5],"tags":[118,120,122,121,108,119,68],"class_list":["post-1951","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-fluids-aerodynamics","category-informative-stuff","category-life-as-it-happens","category-tech-blogs","tag-bionic-beaver","tag-dlib","tag-gpu","tag-opencv","tag-tensorflow","tag-tensorflow-gpu","tag-ubuntu"],"_links":{"self":[{"href":"https:\/\/fayazrasheed.com\/index.php?rest_route=\/wp\/v2\/posts\/1951"}],"collection":[{"href":"https:\/\/fayazrasheed.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fayazrasheed.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fayazrasheed.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fayazrasheed.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1951"}],"version-history":[{"count":32,"href":"https:\/\/fayazrasheed.com\/index.php?rest_route=\/wp\/v2\/posts\/1951\/revisions"}],"predecessor-version":[{"id":2074,"href":"https:\/\/fayazrasheed.com\/index.php?rest_route=\/wp\/v2\/posts\/1951\/revisions\/2074"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/fayazrasheed.com\/index.php?rest_route=\/wp\/v2\/media\/1974"}],"wp:attachment":[{"href":"https:\/\/fayazrasheed.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1951"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fayazrasheed.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1951"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fayazrasheed.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1951"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}