Python-bloggers

Are The New M1 Macbooks Any Good for Data Science? Let’s Find Out

This article was first published on python – Better Data Science , and kindly contributed to python-bloggers. (You can report issue about the content on this page here)
Want to share your content on python-bloggers? click here.

The new Intel-free Macbooks have been around for some time now. Naturally, I couldn’t resist and decided to buy one. What follows is a comparison between the 2019 Intel-based MBP and the new one in programming and data science tasks.

If I had to describe the new M1 chip in a single word, I would be this one – amazing. Continue reading for a more detailed description.

Data science aside, this thing is revolutionary. It runs several times faster than my 2019 MBP while remaining completely silent. I’ve run multiple CPU exhaustive tasks, and the fans haven’t kicked in even once. And, of course, the battery life. It’s incredible —14 hours of medium to heavy use without a problem.

But let’s focus on the benchmarks. There are five in total:

Important notes

If you’re reading this article, I’m assuming you’re considering if the new Macbooks are worth it for data science. They aren’t “deep learning workstations” for sure, but they don’t cost that much, to begin with.

All comparisons throughout the article are made between two Macbook Pros:

Not all libraries are compatible yet on the new M1 chip. I had no problem configuring Numpy and TensorFlow, but Pandas and Scikit-Learn can’t run natively yet – at least I haven’t found working versions.

The only working solution was to install these two through Anaconda. It still runs through a Rosseta 2 emulator, so it’s a bit slower than native.

The test you’ll see aren’t “scientific” in any way, shape or form. They only compare runtimes in a different set of programming and data science tasks between the mentioned machines.

CPU and GPU benchmark

Let’s start with the basic CPU and GPU benchmarks first. Geekbench 5 was used for the tests, and you can see the results below:

Image 1 – Geekbench comparison (CPU and GPU) (image by author)

The results speak for themselves. M1 chip demolished Intel chip in my 2019 Mac. This benchmark only measures overall machine performance and isn’t 100% relevant for data science benchmarks you’ll see later.

Still, things look promising. 

Performance test – Pure Python

Here’s a list of tasks performed in this benchmark:

The test was made only with built-in Python libraries, so Numpy wasn’t allowed. You can see the Numpy benchmark in the next section.

Here’s the code snippet for the test:

And here are the results:

Image 2 – Python speed test – lower is better (image by author)

As you can see, running Python on M1 Mac through Anaconda (and Rosseta 2 emulator) decreased the runtime by 196 seconds. It’s best to run Python natively, as this further reduces the runtime by 43 seconds.

To conclude – Python is approximately three times faster when run natively on a new M1 chip, at least per this benchmark.

Performance test – Numpy

Here’s a list of tasks performed in this benchmark:

The original benchmark script was taken from Markus Beuckelmann on Github, and modified slightly, so both start and end time is captured. Here’s how the script looks like:

Here are the results:

Image 3 – Numpy speed test – lower is better (image by author)

Results obtained with Numpy are a bit strange, to say at least. It looks like Numpy runs faster on my 2019 Intel Mac for some reason. Maybe it’s due to some optimizations, but I can’t say for sure. If you know why, please don’t hesitate to share in the comment section.

Next, let’s compare the Pandas performance.

Performance test – Pandas

Pandas benchmark is quite similar to the Python one. Identical operations were performed, but the results were combined into a single data frame.

Here’s a list of tasks:

Here’s the code snippet for the test:

And here are the results:

Image 4 – Pandas speed test – lower is better (image by author)

As you can see, there’s no measurement for “native” Pandas, as I haven’t managed to install it. Still, Pandas on the M1 chip finished this benchmark two times faster.

Performance test – Scikit-Learn

As with Pandas, I haven’t managed to install Scikit-Learn natively. You’ll only see comparisons between Intel MBP and M1 MBP running through the Rosseta 2 emulator.

Here’s a list of tasks performed in the benchmark:

It’s a more or less standard model training procedure, disregarding testing out multiple algorithms, data preparation, and feature engineering.

Here’s the code snippet for the test:

And here are the results:

Image 5 – Scikit-Learn speed test – lower is better (image by author)

The results convey the same information seen with Pandas – 2019 Intel i5 processor takes two times longer to finish the same task. 

Conclusion

The comparisons with the Intel-based 2019 Mac might be irrelevant to you. That’s great – you have the benchmark scripts so you can run the tests on your machine. Let me know if you do so – I’m eager to find out about your configuration and how it compares.

The new M1 chips are amazing, and the best is yet to come. This is only the first generation, after all. Macbooks aren’t machine learning workstations, but you’re still getting a good bang for the buck. 

Deep learning benchmarks with TensorFlow are coming out next week, so stay tuned.

Connect on LinkedIn.

Join my private email list for more helpful insights.

Learn more

 

The post Are The New M1 Macbooks Any Good for Data Science? Let’s Find Out appeared first on Better Data Science.

To leave a comment for the author, please follow the link and comment on their blog: python – Better Data Science .

Want to share your content on python-bloggers? click here.
Exit mobile version