{"id":1476,"date":"2017-09-17T19:39:53","date_gmt":"2017-09-18T02:39:53","guid":{"rendered":"https:\/\/partofthething.com\/thoughts\/?p=1476"},"modified":"2017-09-17T19:40:05","modified_gmt":"2017-09-18T02:40:05","slug":"getting-your-ubuntu-17-04-computer-set-up-for-the-fast-ai-deep-learning-courses","status":"publish","type":"post","link":"https:\/\/partofthething.com\/thoughts\/getting-your-ubuntu-17-04-computer-set-up-for-the-fast-ai-deep-learning-courses\/","title":{"rendered":"Getting your Ubuntu 17.04 computer set up for the fast.ai deep learning courses"},"content":{"rendered":"<p>I&#8217;m becoming convinced that Jeremy Howard is right to predict that deep learning is going to be &#8220;<a href=\"https:\/\/www.youtube.com\/watch?v=ACU-T9L4_lI\">more important and more transformational than the internet.<\/a>&#8221; If you don&#8217;t know who Jeremy Howard is, he&#8217;s part of the duo behind <a href=\"http:\/\/www.fast.ai\/\">fast.ai free and high-quality deep learning course series<\/a>, which is dedicated to making deep learning accessible to everyone.<br \/>\n<iframe loading=\"lazy\" width=\"560\" height=\"315\" src=\"https:\/\/www.youtube-nocookie.com\/embed\/t4kyRyKyOpo?rel=0\" frameborder=\"0\" allowfullscreen=\"allowfullscreen\"><\/iframe><\/p>\n<p>Deep learning takes advantage of certain graphics processors (GPUs) to be efficient. If you take the course, it&#8217;s recommended that you sign up for an Amazon Web Services machine with an appropriate GPU so you can just run the provided setup scripts and be on your way learning deep learning. But you may want to try to get everything set up on your own machine if you happen to have one. I <a href=\"https:\/\/partofthething.com\/thoughts\/building-a-nas-serverhome-server-in-2017\/\">just built a small server<\/a> and added a modest GPU just for this purpose so I figured I&#8217;d give it a whirl. This is how I did it.<\/p>\n<p><!--more--><\/p>\n<p>Key Specs:<\/p>\n<ul>\n<li>OS: Ubuntu Linux 17.04<\/li>\n<li>RAM: 16 GB of RAM (though I filled that up in Lesson 2 and will be ordering 16 more)<\/li>\n<li>GPU: nVidia GeForce GTX 1060 6GB<\/li>\n<\/ul>\n<p>I started from <a href=\"http:\/\/wiki.fast.ai\/index.php\/Ubuntu_installation\">this script<\/a>, provided by fast.ai. I didn&#8217;t want to bother with anaconda for Python and just installed the packages globally. If you need multiple environments, just set up virtualenv.<\/p>\n<h4>Python libraries<\/h4>\n<p>I kind of mixed Ubuntu packages with pip packages for the Python stuff. During the lessons if you find an import that fails, go ahead and install that package as well.<\/p>\n<p><code>sudo apt install python-sklearn python-matplotlib python-pandas python-pil python-h5py<\/code><\/p>\n<p><code>sudo pip install bcolz theano keras==1.2.2 juypter-notebook kaggle-cli<\/code><\/p>\n<h4>Nvidia, CUDA, and cuDNN installation<\/h4>\n<p>I just installed the proprietary nvidia drivers and cuda stuff right from the ubuntu repos:<\/p>\n<p><code>sudo apt-get install nvidia-381 nvidia-cuda-dev nvidia-cuda-toolkit nvidia-nsight<\/code><\/p>\n<p>Then I <a href=\"https:\/\/developer.nvidia.com\/cudnn\">signed up to be a Developer Member to get access to the nVidia cuDNN libraries. <\/a> I downloaded the 16.04 libs and copied them over. I originally tried the cuDNN-7 libs but got scared by the &#8220;newer than tested&#8221; warning theano gave later (but then Jeremy recommended just not worrying about it so the newer cuDNN libs may work fine).<\/p>\n<pre class=\"\">sudo cp cuda-cdnn-5.1\/lib64\/* \/usr\/local\/cuda\/lib64\/ \r\nsudo cp cuda-cdnn-5.1\/include\/* \/usr\/local\/cuda\/include\/<\/pre>\n<p>I still struggled to get theano imported. I was getting big errors upon testing and finally a dissatisfying message:<\/p>\n<pre class=\"\"><code>$ python -c \"import theano\"<\/code> [errors...] collect2: error: ld returned 1 exit status Using gpu device 0: GeForce GTX 1060 6GB (CNMeM is disabled, cuDNN <strong>None<\/strong>)<\/pre>\n<p>That <code>None<\/code> was a problem; without cuDNN everything will run on the CPU at infinitely slow speeds. There was a g++\/gcc version issue. Installed <code>gcc-4.9<\/code> and <code>g++-4.9<\/code> and made my <code>.theanorc<\/code> file say this:<\/p>\n<pre class=\"\">[global] \r\ndevice = gpu \r\nfloatX = float32\r\ncxx=\/usr\/bin\/g++-4.9 \r\n[cuda] \r\nroot = \/usr\/local\/cuda\r\n[dnn] \r\nenabled = True<\/pre>\n<p>Still no luck. Then, finally, I found that running the following would get it to work.<\/p>\n<pre class=\"\">$ export LIBRARY_PATH=\/usr\/local\/cuda\/lib64\r\n$ python -c \"import theano\"\r\nUsing gpu device 0: GeForce GTX 1060 6GB (CNMeM is disabled, cuDNN 5110)<\/pre>\n<p><em>Woohoo<\/em>! We&#8217;re in business. All the notebooks and things worked great after that. In some if you get MemoryErrors, you may have to decrease <code>num_batches<\/code> from 64 to like 32. When you&#8217;re running lesson 1 you can check gpu status with <code>nvidia-smi<\/code>. My server ramped up from 40W all the way to like 175W under load. Neat!<\/p>\n<figure id=\"attachment_1477\" aria-describedby=\"caption-attachment-1477\" style=\"width: 343px\" class=\"wp-caption aligncenter\"><a href=\"https:\/\/partofthething.com\/thoughts\/wp-content\/uploads\/Screenshot-from-2017-09-17-19-28-17.png\"><img loading=\"lazy\" decoding=\"async\" class=\"size-full wp-image-1477\" src=\"https:\/\/partofthething.com\/thoughts\/wp-content\/uploads\/Screenshot-from-2017-09-17-19-28-17.png\" alt=\"\" width=\"343\" height=\"261\" srcset=\"https:\/\/partofthething.com\/thoughts\/wp-content\/uploads\/Screenshot-from-2017-09-17-19-28-17.png 343w, https:\/\/partofthething.com\/thoughts\/wp-content\/uploads\/Screenshot-from-2017-09-17-19-28-17-300x228.png 300w\" sizes=\"auto, (max-width: 343px) 100vw, 343px\" \/><\/a><figcaption id=\"caption-attachment-1477\" class=\"wp-caption-text\">Power consumption during deep learning. Just a blip of fun today.<\/figcaption><\/figure>\n<p>Deep learning, here I come!<\/p>\n","protected":false},"excerpt":{"rendered":"<p>I&#8217;m becoming convinced that Jeremy Howard is right to predict that deep learning is going to be &#8220;more important and more transformational than the internet.&#8221; If you don&#8217;t know who Jeremy Howard is, he&#8217;s part of the duo behind fast.ai free and high-quality deep learning course series, which is dedicated to making deep learning accessible &hellip; <a href=\"https:\/\/partofthething.com\/thoughts\/getting-your-ubuntu-17-04-computer-set-up-for-the-fast-ai-deep-learning-courses\/\" class=\"more-link\">Continue reading <span class=\"screen-reader-text\">Getting your Ubuntu 17.04 computer set up for the fast.ai deep learning courses<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"activitypub_content_warning":"","activitypub_content_visibility":"","activitypub_max_image_attachments":4,"activitypub_interaction_policy_quote":"anyone","activitypub_status":"","footnotes":""},"categories":[3],"tags":[],"class_list":["post-1476","post","type-post","status-publish","format-standard","hentry","category-computers"],"_links":{"self":[{"href":"https:\/\/partofthething.com\/thoughts\/wp-json\/wp\/v2\/posts\/1476","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/partofthething.com\/thoughts\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/partofthething.com\/thoughts\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/partofthething.com\/thoughts\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/partofthething.com\/thoughts\/wp-json\/wp\/v2\/comments?post=1476"}],"version-history":[{"count":6,"href":"https:\/\/partofthething.com\/thoughts\/wp-json\/wp\/v2\/posts\/1476\/revisions"}],"predecessor-version":[{"id":1562,"href":"https:\/\/partofthething.com\/thoughts\/wp-json\/wp\/v2\/posts\/1476\/revisions\/1562"}],"wp:attachment":[{"href":"https:\/\/partofthething.com\/thoughts\/wp-json\/wp\/v2\/media?parent=1476"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/partofthething.com\/thoughts\/wp-json\/wp\/v2\/categories?post=1476"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/partofthething.com\/thoughts\/wp-json\/wp\/v2\/tags?post=1476"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}