-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathLinux-Deep-Learning-Machine.html
executable file
·358 lines (326 loc) · 21.1 KB
/
Linux-Deep-Learning-Machine.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="description" content="" />
<meta name="author" content="Jordi Warmenhoven" />
<meta name="generator" content="Pelican (VoidyBootstrap theme)" />
<title>Building a modest Linux Deep Learning machine - Penguinsula</title>
<link rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"
integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u"
crossorigin="anonymous" />
<link rel="stylesheet"
href="https://maxcdn.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css"
integrity="sha384-wvfXpqpZZVQGK6TAh5PVlGOfQNHSoD2xbE+QkPxCAFlNEevoEH3Sl0sibVcOQVnN"
crossorigin="anonymous">
<link rel="stylesheet" href="https://jwarmenhoven.github.io/theme/css/pygment.css" />
<link rel="stylesheet" href="https://jwarmenhoven.github.io/theme/css/voidybootstrap.css" />
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js" integrity="sha384-FFgGfda92tXC8nCNOxrCQ3R8x1TNkMFqDZVQdDaaJiiVbjkPBXIJBx0o7ETjy8Bh" crossorigin="anonymous"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js" integrity="sha384-ZoaMbDF+4LeFxg6WdScQ9nnR1QC2MIRxA1O9KWEXQwns1G8UNyIEZIQidzb0T1fo" crossorigin="anonymous"></script>
<![endif]-->
<link rel="shortcut icon" href="https://jwarmenhoven.github.io/favicon.ico" />
</head>
<body>
<nav class="navbar navbar-default">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle"
data-toggle="collapse" data-target="#main-navbar-collapse">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="https://jwarmenhoven.github.io/" rel="home">
<i class="fa fa-home fa-fw fa-lg"> </i> </a>
</div>
<div class="collapse navbar-collapse" id="main-navbar-collapse">
<ul class="nav navbar-nav">
<li>
<a href="https://jwarmenhoven.github.io/pages/about-post.html">About me</a>
</li>
<li>
<a href="https://jwarmenhoven.github.io/pages/projects.html">Projects</a>
</li>
<li class="divider"></li>
<li class="">
<a href="https://jwarmenhoven.github.io/archives.html">Archives</a>
</li>
<li class="divider"></li>
</ul> <!-- /nav -->
</div> <!-- /navbar-collapse -->
</div> <!-- /container -->
</nav> <!-- /navbar -->
<div class="jumbotron" id="overview">
<div class="container">
<h1><a href="https://jwarmenhoven.github.io/">Penguinsula</a></h1>
<p class="lead">Python, Stats, Modelling & Stuff</p>
</div>
</div>
<div class="container" id="main-container">
<div class="row">
<div class="col-md-9" id="content">
<article itemscope="itemscope" itemtype="http://schema.org/BlogPosting">
<header class="article-header">
<abbr class="article-header-date">
Sat 25 August 2018
</abbr> <h1>
<a href="https://jwarmenhoven.github.io/Linux-Deep-Learning-Machine.html" rel="bookmark"
title="Permalink to Building a modest Linux Deep Learning machine">
Building a modest Linux Deep Learning machine
</a>
</h1><div class="article-header-info">
<p>
Posted by <a href="https://jwarmenhoven.github.io/author/jordi-warmenhoven.html">Jordi Warmenhoven</a>
in
<a href="https://jwarmenhoven.github.io/category/blog.html">
Blog</a>
</p>
</div> <!-- /.article-header-info -->
</header>
<div class="content-body" itemprop="text articleBody">
<p>Some time ago I decided to move from a MacOS development environment back to Linux for exploring and working with Python datascience and statistical modelling libraries. Though most of the Python libraries and platforms offer support for MacOS, things are generally easier in Linux. One avoids a lot of special installation and compatability instructions. My first experience with Linux dates from 1996 when I bought a set of Slackware cdroms. Since then I have used Linux on various types of hardware, but not that much during the last few years. I mainly use <a href="https://jupyter-notebook.readthedocs.io/en/latest/">Jupyter Notebooks</a>, which are accessed through a webbrowser. So I will just run the Linux machine as a server and work in the notebooks through from my MacOS desktop using a browser. I find the Jupyter notebook a helpful tool, but <a href="https://twitter.com/joelgrus/status/1033035196428378113">here</a> are some valid points on its downsides.</p>
<p>A second reason for wanting to switch back to Linux has to do with the fact that I want to take a look at running deep learning models on a Graphics Processing Unit (<a href="https://blogs.nvidia.com/blog/2009/12/16/whats-the-difference-between-a-cpu-and-a-gpu/">GPU</a>). My MacOS desktop (iMac) does not have compatible hardware or the possibility of installing such hardware. Today, the <a href="https://developer.nvidia.com/computeworks">GPU's and toolkits from Nvidia</a> are most common and deep learning frameworks like TensorFlow and Theano support mainly those. I must admit that the GPU was not a strict requirement for the new hardware: I am currently interested in probabilistic programming in PyMC3 and those type of models generally do not benefit from running on a GPU. Using the CPU for the computations is often faster! But since i wanted to take a look at Keras/Tensorflow I opted for a GPU anyway, making it the most expensive hardware component in my build...</p>
<p>Below are some details on the hardware and the base installation of the Python libraries. It assumes basic knowledge of hardware components, Linux, Python and Deep Learning frameworks.</p>
<h3>Hardware</h3>
<hr>
<p>My objective was <em>not</em> to build a high-end Deep Learning machine with multiple GPU's of the newest hardware available. I wanted to have a reasonably compact and average machine in terms of performance and cost. Checking component compatibility and reviews with help of <a href="https://pcpartpicker.com/">pcpartpicker</a> was very convenient. The actual installation of the hardware was not very difficult. Carefully read the manual of the motherboard and case. Those will pretty much show you in which order to put things together.</p>
<p><img src="images/hardware_components.png" alt="Image: Hardware components" width="400"/></p>
<ul>
<li>
<p><strong>Motherboard: <a href="https://www.asus.com/uk/Motherboards/PRIME-B250M-PLUS/specifications/">ASUS Prime B250M-Plus</a></strong> <br>
This motherboard has a B250 chipset with support for 6th/7th generation Skylake/Kaby Lake Intel Core processors. Initially I went for the B250M-K which has one slot for GPU instead of two and two slots for RAM instead of four. This would have been fine since I do not intend on running multiple GPU's or upgrade to more RAM. But as it turned out, the B250M-K is not compatible with the case I had bought: it has only one connector for a case fan whereas my case came with two fans. I really liked the case so I decided to change the motherboard since the extra cost was small.</p>
</li>
<li>
<p><strong>CPU: <a href="https://ark.intel.com/products/97123">Intel Core i5 7500 3.4 GHz</a></strong> <br>
A 7th generation Kaby Lake processor with 4 cores from Q1 2017. </p>
</li>
<li>
<p><strong>CPU Cooler: <a href="http://www.coolermaster.com/cooling/cpu-air-cooler/hyper-212-evo/">Cooler Master Hyper 212 EVO</a></strong><br>
The Intel CPU came with a fan but I bought this one afterwards. Mostly to reduce the noise somewhat. I do not think there would have been any problems with the Intel stock cooler since I am not going to overclock the CPU. </p>
</li>
<li>
<p><strong>Video Card: <a href="https://www.asus.com/uk/Graphics-Cards/PH-GTX1060-6G/specifications/">ASUS GeForce GTX 1060 6GB Phoenix</a></strong><br>
Not the newest and most capable GPU on the market, but enough for what I intend to use it for.</p>
</li>
<li>
<p><strong>Memory: <a href="https://www.corsair.com/eu/en/Categories/Products/Memory/VENGEANCE%C2%AE-LPX-16GB-%282-x-8GB%29-DDR4-DRAM-2400MHz-C16-Memory-Kit---Black/p/CMK16GX4M2Z2400C16">Corsair 16GB (2x 8GB) DDR4 2400MHz CL16 Vengeance</a></strong> <br>
The Motherboard supports a maximum of 64GB DDR4 @ 2400 MHz. It required a BIOS update for the motherboard to run the RAM at 2400MHz. </p>
</li>
<li>
<p><strong>Storage: <a href="https://www.samsung.com/uk/memory-storage/960-evo-nvme-m-2-ssd/MZ-V6E250BW/">Samsung 960 EVO 250GB</a></strong><br>
I wanted a SSD disk as the main storage disk.</p>
</li>
<li>
<p><strong>Case: <a href="http://www.fractal-design.com/home/product/cases/define-series/define-mini-c">Fractal Design Define Mini C Svart</a></strong><br>
Nice, compact mATX case. High quality finish and good manual.</p>
</li>
<li>
<p><strong>Power Supply: <a href="http://www.fractal-design.com/home/product/power-supplies/integra-m/integra-m-450w">Fractal Design Integra M 450W</a></strong><br>
All the components together do not draw that much power at all. This modest 450 Watt power supply works just fine. </p>
</li>
</ul>
<p>The total price tag for the components was a little more than 1100 USD.</p>
<h3>Software</h3>
<hr>
<p>Instead of just copying the installation instructions of the various libraries here, I will just mentioned specific points which I think are especially important. You should read all notes in the context of <em>"At the time of installation"</em>. Available versions and dependencies have likely changed since then. </p>
<ul>
<li>
<p><strong><a href="https://help.ubuntu.com/16.04/installation-guide/index.html">Ubuntu 16.04 LTS</a></strong> <br>
I chose the 16.04 release over the more recent 18.04 because the latter is not explicitly mentioned as being compatible with the Nvidia Cuda Toolkit. Judging from various posts on the Internet there are ways to get it to work in 18.04, but I did not want to take any chances. I installed Ubuntu by means of a boot image on a <a href="https://help.ubuntu.com/16.04/installation-guide/amd64/ch04s03.html">USB memory stick</a>. </p>
</li>
<li>
<p><strong><a href="https://developer.nvidia.com/cuda-toolkit-archive">Nvidia CUDA Toolkit 9.0</a></strong><br>
<em>"The NVIDIA® CUDA® Toolkit provides a development environment for creating high performance GPU-accelerated applications. With the CUDA Toolkit, you can develop, optimize and deploy your applications on GPU-accelerated embedded systems, desktop workstations, enterprise data centers, cloud-based platforms and HPC supercomputers."</em><br>
TensorFlow with GPU support in Ubuntu requires CUDA Toolkit 9.0. After carefully following the <a href="https://docs.nvidia.com/cuda/archive/9.0/cuda-installation-guide-linux/index.html">installation and post-installation instructions</a>, I did not encounter any problems with the Ubuntu deb packages. To make sure that my package manager does automatically upgrade to a never version of the toolkit I installed with <code>sudo apt-get install cuda-9.0</code> instead of <code>sudo apt-get install cuda</code>. </p>
</li>
<li>
<p><strong><a href="https://developer.nvidia.com/cudnn">Nvidia cuDNN 7.1.4 for CUDA 9.0</a></strong><br>
<em>"The NVIDIA CUDA® Deep Neural Network library (cuDNN) is a GPU-accelerated library of primitives for deep neural networks. cuDNN provides highly tuned implementations for standard routines such as forward and backward convolution, pooling, normalization, and activation layers. cuDNN is part of the NVIDIA Deep Learning SDK."</em><br>
I installed the deb packages as described in the <a href="https://docs.nvidia.com/deeplearning/sdk/cudnn-archived/cudnn_714/cudnn-install/index.html#install-linux">documentation</a>. You will have to register (free) as a developer to be able to download the library. </p>
</li>
<li>
<p><strong><a href="https://www.anaconda.com/download/#linux">Anaconda 5.2 (Python 3.6)</a></strong><br>
I created a conda environment with Python version 3.6 and installed the typical PyData libraries like Pandas, Numpy, Scipy, Matplotlib and Jupyter. </p>
</li>
<li>
<p><strong><a href="http://deeplearning.net/software/theano/install_ubuntu.html">Theano 1.0.2</a></strong><br>
Bleeding-Edge installation as described in the documentation: <code>pip install</code> from GitHub. I did this within the conda environment. The Ubuntu installation instructions appear a bit dated with regards to the required versions of the dependent libraries. Just install the libraries mentioned using <code>conda install [library]</code>. I installed libgpuarray following the step-by-step system install description (note <code>cmake</code> requirement).<br>
Read the documentation about the configuration of Theano using the <code>.theanorc</code> file.</p>
</li>
<li>
<p><strong><a href="http://docs.pymc.io/">PyMC3 3.5</a></strong><br>
PyMC3 is a Python package for Bayesian modelling and relies on Theano for computations. I installed the development branch with <code>pip install</code> from GitHub within the conda environment. When testing some code to see if I could use the GPU with Theano, I found out that PyMC3 tries to do parallel MCMC sampling by default. It assumes that you have multiple GPU's and this will result in a RuntimeError. Specify <code>cores=1</code> when calling the <code>pm.sample()</code> method. If you have configured Theano to use the CPU instead of the GPU (<code>device = cpu</code> in your <code>.theanorc</code> file), you can enter the number of cores of your cpu. As mentioned earlier, the GPU does generally not speed up computations with PyMC3 models. </p>
</li>
<li>
<p><strong><a href="https://www.tensorflow.org/install/install_linux">TensorFlow 1.9</a></strong><br>
Installed in the conda environment using pip and the URL of the TensorFlow package with GPU support for Python 3.6.</p>
</li>
<li>
<p><strong><a href="https://keras.io/">Keras 2.2.2</a></strong><br>
Installed in the conda environment using pip. It will use TensorFlow as its backend.</p>
</li>
</ul>
<p>There are of course more base packages and libraries that one would install in a typical development environment, but the above are the main parts with regards to Deep Learning and Bayesian modelling. Furthermore, the modelling and Deep Learning ecosystem for Python is <a href="https://t.co/Zn6pjXplXB">developping fast</a>. Many more frameworks are available. I am looking forward to exploring these!</p>
</div>
<div class="article-tag-list">
<span class="label label-default">Tags</span>
<a href="https://jwarmenhoven.github.io/tag/linux.html"><i class="fa fa-tag"></i>Linux</a>
<a href="https://jwarmenhoven.github.io/tag/deep-learning.html"><i class="fa fa-tag"></i>Deep Learning</a>
<a href="https://jwarmenhoven.github.io/tag/gpu.html"><i class="fa fa-tag"></i>GPU</a>
<a href="https://jwarmenhoven.github.io/tag/python.html"><i class="fa fa-tag"></i>Python</a>
</div> <hr />
<div class="well well-sm"> <!-- Social media sharing buttons -->
<!-- Twitter -->
<a href="https://twitter.com/share" class="twitter-share-button"
data-via="penguinsula" >Tweet</a>
<!-- Google+ -->
<div class="g-plus" data-action="share" data-annotation="bubble"></div>
<div class="g-plusone" data-size="medium"></div>
<!-- Facebook -->
<div class="fb-like"
data-href="https://jwarmenhoven.github.io/Linux-Deep-Learning-Machine.html"
data-layout="button_count"
data-action="like" data-show-faces="true"
data-share="true">
</div>
</div> <!-- /Social media sharing buttons -->
<div class="comments">
<h2>Comments</h2>
<div id="disqus_thread"></div>
<script type="text/javascript">
(function() {
var dsq = document.createElement('script');
dsq.type = 'text/javascript'; dsq.async = true;
dsq.src = '//penguinsula.disqus.com/embed.js';
(document.getElementsByTagName('head')[0] ||
document.getElementsByTagName('body')[0]).appendChild(dsq);
})();
</script>
</div>
</article>
</div><!-- /content -->
<div class="col-md-3 sidebar-nav" id="sidebar">
<div class="row">
<div class="col-xs-6 col-md-12">
<h4><i class="fa fa-comment fa-fw fa-lg"></i> Social</h4>
<ul class="list-unstyled social-links">
<li><a href="https://fosstodon.org/@Penguinsula" target="_blank">
<i class="fa fa-pencil-square fa-fw fa-lg" title="Mastodon"></i>
Mastodon
</a></li>
<li><a href="https://twitter.com/penguinsula" target="_blank">
<i class="fa fa-twitter-square fa-fw fa-lg" title="Twitter"></i>
Twitter
</a></li>
<li><a href="https://github.com/jwarmenhoven" target="_blank">
<i class="fa fa-github-square fa-fw fa-lg" title="GitHub"></i>
GitHub
</a></li>
<li><a href="https://www.linkedin.com/in/jordi-warmenhoven-9650805/" target="_blank">
<i class="fa fa-linkedin-square fa-fw fa-lg" title="LinkedIn"></i>
LinkedIn
</a></li>
</ul>
</div>
<div class="col-xs-6 col-md-12">
<h4><i class="fa fa-folder fa-fw fa-lg"></i> Categories</h4>
<ul class="list-unstyled category-links">
<li><a href="https://jwarmenhoven.github.io/category/blog.html" >
<i class="fa fa-folder-open fa-fw fa-lg"></i> Blog</a></li>
</ul>
</div>
</div> <!-- /row -->
<h4><i class="fa fa-tags fa-fw fa-lg"></i> Tags</h4>
<p class="tag-cloud">
<a href="https://jwarmenhoven.github.io/tag/kerberos.html">
<i class="fa fa-tag fa-fw fa-lg"></i>Kerberos
</a>
<a href="https://jwarmenhoven.github.io/tag/nfs4.html">
<i class="fa fa-tag fa-fw fa-lg"></i>NFS4
</a>
<a href="https://jwarmenhoven.github.io/tag/linux.html">
<i class="fa fa-tag fa-fw fa-lg"></i>Linux
</a>
<a href="https://jwarmenhoven.github.io/tag/manjaro.html">
<i class="fa fa-tag fa-fw fa-lg"></i>Manjaro
</a>
<a href="https://jwarmenhoven.github.io/tag/synology.html">
<i class="fa fa-tag fa-fw fa-lg"></i>Synology
</a>
<a href="https://jwarmenhoven.github.io/tag/nas.html">
<i class="fa fa-tag fa-fw fa-lg"></i>NAS
</a>
<a href="https://jwarmenhoven.github.io/tag/deep-learning.html">
<i class="fa fa-tag fa-fw fa-lg"></i>Deep Learning
</a>
<a href="https://jwarmenhoven.github.io/tag/gpu.html">
<i class="fa fa-tag fa-fw fa-lg"></i>GPU
</a>
<a href="https://jwarmenhoven.github.io/tag/python.html">
<i class="fa fa-tag fa-fw fa-lg"></i>Python
</a>
</p>
<hr />
</div><!--/sidebar -->
</div><!--/row-->
</div><!--/.container /#main-container -->
<footer id="site-footer">
<address id="site-colophon">
<p class="text-center text-muted">
Site built using <a href="http://getpelican.com/" target="_blank">Pelican</a>
• Theme based on
<a href="http://www.voidynullness.net/page/voidy-bootstrap-pelican-theme/"
target="_blank">VoidyBootstrap</a> by
<a href="http://www.robertiwancz.com/"
target="_blank">RKI</a>
</p>
</address><!-- /colophon -->
</footer>
<!-- DISQUS script for displaying comment count -->
<script type="text/javascript">
var disqus_shortname = 'penguinsula';
(function () {
var s = document.createElement('script'); s.async = true;
s.type = 'text/javascript';
s.src = '//' + disqus_shortname + '.disqus.com/count.js';
(document.getElementsByTagName('HEAD')[0] || document.getElementsByTagName('BODY')[0]).appendChild(s);
}());
</script>
<!-- javascript -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js" integrity="sha384-nvAa0+6Qg9clwYCGGPpDQLVpLNn0fRaROjHqs13t4Ggj3Ez50XnGQqc/r8MhnRDZ" crossorigin="anonymous"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"
integrity="sha384-Tc5IQib027qvyjSMfHjOMaLkfuWVxZxUPnCJA7l2mCWNIpG9mGCD8wGNIcPD7Txa"
crossorigin="anonymous"></script>
<!-- Facebook -->
<div id="fb-root"></div>
<script>(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
</script>
<!-- Twitter -->
<script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0],p=/^http:/.test(d.location)?'http':'https';if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src=p+'://platform.twitter.com/widgets.js';fjs.parentNode.insertBefore(js,fjs);}}(document, 'script', 'twitter-wjs');</script>
<!-- Google+ -->
<!-- Synchronous
<script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script>
-->
<!-- Asynchronous -->
<script type="text/javascript">
(function() {
var po = document.createElement('script'); po.type = 'text/javascript'; po.async = true;
po.src = 'https://apis.google.com/js/platform.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(po, s);
})();
</script> </body>
</html>