深圳Yolo 视觉
深圳
立即加入
词汇表

CPU

探索CPU 在人工智能和机器学习中的重要作用。了解 CPU 在数据准备、推理中的应用,以及与 GPU/TPU 的比较。

A Central Processing Unit (CPU) is the primary component of a computer that acts as its "brain," responsible for interpreting and executing instructions from hardware and software. In the context of artificial intelligence (AI), the CPU plays a fundamental role in data handling, system orchestration, and executing inference, particularly on edge devices where power efficiency is critical. While specialized hardware like GPUs are often associated with the heavy lifting of training deep learning models, the CPU remains indispensable for the overall machine learning (ML) pipeline.

CPU在人工智能工作流中的作用

Although GPUs are celebrated for their massive parallelism during training, the CPU is the workhorse for many essential stages of the computer vision (CV) lifecycle. Its architecture, typically based on x86 (Intel, AMD) or ARM designs, is optimized for sequential processing and complex logic control.

  • Data Preprocessing: Before a neural network can learn, data must be prepared. CPUs excel at tasks such as file loading, data cleaning, and complex transformations using libraries like NumPy and OpenCV.
  • 边缘推理:在实际部署中,将模型运行在大型服务器上并非总是可行。 CPU支持在消费级硬件上高效部署模型, 例如在笔记本电脑或树莓派上运行Ultralytics
  • Post-Processing: After a model outputs raw probabilities, the CPU often handles the final logic, such as Non-Maximum Suppression (NMS) in object detection, to filter out duplicate predictions and refine results.

CPU vs. GPU vs. TPU

理解硬件环境对优化机器学习运维(MLOps)至关重要。这些处理器在架构和理想应用场景方面存在显著差异。

  • CPU: Designed for versatility and complex logic. It features a few powerful cores that process tasks sequentially. It is best for data augmentation, pipeline management, and low-latency inference on small batches.
  • GPU 图形处理器) 最初用于图形处理,GPU拥有数千个小型核心,专为并行处理设计。 它们已成为模型训练的标准选择, 因为其执行矩阵乘法的速度远快于CPU。
  • TPU (Tensor Processing Unit): A specialized circuit (ASIC) developed by Google Cloud specifically for tensor math. While highly efficient for specific workloads, it lacks the general-purpose flexibility of a CPU.

实际应用

CPUs are frequently the hardware of choice for applications where cost, availability, and energy consumption outweigh the need for massive raw throughput.

  1. Smart Security Cameras: In security alarm systems, cameras often process video feeds locally. A CPU-based object detection model can identify a person or vehicle and trigger an alert without sending video to the cloud, preserving bandwidth and user privacy.
  2. 工业自动化:在工厂车间, 预测性维护系统利用CPU实时监测机械设备的传感器数据。这些系统通过分析振动或温度骤升现象,预判设备故障,确保制造自动化流程顺畅运行,且无需依赖GPU 。

CPU 上运行Ultralytics推理

开发人员常在CPU上测试模型,以验证其与无服务器计算环境或低功耗设备的兼容性。Ultralytics 可让您轻松定位CPU,确保应用程序无处不在地运行。

以下示例演示了如何加载轻量级模型,并在CPU进行推理:

from ultralytics import YOLO

# Load the lightweight YOLO26 nano model
# Smaller models are optimized for faster CPU execution
model = YOLO("yolo26n.pt")

# Run inference on an image, explicitly setting the device to 'cpu'
results = model.predict("https://ultralytics.com/images/bus.jpg", device="cpu")

# Print the detection results (bounding boxes)
print(results[0].boxes.xywh)

To further improve performance on Intel CPUs, developers can export their models to the OpenVINO format, which optimizes the neural network structure specifically for x86 architecture. For managing datasets and orchestrating these deployments, tools like the Ultralytics Platform simplify the workflow from annotation to edge execution.

加入Ultralytics 社区

加入人工智能的未来。与全球创新者联系、协作和共同成长

立即加入