# GPU

## GPU简介

GPU（Graphics Processing Unit，图形处理器），是一种专门做图形或者图像处理的微处理器，近年来也用在了机器学习算法领域。

## GPU和CPU的区别

CPU (Central Processing Unit，中央处理器)就是机器的“大脑”，是完成布局谋略、发号施令、控制行动的“总司令官”。CPU的结构主要包括运算器(ALU，Arithmetic and Logic Unit)、控制单元(CU，Control Unit)、寄存器(Register)、高速缓存器(Cache)和它们之间通讯的数据、控制及状态的总线。

CPU和GPU之所以大不相同，是由于其设计目标的不同，它们分别针对了两种不同的应用场景。CPU需要很强的通用性来处理各种不同的数据类型，同时又要逻辑判断又会引入大量的分支跳转和中断的处理，这些都使得CPU的内部结构异常复杂。而GPU面对的则是类型高度统一的、相互无依赖的大规模数据和不需要被打断的纯净的计算环境。于是CPU和GPU就呈现出非常不同的架构(示意图)：

![](/files/xeWXTk0ugPgqjtUanEds)

为什么GPU特别擅长处理图像数据呢？这是因为图像上的每一个像素点都有被处理的需要，而且每个像素点处理的过程和方式都十分相似，此类场景也就成了GPU的天然温床。

|        | CPU           | GPU             |
| ------ | ------------- | --------------- |
| 结构     | 核数少，线程重       | 核数多，线程轻         |
| 适用场景场景 | 适合处理逻辑复杂的串行任务 | 适合处理逻辑简单相似的并行任务 |

> 参考：
>
> <https://www.sohu.com/a/361288420\\_632967>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://jun-wang.gitbook.io/learnjava/ji-shu-xue-xi/ji-suan-ji-yuan-li/gpu.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
