Alchemy speed x 7! Your Mac can also be GPU-accelerated for PyTorch training

 
  

Click on " Xiaobai Learning Vision " above , and choose to add " Star " or " Top "

重磅干货,第一时间送达

Source | Qubit (QbitAI)

Editing | Fengse, from, Aufei Temple

For a long time, Pytorch only supports CPU for training on Mac.

Just now, Pytorch officially announced that its latest version v1.12 can support GPU acceleration .

Any Mac with an M1-series chip will do.

855b277f8e94e8586c0d3a23ec594cc5.png

This also means that it will be more convenient to use Pytorch to "alchemy" on the Mac!

The training speed can be increased by about 7 times

This feature was introduced by Pytorch in collaboration with Apple's Metal engineering team.

It uses Apple's Metal Performance Shaders (MPS) as a backend for PyTorch to enable GPU-accelerated training.

To optimize computing performance, MPS also fine-tunes each core for the unique characteristics of the Metal GPU family.

Metal is a framework similar to OpenGL, except that OpenGL is suitable for mobile GPU rendering and computing on various platforms, and Metal is dedicated to iOS/MacOS platforms, but it also takes into account performance and ease of use.

MPS is a set of libraries based on the Metal framework, which can be directly called to use the high performance of the GPU for graphics processing and construction of convolutional neural networks.

330be572549882091d4a79aaa6e2a5dc.png

Apple officially tested it on Mac Studio equipped with M1 Ultra, 20-core CPU, 64-core GPU, 128GB RAM and 2TB SSD .

(This lineup can almost be regarded as a luxury configuration).

They trained ResNet50 with batch size 128, HuggingFace BERT with batch size 64 , and VGG16 with batch size=64 .

From the figure below, we can see that compared to using CPU acceleration, using GPU can increase the model training speed by about 7 times, and the evaluation speed can be increased by up to about 20 times.

bdf2cb301683c15db8a5f987645a887d.gif

Seeing this, some netizens began to wonder how it performs compared to laptops equipped with Nvidia GPUs.

15d53a77cd7d58a5609c9cd0c6dacd20.png

Some people said that although the current raw computing performance of the M1 is not as good as Nvidia's products, the power consumption is not bad. In the future, Apple is likely to slowly catch up with performance.

Overall, Mac Studio looks really good right now .

He further explained:

"After all, it is the cheapest machine you can buy for $4,800 that includes 128GB of GPU memory . Now with GPU-accelerated PyTorch support, it can be used to train large models and configure large batch sizes.

For the kind of DL work I do, data loading is more likely to be a bottleneck than actual raw computing power. "

3cdb4e333a62151bf270643b18e5178e.png

You heart it?

Try it now?

Just make sure your macOS operating system is version 12.3 and above, and arm64 native Python is installed, and then go to the official website to download the latest Pytorch preview version.

efd0dfac23c19ccf4f0d23d65fed8f0a.png

Address:
https://pytorch.org/blog/introducing-accelerated-pytorch-training-on-mac/

—End— _ _

下载1:OpenCV-Contrib扩展模块中文版教程

在「小白学视觉」公众号后台回复:扩展模块中文教程,即可下载全网第一份OpenCV扩展模块教程中文版,涵盖扩展模块安装、SFM算法、立体视觉、目标跟踪、生物视觉、超分辨率处理等二十多章内容。


下载2:Python视觉实战项目52讲
在「小白学视觉」公众号后台回复:Python视觉实战项目,即可下载包括图像分割、口罩检测、车道线检测、车辆计数、添加眼线、车牌识别、字符识别、情绪检测、文本内容提取、面部识别等31个视觉实战项目,助力快速学校计算机视觉。


下载3:OpenCV实战项目20讲
在「小白学视觉」公众号后台回复:OpenCV实战项目20讲,即可下载含有20个基于OpenCV实现20个实战项目,实现OpenCV学习进阶。


交流群

欢迎加入公众号读者群一起和同行交流,目前有SLAM、三维视觉、传感器、自动驾驶、计算摄影、检测、分割、识别、医学影像、GAN、算法竞赛等微信群(以后会逐渐细分),请扫描下面微信号加群,备注:”昵称+学校/公司+研究方向“,例如:”张三 + 上海交大 + 视觉SLAM“。请按照格式备注,否则不予通过。添加成功后会根据研究方向邀请进入相关微信群。请勿在群内发送广告,否则会请出群,谢谢理解~

Guess you like

Origin blog.csdn.net/qq_42722197/article/details/131238564