<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	
	xmlns:georss="http://www.georss.org/georss"
	xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#"
	>

<channel>
	<title>GPU Archives &mdash; Tim Dettmers</title>
	<atom:link href="https://timdettmers.com/tag/gpu/feed/" rel="self" type="application/rss+xml" />
	<link>https://timdettmers.com/tag/gpu/</link>
	<description>Making deep learning accessible.</description>
	<lastBuildDate>Sat, 30 Oct 2021 04:25:45 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>
	hourly	</sy:updatePeriod>
	<sy:updateFrequency>
	1	</sy:updateFrequency>
	<generator>https://wordpress.org/?v=6.0.11</generator>

<image>
	<url>https://i0.wp.com/timdettmers.com/wp-content/uploads/2025/12/cropped-profile_2026_400x400.png?fit=32%2C32&#038;ssl=1</url>
	<title>GPU Archives &mdash; Tim Dettmers</title>
	<link>https://timdettmers.com/tag/gpu/</link>
	<width>32</width>
	<height>32</height>
</image> 
<site xmlns="com-wordpress:feed-additions:1">106749684</site>	<item>
		<title>A Full Hardware Guide to Deep Learning</title>
		<link>https://timdettmers.com/2018/12/16/deep-learning-hardware-guide/</link>
					<comments>https://timdettmers.com/2018/12/16/deep-learning-hardware-guide/#comments</comments>
		
		<dc:creator><![CDATA[Tim Dettmers]]></dc:creator>
		<pubDate>Sun, 16 Dec 2018 18:25:41 +0000</pubDate>
				<category><![CDATA[Hardware]]></category>
		<category><![CDATA[AMD]]></category>
		<category><![CDATA[CPU]]></category>
		<category><![CDATA[GPU]]></category>
		<category><![CDATA[Intel]]></category>
		<category><![CDATA[PCIe Lanes]]></category>
		<guid isPermaLink="false">https://timdettmers.wordpress.com/?p=121</guid>

					<description><![CDATA[<p>Here I will guide you step by step through the hardware you will need for a cheap high performance system for deep learning.</p>
<p>The post <a rel="nofollow" href="https://timdettmers.com/2018/12/16/deep-learning-hardware-guide/">A Full Hardware Guide to Deep Learning</a> appeared first on <a rel="nofollow" href="https://timdettmers.com">Tim Dettmers</a>.</p>
]]></description>
										<content:encoded><![CDATA[
<p class="eplus-Jtk1uQ">Deep Learning is very computationally intensive, so you will need a fast CPU with many cores, right? Or is it maybe wasteful to buy a fast CPU? One of the worst things you can do when building a deep learning system is to waste money on hardware that is unnecessary. Here I will guide you step by step through the hardware you will need for a cheap high-performance system.</p>



<span id="more-121"></span>



<p class="eplus-UTx6Bt">Over the years, I build a total of 7 different deep learning workstations and despite careful research and reasoning, I made my fair share of mistake in selecting hardware parts. In this guide, I want to share my experience that I gained over the years so that you do not make the same mistakes that I did before.</p>



<p class="eplus-LmAMuN">The blog post is ordered by mistake severity. This means the mistakes where people usually waste the most money come first.</p>




<h2><strong>GPU</strong></h2>
<p>This blog post assumes that you will use a GPU for deep learning. If you are building or upgrading your system for deep learning, it is not sensible to leave out the GPU. The GPU is just the heart of deep learning applications – the improvement in processing speed is just too huge to ignore.</p>
<p>I talked at length about GPU choice in <a href="https://timdettmers.com/2020/09/07/which-gpu-for-deep-learning/">my GPU recommendations blog post</a>, and the choice of your GPU is probably the most critical choice for your deep learning system. There are three main mistakes that you can make when choosing a GPU: (1) bad cost/performance, (2) not enough memory, (3) poor cooling.</p>
<p>For good cost/performance, I generally recommend an RTX 2070 or an RTX 2080 Ti. If you use these cards you should use 16-bit models. Otherwise, GTX 1070, GTX 1080, GTX 1070 Ti, and GTX 1080 Ti from eBay are fair choices and you can use these GPUs with 32-bit (but not 16-bit).</p>
<p>Be careful about the memory requirements when you pick your GPU. RTX cards, which can run in 16-bits, can train models which are twice as big with the same memory compared to GTX cards. As such RTX cards have a memory advantage and picking RTX cards and learn how to use 16-bit models effectively will carry you a long way. In general, the requirements for memory are roughly the following:</p>
<ul>
<li>Research that is hunting state-of-the-art scores: &gt;=11 GB</li>
<li>Research that is hunting for interesting architectures: &gt;=8 GB</li>
<li>Any other research: 8 GB</li>
<li>Kaggle: 4 &#8211; 8 GB</li>
<li>Startups: 8 GB (but check the specific application area for model sizes)</li>
<li>Companies: 8 GB for prototyping, &gt;=11 GB for training</li>
</ul>
<p>Another problem to watch out for, especially if you buy multiple RTX cards is cooling. If you want to stick GPUs into PCIe slots which are next to each other you should make sure that you get GPUs with a blower-style fan. Otherwise you might run into temperature issues and your GPUs will be slower (about 30%) and die faster.</p>
<figure id="attachment_124" aria-describedby="caption-attachment-124" style="width: 700px" class="wp-caption aligncenter"><a href="https://i0.wp.com/timdettmers.com/wp-content/uploads/2015/03/suspectlineup.jpg"><img data-attachment-id="124" data-permalink="https://timdettmers.com/2018/12/16/deep-learning-hardware-guide/suspectlineup/" data-orig-file="https://i0.wp.com/timdettmers.com/wp-content/uploads/2015/03/suspectlineup.jpg?fit=3264%2C1836&amp;ssl=1" data-orig-size="3264,1836" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;2.4&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;U9200&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1403265762&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;4.13&quot;,&quot;iso&quot;:&quot;122&quot;,&quot;shutter_speed&quot;:&quot;0.016666&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;1&quot;}" data-image-title="suspectlineup" data-image-description="" data-image-caption="" data-medium-file="https://i0.wp.com/timdettmers.com/wp-content/uploads/2015/03/suspectlineup.jpg?fit=300%2C169&amp;ssl=1" data-large-file="https://i0.wp.com/timdettmers.com/wp-content/uploads/2015/03/suspectlineup.jpg?fit=1024%2C576&amp;ssl=1" class="wp-image-124 size-full" src="https://i0.wp.com/timdettmers.com/wp-content/uploads/2015/03/suspectlineup.jpg?resize=700%2C394" alt="" width="700" height="394" border="None" data-recalc-dims="1" /></a><figcaption id="caption-attachment-124" class="wp-caption-text"><strong>Suspect line-up</strong><br />Can you identify the hardware part which is at fault for bad performance? One of these GPUs? Or maybe it is the fault of the CPU after all?</figcaption></figure>
<h2>RAM</h2>
<p>The main mistakes with RAM is to buy RAM with a too high clock rate. The second mistake is to buy not enough RAM to have a smooth prototyping experience.</p>
<h3>Needed RAM Clock Rate</h3>
<p>RAM clock rates are marketing stints where RAM companies lure you into buying &#8220;faster&#8221; RAM which actually yields little to no performance gains. This is best explained by &#8220;<a href="https://www.youtube.com/watch?v=D_Yt4vSZKVk">Does RAM speed REALLY matter?</a>&#8221; video on RAM von Linus Tech Tips.</p>
<p>Furthermore, it is important to know that RAM speed is pretty much irrelevant for fast CPU RAM-&gt;GPU RAM transfers. This is so because (1) if you used <a href="https://pytorch.org/docs/stable/notes/cuda.html#use-pinned-memory-buffers">pinned memory</a>, your mini-batches will be transferred to the GPU without involvement from the CPU, and (2) if you do not use pinned memory the performance gains of fast vs slow RAMs is about 0-3% &#8212; spend your money elsewhere!</p>
<h3>RAM Size</h3>
<p>RAM size does not affect deep learning performance. However, it might hinder you from executing your GPU code comfortably (without swapping to disk). You should have enough RAM to comfortable work with your GPU. This means you should have at least the amount of RAM that matches your biggest GPU. For example, if you have a Titan RTX with 24 GB of memory you should have at least 24 GB of RAM. However, if you have more GPUs you do not necessarily need more RAM.</p>
<p>The problem with this &#8220;match largest GPU memory in RAM&#8221; strategy is that you might still fall short of RAM if you are processing large datasets. The best strategy here is to match your GPU and if you feel that you do not have enough RAM just buy some more.</p>
<p>A different strategy is influenced by psychology: Psychology tells us that concentration is a resource that is depleted over time. RAM is one of the few hardware pieces that allows you to conserve your concentration resource for more difficult programming problems. Rather than spending lots of time on circumnavigating RAM bottlenecks, you can invest your concentration on more pressing matters if you have more RAM.  With a lot of RAM you can avoid those bottlenecks, save time and increase productivity on more pressing problems. Especially in Kaggle competitions, I found additional RAM very useful for feature engineering. So if you have the money and do a lot of pre-processing then additional RAM might be a good choice. So with this strategy, you want to have more, cheap RAM now rather than later.</p>
<h2>CPU</h2>
<p>The main mistake that people make is that people pay too much attention to PCIe lanes of a CPU. You should not care much about PCIe lanes. Instead, just look up if your CPU and motherboard combination supports the number of GPUs that you want to run. The second most common mistake is to get a CPU which is too powerful.</p>
<h3>CPU and PCI-Express</h3>
<p>People go crazy about PCIe lanes! However, the thing is that it has almost no effect on deep learning performance. If you have a single GPU, PCIe lanes are only needed to transfer data from your CPU RAM to your GPU RAM quickly. However, an ImageNet batch of 32 images (32x225x225x3) and 32-bit needs 1.1 milliseconds with 16 lanes, 2.3 milliseconds with 8 lanes, and 4.5 milliseconds with 4 lanes. These are theoretic numbers, and in practice you often see PCIe be twice as slow — but this is still lightning fast! PCIe lanes often have a latency in the nanosecond range and thus latency can be ignored.</p>
<p>Putting this together we have for an ImageNet mini-batch of 32 images and a ResNet-152 the following timing:</p>
<ul>
<li>Forward and backward pass: 216 milliseconds (ms)</li>
<li>16 PCIe lanes CPU-&gt;GPU transfer: About 2 ms (1.1 ms theoretical)</li>
<li>8 PCIe lanes CPU-&gt;GPU transfer: About 5 ms (2.3 ms)</li>
<li>4 PCIe lanes CPU-&gt;GPU transfer: About 9 ms (4.5 ms)</li>
</ul>
<p>Thus going from 4 to 16 PCIe lanes will give you a performance increase of roughly 3.2%. However, if you use <a href="https://pytorch.org/docs/stable/data.html#torch.utils.data.DataLoader">PyTorch&#8217;s data loader</a> with pinned memory you gain exactly 0% performance. So do not waste your money on PCIe lanes if you are using a single GPU!</p>
<p>When you select CPU PCIe lanes and motherboard PCIe lanes make sure that you select a combination which supports the desired number of GPUs. If you buy a motherboard that supports 2 GPUs, and you want to have 2 GPUs eventually, make sure that you buy a CPU that supports 2 GPUs, but do not necessarily look at PCIe lanes.</p>
<h3>PCIe Lanes and Multi-GPU Parallelism</h3>
<p>Are PCIe lanes important if you train networks on multiple GPUs with data parallelism? I have <a href="https://arxiv.org/abs/1511.04561">published a paper on this at ICLR2016</a>, and I can tell you if you have 96 GPUs then PCIe lanes are really important. However, if you have 4 or fewer GPUs this does not matter much. If you parallelize across 2-3 GPUs, I would not care at all about PCIe lanes. With 4 GPUs, I would make sure that I can get a support of 8 PCIe lanes per GPU (32 PCIe lanes in total). Since almost nobody runs a system with more than 4 GPUs as a rule of thumb: Do not spend extra money to get more PCIe lanes per GPU — it does not matter!</p>
<h3>Needed CPU Cores</h3>
<p>To be able to make a wise choice for the CPU we first need to understand the CPU and how it relates to deep learning. What does the CPU do for deep learning? The CPU does little computation when you run your deep nets on a GPU. Mostly it (1) initiates GPU function calls, (2) executes CPU functions.</p>
<p>By far the most useful application for your CPU is data preprocessing. There are two different common data processing strategies which have different CPU needs.</p>
<p>The first strategy is preprocessing while you train:</p>
<p>Loop:</p>
<ol>
<li>Load mini-batch</li>
<li>Preprocess mini-batch</li>
<li>Train on mini-batch</li>
</ol>
<p>The second strategy is preprocessing before any training:</p>
<ol>
<li>Preprocess data</li>
<li>Loop:
<ol>
<li>Load preprocessed mini-batch</li>
<li>Train on mini-batch</li>
</ol>
</li>
</ol>
<p>For the first strategy, a good CPU with many cores can boost performance significantly. For the second strategy, you do not need a very good CPU. For the first strategy, I recommend a minimum of 4 threads per GPU &#8212; that is usually two cores per GPU. I have not done hard tests for this, but you should gain about 0-5% additional performance per additional core/GPU.</p>
<p>For the second strategy, I recommend a minimum of 2 threads per GPU &#8212; that is usually one core per GPU. You will not see significant gains in performance when you have more cores if you are using the second strategy.</p>
<h3>Needed CPU Clock Rate (Frequency)</h3>
<p>When people think about fast CPUs they usually first think about the clock rate.  4GHz is better than 3.5GHz, or is it? This is generally true for comparing processors with the same architecture, e.g. “Ivy Bridge”, but it does not compare well between processors. Also, it is not always the best measure of performance.</p>
<p>In the case of deep learning there is very little computation to be done by the CPU: Increase a few variables here, evaluate some Boolean expression there, make some function calls on the GPU or within the program – all these depend on the CPU core clock rate.</p>
<p>While this reasoning seems sensible, there is the fact that the CPU has 100% usage when I run deep learning programs, so what is the issue here? I did some CPU core rate underclocking experiments to find out.</p>
<figure id="attachment_161" aria-describedby="caption-attachment-161" style="width: 804px" class="wp-caption aligncenter"><a href="https://i0.wp.com/timdettmers.com/wp-content/uploads/2015/03/cpu_underclocking2.png"><img data-attachment-id="161" data-permalink="https://timdettmers.com/2018/12/16/deep-learning-hardware-guide/cpu_underclocking/" data-orig-file="https://i0.wp.com/timdettmers.com/wp-content/uploads/2015/03/cpu_underclocking2.png?fit=603%2C406&amp;ssl=1" data-orig-size="603,406" 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="cpu_underclocking" data-image-description="" data-image-caption="&lt;p&gt;CPU underclocking on MNIST and ImageNet: Performance is measured as time taken on 100 epochs MNIST or half an epoch on ImageNet with different CPU core clock rates, where the maximum clock rate is taken as a base line for each CPU. For comparison: Upgrading from a GTX 580 to a GTX Titan is about +20% performance; from GTX Titan to GTX 980 another +30% performance; GPU overclocking yields about +5% performance for any GPU&lt;/p&gt;
" data-medium-file="https://i0.wp.com/timdettmers.com/wp-content/uploads/2015/03/cpu_underclocking2.png?fit=300%2C202&amp;ssl=1" data-large-file="https://i0.wp.com/timdettmers.com/wp-content/uploads/2015/03/cpu_underclocking2.png?fit=603%2C406&amp;ssl=1" class="wp-image-161" src="https://i0.wp.com/timdettmers.com/wp-content/uploads/2015/03/cpu_underclocking2.png?resize=804%2C541" alt="CPU underclocking on MNIST and ImageNet: Performance is measured as time taken on 100 epochs MNIST or half an epoch on ImageNet with different CPU core clock rates, where the maximum clock rate is taken as a base line for each CPU. For comparison: Upgrading from a GTX 580 to a GTX Titan is about +20% performance; from GTX Titan to GTX 980 another +30% performance; GPU overclocking yields about +5% performance for any GPU" width="804" height="541" data-recalc-dims="1" /></a><figcaption id="caption-attachment-161" class="wp-caption-text"><strong>CPU underclocking on MNIST and ImageNet</strong>: Performance is measured as time taken on 200 epochs MNIST or a quarter epoch on ImageNet with different CPU core clock rates, where the maximum clock rate is taken as a baseline for each CPU. For comparison: Upgrading from a GTX 680 to a GTX Titan is about +15% performance; from GTX Titan to GTX 980 another +20% performance; GPU overclocking yields about +5% performance for any GPU</figcaption></figure>
<p style="text-align: justify;">Note that these experiments are on a hardware that is dated, however, these results should still be the same for modern CPUs/GPUs.</p>
<h2 style="text-align: justify;"><strong>Hard drive/SSD</strong></h2>
<p>The hard drive is not usually a bottleneck for deep learning. However, if you do stupid things it will hurt you: If you read your data from disk when they are needed (blocking wait) then a 100 MB/s hard drive will cost you about 185 milliseconds for an ImageNet mini-batch of size 32 — ouch! However, if you asynchronously fetch the data before it is used (for example torch vision loaders), then you will have loaded the mini-batch in 185 milliseconds while the compute time for most deep neural networks on ImageNet is about 200 milliseconds. Thus you will not face any performance penalty since you load the next mini-batch while the current is still computing.</p>
<p>However, I recommend an SSD for comfort and productivity: Programs start and respond more quickly, and pre-processing with large files is quite a bit faster. If you buy an NVMe SSD you will have an even smoother experience when compared to a regular SSD.</p>
<p>Thus the ideal setup is to have a large and slow hard drive for datasets and an SSD for productivity and comfort.</p>
<h2 style="text-align: justify;"><strong>Power supply unit (PSU)</strong></h2>
<p>Generally, you want a PSU that is sufficient to accommodate all your future GPUs. GPUs typically get more energy efficient over time; so while other components will need to be replaced, a PSU should last a long while so a good PSU is a good investment.</p>
<p>You can calculate the required watts by adding up the watt of your CPU and GPUs with an additional 10% of watts for other components and as a buffer for power spikes. For example, if you have 4 GPUs with each 250 watts TDP and a CPU with 150 watts TDP, then you will need a PSU with a minimum of 4&#215;250 + 150 + 100 = 1250 watts. I would usually add another 10% just to be sure everything works out, which in this case would result in a total of 1375 Watts. I would round up in this case an get a 1400 watts PSU.</p>
<p>One important part to be aware of is that even if a PSU has the required wattage, it might not have enough PCIe 8-pin or 6-pin connectors. Make sure you have enough connectors on the PSU to support all your GPUs!</p>
<p>Another important thing is to buy a PSU with high power efficiency rating – especially if you run many GPUs and will run them for a longer time.</p>
<p>Running a 4 GPU system on full power (1000-1500 watts) to train a convolutional net for two weeks will amount to 300-500 kWh, which in Germany – with rather high power costs of 20 cents per kWh – will amount to 60-100€ ($66-111). If this price is for a 100% efficiency, then training such a net with an 80% power supply would increase the costs by an additional 18-26€ – ouch! This is much less for a single GPU, but the point still holds – spending a bit more money on an efficient power supply makes good sense.</p>
<p>Using a couple of GPUs around the clock will significantly increase your carbon footprint and it will overshadow transportation (mainly airplane) and other factors that contribute to your footprint. If you want to be responsible, please consider going <a href="https://wp.nyu.edu/ml2/carbon-neutral-lab/">carbon neutral like the NYU Machine Learning for Language Group (ML2)</a> — it is easy to do, cheap, and should be standard for deep learning researchers.</p>
<h2>CPU and GPU Cooling</h2>
<p>Cooling is important and it can be a significant bottleneck which reduces performance more than poor hardware choices do. You should be fine with a standard heat sink or all-in-one (AIO) water cooling solution for your CPU, but what for your GPU you will need to make special considerations.</p>
<h3>Air Cooling GPUs</h3>
<p>Air cooling is safe and solid for a single GPU or if you have multiple GPUs with space between them (2 GPUs in a 3-4 GPU case). However, one of the biggest mistakes can be made when you try to cool 3-4 GPUs and you need to think carefully about your options in this case.</p>
<p>Modern GPUs will increase their speed – and thus power consumption – up to their maximum when they run an algorithm, but as soon as the GPU hits a temperature barrier – often 80 °C – the GPU will decrease the speed so that the temperature threshold is not breached. This enables the best performance while keeping your GPU safe from overheating.</p>
<p>However, typical pre-programmed schedules for fan speeds are badly designed for deep learning programs, so that this temperature threshold is reached within seconds after starting a deep learning program. The result is a decreased performance (0-10%) which can be significant for multiple GPUs (10-25%) where the GPU heat up each other.</p>
<p>Since NVIDIA GPUs are first and foremost gaming GPUs, they are optimized for Windows. You can change the fan schedule with a few clicks in Windows, but not so in Linux, and as most deep learning libraries are written for Linux this is a problem.</p>
<p>The only option under Linux is to use to set a configuration for your Xorg server (Ubuntu) where you set the option &#8220;coolbits&#8221;. This works very well for a single GPU, but if you have multiple GPUs where some of them are headless, i.e. they have no monitor attached to them, you have to emulate a monitor which is hard and hacky. I tried it for a long time and had frustrating hours with a live boot CD to recover my graphics settings – I could never get it running properly on headless GPUs.</p>
<p>The most important point of consideration if you run 3-4 GPUs on air cooling is to pay attention to the fan design. The &#8220;blower&#8221; fan design pushes the air out to the back of the case so that fresh, cooler air is pushed into the GPU. Non-blower fans suck in air in the vincity of the GPU and cool the GPU. However, if you have multiple GPUs next to each other then there is no cool air around and GPUs with non-blower fans will heat up more and more until they throttle themselves down to reach cooler temperatures. Avoid non-blower fans in 3-4 GPU setups at all costs.</p>
<h3>Water Cooling GPUs For Multiple GPUs</h3>
<p>Another, more costly, and craftier option is to use water cooling. I do not recommend water cooling if you have a single GPU or if you have space between your two GPUs (2 GPUs in 3-4 GPU board). However, water cooling makes sure that even the beefiest GPU stay cool in a 4 GPU setup which is not possible when you cool with air. Another advantage of water cooling is that it operates much more silently, which is a big plus if you run multiple GPUs in an area where other people work. Water cooling will cost you about $100 for each GPU and some additional upfront costs (something like $50). Water cooling will also require some additional effort to assemble your computer, but there are many detailed guides on that and it should only require a few more hours of time in total. Maintenance should not be that complicated or effortful.</p>
<h3>A Big Case for Cooling?</h3>
<p>I bought large towers for my deep learning cluster, because they have additional fans for the GPU area, but I found this to be largely irrelevant: About 2-5 °C decrease, not worth the investment and the bulkiness of the cases. The most important part is really the cooling solution directly on your GPU — do not select an expensive case for its GPU cooling capability. Go cheap here. The case should fit your GPUs but thats it!</p>
<h3>Conclusion Cooling</h3>
<p>So in the end it is simple: For 1 GPU air cooling is best. For multiple GPUs, you should get blower-style air cooling and accept a tiny performance penalty (10-15%), or you pay extra for water cooling which is also more difficult to setup correctly and you have no performance penalty. Air and water cooling are all reasonable choices in certain situations. I would however recommend air cooling for simplicity in general — get a blower-style GPU if you run multiple GPUs. If you want to user water cooling try to find all-in-one (AIO) water cooling solutions for GPUs.</p>
<h2>Motherboard</h2>
<p>Your motherboard should have enough PCIe ports to support the number of GPUs you want to run (usually limited to four GPUs, even if you have more PCIe slots); remember that most GPUs have a width of two PCIe slots, so buy a motherboard that has enough space between PCIe slots if you intend to use multiple GPUs. Make sure your motherboard not only has the PCIe slots, but actually supports the GPU setup that you want to run. You can usually find information in this if you search your motherboard of choice on newegg and look at PCIe section on the specification page.</p>
<h2>Computer Case</h2>
<p>When you select a case, you should make sure that it supports full length GPUs that sit on top of your motherboard. Most cases support full length GPUs, but you should be suspicious if you buy a small case. Check its dimensions and specifications; you can also try a google image search of that model and see if you find pictures with GPUs in them.</p>
<p>If you use custom water cooling, make sure your case has enough space for the radiators. This is especially true if you use water cooling for your GPUs. The radiator of each GPU will need some space — make sure your setup actually fits into the GPU.</p>
<h3 style="text-align: justify;"><strong>Monitors</strong></h3>
<p style="text-align: justify;">I first thought it would be silly to write about monitors also, but they make such a huge difference and are so important that I just have to write about them.</p>
<p style="text-align: justify;">The money I spent on my 3 27 inch monitors is probably the best money I have ever spent. Productivity goes up by a lot when using multiple monitors. I feel desperately crippled if I have to work with a single monitor.  Do not short-change yourself on this matter. What good is a fast deep learning system if you are not able to operate it in an efficient manner?</p>
<figure id="attachment_123" aria-describedby="caption-attachment-123" style="width: 700px" class="wp-caption aligncenter"><a href="https://i0.wp.com/timdettmers.com/wp-content/uploads/2015/03/2015-03-04-13-58-10.jpg"><img data-attachment-id="123" data-permalink="https://timdettmers.com/2018/12/16/deep-learning-hardware-guide/2015-03-04-13-58-10/" data-orig-file="https://i0.wp.com/timdettmers.com/wp-content/uploads/2015/03/2015-03-04-13-58-10.jpg?fit=3264%2C1836&amp;ssl=1" data-orig-size="3264,1836" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;2.4&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;U9200&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1425477490&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;4.13&quot;,&quot;iso&quot;:&quot;104&quot;,&quot;shutter_speed&quot;:&quot;0.016666&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;1&quot;}" data-image-title="2015-03-04 13.58.10" data-image-description="&lt;p&gt;Typical layout when I do deep learning: Left: Papers, google searcheres, gmail, stackoverflow threads; middle: Code; right: Output windows, R, folders, systems monitors, GPU monitors, to-do list, and other small applications.&lt;/p&gt;
" data-image-caption="" data-medium-file="https://i0.wp.com/timdettmers.com/wp-content/uploads/2015/03/2015-03-04-13-58-10.jpg?fit=300%2C169&amp;ssl=1" data-large-file="https://i0.wp.com/timdettmers.com/wp-content/uploads/2015/03/2015-03-04-13-58-10.jpg?fit=1024%2C576&amp;ssl=1" class="wp-image-123 size-full" src="https://i0.wp.com/timdettmers.com/wp-content/uploads/2015/03/2015-03-04-13-58-10.jpg?resize=700%2C394" alt="2015-03-04 13.58.10" width="700" height="394" data-recalc-dims="1" /></a><figcaption id="caption-attachment-123" class="wp-caption-text"><strong>Typical monitor layout when I do deep learning:</strong> Left: Papers, Google searches, gmail, stackoverflow; middle: Code; right: Output windows, R, folders, systems monitors, GPU monitors, to-do list, and other small applications.</figcaption></figure>
<h4 style="text-align: justify;"><strong>Some words on building a PC</strong></h4>
<p style="text-align: justify;">Many people are scared to build computers. The hardware components are expensive and you do not want to do something wrong. But it is really simple as components that do not belong together do not fit together. The motherboard manual is often very specific how to assemble everything and there are tons of guides and step by step videos which guide you through the process if you have no experience.</p>
<p style="text-align: justify;">The great thing about building a computer is, that you know everything that there is to know about building a computer when you did it once, because all computer are built in the very same way – so building a computer will become a life skill that you will be able to apply again and again. So no reason to hold back!</p>
<h2><strong>Conclusion / TL;DR</strong></h2>
<p><strong>GPU</strong>: RTX 2070 or RTX 2080 Ti. GTX 1070, GTX 1080, GTX 1070 Ti, and GTX 1080 Ti from eBay are good too!<br /><strong>CPU</strong>: 1-2 cores per GPU depending how you preprocess data. &gt; 2GHz; CPU should support the number of GPUs that you want to run. PCIe lanes do not matter.</p>
<p><strong>RAM</strong>:<br />&#8211; Clock rates do not matter — buy the cheapest RAM.<br />&#8211; Buy at least as much CPU RAM to match the RAM of your largest GPU.<br />&#8211; Buy more RAM only when needed.<br />&#8211; More RAM can be useful if you frequently work with large datasets.</p>
<p><strong>Hard drive/SSD</strong>:<br />&#8211; Hard drive for data (&gt;= 3TB)<br />&#8211; Use SSD for comfort and preprocessing small datasets.</p>
<p><strong>PSU</strong>:<br />&#8211; Add up watts of GPUs + CPU. Then multiply the total by 110% for required Wattage.<br />&#8211; Get a high efficiency rating if you use a multiple GPUs.<br />&#8211; Make sure the PSU has enough PCIe connectors (6+8pins)</p>
<p><strong>Cooling</strong>:<br />&#8211; CPU: get standard CPU cooler or all-in-one (AIO) water cooling solution<br />&#8211; GPU:<br />&#8211; Use air cooling<br />&#8211; Get GPUs with &#8220;blower-style&#8221; fans if you buy multiple GPUs<br />&#8211; Set coolbits flag in your Xorg config to control fan speeds</p>
<p><strong>Motherboard</strong>:<br />&#8211; Get as many PCIe slots as you need for your (future) GPUs (one GPU takes two slots; max 4 GPUs per system)</p>
<p><strong>Monitors</strong>:<br />&#8211; An additional monitor might make you more productive than an additional GPU.</p>
<p>Update 2018-12-14: Reworked entire blog post with up-to-date recommendations.<br />Update 2015-04-22: Removed recommendation for GTX 580</p><p>The post <a rel="nofollow" href="https://timdettmers.com/2018/12/16/deep-learning-hardware-guide/">A Full Hardware Guide to Deep Learning</a> appeared first on <a rel="nofollow" href="https://timdettmers.com">Tim Dettmers</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://timdettmers.com/2018/12/16/deep-learning-hardware-guide/feed/</wfw:commentRss>
			<slash:comments>945</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">121</post-id>	</item>
		<item>
		<title>TPUs vs GPUs for Transformers (BERT)</title>
		<link>https://timdettmers.com/2018/10/17/tpus-vs-gpus-for-transformers-bert/</link>
					<comments>https://timdettmers.com/2018/10/17/tpus-vs-gpus-for-transformers-bert/#comments</comments>
		
		<dc:creator><![CDATA[Tim Dettmers]]></dc:creator>
		<pubDate>Wed, 17 Oct 2018 18:13:03 +0000</pubDate>
				<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Accelerators]]></category>
		<category><![CDATA[GPU]]></category>
		<category><![CDATA[Matrix Multiplication]]></category>
		<guid isPermaLink="false">http://timdettmers.com/?p=686</guid>

					<description><![CDATA[<p>On the computational side, there have been confusions about how TPUs and GPUs relate to BERT. BERT base was trained with 4 TPU pods (16 TPU chips) in 4 days and BERT large with 16 TPUs (64 TPU chips) in 4 days. Does this mean only Google can train a BERT model? Does this mean [&#8230;]</p>
<p>The post <a rel="nofollow" href="https://timdettmers.com/2018/10/17/tpus-vs-gpus-for-transformers-bert/">TPUs vs GPUs for Transformers (BERT)</a> appeared first on <a rel="nofollow" href="https://timdettmers.com">Tim Dettmers</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>On the computational side, there have been confusions about how TPUs and GPUs relate to <a href="https://arxiv.org/abs/1810.04805">BERT</a>. BERT base was trained with 4 TPU pods (16 TPU chips) in 4 days and BERT large with 16 TPUs (64 TPU chips) in 4 days. Does this mean only Google can train a BERT model? Does this mean that GPUs are dead? There are two fundamental things to understand here: (1) A TPU is a matrix multiplication engine — it does matrix multiplication and matrix operations, but not much else. It is fast at computing matrix multiplication, but one has to understand that (2) the slowest thing in matrix multiplication is to get the elements from the main memory and load it into the processing unit. In other words, the most expensive part in matrix multiplication is memory loads. Note the computational load for BERT should be about 90% for matrix multiplication. From these facts, we can do a small technical analysis on this topic.</p>
<p><span id="more-686"></span></p>
<h2>Bandwidth Model for TPUs and GPUs</h2>
<h3>Transformers for TPUs</h3>
<p>A common operation in BERT is matrix multiplication A*B=C where A is 256&#215;1024 and B is 1024&#215;1024 in dimension. A TPU computes such a matrix multiplication by splitting the matrix into many smaller 128&#215;128 matrix multiplications. This means we need to load 16 128&#215;128 matrix tiles from matrix A — and due to the nature of matrix multiplication — we need to load 64 tiles from B for every tile in A. This is a total of 16*64=1024 128&#215;128 loads. At 16-bit that is a total of 32 MB of data.</p>
<p><a href="https://i0.wp.com/timdettmers.com/wp-content/uploads/2018/10/Cloud-TPU-Feature.jpg"><img data-attachment-id="698" data-permalink="https://timdettmers.com/2018/10/17/tpus-vs-gpus-for-transformers-bert/cloud-tpu-feature/" data-orig-file="https://i0.wp.com/timdettmers.com/wp-content/uploads/2018/10/Cloud-TPU-Feature.jpg?fit=1123%2C620&amp;ssl=1" data-orig-size="1123,620" 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="Cloud-TPU-Feature" data-image-description="" data-image-caption="" data-medium-file="https://i0.wp.com/timdettmers.com/wp-content/uploads/2018/10/Cloud-TPU-Feature.jpg?fit=300%2C166&amp;ssl=1" data-large-file="https://i0.wp.com/timdettmers.com/wp-content/uploads/2018/10/Cloud-TPU-Feature.jpg?fit=1024%2C565&amp;ssl=1" class="aligncenter wp-image-698" title="TPU vs GPU" src="https://i0.wp.com/timdettmers.com/wp-content/uploads/2018/10/Cloud-TPU-Feature-1024x565.jpg?resize=745%2C411" alt="TPU vs GPU" width="745" height="411" srcset="https://i0.wp.com/timdettmers.com/wp-content/uploads/2018/10/Cloud-TPU-Feature.jpg?resize=1024%2C565&amp;ssl=1 1024w, https://i0.wp.com/timdettmers.com/wp-content/uploads/2018/10/Cloud-TPU-Feature.jpg?resize=300%2C166&amp;ssl=1 300w, https://i0.wp.com/timdettmers.com/wp-content/uploads/2018/10/Cloud-TPU-Feature.jpg?resize=768%2C424&amp;ssl=1 768w, https://i0.wp.com/timdettmers.com/wp-content/uploads/2018/10/Cloud-TPU-Feature.jpg?w=1123&amp;ssl=1 1123w" sizes="(max-width: 745px) 100vw, 745px" data-recalc-dims="1" /></a></p>
<p>Now we make a simplification: We assume that there is no latency if we do two memory loads after each other, which is actually not too unreasonable since often you can hide memory access latency under thread parallelism. In simple words, this means: While we wait for one 128&#215;128 matrix copy to complete, we already do the next one. In doing it this way, we only wait for the first memory copy and we do not wait for other copies. This is a <a href="https://www.quora.com/Why-are-GPUs-well-suited-to-deep-learning">core reason why GPUs are fast</a> and why we use many threads in GPUs thus 0 latency for overlapping memory transfers is not too far off from the real world. Using this simplification, we can now plainly use the memory bandwidth to compute the time needed to load the memory for the matrix multiplication. If we look at the bandwidth of the TPU we find that we have 600 GB/s, so we need 5.2e-05 seconds to transfer the 32 MB of data.</p>
<h3>Transformers on GPUs</h3>
<p>For a GPU we have the same process, but we use smaller tiles with more processors. Similarly to the TPU, we use two loads in parallel to hide memory latency. For GPUs, however, we would have a tile size of 96&#215;96 for 16-bit data. If we take a V100 Tesla GPU, then we can run 160 of these in parallel at full bandwidth with low memory latency. What this means compared to a TPU: Instead of 2 matrix units which can hold 128&#215;128 matrices, the GPU has 160 units (80 SMs, 160 thread blocks, each thread block has two 96&#215;96 matrices) which hold two 96&#215;96 matrices. Again this ensures that we can hide the memory latency through parallelism.</p>
<p><a href="https://i0.wp.com/timdettmers.com/wp-content/uploads/2018/10/010.jpg"><img data-attachment-id="697" data-permalink="https://timdettmers.com/2018/10/17/tpus-vs-gpus-for-transformers-bert/attachment/010/" data-orig-file="https://i0.wp.com/timdettmers.com/wp-content/uploads/2018/10/010.jpg?fit=1024%2C576&amp;ssl=1" data-orig-size="1024,576" 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="010" data-image-description="" data-image-caption="" data-medium-file="https://i0.wp.com/timdettmers.com/wp-content/uploads/2018/10/010.jpg?fit=300%2C169&amp;ssl=1" data-large-file="https://i0.wp.com/timdettmers.com/wp-content/uploads/2018/10/010.jpg?fit=1024%2C576&amp;ssl=1" class="aligncenter wp-image-697" title="TPU vs GPU" src="https://i0.wp.com/timdettmers.com/wp-content/uploads/2018/10/010-1024x576.jpg?resize=818%2C460" alt="TPU vs GPU" width="818" height="460" srcset="https://i0.wp.com/timdettmers.com/wp-content/uploads/2018/10/010.jpg?w=1024&amp;ssl=1 1024w, https://i0.wp.com/timdettmers.com/wp-content/uploads/2018/10/010.jpg?resize=300%2C169&amp;ssl=1 300w, https://i0.wp.com/timdettmers.com/wp-content/uploads/2018/10/010.jpg?resize=768%2C432&amp;ssl=1 768w" sizes="(max-width: 818px) 100vw, 818px" data-recalc-dims="1" /></a></p>
<p>If we repeat the calculation from the top we receive the following: For matrix A with 256&#215;1024 we have 33 96&#215;96 tiles; for B with 1024&#215;1024 we have 121 96&#215;96 tiles. In total, we need to do 33*121=3993 loads of size 96&#215;96 for a total of 70 MB. A V100 runs at 900 GB/s and so the memory loads will take 7.6e-05 seconds. Thus our model predicts that a GPU is 32% slower than a TPU for this specific scenario. Note that matrix tiles stay the same for an RTX 2080 Ti GPU, but the memory bandwidth decreases to 616 GB/s. Which means an RTX 2080 Ti is 54% slower than a TPU.</p>
<p>Note that both TPU and GPUs with Tensor Cores compute the respective matrix multiplication tile in one cycle. Thus the computation is about equally fast — the difference is only in how the memory is loaded.</p>
<h3>BERT Training Time Estimate for GPUs</h3>
<p>Using this data, a GPU cluster of V100s/RTX 2080 Tis with good networking (Infiniband +56GBits/s) and good parallelization algorithms (for example using Microsoft&#8217;s CNTK) we can expect to train BERT large on 64 GPUs (the equivalent to 16 TPUs) or BERT base on 16 GPUs in 5 1/3 days or 8 1/2 days. On an 8 GPU machine for V100/RTX 2080 Tis with any software and any parallelization algorithm (PyTorch, TensorFlow) one can expect to train BERT large in 21 days or 34 days and BERT base in 10 2/3 or 17 days. For a standard 4 GPU desktop with RTX 2080 Ti (much cheaper than other options), one can expect to replicate BERT large in 68 days and BERT base in 34 days.</p>
<h2>Limitations of the Bandwidth Model</h2>
<p>Note that all models are wrong, but some are useful. I would expect that this bandwidth model is in about 30% of the correct runtime values for TPU vs GPU.</p>
<p>The biggest limitation is that these calculations&nbsp;are for specific matrices sizes. Computational differences can be amplified&nbsp;for certain sizes. For example, if your batch-size is 128, there is a slight speedup for GPUs compared to TPUs. If you go below a batch size of 128 you can expect GPUs to be significantly faster; increasing the matrix B further makes TPUs better and better compared to GPUs. Decreasing the size of matrix B will make the performance of GPUs better. Note that the BERT paper optimized matrix A and B sizes for the TPU — one would not choose these dimensions if you train with a GPU. So this comparison might favor TPUs slightly.</p>
<p>Further direct limitations include fused operations. The TPU can calculate additional element-wise operations such as a non-linear activation function or a bias on the fly within a matrix multiplication. This means that the TPU does not need to load from slow global memory as often as a GPU. The GPU also supports these operations but NVIDIA has not implemented them and thus GPU users will not be able to benefit from this. Thus one can expect a slowdown of about 1.6% (loading and storing a 256&#215;1024 matrix) for each element-wise operation for a GPU. For example, if you apply a non-linear function and a bias, then the TPU would be about 3.2% faster compared to GPUs in this scenario.</p>
<h2>The Importance of 32-bit vs 16-bit vs 8-bit</h2>
<p>If we repeat the same calculations from above for 32-bit values (64x64x tiles) we find that TPUs would be 5.3x faster. So the datatype size has a much larger effect than switching from TPU to GPU and vice versa.</p>
<p>TPUs do not support 8-bit training, but Turing GPUs do. So we can also have a look at how 8-bit matrix multiplication would impact performance.&nbsp;<a href="https://arxiv.org/abs/1511.04561">I published research on 8-bit models</a> and it is not too difficult to train them with 8-bit alone. In fact, the <a href="https://arxiv.org/search/cs?searchtype=author&amp;query=Courbariaux%2C+M">literature</a> on <a href="https://arxiv.org/abs/1602.02830">low-bit</a> computing is <a href="https://dawn.cs.stanford.edu/2018/03/09/low-precision/">quite rich</a>. With 32-bit accumulation as supported by Turing GPUs 8-bit training should be even easier.&nbsp; If we can make 8-bit computing work for general models this would entail huge speedups for transformers. If we repeat the above calculations for 8-bit for GPUs (128&#215;128 tile) we find that GPUs are 3.0x faster than TPUs. 8-bit computation on an affordable standard machine with 4 RTX 2080 Ti would take about 11 days for BERT base and 22 days for BERT large. All of this makes 16-bit computational ability for a GPU and important criterion <a href="https://timdettmers.com/2020/09/07/which-gpu-for-deep-learning/">if you are looking for a GPU</a> to work with transformers.</p>
<h2>Conclusion</h2>
<p>TPUs are about 32% to 54% faster for training BERT-like models. One can expect to replicate BERT base on an 8 GPU machine within about 10 to 17 days. On a standard, affordable GPU machine with 4 GPUs one can expect to train BERT base for about 34 days using 16-bit or about 11 days using 8-bit.</p>
<p>The post <a rel="nofollow" href="https://timdettmers.com/2018/10/17/tpus-vs-gpus-for-transformers-bert/">TPUs vs GPUs for Transformers (BERT)</a> appeared first on <a rel="nofollow" href="https://timdettmers.com">Tim Dettmers</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://timdettmers.com/2018/10/17/tpus-vs-gpus-for-transformers-bert/feed/</wfw:commentRss>
			<slash:comments>26</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">686</post-id>	</item>
		<item>
		<title>Deep Learning Hardware Limbo</title>
		<link>https://timdettmers.com/2017/12/21/deep-learning-hardware-limbo/</link>
					<comments>https://timdettmers.com/2017/12/21/deep-learning-hardware-limbo/#comments</comments>
		
		<dc:creator><![CDATA[Tim Dettmers]]></dc:creator>
		<pubDate>Thu, 21 Dec 2017 11:10:23 +0000</pubDate>
				<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Accelerators]]></category>
		<category><![CDATA[AMD]]></category>
		<category><![CDATA[GPU]]></category>
		<category><![CDATA[Intel]]></category>
		<guid isPermaLink="false">http://timdettmers.com/?p=627</guid>

					<description><![CDATA[<p>With the release of the Titan V, we now entered deep learning hardware limbo. It is unclear if NVIDIA will be able to keep its spot as the main deep learning hardware vendor in 2018 and both AMD and Intel Nervana will have a shot at overtaking NVIDIA. So for consumers, I cannot recommend buying any hardware right now. The most prudent choice is to wait until the hardware limbo passes. This might take as little as 3 months or as long as 9 months. So why did we enter deep learning hardware limbo just now?</p>
<p>The post <a rel="nofollow" href="https://timdettmers.com/2017/12/21/deep-learning-hardware-limbo/">Deep Learning Hardware Limbo</a> appeared first on <a rel="nofollow" href="https://timdettmers.com">Tim Dettmers</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>With the release of the Titan V, we now entered deep learning hardware limbo. It is unclear if NVIDIA will be able to keep its spot as the main deep learning hardware vendor in 2018 and both AMD and Intel Nervana will have a shot at overtaking NVIDIA. So for consumers, I cannot recommend buying any hardware right now. The most prudent choice is to wait until the hardware limbo passes. This might take as little as 3 months or as long as 9 months. So why did we enter deep learning hardware limbo just now?</p>
<p><span id="more-627"></span></p>
<p>NVIDIA has decided that it needs to cash-in on its monopoly position before the competition emerges. It needs the cash in order to defend itself in the next 1-2 years. This is reflected by the choice to price the Titan V at $3000. With TensorCores the Titan V has a new shiny deep learning feature, but at the same time, its cost/performance ratio is abysmal. This makes the Titan V very unattractive. But because there is no alternative, people will need to eat what there are served – at least for now.</p>
<p>The competition is strong. We have AMD whose hardware is now already better than NVIDIA’s and plans to get itself together to produce some deep learning software which is actually usable. With this step, the cost/performance ratio will easily outmatch NVIDIA cards and AMD will become the new standard. NVIDIA’s cash advantage will help fight AMD off so that we might see very cheap NVIDIA cards in the future. Note that this will only happen if AMD is able to push forward with good software — if AMD falters, NVIDIA cards will remain expensive and AMD will have lost its opportunity to grab the throne.</p>
<p>There is also a new contender in town: The Neural Network Processor (NNP) form Intel Nervana. With several unique features, it packs quite a punch. These new features make me drool — they are exactly what I want as a CUDA developer. The NNP solves most problems I face when I want to write CUDA kernels which are optimized for deep learning. This chip is the first true deep learning chip.</p>
<p>In general, for a 1-chip vs 1-chip ranking, we will see Nervana &gt; AMD &gt; NVIDIA, just because NVIDIA has to service gaming/deep learning/high-performance computing at once, while AMD only needs to service gaming/deep learning, whereas Nervana can just concentrate on deep learning – a huge advantage. The more concentrated a designed architecture, the less junk is on the chip for deep learning.</p>
<p>However, the winner is not determined by pure performance, and not even by pure cost/performance. It is determined by cost/performance + community + deep learning frameworks.</p>
<p>Let&#8217;s have a closer look at the individual positions of Nervana, AMD, and NVIDIA to see where they stand.</p>
<h2>Nervana’s Neural Network Processors</h2>
<blockquote class="twitter-tweet" data-lang="en">
<p dir="ltr" lang="en">Why <a href="https://twitter.com/NaveenGRao?ref_src=twsrc%5Etfw">@NaveenGRao</a> is excited about <a href="https://twitter.com/hashtag/Intel?src=hash&amp;ref_src=twsrc%5Etfw">#Intel</a> Nervana NNP: <a href="https://t.co/DAqgOYFtoR">https://t.co/DAqgOYFtoR</a> <a href="https://twitter.com/hashtag/AI?src=hash&amp;ref_src=twsrc%5Etfw">#AI</a> <a href="https://t.co/dbLMdnp63t">pic.twitter.com/dbLMdnp63t</a></p>
<p>— Intel AI (@IntelAI) <a href="https://twitter.com/IntelAI/status/925476243788697600?ref_src=twsrc%5Etfw">October 31, 2017</a></p></blockquote>
<p><script async="" src="https://platform.twitter.com/widgets.js" charset="utf-8"></script></p>
<p>Nervana’s design is very special mainly due to its large programmable caches (similar to CUDA shared memory) which are 10 times bigger per chip compared to GPUs and 50 times bigger per compute unit compared to GPUs. With this one will be able to design in-cache algorithms and models. This will speed up inference by at least an order of magnitude and one will be able to easily train on terabytes of data with small in-cache deep learning models, say, a multi-layer LSTM with 200 units. This will make this chip very attractive for startups and larger companies. Due to a special datatype, Flexpoint, one is able to store more data in caches/RAM and compute faster yielding even more benefits. All of this could mean speedup of about 10x compared to current NVIDIA GPUs for everybody. But this is only so if the main obstacles can be overcome: Community and software.</p>
<p>For the normal users and researchers, it will all depend on the community. Without community, we will not see in-cache algorithms. Without community, we will not see good software frameworks and it will be difficult to work with the chip. Everybody wants to use solid deep learning frameworks and it is questionable if Neon, Nervana’s deep learning framework, is up for the task. Software comes before hardware. If Nervana only ships pretty chips and does not push the software and community aspect effectively it will lose out to AMD and NVIDIA.</p>
<p>The community and software question is tightly bound to the price. If the price is too high, and students are not able to afford the NNP then no community can manifest itself around it. You do not get robust communities by just catering for industry. Although industry yields the main income for hardware companies, students are the main driver for the community. So if the price is right and students can afford it, then the community and the software will follow. Anything above $3000 will not work out. Anything above $2000 is critical and one would require special discounts for students to create a robust community. An NNP priced at $2000 will be manageable and find some adoption. Anything below $1500 will make Nervana the market leader for at least 2-3 years. An NNP at $1000 would make it extremely tough for NVIDIA and AMD to compete — software would not even be a question here, it follows automatically.</p>
<p>I personally will switch to NNPs if they are priced below $2500. They are just so much superior to GPUs for deep learning and I will be able to do things which are just impossible with NVIDIA hardware. If they are over $2500 then it also reaches my pain point for good hardware. I save up a lot of money to buy hardware — good hardware is just important to me — but I have to live from something.</p>
<p>For usual consumers not only the price will be important, but also how the community is handled. If we do not see Intel immediately pumping resources into the community to start up a solid software machinery then the NNP is likely to stagnate and die off. Unfortunately, Intel has a good history of mismanaging communities — it would be a shame if this happens because I really would like to see Nervana succeed.</p>
<p>In summary, we will see Nervana’s NNP will emerge as a clear winner if it will be priced below $2000 and if we see strong community and software development within the first few months after its release. With a higher price and less community support, the NNP will be strong, but might not be able to surpass other solutions in terms of cost/performance and convenience. If the software and community efforts fail or if the NNP is priced at $4000 it will likely fail. A price above $2000 will require significant discounts for students for the NNP to be viable.</p>
<h2>AMD: Cheap and Powerful – If You Can Use It</h2>
<p>&nbsp;</p>
<p><figure id="attachment_630" aria-describedby="caption-attachment-630" style="width: 500px" class="wp-caption aligncenter"><a href="https://i0.wp.com/timdettmers.com/wp-content/uploads/2017/12/AMD_Fiji_GPU_package_with_GPU_HBM_memory_and_interposer.jpg"><img data-attachment-id="630" data-permalink="https://timdettmers.com/2017/12/21/deep-learning-hardware-limbo/amd_fiji_gpu_package_with_gpu_hbm_memory_and_interposer/" data-orig-file="https://i0.wp.com/timdettmers.com/wp-content/uploads/2017/12/AMD_Fiji_GPU_package_with_GPU_HBM_memory_and_interposer.jpg?fit=3872%2C2592&amp;ssl=1" data-orig-size="3872,2592" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;5&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;NIKON 1 V1&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1434546595&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;22.7&quot;,&quot;iso&quot;:&quot;400&quot;,&quot;shutter_speed&quot;:&quot;0.066666666666667&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;1&quot;}" data-image-title="AMD_Fiji_GPU_package_with_GPU,_HBM_memory_and_interposer" data-image-description="" data-image-caption="" data-medium-file="https://i0.wp.com/timdettmers.com/wp-content/uploads/2017/12/AMD_Fiji_GPU_package_with_GPU_HBM_memory_and_interposer.jpg?fit=300%2C201&amp;ssl=1" data-large-file="https://i0.wp.com/timdettmers.com/wp-content/uploads/2017/12/AMD_Fiji_GPU_package_with_GPU_HBM_memory_and_interposer.jpg?fit=1024%2C685&amp;ssl=1" class="wp-image-630" src="https://i0.wp.com/timdettmers.com/wp-content/uploads/2017/12/AMD_Fiji_GPU_package_with_GPU_HBM_memory_and_interposer-300x201.jpg?resize=500%2C335" alt="" width="500" height="335" srcset="https://i0.wp.com/timdettmers.com/wp-content/uploads/2017/12/AMD_Fiji_GPU_package_with_GPU_HBM_memory_and_interposer.jpg?resize=300%2C201&amp;ssl=1 300w, https://i0.wp.com/timdettmers.com/wp-content/uploads/2017/12/AMD_Fiji_GPU_package_with_GPU_HBM_memory_and_interposer.jpg?resize=768%2C514&amp;ssl=1 768w, https://i0.wp.com/timdettmers.com/wp-content/uploads/2017/12/AMD_Fiji_GPU_package_with_GPU_HBM_memory_and_interposer.jpg?resize=1024%2C685&amp;ssl=1 1024w, https://i0.wp.com/timdettmers.com/wp-content/uploads/2017/12/AMD_Fiji_GPU_package_with_GPU_HBM_memory_and_interposer.jpg?w=2000&amp;ssl=1 2000w, https://i0.wp.com/timdettmers.com/wp-content/uploads/2017/12/AMD_Fiji_GPU_package_with_GPU_HBM_memory_and_interposer.jpg?w=3000&amp;ssl=1 3000w" sizes="(max-width: 500px) 100vw, 500px" data-recalc-dims="1" /></a><figcaption id="caption-attachment-630" class="wp-caption-text">Source: <a href="https://commons.wikimedia.org/wiki/File:AMD_Fiji_GPU_package_with_GPU,_HBM_memory_and_interposer.jpg">Wikipedia</a></figcaption></figure></p>
<p>AMDs cards are incredible. The Vega Frontier Edition series clearly outmatches NVIDIA counterparts, and, from <a href="https://www.xcelerit.com/computing-benchmarks/insights/benchmarks-deep-learning-nvidia-p100-vs-v100-gpu/">unbiased benchmarks</a>&nbsp;of Volta vs Pascal, it seems that the Vega Frontier will be on-a-par or better compared to a Titan V if it is liquid cooled. Note that the Vega is based on an old architecture while the Titan V is brand new. The new AMD architecture, which will be released in 2018Q3 will increase performance further still.</p>
<p>AMD hopes to advance deep learning hardware by just switching from 32-bit floats to 16-bit floats. This is a very simple and powerful strategy. The chips will not be useful for high-performance computing, but they will be solid for gamers and the deep learning community while development costs will be low because 16-bit float computation is straightforward.</p>
<p>They will not be able to compete in terms of performance with Nervana’s NNP, but the cost/performance might outmatch everything on the market. You can get a liquid cooled Vega Frontier for $700 which might be just a little worse than a $3000 Titan V.</p>
<p>The problem is software. Even if you have this powerful AMD GPU, you will hardly be able to use it – no major framework supports AMD GPUs well enough.</p>
<p>AMD is in limbo itself – in software limbo. It seems they want to abandon OpenCL for <a href="https://github.com/ROCm-Developer-Tools/HIP">HIP</a> but currently they officially still push and support the OpenCL path. If they push through with HIP, and if they put some good deep learning software on the market (not only libraries for convolution and matrix multiplication but full deep learning frameworks, say, HIP support for PyTorch) in the next 9 months then their release of their new GPU in 2018Q3 has the potential to demolish all competitors.</p>
<p>So in summary, if AMD gets its shit together in terms of software, it might become the dominating deep learning hardware solution.</p>
<h2>NVIDIA: The Titan</h2>
<p><a href="https://i0.wp.com/timdettmers.com/wp-content/uploads/2017/12/Titan_V.jpg"><img data-attachment-id="632" data-permalink="https://timdettmers.com/2017/12/21/deep-learning-hardware-limbo/titan_v/" data-orig-file="https://i0.wp.com/timdettmers.com/wp-content/uploads/2017/12/Titan_V.jpg?fit=1920%2C1080&amp;ssl=1" data-orig-size="1920,1080" 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="Titan_V" data-image-description="" data-image-caption="" data-medium-file="https://i0.wp.com/timdettmers.com/wp-content/uploads/2017/12/Titan_V.jpg?fit=300%2C169&amp;ssl=1" data-large-file="https://i0.wp.com/timdettmers.com/wp-content/uploads/2017/12/Titan_V.jpg?fit=1024%2C576&amp;ssl=1" class="aligncenter wp-image-632" src="https://i0.wp.com/timdettmers.com/wp-content/uploads/2017/12/Titan_V-1024x576.jpg?resize=500%2C281" alt="" width="500" height="281" srcset="https://i0.wp.com/timdettmers.com/wp-content/uploads/2017/12/Titan_V.jpg?resize=1024%2C576&amp;ssl=1 1024w, https://i0.wp.com/timdettmers.com/wp-content/uploads/2017/12/Titan_V.jpg?resize=300%2C169&amp;ssl=1 300w, https://i0.wp.com/timdettmers.com/wp-content/uploads/2017/12/Titan_V.jpg?resize=768%2C432&amp;ssl=1 768w, https://i0.wp.com/timdettmers.com/wp-content/uploads/2017/12/Titan_V.jpg?w=1920&amp;ssl=1 1920w" sizes="(max-width: 500px) 100vw, 500px" data-recalc-dims="1" /></a></p>
<p>NVIDIA’s position is solid. They have the best software, the best tools, their hardware is good and the community is large, strong and well integrated.</p>
<p>NVIDIA’s main issue is that they have to serve multiple communities: High-performance computing people, deep learning people, and gamers, and this is a huge strain on their hardware. It is expensive to design chips which are custom made for these communities and NVIDIA’s strategy was currently to design a one-size-fits-all architecture. This worked until it didn’t. The Titan V is just mediocre all-around.</p>
<p>With the emerging competitors, NVIDIA has two choices. (1) Push the price on their cards down until they starve the competition to death, or (2) they can develop specialized deep learning hardware on their own. NVIDIA has the resources to pursue the first strategy, and it also has the expertise for the second strategy. A new design, however, will take some time and NVIDIA might lose the throne to another company in the meantime. So we might see both strategies played out a once: Starving competitors so that NVIDIA can compete until their own deep learning chip hits the market.</p>
<p>In summary, NVIDIAs throne is threatened, but it has the resources and the expertise to fight against emerging players. We will probably see cheaper NVIDIA cards in the future and chips which are more specialized for deep learning. If NVIDIA does not lower its prices it might (temporarily) pass the throne to another player.</p>
<h2>Conclusion</h2>
<p>Deep learning hardware limbo means that it makes no sense to invest in deep learning hardware right now, but it also means we will have cheaper NVIDIA cards, usable AMD cards, and ultra-fast Nervana cards quite soon. It is an exciting time and we consumers will profit from this immensely. But for now, we have to be patient. We have to wait. I will keep you updated as the situation changes.</p>
<p>The post <a rel="nofollow" href="https://timdettmers.com/2017/12/21/deep-learning-hardware-limbo/">Deep Learning Hardware Limbo</a> appeared first on <a rel="nofollow" href="https://timdettmers.com">Tim Dettmers</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://timdettmers.com/2017/12/21/deep-learning-hardware-limbo/feed/</wfw:commentRss>
			<slash:comments>91</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">627</post-id>	</item>
		<item>
		<title>The Brain vs Deep Learning Part I: Computational Complexity — Or Why the Singularity Is Nowhere Near</title>
		<link>https://timdettmers.com/2015/07/27/brain-vs-deep-learning-singularity/</link>
					<comments>https://timdettmers.com/2015/07/27/brain-vs-deep-learning-singularity/#comments</comments>
		
		<dc:creator><![CDATA[Tim Dettmers]]></dc:creator>
		<pubDate>Mon, 27 Jul 2015 10:20:05 +0000</pubDate>
				<category><![CDATA[Deep Learning]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[Neuroscience]]></category>
		<category><![CDATA[Convolution]]></category>
		<category><![CDATA[GPU]]></category>
		<category><![CDATA[High Performance Computing]]></category>
		<guid isPermaLink="false">https://timdettmers.wordpress.com/?p=312</guid>

					<description><![CDATA[<p>In this blog post I will delve into the brain and explain its basic information processing machinery and compare it to deep learning. I do this by moving step-by-step along with the brains electrochemical and biological information processing pipeline and relating it directly to the architecture of convolutional nets. Thereby we will see that a neuron and a convolutional net are very similar information processing machines. While performing this comparison, I will also discuss the computational complexity of these processes and thus derive an estimate for the brains overall computational power. I will use these estimates, along with knowledge from high performance computing, to show that it is unlikely that there will be a technological singularity in this century.</p>
<p>The post <a rel="nofollow" href="https://timdettmers.com/2015/07/27/brain-vs-deep-learning-singularity/">The Brain vs Deep Learning Part I: Computational Complexity — Or Why the Singularity Is Nowhere Near</a> appeared first on <a rel="nofollow" href="https://timdettmers.com">Tim Dettmers</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>In this blog post I will delve into the brain and explain its basic information processing machinery and compare it to deep learning. I do this by moving step-by-step along with the brains electrochemical and biological information processing pipeline and relating it directly to the architecture of convolutional nets. Thereby we will see that a neuron and a convolutional net are very similar information processing machines. While performing this comparison, I will also discuss the computational complexity of these processes and thus derive an estimate for the brains overall computational power. I will use these estimates, along with knowledge from high performance computing, to show that it is unlikely that there will be a technological singularity in this century.</p>
<p><span id="more-312"></span></p>
<p>This blog post is complex as it arcs over multiple topics in order to unify them into a coherent framework of thought. I have tried to make this article as readable as possible, but I might have not succeeded in all places. Thus, if you find yourself in an unclear passage it might become clearer a few paragraphs down the road where I pick up the thought again and integrate it with another discipline.</p>
<p>First I will give a brief overview about the predictions for a technological singularity and topics which are aligned with that. Then I will start the integration of ideas between the brain and deep learning. I finish with discussing high performance computing and how this all relates to predictions about a technological singularity.</p>
<p>The part which compares the brains information processing steps to deep learning is self-contained, and readers which are not interested in predictions for a technological singularity may skip to this part.</p>
<h2>Part I: Evaluating current predictions of a technological singularity</h2>
<p>There were a lot of headlines recently about predictions that artificial intelligence will reach super-human intelligence as early as 2030 and that this might herald the beginning of human extinction, or at least dramatically altering everyday life. How was this prediction made?</p>
<h3>Factors which help to predict a singularity</h3>
<p>Ray Kurzweil has made many very accurate <a href="https://en.wikipedia.org/wiki/Predictions_made_by_Ray_Kurzweil#2029">predictions</a> and his methods to reach these predictions are quite simple for computing devices: Look at the exponential growth of computing power, efficiency, and size, and then extrapolate. This way, you could easily predict the emergence of small computers which fit into your hands and with a bit of creativity, one could imagine that one day there would be tablets and smartphones. The trends were there, you just needed to imagine what could be done with computers which you can hold in your hand.</p>
<p>Similarly, Ray Kurzweil predicted the emergence of strong AI which is as intelligent or more intelligent than humans. For this prediction he also used data for the exponential growth of computing power and compared this to an estimate for the computational power of the brain.</p>
<p>He also acknowledges that the software will be as important as the hardware, and that the software development of strong AI will take longer because such software can only be developed once fast computer systems are available. This can be felt in the area of deep learning, where solid ideas of the 1990s were unfeasible due to the slow computers. Once graphic processing units (GPUs) were used, these computing limitations were quickly removed and rapid progress could be made.</p>
<p>However, Kurzweil also stresses that once the hardware level is reached, first “simple” strong AI systems will be developed quickly. He sets the date for brain-like computational power to 2020 and the emergence of strong AI (first human like intelligence or better) to 2030. Why these numbers? With persisting growth in computing power in 2019 we will reach the computing power which is equivalent to the human brain — or will we?</p>
<p>This estimate is based on two things: (1) The estimate for the complexity of the brain, (2) the estimate for the growth in computing power. As we will see, both these estimates are not up-to-date with current technology and knowledge about neuroscience and high performance computing.</p>
<p>Our knowledge of neuroscience doubles about every year. Using this doubling period, in the year of 2005 we would only have possessed about 0.098% of the neuroscience knowledge that we have today. This number is a bit off, because the doubling time was about 2 years in 2005 while it is less than a year now, but overall it is way below 1 %.</p>
<p>The thing is that Ray Kurzweil based his predictions on the neuroscience of 2005 and never updated them. An estimate for the brains computational power based on 1% of the neuroscience knowledge does not seem right. Here is small list of a few important discoveries made in the last two years which increase the computing power of the brain by many orders of magnitude:</p>
<ul>
<li>It was shown that brain connections rather than being passive cables, can themselves process information and alter the behavior of neurons in meaningful ways, e.g. brain connections help you to see the objects in everyday life. This fact alone increases brain computational complexity by several orders of magnitude</li>
<li>Neurons which do not fire still learn: There is much more going on than electrical spikes in neurons and brain connections: Proteins, which are the little biological machines which make everything in your body work, combined with local electric potential do a lot of information processing on their own — no activation of the neuron required</li>
<li>Neurons change their genome dynamically to produce the right proteins to handle everyday information processing tasks. Brain: “Oh you are reading a blog. Wait a second, I just upregulate this reading-gene to help you understand the content of the blog better.” (This is an exaggeration — but it is not too far off)</li>
</ul>
<p>Before we look at the complexity of the brain, let us first look at brain simulations. Brain simulations are often used to predict human-like intelligence. If we can simulate a human brain, then it will not be long until we are able to develop human-like intelligence, right? So the next paragraph looks at this reasoning. Can brain simulations really provide reliable evidence for predicting the emergence of artificial intelligence?</p>
<h3>The problems with brain simulations</h3>
<p>Brain simulations simulate the electrical signals which are emitted by neurons and the size of the connections between neurons. A brain simulation starts with random signals and the whole system stabilizes according to rules which are thought to govern information processing steps in the brain. After running these rules for some time, stable signals may form which can be compared to the signals of the brain. If the signals of the simulation are similar to recordings of the brain, this increases our confidence that our chosen rules are somewhat similar to the rules that the brain uses. Thus we can validate large scale information processing rules in the brain. However, the big problem with brain simulations is, that this is pretty much all we can do.</p>
<p>We do not gain any understanding what these signals mean or what function they could possess. We cannot test any meaningful hypotheses with this brain model other than the vague “our rules produce similar activity”. The lack of precise hypotheses which make accurate predictions (“If the activity is like this, then the circuit detected an apple instead of an orange”) is one of the loudest <a href="https://www.nature.com/news/neuroscience-where-is-the-brain-in-the-human-brain-project-1.15803">criticism of the European brain simulation project</a>. The brain project is regarded as rather useless by many neuroscientists and even dangerous, because it sucks away money for useful neuroscience projects which actually shed light on neural information processing.</p>
<p>Another problem is that these brain simulations rely on models which are outdated, incomplete and which dismiss many biological parts in neurological information processing. This is mainly so, because the electrical information processing in the brain is much better understood. Another more conveniently reason is, that current models are already able to reproduce the needed output patterns (which is the main goal after all) and so there is no need to update these models to be more brain-like.</p>
<p>So to summarize, the problems with brain simulations are:</p>
<ul>
<li>Not possible to test specific scientific hypotheses (compare this to the large hadron collider project with its perfectly defined hypotheses)</li>
<li>Does not simulate real brain processing (no firing connections, no biological interactions)</li>
<li>Does not give any insight into the functionality of brain processing (the meaning of the simulated activity is not assessed)</li>
</ul>
<p>The last point is the most important argument against the usefulness of brain processing for strong-AI estimation. If we could develop a brain simulation of the visual system, which would do well on say, the MNIST and ImageNet data sets, this would be useful to estimate progress in brain-like AI. But without this, or any similar observable function, brain simulations remain rather useless with respect to AI.</p>
<p>With this said, brain simulations are still valuable to test hypothesized general rules of information processing in the brain —we have nothing better for this — but they are quite useless to make sense of what the information processing in the brain means, and thus constitute unreliable evidence for predicting the progress in AI. Anything that relies on brain simulation as evidence for predictions of future strong-AI should be looked at with great skepticism.</p>
<h3>Estimating the brains computational complexity</h3>
<p>As mentioned in the introduction, the estimates of the brain&#8217;s complexity are a decade old and many new discoveries made this old estimate obsolete. I never came across an estimate which is up to date, so here I derive my own estimate. While doing this, I will focus mostly on the electrochemical information processing and neglect the biological interactions within the neuron, because they are too complex (and this blog post is already very long). Therefore the estimate that is derived here can be thought of as a lower bound of complexity — it should always be assumed that the brain is more complex than this.</p>
<p>During the construction of this model of complexity, I will also relate every step in the model with its deep learning equivalents. This will give you a better understanding of how close deep learning is related to and how fast deep learning really is compared to the human brain</p>
<h3>Defining reference numbers for the model</h3>
<p>We know some facts and estimates which help us to start with our model building:</p>
<ul>
<li>The brain uses learning algorithms which are very different from deep learning, but the architecture of neurons is similar to convolutional nets</li>
<li>The adult brain has 86 billion neurons, about 10 trillion synapse, and about 300 billion dendrites (tree-like structures with synapses on them)</li>
<li>The brain of a child has far more than 100 billion neurons, and has synapses and dendrites in excess of 15 trillion and 150 billion, respectively</li>
<li>The brain of a fetus has more than a trillion neurons; neurons which are misplaced die quickly (this is also the reason why adults have fewer neurons than children)</li>
</ul>
<p><figure id="attachment_313" aria-describedby="caption-attachment-313" style="width: 150px" class="wp-caption alignleft"><a href="https://i0.wp.com/timdettmers.com/wp-content/uploads/2015/07/cerebellum_animation_small.gif?ssl=1"><img data-attachment-id="313" data-permalink="https://timdettmers.com/2015/07/27/brain-vs-deep-learning-singularity/cerebellum_animation_small/" data-orig-file="https://i0.wp.com/timdettmers.com/wp-content/uploads/2015/07/cerebellum_animation_small.gif?fit=150%2C150&amp;ssl=1" data-orig-size="150,150" 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="Cerebellum_animation_small" data-image-description="" data-image-caption="" data-medium-file="https://i0.wp.com/timdettmers.com/wp-content/uploads/2015/07/cerebellum_animation_small.gif?fit=150%2C150&amp;ssl=1" data-large-file="https://i0.wp.com/timdettmers.com/wp-content/uploads/2015/07/cerebellum_animation_small.gif?fit=150%2C150&amp;ssl=1" class="wp-image-313 size-full" src="https://i0.wp.com/timdettmers.com/wp-content/uploads/2015/07/cerebellum_animation_small.gif?resize=150%2C150&#038;ssl=1" alt="Cerebellum_animation_small" width="150" height="150" data-recalc-dims="1" /></a><figcaption id="caption-attachment-313" class="wp-caption-text">Location of the cerebellum which contains roughly 3/4 of all neurons and connections. Image source: <a href="https://commons.wikimedia.org/wiki/File:Cerebellum_animation_small.gif">1</a></figcaption></figure></p>
<p><figure id="attachment_314" aria-describedby="caption-attachment-314" style="width: 150px" class="wp-caption alignleft"><a href="https://i0.wp.com/timdettmers.com/wp-content/uploads/2015/07/cerebrum_animation_small.gif?ssl=1"><img data-attachment-id="314" data-permalink="https://timdettmers.com/2015/07/27/brain-vs-deep-learning-singularity/cerebrum_animation_small/" data-orig-file="https://i0.wp.com/timdettmers.com/wp-content/uploads/2015/07/cerebrum_animation_small.gif?fit=150%2C150&amp;ssl=1" data-orig-size="150,150" 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="Cerebrum_animation_small" data-image-description="" data-image-caption="" data-medium-file="https://i0.wp.com/timdettmers.com/wp-content/uploads/2015/07/cerebrum_animation_small.gif?fit=150%2C150&amp;ssl=1" data-large-file="https://i0.wp.com/timdettmers.com/wp-content/uploads/2015/07/cerebrum_animation_small.gif?fit=150%2C150&amp;ssl=1" class="wp-image-314 size-full" src="https://i0.wp.com/timdettmers.com/wp-content/uploads/2015/07/cerebrum_animation_small.gif?resize=150%2C150&#038;ssl=1" alt="Cerebrum_animation_small" width="150" height="150" data-recalc-dims="1" /></a><figcaption id="caption-attachment-314" class="wp-caption-text">Location of the cerebrum; also referred to as &#8220;the cortex&#8221;. More precisely, the cortex is the outer layer of the brain, which contains most neurons of the cerebrum. Image source: <a href="https://commons.wikimedia.org/wiki/File:Cerebrum_animation_small.gif">1</a></figcaption></figure></p>
<ul>
<li>The cerebellum, the super computer of the brain, contains roughly ¾ of all neurons (this ratio is consistent in most mammal species)</li>
<li>The cerebrum, the main driver of “intelligence”, contains roughly ¼ of all neurons</li>
<li>An average neuron in the cerebellum has about 25000 synapses</li>
<li>An average neuron in the cerebrum has about 5000-15000 synapses</li>
</ul>
<p>The number of neurons is well known; the number of synapses and dendrites is only known within a certain boundary and I chose conservative estimates here.</p>
<p>The average synapses per neuron differ wildly between neurons, and the number here is a rough average. It is known that most synapses in the cerebellum are made between dendrites of Purkinje neurons and two different types of neurons that make connections that “climb up” or “cross parallel” with the Purkinje’s synapses. It is known that Purkinje cells have about 100000 synapses each. Because these cells have by far the largest weight in the cerebellum, one can estimate the complexity of the brain best if one looks at these neurons and at the interactions that they make.</p>
<p><figure id="attachment_316" aria-describedby="caption-attachment-316" style="width: 500px" class="wp-caption aligncenter"><a href="https://i0.wp.com/timdettmers.com/wp-content/uploads/2015/07/neuron_types.gif?ssl=1"><img data-attachment-id="316" data-permalink="https://timdettmers.com/2015/07/27/brain-vs-deep-learning-singularity/neuron_types/" data-orig-file="https://i0.wp.com/timdettmers.com/wp-content/uploads/2015/07/neuron_types.gif?fit=500%2C302&amp;ssl=1" data-orig-size="500,302" 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="neuron_types" data-image-description="" data-image-caption="" data-medium-file="https://i0.wp.com/timdettmers.com/wp-content/uploads/2015/07/neuron_types.gif?fit=300%2C181&amp;ssl=1" data-large-file="https://i0.wp.com/timdettmers.com/wp-content/uploads/2015/07/neuron_types.gif?fit=500%2C302&amp;ssl=1" class="wp-image-316 size-full" src="https://i0.wp.com/timdettmers.com/wp-content/uploads/2015/07/neuron_types.gif?resize=500%2C302&#038;ssl=1" alt="neuron_types" width="500" height="302" data-recalc-dims="1" /></a><figcaption id="caption-attachment-316" class="wp-caption-text">There are many hundreds of different types of neurons; here some of the more common neurons. Thanks to Robert Stufflebeam for this image (<a href="http://www.mind.ilstu.edu/curriculum/neurons_intro/neurons_intro.php">source</a>).</figcaption></figure></p>
<p>It is important to differentiate between the complexity of a brain region and its functional importance. While almost all computation is carried out by the cerebellum, almost all important functions are carried out by the cerebrum (or cortex). The cortex uses the cerebellum to generate predictions, corrections and conclusions, but the cortex accumulates these insights and acts upon them.</p>
<p>For the cerebrum it is known that neurons almost never have more than 50000 synapses, and unlike the cerebellum, most neurons have a number of synapses within the range of 5000-15000.</p>
<h3>How do we use these numbers?</h3>
<p>A common approach for estimating the computational complexity of the brain is to assume all information processing in the brain can be represented by the combination of impulses when a neuron fires (action potentials) and the size (mostly number of receptors) of the synapses that each neuron has. Thus one can multiply the estimates for the number of neurons and their synapses and add everything together. Then one multiplies this by the rate of fire for the average neurons which is about 200 action potentials per second. This model is what Ray Kurzweil uses to create his estimate. While this model was okay a few decades ago, it is not suitable to model the brain from a modern view point, as it leaves out much of the important neurological information processing which is so much more than mere firing neurons.</p>
<p>A model which approximates the behavior of neurons more accurately is the extended linear-nonlinear-Poisson cascade model (LNP). The extended LNP model is <a href="https://www.sciencedirect.com/science/article/pii/S0959438814000130">currently viewed as an accurate model of how neurons process information</a>. However, the extended LNP model still leaves out some fine details, which are deemed unimportant to model large scale brain function. Indeed adding these fine details to the model will add almost no additional computational complexity, but makes the model more complex to understand — thus including these details in simulations would violate the scientific method which seeks to find the simplest models for a given theory. However, this extended model is actually very similar to deep learning and thus I will include these details here.</p>
<p>There are other good models that are also suitable for this. The primary reason why I chose the LNP model is that it is very close to deep learning. This makes this model perfect to compare the architecture of a neuron to the architecture of a convolutional net. I will do this in the next section and at the same time I will derive an estimate for the complexity of the brain.</p>
<h2>Part II: The brain vs. deep learning — a comparative analysis</h2>
<p>Now I will explain step by step how the brain processes information. I will mention the steps of information processing which are well understood and which are supported by reliable evidence. On top of these steps, there are many intermediary steps at the biological level (proteins and genes) which are still poorly understood but known to be very important for information processing. I will not go into depth into these biological processes but provide a short outline, which might help the knowledge hungry readers to delve into these depths themselves. We now begin this journey from the neurotransmitters released from a firing neuron and walk along all its processes until we reach the point where the next neuron releases its neurotransmitters, so that we return to where we started.</p>
<p>The next section introduces a couple of new terms which are necessary to follow the rest of the blog post, so read it carefully if you are not familiar with basic neurobiology.</p>
<p><figure id="attachment_343" aria-describedby="caption-attachment-343" style="width: 1193px" class="wp-caption aligncenter"><a href="https://i0.wp.com/timdettmers.com/wp-content/uploads/2015/07/neuron_anatomy1.jpg?ssl=1"><img data-attachment-id="343" data-permalink="https://timdettmers.com/2015/07/27/brain-vs-deep-learning-singularity/neuron_anatomy-2/" data-orig-file="https://i0.wp.com/timdettmers.com/wp-content/uploads/2015/07/neuron_anatomy1.jpg?fit=1193%2C685&amp;ssl=1" data-orig-size="1193,685" 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="neuron_anatomy" data-image-description="" data-image-caption="" data-medium-file="https://i0.wp.com/timdettmers.com/wp-content/uploads/2015/07/neuron_anatomy1.jpg?fit=300%2C172&amp;ssl=1" data-large-file="https://i0.wp.com/timdettmers.com/wp-content/uploads/2015/07/neuron_anatomy1.jpg?fit=1024%2C588&amp;ssl=1" class="wp-image-343 size-full" src="https://i0.wp.com/timdettmers.com/wp-content/uploads/2015/07/neuron_anatomy1.jpg?resize=1193%2C685&#038;ssl=1" alt="neuron_anatomy" width="1193" height="685" data-recalc-dims="1" /></a><figcaption id="caption-attachment-343" class="wp-caption-text">Image sources: <a href="https://commons.wikimedia.org/wiki/File:Neuron_Hand-tuned.svg">1</a>,<a href="https://commons.wikimedia.org/wiki/File:SynapseSchematic_lines.svg">2</a>,3,4</figcaption></figure></p>
<p>Neurons use the axon — a tube like structure— to transmit their electric signals over long stretches in the brain. When a neuron fires, it fires an action potential — an electrical signal— down its axon which branches into a tree of small endings, called axon terminals. On the ending of each of these axon terminals sit some proteins which convert this electrical message back into a chemical one: Small balls — called synaptic vesicles — filled with a couple of neurotransmitters each are released into an area outside of the neuron, called synaptic cleft. This area separates the axon terminal from the beginning of the next neuron (a synapse) and allows the neurotransmitter to move freely to pursue different tasks.</p>
<p>The synapses are most commonly located at a structure which looks very much like the roots of a tree or plant; this is the dendritic tree composed of dendrites which branch into larger arms (this represents the connections between neurons in a neural network), which finally reach the core of the cell, which is called soma. These dendrites hold almost all synapses which connect one neuron to the next and thus form the principal connections. A synapse may hold hundreds of receptors to which neurotransmitter can bind themselves.</p>
<p>You can imagine this compound of axon terminal and synapses at a dendrite as the (dense) input layer (of an image if you will) into a convolutional net. Each neuron may have less than 5 dendrites or as many as a few hundred thousand. Later we will see that the function of the dendritic tree is similar to the combination of a convolutional layer followed by max-pooling in a convolutional network.</p>
<p>Going back to the biological process, the synaptic vesicles merge with the surface of the axon terminal and turn themselves inside-out spilling their neurotransmitters into the synaptic cleft. There the neurotransmitters drift in a vibrating motion due to the temperature in the environment, until they (1) find a fitting lock (receptor protein) which fits their key (the neurotransmitter), (2) the neurotransmitters encounter a protein which disintegrates them, or (3) the neurotransmitters encounter a protein which pulls them back into the axon (reuptake) where they are reused. Antidepressants mostly work by (3) preventing, or (4) enhancing the reuptake of the neurotransmitter serotonin; (3) preventing reuptake will yield changes in information processing after some days or weeks, while (4) enhancing reuptake leads to changes within seconds or minutes. So neurotransmitter reuptake mechanisms are integral for minute to minute information processing. Reuptake is ignored in the LNP model.</p>
<p>However, the combination of the amount of neurotransmitters released, the number of synapses for a given neurotransmitter, and how many neurotransmitters actually make it into a fitting protein on the synapse can be thought of as the weight parameter in a densely (fully) connected layer of a neural network, or in other words, the total input to a neuron is the sum of all axon-terminal-neurotransmitter-synapse interactions. Mathematically, we can model this as the dot product between two matrices (A dot B; [amount of neurotransmitters of all inputs] dot [amount of fitting proteins on all synapses]).</p>
<p>After a neurotransmitter has locked onto a fitting protein on a synapse, it can do a lot of different things: Most commonly, neurotransmitters will just (1) open up channels, to let charged particles flow (through diffusion) into the dendrites, but it can also cause a rarer effect with huge consequences: The neurotransmitter (2) binds to a G-protein which then produces a protein signaling cascade which, (2a) activates (upregulates) a gene which is then used to produce a new protein which is integrated into either the surface of the neuron, its dendrites, and/or its synapses; which (2b) alerts existing proteins to do a certain function at a specific site (create or remove more synapses, unblock some entrances, attach new proteins to the surface of the synapse). This is ignored in the NLP model.</p>
<p>Once the channels are open, negatively or positively charged particles enter into the dendritic spine. A dendritic spine is a small mushroom-like structure on to which the synapse is attached. These dendritic spines can store electric potential and have their own dynamics of information processing. This is ignored in the NLP model.</p>
<p><figure id="attachment_337" aria-describedby="caption-attachment-337" style="width: 471px" class="wp-caption aligncenter"><a href="https://i0.wp.com/timdettmers.com/wp-content/uploads/2015/07/dendritic_spine.jpg?ssl=1"><img data-attachment-id="337" data-permalink="https://timdettmers.com/2015/07/27/brain-vs-deep-learning-singularity/dendritic_spine/" data-orig-file="https://i0.wp.com/timdettmers.com/wp-content/uploads/2015/07/dendritic_spine.jpg?fit=471%2C335&amp;ssl=1" data-orig-size="471,335" 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="dendritic_spine" data-image-description="" data-image-caption="" data-medium-file="https://i0.wp.com/timdettmers.com/wp-content/uploads/2015/07/dendritic_spine.jpg?fit=300%2C213&amp;ssl=1" data-large-file="https://i0.wp.com/timdettmers.com/wp-content/uploads/2015/07/dendritic_spine.jpg?fit=471%2C335&amp;ssl=1" class="wp-image-337 size-full" src="https://i0.wp.com/timdettmers.com/wp-content/uploads/2015/07/dendritic_spine.jpg?resize=471%2C335&#038;ssl=1" alt="dendritic_spine" width="471" height="335" data-recalc-dims="1" /></a><figcaption id="caption-attachment-337" class="wp-caption-text">Dendritic spines have their own internals information processing dynamics which is largely determined by its shape and size. Image source: <a href="https://en.wikipedia.org/wiki/File:Spline_types_3D.png">1</a>,<a href="https://en.wikipedia.org/wiki/File:Dendritic_spines.jpg">2</a></figcaption></figure></p>
<p>The charge of the particles that may enter the dendritic spine are either negatively or positively charged — some neurotransmitters only open channels for negative particles, others only for positive ones. There are also channels which let positively charged particles leave the neuron, thus increasing the negativity of the electric potential (a neuron “fires” if it becomes too positive). The size and shape of the mushroom-like dendritic spine corresponds to its behavior. This is ignored in the NLP model.</p>
<p>Once particles entered the spine, there are many things they can affect. Most commonly, they will (1) just travel along the dendrites to the cell body in the neuron and then, if the cell gets too positively charged (depolarization) they induce an action potential (the neuron “fires”). But other actions are also common:  The charged particles accumulate in the dendritic spine directly and (2) open up voltage-gated channels which may polarize the cell further (this is an example of the dendritic spine information processing mentioned above). Another very important process are (3) dendritic spikes.</p>
<h3>Dendritic spikes</h3>
<p>Dendritic spikes are a phenomenon which has been known to exist for some years, but only in 2013 the techniques were advanced enough to collect the data to show that these spikes were important for information processing. To measure dendritic spikes, you have to attach some very tiny clamps onto dendrites with the help of a computer which moves the clamp with great precision. To have some sort of idea where your clamp is, you need a special microscope to observe the clamp as you progress onto a dendrite. Even then you mostly attach the clamp in a rather blind matter because at such tiny scale every movement made is a rather giant leap. Only a few teams in the world have the equipment and skill to attach such clamps onto dendrites.</p>
<p>However, the direct data gathered by those few teams was enough to establish dendritic spikes as important information processing events. Due to the introduction of dendritic spikes into computational models of neurons, the complexity of a single neuron has become very similar to a convolutional net with two convolutional layers. As we see later the LNP model also uses non-linearities very similar to a rectified linear function, and also makes use of a spike generator which is very similar to dropout – so a neuron is very much like an entire convolutional net. But more about that later and back to dendritic spikes and what exactly they are.</p>
<p>Dendritic spikes occur when a critical level of depolarization is reached in a dendrite. The depolarization discharges as an electric potential along the walls of the dendrite and may trigger voltage-gated channels along its way through the dendritic tree and eventually, if strong enough, the electric potential reaches the core of the neuron where it may trigger a true action potential. If the dendritic spike fails to trigger an action potential, the opened voltage-gated channels in neighboring dendrites may do exactly that a split second later. Due to channels opened from the dendritic spike more charged particles enter the neuron, which then may either trigger (common) or stifle (rare) a full action potential at the neurons cell body (soma).</p>
<p><figure id="attachment_339" aria-describedby="caption-attachment-339" style="width: 677px" class="wp-caption aligncenter"><a href="https://i0.wp.com/timdettmers.com/wp-content/uploads/2015/07/dendritic_spikes.png?ssl=1"><img data-attachment-id="339" data-permalink="https://timdettmers.com/2015/07/27/brain-vs-deep-learning-singularity/dendritic_spikes/" data-orig-file="https://i0.wp.com/timdettmers.com/wp-content/uploads/2015/07/dendritic_spikes.png?fit=677%2C263&amp;ssl=1" data-orig-size="677,263" 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="dendritic_spikes" data-image-description="" data-image-caption="" data-medium-file="https://i0.wp.com/timdettmers.com/wp-content/uploads/2015/07/dendritic_spikes.png?fit=300%2C117&amp;ssl=1" data-large-file="https://i0.wp.com/timdettmers.com/wp-content/uploads/2015/07/dendritic_spikes.png?fit=677%2C263&amp;ssl=1" class="wp-image-339 size-full" title="background-color: #fff" src="https://i0.wp.com/timdettmers.com/wp-content/uploads/2015/07/dendritic_spikes.png?resize=677%2C263&#038;ssl=1" alt="dendritic_spikes" width="677" height="263" data-recalc-dims="1" /></a><figcaption id="caption-attachment-339" class="wp-caption-text">A shows a computer model of a neuron that does not model dendritic spikes; B models simple dynamics of dendritic spikes; C models more complex dynamics of dendritic spikes which takes into account the one dimensional diffusion of particles (which is similar to a convolution operation). Take note that these images are only snapshots in a particular moment of time. A big thanks to <a href="https://groups.oist.jp/onu">Berd Kuhn</a>. Image copyright © 2014 Anwar, Roome, Nedelescu, Chen, Kuhn and De Schutter as published in <em><a href="https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4107854/">Frontiers in Cellular Neuroscience</a> <a href="#anwar14">(Anwar et al. 2014)</a></em></figcaption></figure></p>
<p>This process is very similar to max-pooling, where a single large activation “overwrites” other neighboring values. However, after a dendritic spike, neighboring values are not overwritten like during max-pooling used in deep learning, but the opening of voltage-gated channels greatly amplifies the signals in all neighboring branches within the dendritic tree. Thus a dendritic spike may heighten the electrochemical levels in neighboring dendrites to a level which is more similar to the maximum input — this effect is close to max-pooling.</p>
<p>Indeed it was shown that dendritic spikes in the visual system serve the same purpose as max pooling in convolutional nets for object recognition: In deep learning, max-pooling is used to achieve (limited) rotation, translation, and scale invariance (meaning that our algorithm can detect an object in an image where the object is rotated, moved, or shrunk/enlarged by a few pixels). One can think of this process as setting all surrounding pixels to the same large activation and make each activation share the weight to the next layer (in software the values are discarded for computational efficiency — this is mathematically equivalent). Similarly, it was shown that dendritic spikes in the visual system are sensitive to the orientation of an object. So dendritic spikes do not only have computational similarity, but also similarities in function.</p>
<p>The analogy does not end here. During neural back-propagation — that is when the action potential travels from the cell body back into the dendritic tree — the signal cannot backpropagate into the dendritic branch where the dendritic spike originated because these are “deactivated” due to the recent electrical activity. Thus a clear learning signal is sent to inactivated branches. At first this may seem like the exact opposite from the backpropagation used for max-pooling, where everything but the max-pooling activation is backpropagated. However, the absence of a backpropagation signal in a dendrite is a rare event and represents a learning signal on its own. Thus, dendrites which produce dendritic spikes have special learning signals just like activated units in max-pooling.</p>
<p>To better understand what dendritic spikes are and what they look like, I very much want to encourage you to watch <a href="https://www.hhmi.org/research/how-do-neurons-compute-output-their-inputs">this video</a> (for which I do not have the copyright). The video shows how two dendritic spikes lead to an action potential.</p>
<p>This combination of dendritic spikes and action potentials and the structure of the dendritic tree has been found to be critical for learning and memory in the hippocampus, the main brain region responsible for forming new memories and writing them to our “hard drive” at night.</p>
<p>Dendritic spikes are one of the main drivers of computational complexity which have been left out from past models of the complexity of the brain. Also, these new findings show that neural back-propagation does not have to be neuron-to-neuron in order to learn complex functions; a single neuron already implements a convolutional net and thus has enough computational complexity to model complex phenomena. As such, there is little need for learning rules that span multiple neurons — a single neuron can produce the same outputs we create with our convolutional nets today.</p>
<p>But these findings about dendritic spikes are not the only advance made in our understanding of the information processing steps during this stage of the neural information processing pathway. Genetic manipulation and targeted protein synthesis are sources that increase computational complexity by orders of magnitude, and only recently we made advances which reveal the true extend of biological information processing.</p>
<h3>Protein signaling cascades</h3>
<p>As I said in the introduction of this part, I will not cover the parts of biological information processing extensively, but I want to give you enough information so that you can start learning more from here.</p>
<p>One thing one has to understand is that a cell looks much different from how it is displayed in text books. Cells crawl with proteins: There are about 10 billion proteins in any given human cell and these proteins are not idle: They combine with other proteins, work on a task, or jitter around to find new tasks to work on.</p>
<p>All the functions described above are the work of proteins. For example the key-and-lock mechanism and the channels that play the gatekeeper for the charged particles that leave and enter the neuron are all proteins. The proteins I mean in this paragraph are not these common proteins, but proteins with special biological functions.</p>
<p>As an example the abundant neurotransmitter glutamate may bind to a NDMA receptor which then opens up its channels for many different kinds of charged particles and after being opened, the channel only closes when the neuron fires. The strength of synapses is highly dependent on this process, where the synapse is adjusted according to the location of the NDMA receptor and the timing of signals which are backpropagated to the synapses. We know this process is critical to learning in the brain, but it is only a small piece in a large puzzle.</p>
<p>The charged particles which may enter the neuron may additionally induce protein signaling cascades own their own. For example the cascade below shows how an activated NMDA receptor (green) lets charged calcium CA2+ inside which triggers a cascade which eventually leads to AMPAR receptors (violet) being trafficked and installed on the synapse.</p>
<p><figure id="attachment_321" aria-describedby="caption-attachment-321" style="width: 767px" class="wp-caption aligncenter"><a href="https://i0.wp.com/timdettmers.com/wp-content/uploads/2015/07/regulationofampartrafficking.jpg?ssl=1"><img data-attachment-id="321" data-permalink="https://timdettmers.com/2015/07/27/brain-vs-deep-learning-singularity/regulationofampartrafficking/" data-orig-file="https://i0.wp.com/timdettmers.com/wp-content/uploads/2015/07/regulationofampartrafficking.jpg?fit=767%2C599&amp;ssl=1" data-orig-size="767,599" 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="RegulationOfAMPARTrafficking" data-image-description="" data-image-caption="" data-medium-file="https://i0.wp.com/timdettmers.com/wp-content/uploads/2015/07/regulationofampartrafficking.jpg?fit=300%2C234&amp;ssl=1" data-large-file="https://i0.wp.com/timdettmers.com/wp-content/uploads/2015/07/regulationofampartrafficking.jpg?fit=767%2C599&amp;ssl=1" class="wp-image-321 size-full" src="https://i0.wp.com/timdettmers.com/wp-content/uploads/2015/07/regulationofampartrafficking.jpg?resize=767%2C599&#038;ssl=1" alt="RegulationOfAMPARTrafficking" width="767" height="599" data-recalc-dims="1" /></a><figcaption id="caption-attachment-321" class="wp-caption-text">Image source: <a href="https://commons.wikimedia.org/wiki/File:RegulationOfAMPARTrafficking.jpg">1</a></figcaption></figure></p>
<p>It was shown again and again that these special proteins have a great influence on the information processing in neurons, but it is difficult to pick out a specific type of protein from this seemingly chaotic soup of 10 billion proteins and study its precise function. Findings are often complex with a chain of reactions involving many different proteins until a desired end-product or end-function is reached. Often the start and end functions are known but not the exact path which led from one to the other. Sophisticated technology helped greatly to study proteins in detail, and as technology gets better and better we will further our understanding of biological information processing in neurons.</p>
<h3>Genetic manipulation</h3>
<p>The complexity of biological information processing does not end with protein signaling cascades, the 10 billion proteins are not a random soup of workers that do their tasks, but these workers are designed in specific quantities to serve specific functions that are relevant at the moment. All this is controlled by a tight feedback loop involving helper proteins, DNA, and messenger RNA (mRNA).</p>
<p>If we use programming metaphors to describe this whole process, then the DNA represents the whole github website with all its public packages, and messenger RNA is a big library which features many other smaller libraries with different functions (something like the C++ boost library).</p>
<p>It all begins with a programming problem you want to solve (a biological problem is detected). You use google and stackoverflow to find recommendations for libraries which you can use to solve the problem and soon you find a post that suggests that you use library X to solve problem Y (problem Y is detected on a local level in a cell with known solution of protein X; the protein that detected this defect then cascades into a chain of protein signals which leads to the upregulation of the gene G which can produce protein X; here upregulation is a &#8220;Hey! Produce more of this, please!&#8221; signal to the nucleus of the cell where the DNA lies). You download the library and compile it (the gene G is copied (transcribed) as a short string of mRNA from the very long string of DNA). You then do configure the install (the mRNA leaves the core) with the respective configuration (the mRNA is translated into a protein, the protein may be adjusted by other proteins after this), and install the library in a global “/lib” directory (the protein folds itself into its correct form after which it is fully functional). After you have installed the library, you import the needed part of the library to your program (the folded protein travels (randomly) to the site where it is needed) and you use certain functions of this library to solve your problem (the protein does some kind of work to solve the problem).</p>
<p>Additional to this, neurons may also dynamically alter their genome, that is they can dynamically change their github repository to add or remove libraries.</p>
<p>To understand this process further, you may want to watch the following video, which shows how HIV produces its proteins and how the virus can change the host DNA to suit its needs. The process described in this video animation is very similar to what is going on in neurons. To make it more similar to the process in neurons, imagine that HIV is a neurotransmitter and that everything contained in the HIV cell is in the neuron in the first place. What you have then is an accurate representation of how neurons make use of theirs genes and proteins:</p>
<p><iframe class="youtube-player" width="640" height="360" src="https://www.youtube.com/embed/RO8MP3wMvqg?version=3&#038;rel=1&#038;showsearch=0&#038;showinfo=1&#038;iv_load_policy=1&#038;fs=1&#038;hl=en-US&#038;autohide=2&#038;start=59&#038;wmode=transparent" allowfullscreen="true" style="border:0;" sandbox="allow-scripts allow-same-origin allow-popups allow-presentation"></iframe></p>
<p>You may ask, isn’t it so that every cell in your body has (almost) the same DNA in order to be able to replicate itself? Generally, this is true for most cells, but not true for most neurons. Neurons will typically have a genome that is different from the original genome that you were assigned to at birth. Neurons may have additional or fewer chromosomes and have sequences of information removed or added from certain chromosomes.</p>
<p>It was shown, that this behavior is important for information processing and if gone awry, this may contribute to brain disorders like depression or Alzheimer’s disease. Recently it was also shown, that neurons change their genome on a daily basis to improve information processing demands.</p>
<p>So when you sit at your desk for five days, and then on the weekend decide to go on a hike, it makes good sense that the brain adapts its neurons for this new task, because entirely different information processing is needed after this change of environment.</p>
<p>Equally, in an evolutionary sense, it would be beneficial to have different “modes” for hunting/gathering and social activity within the village — and it seems that this function might be for something like this. In general, the biological information processing apparatus is extremely efficient in responding to slower information processing demands that range from minutes to hours.</p>
<p>With respect to deep learning, an equivalent function would be to alter the function of a trained convolutional net in significant but rule-based ways; for example to apply a transformation to all parameters when changing from one to another task (recognition of street numbers -&gt; transform parameters -&gt; recognition of pedestrians).</p>
<p>Nothing of this biological information processing is modeled by the LNP model.</p>
<p>Looking back at all this, it seems rather strange that so many researchers think they that they can replicate the brain&#8217;s behavior by concentrating on the electrochemical properties and inter-neuron interactions only. Imagine that every unit in a convolutional network has its own github, from which it <em>learns</em> to dynamically download, compile and use the best libraries to solve a certain task. From all this you can see that a single neuron is probably more complex than an entire convolutional net, but we continue from here in our focus on electrochemical processes and see where it leads us.</p>
<h3>Back to the LNP model</h3>
<p>After all this above, there is only one more relevant step in information processing for our model. Once a critical level of depolarization is reached, a neuron will most often fire, but not always. There are mechanisms that prevent a neuron from firing. For example shortly after a neuron fired, its electric potential is too positive to produce a fully-fledged action potential, and thus it cannot fire again. This blockage may be present even when a sufficient electric potential is reached, because this blockade is a biological function and not a physical switch.</p>
<p>In the LNP model, this blockage of an action potential is modeled as an inhomogeneous Poisson process which has a Poisson distribution. A Poisson process with a Poisson distribution as a model means that the neuron has a very high probability to fire the first or second time it reached its threshold potential, but it may also be (with a exponentially decreasing probability) that a neuron may not fire for many more times.</p>
<p><figure id="attachment_325" aria-describedby="caption-attachment-325" style="width: 652px" class="wp-caption aligncenter"><a href="https://i0.wp.com/timdettmers.com/wp-content/uploads/2015/07/poisson.png?ssl=1"><img data-attachment-id="325" data-permalink="https://timdettmers.com/2015/07/27/brain-vs-deep-learning-singularity/poisson/" data-orig-file="https://i0.wp.com/timdettmers.com/wp-content/uploads/2015/07/poisson.png?fit=652%2C347&amp;ssl=1" data-orig-size="652,347" 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="Poisson" data-image-description="" data-image-caption="" data-medium-file="https://i0.wp.com/timdettmers.com/wp-content/uploads/2015/07/poisson.png?fit=300%2C160&amp;ssl=1" data-large-file="https://i0.wp.com/timdettmers.com/wp-content/uploads/2015/07/poisson.png?fit=652%2C347&amp;ssl=1" class="wp-image-325 size-full" src="https://i0.wp.com/timdettmers.com/wp-content/uploads/2015/07/poisson.png?resize=652%2C347&#038;ssl=1" alt="Poisson" width="652" height="347" data-recalc-dims="1" /></a><figcaption id="caption-attachment-325" class="wp-caption-text">A Poisson(0.5) distribution with a randomly drawn sample. Here 0,1,2,3 represents the waiting time until the neuron fires, thus 0 means it fires without delay, while 2 means it will not fire for two cycles even if it could fire physically.</figcaption></figure></p>
<p>There are exceptions to this rule, where neurons disable this mechanism and fire continuously at the rates which are governed by the physics alone — but these are special events which I will ignore at this point. Generally, this whole process is very similar to dropout used in deep learning which uses a uniform distribution instead of a Poisson distribution; thus this process can be viewed as some kind of regularization method that the brain uses instead of dropout.</p>
<p>In the next step, if the neuron fires, it releases an action potential. The action potential has very little difference in its amplitude, meaning the electric potential generated by the neuron almost always has the same magnitude, and thus is a reliable signal. As this signal travels down the axon it gets weaker and weaker. When it flows into the branches of the axon terminal, its final strength will be dependent on the shape and length of these branches; so each axon terminal will receive a different amount of electrical potential. This spatial information, together with the temporal information due to the spiking pattern of action potentials, is then translated into electrochemical information (it was shown that they are translated into spikes of neurotransmitters themselves that last about 2ms). To adjust the output signal, the axon terminal can move, grow or shrink (spatial), or it may alter its protein makeup which is responsible for releasing the synaptic vesicles (temporal).</p>
<p>Now we are back at the beginning: Neurotransmitters are released from the axon terminal (which can be modeled as a dense matrix multiplication) and the steps repeat themselves.</p>
<h3>Learning and memory in the brain</h3>
<p>Now that we went through the whole process back to back, let us put all this into context to see how the brain uses all this in concert.</p>
<p>Most neurons repeat the process of receive-inputs-and-fire about 50 to 1000 times per second; the firing frequency is highly dependent on the type of neuron and if a neuron is actively processesing tasks. Even if a neuron does not process a task it will fire continuously in a random fashion.  Once some meaningful information is processed, this random firing activity makes way for a highly synchronized activity between neighboring neurons in a brain region. This synchronized activity is poorly understood, but is thought to be integral to understanding information processing in the brain and how it learns.</p>
<p>Currently, it is not precisely known how the brain learns. We do know that it adjusts synapses with some sort of reinforcement learning algorithm in order to learn new memories, but the precise details are unclear and the weak and contradicting evidence indicates that we are missing some important pieces of the puzzle. We got the big picture right, but we cannot figure out the brain&#8217;s learning algorithm without the fine detail which we are still lacking.</p>
<p>Concerning memories, we know that some memories are directly stored in the hippocampus, the main learning region of the brain (if you lose your hippocampus in each brain hemisphere, you cannot form new memories). However, most long-term memories are created and integrated with other memories during your REM sleep phase, when so called sleep spindles unwind the information of your hippocampus to all other brain areas. Long-term memories are generally all local: Your visual memories are stored in the visual system; your memories for your tongue (taste, texture) are stored in the brain region responsible for your tongue, etcetera.</p>
<p>It is also known, that the hippocampus acts as a memory buffer. Once it is full, you need to sleep to empty its contents to the rest of your brain (through sleep spindles during REM sleep); this might be why babies sleep so much and so irregularly —once their learning buffer is full, they sleep to quickly clear their buffer in order to learn more after they wake. You can still learn when this memory buffer is full, but retention is much worse and new memories might wrangle with other memories in the buffer for space and displace them —so really get your needed amount of sleep. Sleeping less and irregularly is unproductive, especially for students who need to learn.</p>
<p><figure id="attachment_341" aria-describedby="caption-attachment-341" style="width: 200px" class="wp-caption aligncenter"><a href="https://i0.wp.com/timdettmers.com/wp-content/uploads/2015/07/hippocampus_small.gif?ssl=1"><img data-attachment-id="341" data-permalink="https://timdettmers.com/2015/07/27/brain-vs-deep-learning-singularity/hippocampus_small/" data-orig-file="https://i0.wp.com/timdettmers.com/wp-content/uploads/2015/07/hippocampus_small.gif?fit=200%2C200&amp;ssl=1" data-orig-size="200,200" 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="Hippocampus_small" data-image-description="" data-image-caption="" data-medium-file="https://i0.wp.com/timdettmers.com/wp-content/uploads/2015/07/hippocampus_small.gif?fit=200%2C200&amp;ssl=1" data-large-file="https://i0.wp.com/timdettmers.com/wp-content/uploads/2015/07/hippocampus_small.gif?fit=200%2C200&amp;ssl=1" class="wp-image-341 size-full" src="https://i0.wp.com/timdettmers.com/wp-content/uploads/2015/07/hippocampus_small.gif?resize=200%2C200&#038;ssl=1" alt="Hippocampus_small" width="200" height="200" data-recalc-dims="1" /></a><figcaption id="caption-attachment-341" class="wp-caption-text">The hippocampus in each hemisphere is shown in red. Image source: <a href="https://commons.wikimedia.org/wiki/File:Hippocampus_small.gif">1</a></figcaption></figure></p>
<p>Because memories are integrated with other memories during your “write buffer to hard-drive” stage, sleep is also very important for creativity. The next time you recall a certain memory after you slept, it might be altered with some new information that your brain thought to be fitting to attach to that memory.</p>
<p>I think we all had this: We wake up with some crazy new idea, only to see that it was quite nonsensical in the first place — so our brain is not perfect either and makes mistakes. But other times it just works: One time I tortured myself with a math problem for 7 hours non-stop, only to go to bed disappointed with only about a quarter of the whole problem solved. After I woke, I immediately had two new ideas how to solve the problem: The first did not work; but second made things very easy and I could sketch a solution to the math problem within 15 minutes — an ode to sleep!</p>
<p>Now why do I talk about memories when this blog post is about computation? The thing is that memory creation — or in other words — a method to store computed results for a long time, is critical for any intelligence. In brain simulations, one is satisfied if the synapse and activations occur in the same distribution as they do in the real brain, but one does not care if these synapses or activations correspond to anything meaningful — like memories or “distributed representations” needed for functions such as object recognition. This is a great flaw. Brain simulations have no memories.</p>
<p>In brain simulation, the diffusion of electrochemical particles is modeled by differential equations. These differential equations are complex, but can be modeled with simple techniques like Euler’s method to approximate these complex differential equations. The result has poor accuracy (meaning high error) but the algorithm is very computationally efficient and the accuracy is sufficient to reproduce the activities of real neurons along with their size and distribution of synapses. The great disadvantage is that we generally cannot learn parameters from a method like this — we cannot create meaningful memories.</p>
<p>However, as I have shown in <a href="https://timdettmers.com/2015/03/26/convolution-deep-learning/">my blog post about convolution</a>, we can also model diffusion by applying convolution — a very computationally complex operation. The advantage about convolution is that we can use methods like maximum-likelihood estimation with backpropagation to learn parameters which lead to meaningful representations which are akin to memories (just like we do in convolutional nets). This is exactly akin to the LNP model with its convolution operation.</p>
<p>So besides its great similarity to deep learning models, the LNP model is also justified in that it is actually possible to learn parameters which yield meaningful memories (where with memories I mean here distributed representations like those we find in deep learning algorithms).</p>
<p>This then also justifies the next point where I estimate the brain&#8217;s complexity by using convolution instead of Euler’s method on differential equations.</p>
<p>Another point to take away from for our model is, that we currently have no complexity assigned for the creation of memories (we only modeled the forward pass, not the backward pass with backpropagation). As such, we underestimate the complexity of the brain, but because we do not know how the brain learns, we cannot make any accurate estimates for the computational complexity of learning. With that said and kept in the back of our mind, let us move on to bringing the whole model together for a lower bound of computational complexity.</p>
<h3>Bringing it all together for a mathematical estimation of complexity</h3>
<p><a href="https://i0.wp.com/timdettmers.com/wp-content/uploads/2015/07/brain_complexity.png?ssl=1"><img data-attachment-id="333" data-permalink="https://timdettmers.com/2015/07/27/brain-vs-deep-learning-singularity/brain_complexity/" data-orig-file="https://i0.wp.com/timdettmers.com/wp-content/uploads/2015/07/brain_complexity.png?fit=780%2C278&amp;ssl=1" data-orig-size="780,278" 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="brain_complexity" data-image-description="" data-image-caption="" data-medium-file="https://i0.wp.com/timdettmers.com/wp-content/uploads/2015/07/brain_complexity.png?fit=300%2C107&amp;ssl=1" data-large-file="https://i0.wp.com/timdettmers.com/wp-content/uploads/2015/07/brain_complexity.png?fit=780%2C278&amp;ssl=1" class="aligncenter wp-image-333 size-full" src="https://i0.wp.com/timdettmers.com/wp-content/uploads/2015/07/brain_complexity.png?resize=780%2C278&#038;ssl=1" alt="brain_complexity" width="780" height="278" data-recalc-dims="1" /></a></p>
<p>The next part is a bit tricky: We need to estimate the numbers for N, M, n and m and these differ widely among neurons.</p>
<p>We know that 50 of the 86 billion neurons in the brain are cerebellar granule neurons, so these neurons and their connection will be quite important in our estimation.</p>
<p>Cerebellar granule neurons are very tiny neurons with about 4 dendrites. Their main input is from the cortex. They integrate these signals and then send them along a T-shaped axon which feeds into the dendrites of Purkinje neurons.</p>
<p>Purkinje neurons are by far the most complex neurons, but there are only about 100 million of them. They may have more than a 100000 synapses each and about 1000 dendrites. Multiple Purkinje neurons bundle their outputs in about a dozen deep nuclei (a bunch of densely packed neurons) which then send signals back to the cortex.</p>
<p>This process is very crucial for non-verbal intelligence, abstract thinking and abstract creativity (creativity: Name as many words beginning with the letter A; abstract creativity: What if gravity bends space-time (general relativity)? What if these birds belonged to the same species when they came to this island (evolution)?). It was thought a few decades ago that the cerebellum only computes outputs for movement; for example while Einstein’s cerebrum was handled and studied carefully, his cerebellum was basically just cut off and put away, because it was regarded as a “primitive” brain part.</p>
<p>But since then it was shown that the cerebellum forms 1:1 connections with most brain regions of the cortex. Indeed, changes in the front part of the cerebellum during the ages 23 to 25 may change your non-verbal IQ by up to 30 points, and changes of 10-15 IQ points are common. This is very useful in most instances, whereas we lose neurons which perform a function which we do not need in everyday lives (calculus, or the foreign language which you learned but never used).</p>
<p>So it is crucial to get the estimation of the cerebellum right not only because it contains most neurons, but also because it is important for intelligence and information processing in general.</p>
<h3>Estimation of cerebellar filter dimensions</h3>
<p>Now if we look at a single dendrite, it branches off into a few branches and thus has a tree like structure. Along its total length it is usually packed with synapses. Dendritic spikes can originate in any branch of a dendrite (spatial dimension). When we take 3 branches per dendrite, and 4 dendrites in total we have a convolutional filter of size 3 and 4 for cerebellar granule neurons. Since linear convolution over two dimensions is the same as convolution over one dimension followed by convolution over the other dimension, we can also model this as a single 3&#215;4 convolution operation. Also note that this is mathematically identical to a model that describes the diffusion of particles originating from different sources (feature map) which diffuse according to a rule in their neighborhood (kernel) — this is exactly what happens at a physical level. More on this view in <a href="https://timdettmers.com/2015/03/26/convolution-deep-learning/">my blog post about convolution</a>.</p>
<p>Here I have chosen to represent the spatial domain with a single dimension. It was shown that the shape of the dendritic tree is also important in the resulting information processing and thus we would need two dimensions for the spatial domain. However, data is lacking to represent this mathematically in a meaningful way and thus I proceed with the simplification to one spatial dimension.</p>
<p>The temporal dimension is also important here: Charged particles may linger for a while until they are pumped out of the neuron. It is difficult to estimate a meaningful time frame, because the brain uses continuous time while our deep learning algorithms only know discrete time steps.</p>
<p>No single estimate makes sense from a biological perspective, but from a psychological perspective we know that the brain can take up unconscious information that is presented in an image in about 20 milliseconds (this involves only some fast, special parts of the brain). For conscious recognition of an object we need more time — at least 65 milliseconds, and on average about 80-200 milliseconds for reliable conscious recognition. This involves all the usual parts that are active for object recognition.</p>
<p>From these estimates, one can think about this process as “building up the information of the seen image over time within a neuron”. However, a neuron can only process information if it can differentiate meaningful information from random information (remember, neurons fire randomly if they do not actively process information). Once a certain level of “meaningful information” is present, the neuron actively reacts to that information. So in a certain sense information processing can be thought of as an epidemic of useful information that spreads across the brain: Information can only spread to one neuron, if the neighboring neuron is already infected with this information. Thinking in this way, such an epidemic of information infects all neurons in the brain within 80-200 milliseconds.</p>
<p>As such we can say that, while the object lacks details in the first 20 milliseconds, there is full detail at about 80-200 milliseconds. If we translate this into discrete images at the rate of 30 frames per second (normal video playback) —or in other words time steps — then 20 milliseconds would be 0.6 time steps, and 80-200 milliseconds 2.4-6 time steps. This means, that all the visual information that a neuron needs for its processing will be present in the neuron within 2.4 to 6 frames.</p>
<p>To make calculations easier, I here now choose a fixed time dimension of 5 time steps for neural processes. This means for the dendrites we have spatio-temporal convolutional filters of size 3x4x5 for cerebellar granule neurons. For Purkinje neurons a similar estimate would be filters of a size of about 10x1000x5. The non-linearity then reduces these inputs to a single number for each dendrite. This number represents an instantaneous firing rate, that is, the number represents how often the neuron fires in the respective interval of time, for example at 5 Hz, 100 Hz, 0 Hz etcetera. If the potential is too negative, no spike will result (0 HZ); if the potential is positive enough, then the magnitude of the spike is often proportional to the magnitude of the electric potential —but not always.</p>
<p>It was shown that dendritic summation of this firing rate can be linear (the sum), sub-linear (less than the sum), supra-linear (more than the sum) or bistable (less than the sum, or more than the sum, depending on the respective input); these behaviors of summation often differ from neuron to neuron. It is known that Purkinje neurons use linear summation, and thus their summation to form a spike rate is very similar to the rectified linear function max(0,x) which is commonly used in deep learning. Non-linear sums can be thought of different activation functions. It is important to add, that the activation function is determined by the type of the neuron.</p>
<p>The filters in the soma (or cell body) can be thought of as an additional temporal convolutional filter with a size of 1 in the spatial domain. So this is a filter that reduces the input to a single dimension with a time dimension of 5, that is, a 1x1x5 convolutional filter (this will be the same for all neurons).</p>
<p>Again, the non-linearity then reduces this to an instantaneous firing rate, which then is dropped out by a Poisson process, which is then fed into a weight-matrix.</p>
<p>At this point I want to again emphasize, that it is <u>not</u> correct to view the output of a neuron as binary; the information conveyed by a firing neuron is more like an if-then-else branch: “if(fire == True and dropout == False){ release_ neurotransmitters(); }else{ sleep(0.02); }”</p>
<p>The neurotransmitters are the true output of a neuron, but this is often confused. The source of this confusion is that it is very difficult to study neurotransmitter release and its dynamics with a synapse, while it is ridiculously easy to study action potentials. Most models of neurons thus model the output as action potentials because we have a lot of reliable data here; we do not have such data for neurotransmitter interactions at a real-time level. This is why action potentials are often confused as the true outputs of neurons when they are not.</p>
<p>When a neuron fires, this impulse can be thought of as being converted to a discrete number at the axon terminal (number of vesicles which are released) and is multiplied by another discrete number which represents the amount of receptors on the synapse (this whole process corresponds to a dense or fully connected weight in convolutional nets). In the next step of information processing, charged particles flow into the neuron and build up a real-valued electric potential. This has also some similarities to batch-normalization, because values are normalized into the range [0,threshold] (neuron: relative to the initial potential of the neuron; convolutional net: relative to the mean of activations in batch-normalization). When we look at this whole process, we can model it as a matrix multiplication between two real-valued matrices (doing a scaled normalization before or after this is mathematically equivalent, because matrix multiplication is a linear operation).</p>
<p>Therefore we can think of axon-terminal-synapse interactions between neurons as a matrix multiplication between two real-valued matrices.</p>
<h3>Estimation of cerebellar input/output dimensions</h3>
<p>Cerebellar granule neurons typically receive inputs from about four axons (most often connections from the cortex). Each axon forms about 3-4 synapses with the dendritic claw of the granule neuron (a dendrite ending shaped as if you would hold a tennis ball in your hand) so there are a total of about 15 inputs via synapses to the granule neurons. The granule neuron itself ends in a T shaped axon which crosses directly through the dendrites of Purkinje neurons with which it forms about 100 synapses.</p>
<p>Purkinje neurons receive inputs from about 100000 connections made with granule neurons and they themselves make about 1000 connections in the deep nuclei. There are estimates which are much higher and no accurate number for the number of synapses exists as far as I know. The number of 100000 synapses might be a slight overestimate (but 75000 would be too conservative), but I use it anyways to make the math simpler.</p>
<p>All these dimensions are taken times the time dimension as discussed above, so that the input for granule neurons for example has a dimensionality of 15&#215;5.</p>
<p>So with this we can finally calculate the complexity of a cerebellar granule neuron together with the Purkinje neurons.</p>
<p><a href="https://i0.wp.com/timdettmers.com/wp-content/uploads/2015/07/brain_computational_estimate.png?ssl=1"><img data-attachment-id="334" data-permalink="https://timdettmers.com/2015/07/27/brain-vs-deep-learning-singularity/brain_computational_estimate/" data-orig-file="https://i0.wp.com/timdettmers.com/wp-content/uploads/2015/07/brain_computational_estimate.png?fit=776%2C493&amp;ssl=1" data-orig-size="776,493" 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="brain_computational_estimate" data-image-description="" data-image-caption="" data-medium-file="https://i0.wp.com/timdettmers.com/wp-content/uploads/2015/07/brain_computational_estimate.png?fit=300%2C191&amp;ssl=1" data-large-file="https://i0.wp.com/timdettmers.com/wp-content/uploads/2015/07/brain_computational_estimate.png?fit=776%2C493&amp;ssl=1" class="aligncenter wp-image-334 size-full" src="https://i0.wp.com/timdettmers.com/wp-content/uploads/2015/07/brain_computational_estimate.png?resize=776%2C493&#038;ssl=1" alt="brain_computational_estimate" width="776" height="493" data-recalc-dims="1" /></a></p>
<p>So my estimate would be 1.075&#215;10^21 FLOPS for the brain, the fastest computer on earth as of July 2013 has 0.58&#215;10^15 FLOPS for practical application (more about this below).</p>
<h3>Part III: Limitations and criticism</h3>
<p>While I discussed how the brain is similar to deep learning, I did not discuss how the brain is different. One great disparity is that the dropout in the brain works with respect to all inputs, while dropout in a convolutional network works with respect to each single unit. What the brain is doing makes little sense in deep learning right now; however, if you think about combining millions of convolutional nets with each other, it makes good sense to do as the brain does. The dropout of the brain certainly would work well to decouple the activity of neurons from each other, because no neuron can depend on information from a single other neuron (because it might be dropped out), so that it is forced to take into account all the neurons it is connected with, thus eliminating biased computation (which is basically regularization).</p>
<p>Another limitation of the model is that it is a lower bound. This estimate does not take into account:</p>
<ul>
<li>Backpropagation, i.e. signals that travel from the soma to the dendrites; the action potential is reflected within the axon and travels backwards (these two things may almost double the complexity)</li>
<li>Axon terminal information processing</li>
<li>Multi-neurotransmitter vesicles (can be thought of multiple output channels or filters, just as an image has multiple colors)</li>
<li>Geometrical shape of the dendritic tree</li>
<li>Dendritic spine information processing</li>
<li>Non-axodendritic synapses (axon-axon and axon-soma connections)</li>
<li>Electrical synapses</li>
<li>Neurotransmitter induced protein activation and signaling</li>
<li>Neurotransmitter induced gene regulation</li>
<li>Voltage induced (dendritic spikes and backpropagating signals) gene regulation</li>
<li>Voltage induced protein activation and signaling</li>
<li>Glia cells (besides having an extremely abnormal brain (about one in a billion), Einstein also had abnormally high levels of glia cells)</li>
</ul>
<p>All these things have been shown to be important for information processing in the brain. I did not include them in my estimate because this would have made everything:</p>
<ul>
<li>Too complex: What I have discussed so far is extremely simple if you compare that to the vastness and complexity of biological information processing</li>
<li>Too special: Non-axodendritic synapses can have unique information processing algorithms completely different from everything listed here, e.g. direct electrical communication between a neighboring bundle of neurons</li>
<li>And/or evidence is lacking to create a reliable mathematical model: Neural backpropagation, geometry of the dendritic trees, and dendritic spines</li>
</ul>
<p>Remember that these estimates are for the whole brain. Local brain regions might have higher computational processing speed than this average when they are actively processing stimuli. Also remember that the cerebellum makes up almost all computational processing. Other brain regions integrate the knowledge of the cerebellum, but the cerebellum acts as a transformation and abstraction module for almost all information in the brain (except vision and hearing).</p>
<h3>But wait, but we can do all this with much less computational power! We already have super-human performance in computer vision!</h3>
<p>I would not say that we have super-human performance in computer vision. What we have is a system that beats human at naming things in images that are taken out of context of the real world (what happens before we see something in the real world shapes our perception dramatically). We almost always can recognize things in our environment, but we most often just do not know (or care about) the name of what we see.</p>
<p>Humans do not have the visual system to label things. Try to make a list of 1000 common physical objects in the real world —not an easy task.</p>
<p>To not recognize an object for us humans would mean that we see an object but cannot make sense of it. If you forgot the name of an old classmate, it does not mean you did not recognize her; it just means you forgot her name. Now imagine you get off a train stop and you know a good friend is waiting for you somewhere at the stop. You see somebody 300 meters away waving their hands who is looking in your direction — is it your friend? You do not know; you cannot recognize if it is her. That’s the difference between mere labels and object recognition.</p>
<p>Now if you cannot recognize something in a 30&#215;30 pixel image, but the computer can, this also does not necessarily mean that the computer has super-human object recognition performance. First and foremost this means that your visual system does not work well for pixeled information. Our eyes are just not used to that.</p>
<p>Now take a look outside a window and try to label all the things you see. It will be very easy for most things, but for other things you do not know the correct labels! For example, I do not know the name for a few plants that I see when I look out of my window. However, we are fully aware what it is what we see and can name many details of the object. For example, alone by assessing their appearance, I know a lot about how much water and sunshine the unknown plants need, how fast they grow, in which way they grow, if they are old or young specimens; I know how they feel like if I touch them — or more generally — I know how these plants grow biologically and how they produce energy, and so on. I can do all this without knowing its name. Current deep learning systems cannot do this and will not do this for quite some time. Human-level performance in computer vision is far away indeed! We just reached the very first step (object recognition) and now the task is to make computer vision smart, rather than making it just good at labeling things.</p>
<p>Evolutionarily speaking, the main functions of our visual system have little to do with naming things that we see: Hunt and avoid being hunted, to orient ourselves in nature during foraging and make sure we pick the right berries and extract roots efficiently— these are all important functions, but probably one of the most important functions of our vision is the social function within a group or relationship.</p>
<p>If you Skype with someone it is quite a different communication when they have their camera enabled compared to if they have not. It is also very different to communicate with someone whose image is on a static 2D surface compared to communicating in person. Vision is critical for communication.</p>
<p>Our deep learning cannot do any of this efficiently.</p>
<h3>Making sense of a world without labels</h3>
<p>One striking case which also demonstrates the power of vision for true understanding of the environment without any labels is the case of <a href="https://en.wikipedia.org/wiki/Genie_(feral_child)">Genie</a>. Genie was strapped into place and left alone in a room at the age of 20 months. She was found with severe malnutrition 12 years later. She had almost no social interaction during this time and thus did not acquire any form of verbal language.</p>
<p>Once she got in contact with other human beings she was taught English as a language (and later also sign language), but she never really mastered it. Instead she quickly mastered non-verbal language and was truly exceptional at that.</p>
<p>To strangers she almost exclusively communicated with non-verbal language. There are instances where these strangers would stop in their place, leave everything behind, walk up to her and hand her a toy or another item — that item was always something that was known to be something liked and desired.</p>
<p>In one instance a woman got out of her car at a stoplight at an intersection, emptied her purse and handed it to Genie. The woman and Genie did not exchange a word; they understood each other completely non-verbally.</p>
<p>So what Genie did, was to pick up cues with her visual system and translated the emotional and cognitive state of that woman into non-verbal cues and actions, which she would then use to change the mental state of the woman. In turn that the woman would then desire to give the purse to Genie (which Genie probably could not even see).</p>
<p>Clearly, Genie was very exceptional at non-verbal communication — but what would happen if you pitched her against a deep learning object recognition system? The deep learning system would be much better than Genie on any data set you would pick. Do you think it would be fair to say that the convolutional net is better at object recognition than Genie is? I do not think so.</p>
<p>This shows how primitive and naïve our approach to computer vision is. Object recognition is a part of human vision, but it is not what makes it exceptional.</p>
<h3>Can we do with less computational power?</h3>
<p>“We do not need as much computational power as the brain has, because our algorithms are (will be) better than that of the brain.”</p>
<p>I hope you can see after the descriptions in this blog post that this statement is rather arrogant.</p>
<p>We do not know how the brain really learns. We do not understand information processing in the brain in detail. And yet we dare to say we can do better?</p>
<p>Even if we did know how the brain works in all its details, it would still be rather naïve to think we could create general intelligence with much less. The brain developed during many hundreds of millions of years through evolution. Evolutionary, it is the most malleable organ there is: The human cortex shrunk by about 10% during the last 20000 years, and the human brain adapted rapidly to the many ways we use verbal language — a very recent development in evolutionary terms.</p>
<p>It was also shown that the number of neurons in each animal’s brain is almost exactly the amount which it can sustain through feeding (we probably killed off the majority of all mammoths by about 20000 years ago). We humans have such large brains because we invented fire and cooking with which we could predigest food which made it possible to sustain more neurons. Without cooking, the intake of calories would not be high enough to sustain our brains and we would helplessly starve (at least a few thousand years ago; now you could survive on a raw vegan diet easily — just walk into a supermarket and buy a lot of calorie-dense foods). With this fact, it is very likely that brains are optimized exhaustively to create the best information processing which is possible for the typical calorie intake of the respective species — the function which is most expensive in an animal will be most ruthlessly optimized to enhance survival and procreation. This is also very much in line with all the complexity of the brain; every little function is optimized thoroughly and only as technology advances we can understand step by step what this complexity is made for.</p>
<p>There are many hundreds of different types of neurons in the brain, each with their designated function. Indeed, neuroscientists often can differentiate different brain regions and their function by looking at the changing architecture and neuron types in a brain region. Although we do not understand the details of how the circuits perform information processing, we can see that each of these unique circuits is designed carefully to perform a certain kind of function. These circuits are often replicated in evolutionary distinct species which share a common ancestor that branched off into these different species hundreds of millions of years ago, showing that such structures are evolutionarily optimal for the tasks they are processing.</p>
<p>The equivalent in deep learning would be, if we had 10000 different architectures of convolutional nets (with its own set of activation functions and more) which we combine meticulously to improve the overall function of our algorithm ― do you really think we can build something which can produce as complex information processing, but which follows a simple general architecture?</p>
<p>It is rather naïve to think that we can out-wit this fantastically complex organ when we are not even able to understand its learning algorithms.</p>
<p>On top of this, the statement that we will develop better algorithms than the brain uses is unfalsifiable. We can only prove it when we achieve it, we cannot disprove it. Thus it is a rather nonsensical statement that has little practical value. Theories are usually useful even when there is not enough evidence to show that they are correct.</p>
<p>The standard model of physics is an extremely useful theory used by physicists and engineers around the world in their daily life to develop the high tech products we enjoy; and yet this theory is not complete, it was amended just a few days ago when a new particle was proven to exist in the LHC experiment.</p>
<p>Imagine if there were another model, but you would only be able to use it when we have proven the existence of <em>all particles</em>. This model would then be rather useless. When it makes no predictions at all about the behavior in the world, we would be unable to manufacture and develop electronics with this theory. Similarly, the statement that we can develop more efficient algorithms than the brain does not help; it rather makes it more difficult to make further progress. The brain should really be our main point of orientation.</p>
<p>Another argument, which would be typical for Yann LeCun (he made a similar argument during a panel) would be: Arguably, airplanes are much better at flying than birds are; yet, if you describe the flight of birds it is extremely complex and every detail counts, while the flight of airplanes is described simply by the fluid flow around an airfoil. Why is it wrong to expect this simplicity from deep learning when compared to the brain?</p>
<p>I think this argument has some truth in it, but essentially, it asks the wrong question. I think it is clear that we need not to replicate everything in detail in order to achieve artificial intelligence, but the real question is: Where do we draw the line? If you get to know that neurons can be modeled in ways that closely resemble convolutional nets, would you go so far and say, that this model is too complex and we need to make it simpler?</p>
<h2>Part IV: Predicting the growth of practical computational power</h2>
<p>There is one dominant measure of performance in high-performance computing (HPC) and this measure is floating point operations per second (FLOPS) on the High Performance LINPACK (HPL) benchmark – which measures how many computations a system can do in a second when doing distributed dense matrix operations on hundreds or thousands of computers. There exists the TOP 500 list of supercomputers, which is a historical list based on this benchmark which is the main reference point for the performance of a new supercomputer system.</p>
<p>But a big but comes with the LINPACK benchmark. <a href="http://www.netlib.org/utk/people/JackDongarra/PAPERS/HPCG-benchmark.pdf">It does not reflect the performance in real, practical applications</a> which run on modern supercomputers on a daily basis, and thus, the fastest computers on the TOP 500 list are not necessarily the fastest computers for practical applications.</p>
<p>Everybody in the high performance computing community knows this, but it is so entrenched in the business routine in this area, that when you design a new supercomputer system, you basically have to show that your system will be able to get a good spot on the TOP 500 in order to get funding for that supercomputer.</p>
<p>Sometimes such systems are practically unusable, like the Tianhe-2 supercomputer which still holds the top spot on the LINPACK benchmark after more than three years. The potential of this supercomputer goes largely unused because it is too expensive to run (electricity) and the custom hardware (custom network, Intel Xeon Phi) requires new software, which would need years of development to reach the levels of sophistication of standard HPC software. The Tianhe-2 runs only at roughly one third of its capacity, or in other words, it practically stands idle for nearly 2 out of 3 minutes. The predecessor of the Tianhe-2, the Tianhe-1, fastest computer in the world in 2010 (according to LINPACK), has not been used since 2013 due to bureaucracy reasons.</p>
<p>While outside of China, other supercomputers of similar design fare better, they typically do not perform so well in practical applications. This is so, because the used accelerators like graphic processing units (GPUs) or Intel Xeon Phis can deliver high FLOPS in such a setup, but they are severely limited by network bandwidth bottlenecks.</p>
<p>To correct the growing uselessness of the LINPACK benchmark a new measure of performance was developed: The high performance conjugate gradient benchmark (HPCG). This benchmark performs conjugate gradient, which requires more communication than LINPACK and as such comes much closer to performance numbers for real applications. I will use this benchmark to create my estimates for a singularity.</p>
<p><figure id="attachment_327" aria-describedby="caption-attachment-327" style="width: 1000px" class="wp-caption aligncenter"><a href="https://i0.wp.com/timdettmers.com/wp-content/uploads/2015/07/top500_2.jpg?ssl=1"><img data-attachment-id="327" data-permalink="https://timdettmers.com/2015/07/27/brain-vs-deep-learning-singularity/top500_2/" data-orig-file="https://i0.wp.com/timdettmers.com/wp-content/uploads/2015/07/top500_2.jpg?fit=1000%2C800&amp;ssl=1" data-orig-size="1000,800" 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="top500_2" data-image-description="" data-image-caption="" data-medium-file="https://i0.wp.com/timdettmers.com/wp-content/uploads/2015/07/top500_2.jpg?fit=300%2C240&amp;ssl=1" data-large-file="https://i0.wp.com/timdettmers.com/wp-content/uploads/2015/07/top500_2.jpg?fit=1000%2C800&amp;ssl=1" class="wp-image-327 size-full" src="https://i0.wp.com/timdettmers.com/wp-content/uploads/2015/07/top500_2.jpg?resize=1000%2C800&#038;ssl=1" alt="top500_2" width="1000" height="800" data-recalc-dims="1" /></a><figcaption id="caption-attachment-327" class="wp-caption-text">The TOP500 for the last decade and some data for the HPCG (data collection only began recently). The dashed lines indicate a forecast. The main drivers of computational growth are also shown: Multicore CPU, GPU, and in 2016-2017 3D memory, and some new unknown technology in 2020. Will this growth be sustainable?</figcaption></figure></p>
<p>However, this benchmark still dramatically overestimates the computing power that can be reached for artificial intelligence applications when we assume that these applications are based on deep learning.</p>
<p>Deep learning is currently the most promising technique for reaching artificial intelligence. It is certain that deep learning — as it is now — will not be enough, but one can say for sure that something similar to deep learning will be involved in reaching strong AI.</p>
<p>Deep learning, unlike other applications has an unusually high demand for network bandwidth. It is so high that for some supercomputer designs which are in the TOP 500 a deep learning application would run slower than on your desktop computer. Why is this so? Because parallel deep learning involves massive parameter synchronization which requires extensive network bandwidth: If your network bandwidth is too slow, then at some point deep learning gets slower and slower the more computers you add to your system. As such, very large systems which are usually quite fast may be extremely slow for deep learning.</p>
<p>The problem with all this is that the development of new network interconnects which enable high bandwidth is difficult and advances are made much more slowly than the advances of computing modules, like CPUs, GPUs and other accelerators. Just recently, Mellanox reached a milestone where they could manufacture switches and InfiniBand cards which operate at 100Gbits per second. This development is still rather experimental, and it is difficult to manufacture fiber-optic cables which can operate at this speed. As such, no supercomputer implements this new development as of yet. But with this milestone reached, there will not be another milestone for many quite a while. The doubling time for network interconnect bandwidth is about 3 years.</p>
<p>Similarly, there is a memory problem. While the speed of theoretical processing power of CPUs and GPUs keeps increasing, the memory bandwidth of RAM is almost static. This is a great problem, because now we are at a point where it costs more time to move the data to the compute circuits than to actually make computations with it.</p>
<p>With new developments such as 3D memory one can be sure that further increases in memory bandwidth will be achieved, but we have nothing after that to increase the performance further. We need new ideas and new technology. Memory will not scale itself by getting smaller and smaller.</p>
<p>However, currently the biggest hurdle of them all is power consumption. The Tianhe-2 uses 24 megawatts of power, which totals to $65k-$100k in electricity cost per day, or about $23 million per year. The power consumed by the Tianhe-2 would be sufficient to power about 6000 homes in Germany or 2000 homes in the US (A/C usage).</p>
<p><figure id="attachment_345" aria-describedby="caption-attachment-345" style="width: 753px" class="wp-caption aligncenter"><a href="https://i0.wp.com/timdettmers.com/wp-content/uploads/2015/07/hpc_constraints.png?ssl=1"><img data-attachment-id="345" data-permalink="https://timdettmers.com/2015/07/27/brain-vs-deep-learning-singularity/hpc_constraints/" data-orig-file="https://i0.wp.com/timdettmers.com/wp-content/uploads/2015/07/hpc_constraints.png?fit=753%2C476&amp;ssl=1" data-orig-size="753,476" 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="hpc_constraints" data-image-description="" data-image-caption="" data-medium-file="https://i0.wp.com/timdettmers.com/wp-content/uploads/2015/07/hpc_constraints.png?fit=300%2C190&amp;ssl=1" data-large-file="https://i0.wp.com/timdettmers.com/wp-content/uploads/2015/07/hpc_constraints.png?fit=753%2C476&amp;ssl=1" class="wp-image-345 size-full" src="https://i0.wp.com/timdettmers.com/wp-content/uploads/2015/07/hpc_constraints.png?resize=753%2C476&#038;ssl=1" alt="hpc_constraints" width="753" height="476" data-recalc-dims="1" /></a><figcaption id="caption-attachment-345" class="wp-caption-text">An overview about how the performance constraints changed from old to new supercomputers. Adapted from <a href="https://www2.lbl.gov/Publications/Deputy-Director/bio.html">Horst Simon</a>&#8216;s <a href="https://www.researchgate.net/profile/Horst_Simon/publication/261879110_Why_we_need_Exascale_and_why_we_won't_get_there_by_2020/links/0c960535dbade00bbc000000.pdf">presentation</a></figcaption></figure></p>
<h3>Physical limitations</h3>
<p>Furthermore, there are physical problems around the corner. Soon, our circuits will be so small that electrons will start to show quantum effects. One such quantum effect is quantum tunneling. In quantum tunneling an electron sits in two neighboring circuits at once, and decides randomly to which of these two locations it will go next.</p>
<p>If this would happen at a larger scale, it would be like charging your phone right next to your TV, and the electrons decide they want to go to your cell phone cable rather than to your TV; so they jump over to the phone cable cutting off the power to your TV. Quantum tunneling will become relevant in 2016-2017 and has to be taken into account from there on. New materials and “insulated” circuits are required to make everything work from here on.</p>
<p>With new materials, we need new production techniques which will be very costly because all computer chips relied on the same, old but reliable production process. We need research and development to make our known processes working with these new materials and this will not only cost money but also cost time. This will also fuel a continuing trend where the cost for producing computer chips increases exponentially (and growth may slow due to costs). Currently, the tally is at $9bn for such a semiconductor fabrication plant (fab) increasing at a relatively stable rate of about 7-10% higher costs per year for the past decades.</p>
<p>After this, we are at the plain physical limits. A transistor will be composed of not much more than a handful of atoms. We cannot go smaller than this, and this level of manufacturing will require extensive efforts in order to get such devices working properly. This will start to happen around 2025 and the growth may slow from here due to physical limitations.</p>
<h3>Recent trends in the growth of computational power</h3>
<p>So to summarize the previous section: (1) LINPACK performance does not reflect practical performance because it does not test memory and network bandwidth constraints; (2) memory and network bandwidth are now more important than computational power, however (3) advances in memory and network bandwidth will be sporadic and cannot compete with the growth in computational power; (4) electrical costs are a severe limitation (try to justify a dedicated power plant for a supercomputer if citizen face sporadic power outages), and also (5) computational power will be limited by physical boundaries in the next couple of years.</p>
<p>It may not come to a surprise then that the growth in computational power has been slowing down in recent years; this is mainly due to power efficiencies which will only be improved gradually, but the other factors also take its toll, like network interconnects which cannot keep up with accelerators like GPUs.</p>
<p>If one takes the current estimate of practical FLOPS of the fastest supercomputer, the Tianhe-2 with 0.58 petaflops on HPCG, then it would take 21 doubling periods until the lower bound of the brain&#8217;s computational power is reached. If one uses Moore’s Law, we would reach that by 2037; if we take the growth of the last 60 years, which is about 1.8 years per doubling period, we will reach this in the year 2053. If we take a lower estimate of 3 years for the doubling period due to the problems listed above we will reach this in 2078. While for normal supercomputing applications memory bandwidth is the bottleneck for practical applications as of now, this may soon change to networking bandwidth, which doubles about every 3 years. So the 2078 estimate might be quite accurate.</p>
<p><figure id="attachment_328" aria-describedby="caption-attachment-328" style="width: 893px" class="wp-caption aligncenter"><a href="https://i0.wp.com/timdettmers.com/wp-content/uploads/2015/07/growth.jpg?ssl=1"><img data-attachment-id="328" data-permalink="https://timdettmers.com/2015/07/27/brain-vs-deep-learning-singularity/growth/" data-orig-file="https://i0.wp.com/timdettmers.com/wp-content/uploads/2015/07/growth.jpg?fit=893%2C634&amp;ssl=1" data-orig-size="893,634" 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="growth" data-image-description="" data-image-caption="" data-medium-file="https://i0.wp.com/timdettmers.com/wp-content/uploads/2015/07/growth.jpg?fit=300%2C213&amp;ssl=1" data-large-file="https://i0.wp.com/timdettmers.com/wp-content/uploads/2015/07/growth.jpg?fit=893%2C634&amp;ssl=1" class="wp-image-328 size-full" src="https://i0.wp.com/timdettmers.com/wp-content/uploads/2015/07/growth.jpg?resize=893%2C634&#038;ssl=1" alt="growth" width="893" height="634" data-recalc-dims="1" /></a><figcaption id="caption-attachment-328" class="wp-caption-text">Growth in computing performance with respect to the HPCG benchmark. Both computing performance and factory costs are assumed to keep growing steadily at an exponential rate with doubling period of 18 or 36 months, respectively.</figcaption></figure></p>
<p>Now remember that, (1) the HPCG benchmark has much higher performance than typical deep learning applications which rely much more on network and memory bandwidth, and (2) that my estimate for the computational complexity of the brain is a lower bound. One can see that an estimate beyond 2100 might be not too far off. To sustain such a long and merciless increase in computation performance will require that we develop and implement many new ideas while operating at the border of physical limitations as soon as by 2020. Will this be possible?</p>
<p>Where there&#8217;s a will, there&#8217;s a way — the real question is: Are we prepared to pay the costs?</p>
<h1>Conclusion</h1>
<p>Here I have discussed the information processing steps of the brain and their complexity and compared them to those of deep learning algorithms. I focused on a discussion of basic electrochemical information processing and neglected biological information processing.</p>
<p>I used an extended linear-nonlinear-Poisson cascade model as groundwork and related it to convolutional architectures.</p>
<p>With this model, I could show that a single neuron has an information processing architecture which is very similar to current convolutional nets, featuring convolutional stages with rectified non-linearities which activities are then regularized by a dropout-like method. I also established a connection between max-pooling and voltage-gated channels which are opened by dendritic spikes. Similarities to batch-normalization exist.</p>
<p>This straightforward similarity gives strong reason to believe that deep learning is really on the right path. It also indicates that ideas borrowed from neurobiological processes are useful for deep learning (the problem was that progress in deep learning architectures often preceded knowledge in neurobiological processes).</p>
<p>My model shows that it can be estimated that the brain operates at least 10x^21 operations per second. With current rates of growth in computational power we could achieve supercomputers with brain-like capabilities by the year 2037, but estimates after the year 2080 seem more realistic when all evidence is taken into account. This estimate only holds true if we succed to stomp limitations like physical barriers (for example quantum-tunneling), capital costs for semiconductor fabrication plants, and growing electrical costs. At the same time we constantly need to innovate to solve memory bandwidth and network bandwidth problems which are or will be the bottlenecks in supercomputing. With these considerations taken into account, it is practically rather unlikely that we will achieve human-like processing capabilities anytime soon.</p>
<h2>Closing remarks</h2>
<p>My philosophy of this blog post was to present all information on a single web-page rather than scatter information around. I think this design helps to create a more sturdy fabric of knowledge, which, with its interwoven strains of different fields, helps to create a more thorough picture of the main ideas involved.  However, it has been quite difficult to organize all this information into a coherent picture and some points might be more confusing than enlightening. Please leave a comment below to let me know if the structure and content need improvement, so that I can adjust my next blog post accordingly.</p>
<p>I would also love general feedback for this blog post.</p>
<p>Also make sure to share this blog post with your fellow deep learning colleagues. People with raw computer science backgrounds often harbor misconceptions about the brain, its parts and how it works. I think this blog post could be a suitable remedy for that.</p>
<h2>The next blog post</h2>
<p>The second post in this series on neuroscience and psychology will focus on the most important brain regions and their function and connectivity. The last and third part in the series will focus on psychological processes, such as memory and learning, and what we can learn from that with respect to deep learning.</p>
<h4><strong>Acknowledgments</strong></h4>
<p>I would like to thank Alexander Tonn for his useful advice and for proofreading this blog post.</p>
<h4><strong>Important references and sources </strong></h4>
<p><strong>Neuroscience</strong></p>
<p>Brunel, N., Hakim, V., &amp; Richardson, M. J. (2014). Single neuron dynamics and computation. <i>Current opinion in neurobiology</i>, <i>25</i>, 149-155.</p>
<p>Chadderton, P., Margrie, T. W., &amp; Häusser, M. (2004). Integration of quanta in cerebellar granule cells during sensory processing. <i>Nature</i>, <i>428</i>(6985), 856-860.</p>
<p>De Gennaro, L., &amp; Ferrara, M. (2003). Sleep spindles: an overview. <i>Sleep medicine reviews</i>, <i>7</i>(5), 423-440.</p>
<p>Ji, D., &amp; Wilson, M. A. (2007). Coordinated memory replay in the visual cortex and hippocampus during sleep. <i>Nature neuroscience</i>, <i>10</i>(1), 100-107.</p>
<p>Liaw, J. S., &amp; Berger, T. W. (1999). Dynamic synapse: Harnessing the computing power of synaptic dynamics. <i>Neurocomputing</i>, <i>26</i>, 199-206.</p>
<p>Ramsden, S., Richardson, F. M., Josse, G., Thomas, M. S., Ellis, C., Shakeshaft, C., &#8230; &amp; Price, C. J. (2011). Verbal and non-verbal intelligence changes in the teenage brain. <i>Nature</i>, <i>479</i>(7371), 113-116.</p>
<p>Smith, S. L., Smith, I. T., Branco, T., &amp; Häusser, M. (2013). Dendritic spikes enhance stimulus selectivity in cortical neurons in vivo. <i>Nature</i>, <i>503</i>(7474), 115-120.</p>
<p><a href="https://www.ncbi.nlm.nih.gov/pmc/articles/PMC3230671/">Stoodley, C. J., &amp; Schmahmann, J. D. (2009). Functional topography in the human cerebellum: a meta-analysis of neuroimaging studies. <i>Neuroimage</i>,<i>44</i>(2), 489-501.</a></p>
<p><strong>High performance computing</strong></p>
<p>Dongarra, J., &amp; Heroux, M. A. (2013). Toward a new metric for ranking high performance computing systems. <i>Sandia Report, SAND2013-4744</i>, <i>312</i>.</p>
<p><a href="https://prod-ng.sandia.gov/techlib-noauth/access-control.cgi/2013/138752.pdf">PDF: HPCG Specification</a></p>
<p><a href="https://top500.org/news/no-exascale-for-you-an-interview-with-berkeley-labs-horst-simon/">Interview: Why there will be no exascale computing before 2020</a></p>
<p><a href="https://www.researchgate.net/profile/Horst_Simon/publication/261879110_Why_we_need_Exascale_and_why_we_won't_get_there_by_2020/links/0c960535dbade00bbc000000.pdf">Slides: Why there will be no exascale computing before 2020</a></p>
<p><a href="http://vrworld.com/2015/03/23/jack-dongarra-on-the-great-exascale-challenge-and-rising-hpc-powers/">Interview: Challenges of exascale computing</a></p>
<p><strong>Image references</strong></p>
<p><a id="anwar14"></a><a href="https://www.ncbi.nlm.nih.gov/pmc/articles/PMC4107854/">Anwar, H., Roome, C. J., Nedelescu, H., Chen, W., Kuhn, B., &amp; De Schutter, E. (2014). Dendritic diameters affect the spatial variability of intracellular calcium dynamics in computer models. <i>Frontiers in cellular neuroscience</i>, <i>8</i>.</a></p>
<p>The post <a rel="nofollow" href="https://timdettmers.com/2015/07/27/brain-vs-deep-learning-singularity/">The Brain vs Deep Learning Part I: Computational Complexity — Or Why the Singularity Is Nowhere Near</a> appeared first on <a rel="nofollow" href="https://timdettmers.com">Tim Dettmers</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://timdettmers.com/2015/07/27/brain-vs-deep-learning-singularity/feed/</wfw:commentRss>
			<slash:comments>183</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">312</post-id>	</item>
		<item>
		<title>How to Parallelize Deep Learning on GPUs Part 2/2: Model Parallelism</title>
		<link>https://timdettmers.com/2014/11/09/model-parallelism-deep-learning/</link>
					<comments>https://timdettmers.com/2014/11/09/model-parallelism-deep-learning/#comments</comments>
		
		<dc:creator><![CDATA[Tim Dettmers]]></dc:creator>
		<pubDate>Sun, 09 Nov 2014 19:16:55 +0000</pubDate>
				<category><![CDATA[Deep Learning]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[GPU]]></category>
		<category><![CDATA[High Performance Computing]]></category>
		<category><![CDATA[Parallel Computing]]></category>
		<guid isPermaLink="false">http://timdettmers.wordpress.com/?p=85</guid>

					<description><![CDATA[<p>Model parallelism enables fast training of large neural networks: Read on to understand how it is done and why it is so good for large networks.</p>
<p>The post <a rel="nofollow" href="https://timdettmers.com/2014/11/09/model-parallelism-deep-learning/">How to Parallelize Deep Learning on GPUs Part 2/2: Model Parallelism</a> appeared first on <a rel="nofollow" href="https://timdettmers.com">Tim Dettmers</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>In my last blog post I explained what model and data parallelism is and analysed <a title="How to Parallelize Deep Learning on GPUs Part 1/2: Data Parallelism" href="http://timdettmers.com/2014/10/09/deep-learning-data-parallelism/" target="_blank" rel="noopener noreferrer">how to use data parallelism effectively in deep learning</a>. In this blog post I will focus on model parallelism.</p>
<p><span id="more-85"></span></p>
<p>To recap, model parallelism is, when you split the model among GPUs and use the same data for each model; so each GPU works on a part of the model rather than a part of the data. In deep learning, one approach is to do this by splitting the weights, e.g. a 1000&#215;1000 weight matrix would be split into a 1000&#215;250 matrix if you use four GPUs.</p>
<figure><img id="featured-image" src="https://i0.wp.com/timdettmers.com/wp-content/uploads/2014/11/modelpara1.png?resize=1025%2C626" alt="" width="1025" height="626 /" data-recalc-dims="1"><figcaption>Model parallelism diagram. Synchronizing communication is needed after each dot product with the weight matrix for both forward and backward pass.</figcaption></figure>
<p>One advantage of this approach is immediately apparent: If we split the weights among the GPUs we can have very large neural networks which weights would not fit into the memory of a single GPU. In part I mentioned this in an earlier blog post, where I also said that such large neural networks are largely unnecessary. However, for very big unsupervised learning tasks – which will become quite important in the near future – such large networks will be needed in order to learn fine grained features that could learn “intelligent” behavior.</p>
<p>How does a forward and backward pass work with such split matrices? This is most obvious when we do the matrix algebra step by step:</p>
<p>We start looking at <img src="https://s0.wp.com/latex.php?latex=%7B%5Cbf%7BA%7D%2C%5Cbf%7BB%7D+%3D+%5Cbf%7BC%7D%7D&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002" alt="{&#92;bf{A},&#92;bf{B} = &#92;bf{C}}" class="latex" /> &nbsp;which would be the dot matrix multiply for the usual forward pass case. The dimensions for using model parallelism with two GPUs for a batch size of 128 and a 1000&#215;500 weight matrix would be:</p>
<p>Standard: 128&#215;1000 dot 1000&#215;500 = 128&#215;500</p>
<p>Split by weight matrix first dimension: 128&#215;500 dot 500&#215;500 = 128&#215;500 -&gt; add matrices</p>
<p>Split by weight matrix second dimension: 128&#215;1000 dot 1000&#215;250 = 128&#215;250 -&gt; stack matrices</p>
<p>To calculate the errors in the layer below we need to pass the current error through to the next layer, or more mathematically, we calculate the deltas by taking the dot product of the error of the previous layer <img src="https://s0.wp.com/latex.php?latex=%7Bi%7D&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002" alt="{i}" class="latex" /> and the weights that connect to the next layer <img src="https://s0.wp.com/latex.php?latex=%7Bj%7D&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002" alt="{j}" class="latex" /> , i.e. <img src="https://s0.wp.com/latex.php?latex=%7B%5Cbf%7Bdelta_j%7D%2C%5Cbf%7BW%5ET%7D+%3D+%5Cbf%7Bdelta_i%7D%7D&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002" alt="{&#92;bf{delta_j},&#92;bf{W^T} = &#92;bf{delta_i}}" class="latex" />:</p>
<p>Standard: 128&#215;500 dot 500&#215;1000 = 128&#215;1000</p>
<p>Split by weight matrix first dimension: 128&#215;500 dot 500&#215;500 = 128&#215;500 -&gt; stack matrices</p>
<p>Split by weight matrix second dimension: 128&#215;250 dot 250&#215;1000 = 128&#215;1000 -&gt; add matrices</p>
<p>We see here, we need to synchronize (adding or stacking weights) after each dot product and you may think that this is slow when compared to data parallelism, where we synchronize only once. But one can quickly see that this is not so for most cases if we do the math: In data parallelism a 1000&#215;500 gradient needs to be transferred once for the 1000&#215;500 layer – that’s 500000 elements; for model parallelism we just need to transfer a small matrix for each forward and backward pass with a total of 128000 or 160000 elements – that’s nearly 4 times less data! So the network card bandwidth is still the main bottleneck in the whole application, but much less so than in the data parallelism case.</p>
<p>This is of course all relative and depends on the network architecture. Data parallelism will be quite fast for small networks and very slow for large networks, the opposite is true for model parallelism. The more parameters we have, the more beneficial is model parallelism. Its true strength comes to play if you have neural networks where the weights do not fit into a single GPU memory. Here model parallelism might achieve that for which one would need thousands of CPUs.</p>
<p>However, if you run small networks where the GPUs are not saturated and have some free capacity (not all cores are running), then model parallelism will be slow. Unlike data parallelism, there are no tricks you can use to hide the communication needed for synchronization, this is because we have only partial information for the whole batch. With this partial information we cannot compute the activities in the next layer and thus have to wait for the completion of the synchronization to move forward.</p>
<p>How the advantages and disadvantages can be combined is best shown by Alex Krizhevsky who <a title="One weird trick for parallelizing convolutional neural networks" href="https://arxiv.org/pdf/1404.5997v2.pdf" target="_blank" rel="noopener noreferrer">demonstrates the efficiency</a> of using data parallelism in the convolutional layers and model parallelism in the dense layers of a convolutional neural network.</p>
<p>The post <a rel="nofollow" href="https://timdettmers.com/2014/11/09/model-parallelism-deep-learning/">How to Parallelize Deep Learning on GPUs Part 2/2: Model Parallelism</a> appeared first on <a rel="nofollow" href="https://timdettmers.com">Tim Dettmers</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://timdettmers.com/2014/11/09/model-parallelism-deep-learning/feed/</wfw:commentRss>
			<slash:comments>21</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">85</post-id>	</item>
		<item>
		<title>How to Parallelize Deep Learning on GPUs Part 1/2: Data Parallelism</title>
		<link>https://timdettmers.com/2014/10/09/deep-learning-data-parallelism/</link>
					<comments>https://timdettmers.com/2014/10/09/deep-learning-data-parallelism/#comments</comments>
		
		<dc:creator><![CDATA[Tim Dettmers]]></dc:creator>
		<pubDate>Thu, 09 Oct 2014 14:59:09 +0000</pubDate>
				<category><![CDATA[Deep Learning]]></category>
		<category><![CDATA[Hardware]]></category>
		<category><![CDATA[GPU]]></category>
		<category><![CDATA[High Performance Computing]]></category>
		<category><![CDATA[Parallel Computing]]></category>
		<guid isPermaLink="false">http://timdettmers.wordpress.com/?p=65</guid>

					<description><![CDATA[<p>Model parallelism is the bread and butter parallelism algorithm for deep learning. Here I explain how it works, and where the bottlenecks lie, which may cripple performance.</p>
<p>The post <a rel="nofollow" href="https://timdettmers.com/2014/10/09/deep-learning-data-parallelism/">How to Parallelize Deep Learning on GPUs Part 1/2: Data Parallelism</a> appeared first on <a rel="nofollow" href="https://timdettmers.com">Tim Dettmers</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>In my <a title="How To Build and Use a Multi GPU System for Deep Learning" href="http://timdettmers.com/2014/09/21/how-to-build-and-use-a-multi-gpu-system-for-deep-learning/">last blog post</a> I showed what to look out for when you build a GPU cluster. Most importantly, you want a fast network connection between your servers and using MPI in your programming will make things much easier than to use the options available in CUDA itself.</p>
<p><span lang="en-US">In this blog post I explain how to utilize such a cluster to parallelize neural networks in different ways and what the advantages and downfalls are for such algorithms. The two different algorithms are data and model parallelism. In this blog entry I will focus on data parallelism.</span></p>
<p><span id="more-65"></span></p>
<p><span lang="en-US">So what are these two? Data parallelism is when you use the same model for every thread, but feed it with different parts of the data; model parallelism is when you use the same data for every thread, but split the model among threads.</span></p>
<p><span lang="en-US">For neural networks this means that data parallelism uses the same weights and but different mini-batches in each thread; the gradients need to be synchronized, i.e. averaged, after each pass through a mini-batch.</span></p>
<p><span lang="en-US">Model parallelism splits the weights of the net equally among the threads and all threads work on a single mini-batch; here the generated output after each layer needs to be synchronized, i.e. stacked, to provide the input to the next layer.</span></p>
<p><span lang="en-US">Each method has its advantages and disadvantages which change from architecture to architecture. Let us look at data parallelism first and its bottlenecks first and in the next post I will look at model parallelism.<br />
</span></p>
<p><b>Severity of the network bottleneck of data parallelism</b></p>
<p><span lang="en-US">The idea of data parallelism is simple. If you have, say, 4 GPUs you split a mini-batch into parts for each of them, say, you split a mini-batch with 128 examples into 32 examples for each GPU. Then you feed the respective batch through the net and obtain gradients for each split of the mini-batch. You then use MPI to collect all the gradients and update the parameters with the overall average.</span></p>
<figure><img id="featured-image" src="https://i0.wp.com/timdettmers.com/wp-content/uploads/2014/10/datapara1.png?resize=1025%2C626" alt="Featured image" width="1025" height="626"  data-recalc-dims="1"><figcaption>Data parallelism diagram. There is no communication in the forward pass, and during the backward pass you synchronize gradients.</figcaption></figure>
<p><span lang="en-US">The biggest problem with this approach is that during the backward pass you have to pass the whole gradient to the all other GPUs. If you have a 1000&#215;1000 weight matrix then you need to pass 4000000 bytes to each network. If we take a 40Gbit/s network card – which is already quite fast – then you will need <img src="https://s0.wp.com/latex.php?latex=%7B%5Cfrac%7B4000000%7D%7B40%7D%5Cfrac%7B1%7D%7B40%5Ctimes+1024%5Ctimes+1024+%5Ctimes+102%7D%5Cfrac%7B1%7D%7B8%5Ctimes+1000%7D+%3D+0.75%5Cmbox%7Bms%7D%7D&#038;bg=ffffff&#038;fg=000&#038;s=0&#038;c=20201002" alt="{&#92;frac{4000000}{40}&#92;frac{1}{40&#92;times 1024&#92;times 1024 &#92;times 102}&#92;frac{1}{8&#92;times 1000} = 0.75&#92;mbox{ms}}" class="latex" /> &nbsp;to pass the data from one node to another node (however, there is some additional overhead that is neglected here). If you have six GPUs in two nodes you need to pass the data to five other GPUs, three of which need to go through the network card (3x 0.75ms), while two can use PCIe 3.0 to pass the data to the other two GPUs (about three times as fast; 2x 0.25ms). However, the PCIe pass is independent of the network card pass, so the time needed is determined by the network card time alone, i.e. 2.25ms. However, only one GPU can transfer data through the network card at any one time in any one node, so that we have to multiply that time by three, i.e. 7.75ms. Now the bottom line is, that we just need about 0.2ms for a matrix multiply through that layer (100&#215;1000 dot 1000&#215;1000) and about twice as much for the backward pass. We can pass the gradient while we work on the next layer, but in the end the network card speed limits our overall computation by quite a bit. This is more marked the larger you scale your system: A four node system working on the same problem needs about 20.25ms to pass the gradients around to the other GPUs. One can easily see that data parallelism does not scale with size of the cluster. </span></p>
<p><span lang="en-US">To counter this bottleneck is to reduce the parameters of the gradient through max pooling, maxout units or by simply using convolution. Another way is to increase the computational time/network time ratio by other means, e.g. by using is computationally intensive optimization techniques like RMSProp. You need the same time to pass the gradients to each other, but more time is spend on computation, thus increasing the utility of the fast GPUs.</span></p>
<p><span lang="en-US">Another thing you can do when you use computationally intensive optimization techniques is to hide latency of networking under the computation of the gradients. This means while you passing the first gradient to all other nodes, you can already start a big RMSProp computation asynchronously for the next layer. This technique can give a speedup of about 0-20 % depending on network architecture.</span></p>
<p><span lang="en-US">But this is not the only problem with data parallelism. There is a very technical bottleneck hidden in the GPU architecture which took me quite a while to understand. To understand why the GPU architecture is a problem we first need to look at the usage and purpose of mini-batches.</span></p>
<p><span lang="en-US"><b>A divergence: Why do we use mini-batches?</b></span></p>
<p><span lang="en-US">If we start with randomly initialized parameters or even if we start with pretrained parameters, we do not need a pass through all the data to get an accurate gradient update that will head into the direction of a local minimum. If we take MNIST as an example, if we have a gradient which includes 10 common mistakes that the network does for each class (mini-batch size of about 128), then we will go into a direction that reduces the error greatly already as the gradient captures rough and common mistakes. If we choose a greater batch size (say 512) then we not only capture common errors, but also catch errors that are more subtle. However, it is not very sensible to fine-tune a system if you know it still has major errors. So overall we gain little by increasing the batch size. We need more computation to do roughly the same and this is the main argument why we use a mini-batch size as small as possible. However, if we choose a mini-batch size that is too small, then we do not capture all the common errors which are relevant for the data set and thus our gradient might not head near a local optimum, so there is a limit how small you can make mini-batches.</span></p>
<p><span lang="en-US">How does this relate to data parallelism? If we want a mini-batch size of 128 and use data parallelism to divide it among, say, eight GPUs, then each net calculates gradients for 16 samples which is then averages with the data from the other GPUs. And exactly here kicks the hardware bottleneck in.</span></p>
<p><span lang="en-US"><b>Memory tiles: Patches of fast GPU memory for efficient dot product calculations</b></span></p>
<p><span lang="en-US">To calculate dot products on the GPU, you need to copy small patches, called memory tiles, into shared memory, i.e. very fast but very small memory (limited to a few kilobytes). The problem is that the standard cuBLAS uses either a 64&#215;128 memory tiles and when you have a batch size less than 64 you waste a lot of precious shared memory. Also if you use a batch size not equal to a multiple of 32 you equally waste shared memory (threads are only started in blocks of 32 threads), so one should use a batch size which is a multiple of 32 or multiple of 64 if possible. For data parallelism this means that you lose significant processing speed once you go below a batch size of 64 for each GPU. If you have many GPUs this can be quite limiting and this is yet another reason why the data parallelism approach does not scale well beyond a certain point.</span></p>
<p><span lang="en-US">All in all this sounds quite dire for data parallelism, but data parallelism has its uses. If you know the bottlenecks, you can wield data parallelism as a might tool for certain applications. This is demonstrated by Alex Krishevsky in his <a title="One weird trick for parallelizing convolutional neural networks" href="https://arxiv.org/pdf/1404.5997v2.pdf" target="_blank" rel="noopener noreferrer">paper</a> where he uses data parallelism in the convolutional layers of his net, and thus achieves a speedup of 3.74x by using four GPUs and 6.25x using eight GPUs. His system features two CPUs and 8 GPUs in one node, so he can use the full PCIe speed for the two sets of four GPUs and relatively fast PCIe connection between CPUs to distribute the data among all eight GPUs. </span></p>
<p><span lang="en-US">Besides convolutional neural networks, another use of data parallelism might be to use it in recurrent neural networks, which typically have less parameters and highly computationally intensive gradient updates – both are wins for data parallelism.</span></p>
<p><span lang="en-US">In my next blog post I will focus on model parallelism, which is efficient for large networks and scales well to larger clusters.</span></p>
<p>The post <a rel="nofollow" href="https://timdettmers.com/2014/10/09/deep-learning-data-parallelism/">How to Parallelize Deep Learning on GPUs Part 1/2: Data Parallelism</a> appeared first on <a rel="nofollow" href="https://timdettmers.com">Tim Dettmers</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://timdettmers.com/2014/10/09/deep-learning-data-parallelism/feed/</wfw:commentRss>
			<slash:comments>20</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">65</post-id>	</item>
		<item>
		<title>How To Build and Use a Multi GPU System for Deep Learning</title>
		<link>https://timdettmers.com/2014/09/21/how-to-build-and-use-a-multi-gpu-system-for-deep-learning/</link>
					<comments>https://timdettmers.com/2014/09/21/how-to-build-and-use-a-multi-gpu-system-for-deep-learning/#comments</comments>
		
		<dc:creator><![CDATA[Tim Dettmers]]></dc:creator>
		<pubDate>Sun, 21 Sep 2014 15:52:40 +0000</pubDate>
				<category><![CDATA[Hardware]]></category>
		<category><![CDATA[GPU]]></category>
		<category><![CDATA[High Performance Computing]]></category>
		<category><![CDATA[Parallel Computing]]></category>
		<guid isPermaLink="false">http://timdettmers.wordpress.com/?p=52</guid>

					<description><![CDATA[<p>You can use a GPU cluster to accelerate deep learning dramatically. Here you learn how to build and use a successful cluster and how to make sure that you avoid the bottlenecks in large deep learning systems.</p>
<p>The post <a rel="nofollow" href="https://timdettmers.com/2014/09/21/how-to-build-and-use-a-multi-gpu-system-for-deep-learning/">How To Build and Use a Multi GPU System for Deep Learning</a> appeared first on <a rel="nofollow" href="https://timdettmers.com">Tim Dettmers</a>.</p>
]]></description>
										<content:encoded><![CDATA[<p>When I started using GPUs for deep learning my deep learning skills improved quickly. When you can run experiments of algorithms and algorithms with different parameters and gain rapid feedback you can just learn much more quickly. At the beginning, deep learning is a lot of trial and error: You have to get a feel what parameters need to be adjusted, or what puzzle piece is missing in order to get a good result. A GPU helps you to fail quickly and learn important lessons so that you can keep improving. Soon my deep learning skills were sufficient to take the <a title="How I did it: Crowdflower 2nd place" href="https://www.kaggle.com/c/crowdflower-weather-twitter/discussion/6488#35640" target="_blank" rel="noopener noreferrer">2<sup>nd</sup> place in the Crowdflower competition</a> where the task was to predict weather labels from given tweets (sunny, raining etc.).</p>
<p>After this success I was tempted to use multiple GPUs in order to train deep learning algorithms even faster. I also took interest in learning very large models which do not fit into a single GPU. I thus wanted to build a little GPU cluster and explore the possibilities to speed up deep learning with multiple nodes with multiple GPUs. At the same time I was offered to do contract work as a data base developer through my old employer. This gave me opportunity to get the money to build the GPU cluster I thought of.</p>
<p><span id="more-52"></span></p>
<p><strong>Important components in a GPU cluster</strong></p>
<p>When I did my research on which hardware to buy I soon realized, that the main bottleneck will be the network bandwidth, i.e. how much data can be transferred from computer to computer per second. The network bandwidth of network cards (affordable cards are at about 4GB/s) does not come even close to the speed of PCIe 3.0 bandwidth (15.75 GB/s). So GPU-to-GPU communication within a computer will be fast, but it will be slow between computers. On top of that most network card only work with memory that is registered with the CPU and so the GPU to GPU transfer between two nodes would be like this: GPU 1 to CPU 1 to Network Card 1 to Network Card 2 to CPU 2 to GPU 2. What this means is, if one chooses a slow network card then there might be no speedups over a single computer. Even with fast network cards, if the cluster is large, one does not even get speedups from GPUs when compared to CPUs as the GPUs just work too fast for the network cards to keep up with them.</p>
<p>This is the reason why many big companies like Google and Microsoft are using CPU rather than GPU clusters to train their big neural networks. Luckily, Mellanox and Nvidia recently came together to work on that problem and the result is GPUDirect RDMA, a network card driver that can make sense of GPU memory addresses and thus can transfer data directly from GPU to GPU between computers.</p>
<figure><a href="https://i0.wp.com/timdettmers.com/wp-content/uploads/2014/09/rdma.png"><img data-attachment-id="10" data-permalink="https://timdettmers.com/2023/01/30/which-gpu-for-deep-learning/gpu-pic-copy/" data-orig-file="https://i0.wp.com/timdettmers.com/wp-content/uploads/2014/08/gpu-pic-copy.jpg?fit=791%2C418&amp;ssl=1" data-orig-size="791,418" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;2.4&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;U9200&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1407955348&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;4.13&quot;,&quot;iso&quot;:&quot;64&quot;,&quot;shutter_speed&quot;:&quot;0.033333&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;1&quot;}" data-image-title="GPU pic &#8211; Copy" data-image-description="" data-image-caption="" data-medium-file="https://i0.wp.com/timdettmers.com/wp-content/uploads/2014/08/gpu-pic-copy.jpg?fit=300%2C159&amp;ssl=1" data-large-file="https://i0.wp.com/timdettmers.com/wp-content/uploads/2014/08/gpu-pic-copy.jpg?fit=791%2C418&amp;ssl=1" class="alignnone size-full wp-image-10" src="https://i0.wp.com/timdettmers.com/wp-content/uploads/2014/09/rdma.png?resize=660%2C297" alt="GPU pic - Copy" width="660" height="297"  data-recalc-dims="1"></a><figcaption>NVIDIA GPUDirect RDMA can bypass the CPU for inter-node communication – data is directly transfered between two GPUs.</figcaption></figure>
<p>Generally your best bet for cheap network cards is eBay. I won an auction for a set of 40Gbit/s Mellanox network cards that support GPUDirect RDMA along with the fitting fibre cable on eBay. I already had two GTX Titan GPUs with 6GB of memory and as I wanted to build huge models that do not fit into a single memory, so I decided to keep the 6GB cards and buy more of them to build a cluster that features 24GB memory. In retrospect this was a rather foolish (and expensive) idea, but little did I know about the performance of such large models and how to evaluate the performance of GPUs. All the lessons I learned from this can be found <a title="Which GPU(s) to Get for Deep Learning: My Experience and Advice for Using GPUs in Deep Learning" href="https://timdettmers.com/2020/09/07/which-gpu-for-deep-learning/" target="_blank" rel="noopener noreferrer">here</a>. Besides that the hardware is rather straightforward. For fast inter-node communication PCIe 3.0 is faster than PCIe 2.0, so I got a PCIe 3.0 board. It is also a good idea to have about two times the RAM than you have GPU memory to be able to work more freely to handle big nets. As deep learning programs use a single thread for a GPU most of the time, a CPU with as many cores as GPUs you have is often sufficient.</p>
<p><strong>Hardware: Check. Software: ?</strong></p>
<p>There are basically two options how to do multi-GPU programming. You do it in CUDA and have a single thread and manage the GPUs directly by setting the current device and by declaring and assigning a dedicated memory-stream to each GPU, or the other options is to use <a title="CUDA-aware MPI introduction" href="https://developer.nvidia.com/blog/introduction-cuda-aware-mpi/" target="_blank" rel="noopener noreferrer">CUDA-aware MPI</a> where a single thread is spawned for each GPU and all communication and synchronization is handled by MPI. The first method is rather complicated as you need to create efficient abstractions where you loop through the GPUs and handle streaming and computing. Even with efficient abstractions your code can blow up quickly in line count making it less readable and maintainable.</p>
<figure><a href="https://i0.wp.com/timdettmers.com/wp-content/uploads/2014/09/mpi.png"><img data-attachment-id="10" data-permalink="https://timdettmers.com/2023/01/30/which-gpu-for-deep-learning/gpu-pic-copy/" data-orig-file="https://i0.wp.com/timdettmers.com/wp-content/uploads/2014/08/gpu-pic-copy.jpg?fit=791%2C418&amp;ssl=1" data-orig-size="791,418" data-comments-opened="1" data-image-meta="{&quot;aperture&quot;:&quot;2.4&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;U9200&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;1407955348&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;4.13&quot;,&quot;iso&quot;:&quot;64&quot;,&quot;shutter_speed&quot;:&quot;0.033333&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;1&quot;}" data-image-title="GPU pic &#8211; Copy" data-image-description="" data-image-caption="" data-medium-file="https://i0.wp.com/timdettmers.com/wp-content/uploads/2014/08/gpu-pic-copy.jpg?fit=300%2C159&amp;ssl=1" data-large-file="https://i0.wp.com/timdettmers.com/wp-content/uploads/2014/08/gpu-pic-copy.jpg?fit=791%2C418&amp;ssl=1" class="alignnone size-full wp-image-10" src="https://i0.wp.com/timdettmers.com/wp-content/uploads/2014/09/mpi.png?resize=607%2C113" alt="GPU pic - Copy" width="607" height="113"  data-recalc-dims="1"></a><figcaption>Some sample MPI code. The first action spreads one chuck of data to all others computer in the network; the second action receives one chuck of data from every process. That is all you need to do, it is very easy!</figcaption></figure>
<p>The second option is much more efficient and clean. MPI is the standard in high performance computing and its standardized library means that you can be sure that a MPI method really does what it is supposed to do. Underlying MPI the same principles are used as in the first method describes above, but the abstraction is so good that it is quite easy to adapt single GPU code to multiple GPU code (at least for data parallelism). The result is clean and maintainable code and as such I would always recommend using MPI for multi-GPU computing. &nbsp;As MPI libraries come in many languages and you can pair them with the language of your choice. With these two components you are ready to go and can immediately start programming deep learning algorithms for multiple GPUs.</p>
<p>[Image source: &nbsp;<a title="GPUDirect" href="https://developer.nvidia.com/gpudirect" target="_blank" rel="noopener noreferrer">NVIDIA GPUDirect Key Technologie</a>s]</p>
<p>The post <a rel="nofollow" href="https://timdettmers.com/2014/09/21/how-to-build-and-use-a-multi-gpu-system-for-deep-learning/">How To Build and Use a Multi GPU System for Deep Learning</a> appeared first on <a rel="nofollow" href="https://timdettmers.com">Tim Dettmers</a>.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://timdettmers.com/2014/09/21/how-to-build-and-use-a-multi-gpu-system-for-deep-learning/feed/</wfw:commentRss>
			<slash:comments>139</slash:comments>
		
		
		<post-id xmlns="com-wordpress:feed-additions:1">52</post-id>	</item>
	</channel>
</rss>
