I. Why GPU
Actually, GPU computing is not "better" than CPU computing, but rather "faster".
Calculation is calculation; mathematically, everything is the same. 1+1 is 2 no matter what you use to calculate it. A CPU can also calculate neural networks, and the neural networks it calculates perform very well in practical applications, although the speed will be very slow.
The Origin of GPUs
GPU stands for Graphics Processing Unit, which, as the name suggests, processes graphics.
Before an image is displayed on a computer monitor, it undergoes a series of processing steps, a process known as "rendering." In older computers without GPUs, rendering was handled by the CPU. What exactly is rendering? It involves performing a series of graphical calculations, which are often very time-consuming, consuming a significant portion of the CPU's time. Meanwhile, the CPU also has to handle many other tasks. Therefore, a processor specifically designed for these graphics processing operations—the GPU—was developed. This freed the CPU from the heavy burden of graphics calculations.
Since GPUs are designed specifically for rendering, they can only do those rendering tasks.
The rendering process specifically involves calculating the positions and colors of geometric points. Mathematically, both of these calculations involve multiplying four-dimensional vectors and transformation matrices. Therefore, GPUs are designed as dedicated processors specifically suited for performing such calculations. Why dedicated? Because there are many things they cannot do.
CPUs are highly versatile, but their performance is low in specialized fields. Engineering is about compromise; if one area is strong, another will be weak. Later, games and 3D design placed increasingly higher demands on rendering, leading to ever-improving GPU performance. In terms of purely theoretical computational performance, GPUs are tens or even hundreds of times faster than CPUs.
People wondered, since GPUs are so powerful, wouldn't using GPUs for computation be significantly faster than using CPUs? This led to the concept of GPGPU (general-purpose GPU). However, as mentioned earlier, GPUs are specifically designed for image rendering; they are only suitable for those operations. Fortunately, some operations are very similar to what GPUs are primarily designed for, and in these cases, GPUs can be used to improve speed, such as deep learning.
One successful application of deep learning technology is called Convolutional Neural Networks (CNNs). Mathematically, these networks are combinations of convolution and matrix operations, and convolution operations can also be performed using matrix operations through certain mathematical means. These operations are the same as the matrix operations on graphics points that GPUs can perform. Therefore, deep learning can be very effectively accelerated using GPUs.
Previously, the concept of GPGPU (General Purpose GPU) wasn't very popular; GPUs were designed primarily for graphics rendering. To utilize GPUs for computational assistance, one had to strictly adhere to the GPU's hardware architecture. However, with the increasing popularity of GPGPUs, manufacturers are now taking into account the needs of the computing field when designing and producing GPUs.
II. Differences between GPGPU and GPU
GPUs were created to solve the problem of graphics rendering efficiency, but with technological advancements, GPUs have become increasingly powerful, especially after the advent of shaders (which allow us to program on the GPU). GPUs can do more and more, no longer limited to the graphics field, so some people have started to extend their capabilities to other computationally intensive fields, which is the origin of GP (General Purpose) GPUs.
III. Why is it fast?
For example, when you use a photo editing app like Meitu to add a blur effect to an image, the CPU does the following:
Using a small window of a blur filter operator, the process starts from the top left corner of the image and moves from left to right, then back to right, until the entire image is processed. Because the CPU has only one or a few cores, this operation can only be performed by iterating from beginning to end.
However, some astute readers might notice that each window processes the image independently, without any interaction between them. Wouldn't it be faster to process the image using several filter windows simultaneously? This is where GPUs come in. Typical GPUs have hundreds of cores, meaning we can have several hundred filter windows processing the image concurrently.
Therefore, GPUs were initially designed to handle graphics rendering, a task characterized by its distributed nature and the relatively independent nature of each processing unit, with minimal interdependence. Similarly, some machine learning algorithms, such as genetic algorithms and neural networks, also exhibit this distributed and locally independent characteristic (e.g., the computation of one link in a neural network occurs simultaneously with another, without mutual dependence). In such cases, a large number of small cores can be used to accelerate computation.
Disclaimer: This article is a reprint. If there are any copyright issues, please contact us promptly for deletion (QQ: 2737591964). We apologize for any inconvenience.