Apple M1 chip scientific computing (Numpy) computing speed

The previous article compared the compilation speed gap between the M1 chip and Intel's traditional six-core processor on matlab. Both are equally fast. Interested friends can take a look~ Apple M1 chip, MATLAB (2022a) performance test

The reason for choosing the i7-10750H as the reference object is that it is the most classic notebook-end 6-core 12-thread processor in the toothpaste factory, and it belongs to the same period as the M1 chip. In addition, i7-8750h and i7-9750H have the same number of cores and threads, and the performance is not bad. Everyone should be very familiar with it, and it is also the most widely used.

This time, let's analyze the calculation speed of M series chips using python's numpy package.

1. Summary

For practitioners of machine learning or deep learning, python's numpy package is essential. So what is Apple Silicon's current support for numpy? , Compared with the traditional gaming notebook 6-core processor, is its performance superior?

2. Experimental equipment and code preparation

2.1 Experiment code

The code used in this section is a routine in Chapter 8 of "Advanced Deep Learning: Natural Language Processing". This is a good book, written in a relatively simple and easy-to-understand manner, and I recommend reading it to friends who are new to NLP!

The routine in the eighth chapter of the book is used, that is, the seq2seq model using the attention mechanism, which has a certain amount of calculation. The entire model is written entirely based on numpy and does not use any deep learning framework.

2.2 Experimental equipment

Windows gaming notebook with i7-10750H and M1 Macbook Air

3. Experimental results

3.1 Performance of M1

The first experiment was completed in 171 seconds.

176 seconds and 168 seconds for the second and third times

Average duration is 172 seconds

Use EUL to look at the CPU usage. The cpu is already full, indicating that numpy has no compatibility issues on M1.

Use the sudo powermetrics command to view the power consumption of the CPU.

At this time, the power consumption of the CPU has reached 9.26W. If the power consumption of the screen is added, the power consumption of the whole machine must have exceeded 10W. The battery capacity of the Macbook Air M1 is 49.9 Wh. If this power consumption level is followed, it can last for 4-5 hours under high load, which is very strong. But no one should use a laptop to run scientific calculations for an afternoon QWQ.

3.2 i7-10750H的表现

注意这里是插电使用的,处理器的频率跑在4.27GHZ。

cpu的占用已经满了

接下来开始训练

第一次实验132秒完成,第二次和第三次均为138秒。平均时长136秒。intel的优势还是较为明显的,黑归黑,但intel的芯片至少在机器学习方面是绝对不弱的。再插一句,intel在sklearn里是可以调用加速库的。

但缺点也是非常明显的,用hwinfo看一下功耗,发现cpu已经来到了57W,这是M1的5-6倍。

四、总结

总体来讲,本文的测试仍不是非常严谨,大家多多见谅,但可以作为参考。M1的优势是其夸张的能效比和优秀的离电性能,并且对于numpy的兼容性已经非常不错了,而传统的intel 6核处理器也很优秀,在运行速度上占据上风,但高功耗是其缺点。

Guess you like

Origin blog.csdn.net/tortorish/article/details/128982101