Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

jinnyman

macrumors 6502a
Sep 2, 2011
762
671
Lincolnshire, IL
Well. out of curiosity, I ran the code through my MBP 13" with rosetta2 CPU only. The fan hit over 7000 RPM for the first time!

Each epoch took avg 65 sec.
 

white7561

macrumors 6502a
Jun 28, 2016
934
386
World
It should be quite comparable. Even with Colab Pro, it's not guaranteed that you get a faster GPU. The slower GPUs in Colab are in practice quite comparable to the M1 Pro GPU. It hugely depends on your specific models. People have benchmarked somewhere that standard MNIST (I believe) models might run slighlyt (~20%) faster. I've found some of my personal stuff running slightly slower.

On Colab Pro, the fastest GPUs are at about 9TFLOPS, compared to 5 for the M1 Pro. So if you get an instance with those, the M1 Pro will be about half the speed.

However, code optimazations for the M1 architecture in the future might make things a bit faster.

Also, some models might not benefit from a GPU at all, and of course M1 has a pretty fast CPU.
I see. Do you think that we will ever be able to utilize the Neural Engine from our Macs to increase the speed further in future updates???

I'm really new to AI etc and about to start a course on it. So pardon if my questions like comparing it to google colab etc is kinda a newbie question :)
 

Xiao_Xi

macrumors 68000
Oct 27, 2021
1,627
1,101
Do you think that we will ever be able to utilize the Neural Engine from our Macs to increase the speed further in future updates???
After you train the model, you should convert your Tensorflow/Pytorch model to CoreML to use the Neural Engine and speed up predictions.


Philip Turner in the Apple dev forum claims that "The neural engine can't be used for training. It uses only 16-bit half precision, not 16-bit bfloat16. That means gradients can't propagate through it for ML, but ANE can be used for inference."
Source: https://developer.apple.com/forums/thread/697983

Can someone confirm it?
 
  • Like
Reactions: white7561

project_2501

macrumors 6502a
Jul 1, 2017
676
792
I see. Do you think that we will ever be able to utilize the Neural Engine from our Macs to increase the speed further in future updates???

I'm really new to AI etc and about to start a course on it. So pardon if my questions like comparing it to google colab etc is kinda a newbie question :)

you can run MNIST on a Raspberry Pi Zero. It costs about £4. It's 500 times cheaper than my laptop, and only 25 times slower.

 

mi7chy

macrumors G4
Oct 24, 2014
10,619
11,292
you can run MNIST on a Raspberry Pi Zero. It costs about £4. It's 500 times cheaper than my laptop, and only 25 times slower.


Any comparisons to the new $15 Pi Zero 2 W, base $35 Pi 4 or Coral?
 
Last edited:

Xiao_Xi

macrumors 68000
Oct 27, 2021
1,627
1,101
Eloquent Arduino has run benchmanks with:
  • Arduino Nano 33 BLE Sense (Cortex M4 @ 64 MHz)
  • ESP32 (Xtensa dual-core @ 240 MHz)
  • Feather M4 Express (Cortex M4F @ 200 MHz)
  • STM32 Nucleo H743ZI2 (Cortex M7 @ 480 MHz)
  • Arduino Portenta (Cortex M7 @ 480 MHz)
  • Teensy 4.0 (Cortex M7 @ 600 MHz)
  • Raspberry Pi Pico (Rp2040 / Cortex M0+ @ 125 MHz)

I hope the benchmark can help you although those are not the micros you are interested in.
 
  • Like
Reactions: project_2501

iDron

macrumors regular
Apr 6, 2010
219
252
I see. Do you think that we will ever be able to utilize the Neural Engine from our Macs to increase the speed further in future updates???

I'm really new to AI etc and about to start a course on it. So pardon if my questions like comparing it to google colab etc is kinda a newbie question :)
As others have said, I don’t think the neural engine will be very helpful for training. I’m actually wondering why apple built this into all its chips. I’ve never seen it being used on my MacBook and I wouldn’t see where it would be beneficial in day to day iPhone apps.

Don’t plan on benefitting from it. It may be used for inference though.
 
  • Like
Reactions: white7561

leman

macrumors Core
Oct 14, 2008
19,516
19,664
As others have said, I don’t think the neural engine will be very helpful for training. I’m actually wondering why apple built this into all its chips. I’ve never seen it being used on my MacBook and I wouldn’t see where it would be beneficial in day to day iPhone apps.

It’s used for image classification maybe Touch ID,, built in camera, possibly audio processing, Siri and stuff like that. As to why Apple built it or why it has limitations it has, I think it’s pretty obvious: Apple wanted to have an ultra-low-power inference hardware to power its OS-level ML features. The neural engine was never intended to be a general-purpose ML solution, just run a certain common subset of networks with minimal energy expenditure. Apples General-purpose ML hardware are the AMX units.
 
  • Like
Reactions: iDron

white7561

macrumors 6502a
Jun 28, 2016
934
386
World
It’s used for image classification maybe Touch ID,, built in camera, possibly audio processing, Siri and stuff like that. As to why Apple built it or why it has limitations it has, I think it’s pretty obvious: Apple wanted to have an ultra-low-power inference hardware to power its OS-level ML features. The neural engine was never intended to be a general-purpose ML solution, just run a certain common subset of networks with minimal energy expenditure. Apples General-purpose ML hardware are the AMX units.
AFAIK there are some AI features that use the neural engine. Like for example if you opened a picture with texts in it. You can hover and copy it . So like OCR
 

iDron

macrumors regular
Apr 6, 2010
219
252
It’s used for image classification maybe Touch ID,, built in camera, possibly audio processing, Siri and stuff like that. As to why Apple built it or why it has limitations it has, I think it’s pretty obvious: Apple wanted to have an ultra-low-power inference hardware to power its OS-level ML features. The neural engine was never intended to be a general-purpose ML solution, just run a certain common subset of networks with minimal energy expenditure. Apples General-purpose ML hardware are the AMX units.
Okay. But is this so much better than using CPU/GPU? Given it is not being used a long time, quite often probably just seconds or even fractions of a second. Slightly better power efficiency does not really matter then.
 

leman

macrumors Core
Oct 14, 2008
19,516
19,664
Okay. But is this so much better than using CPU/GPU? Given it is not being used a long time, quite often probably just seconds or even fractions of a second. Slightly better power efficiency does not really matter then.

Apple obviously things it does matter. I tend to agree with them. The NPU seems to be orders of magnitude more efficient than other matrix units, which means that you can get a bunch of useful tricks (like the text recognition in the photos) or high quality video calls without significantly impacting your battery. In the end, its these small things that make a huge qualitative real-world difference when using Apple products. And given how little space the NPU takes on chip, I'd say its well worth it.
 
  • Like
Reactions: iDron

iDron

macrumors regular
Apr 6, 2010
219
252
Apple obviously things it does matter. I tend to agree with them. The NPU seems to be orders of magnitude more efficient than other matrix units, which means that you can get a bunch of useful tricks (like the text recognition in the photos) or high quality video calls without significantly impacting your battery. In the end, its these small things that make a huge qualitative real-world difference when using Apple products. And given how little space the NPU takes on chip, I'd say its well worth it.

Well that's probably true, if you consider it would automatically OCR every photo taken for example. So the ANE is actually meant to be used mostly by system processes then? Even for inference it might not make sense to worry about it as an individual developer, data scientist or researcher.
 

leman

macrumors Core
Oct 14, 2008
19,516
19,664
Well that's probably true, if you consider it would automatically OCR every photo taken for example. So the ANE is actually meant to be used mostly by system processes then? Even for inference it might not make sense to worry about it as an individual developer, data scientist or researcher.

It's meant as a very energy efficient way to implement some basic ML features in your apps and services without paying the usual energy cost associated with ML. It's about making ML integrate as naturally and seamlessly into the system as possible, without impacting the user experience with diminishing battery life or heating up their system.

As such, I think that the NPU can be very valuable for app developers who want to add some ML features while still offering that polished experience that users of Apple devices expect. But again, Apple's NPU is not about maximising performance, it's about providing a user-oriented service with the lowest energy cost. Or, to put differently, it's about enabling new class of user applications without compromising the system.

If you are a researcher, ANE is probably not very useful to you, as you need both high performance and a lot of flexibility (ANE offers neither).
 

Andropov

macrumors 6502a
May 3, 2012
746
990
Spain
Another cool thing about the NPU is that you could develop something GPU intensive (a game, a video editor...) and add machine learning features to it without dropping frames.

In fact, I remember that when the A12 was still new and shiny, some people said that if the GPU was idle, NPU-capable CoreML tasks would be scheduled to the GPU, but if the GPU was busy, they'd run on the NPU instead.

I don't know if this is still true or if it ever was (I never got around to trying it). But I always thought it was weird that CoreML would prefer to schedule tasks to the GPU instead of the NPU when both were capable.
 

Xiao_Xi

macrumors 68000
Oct 27, 2021
1,627
1,101
It seems that Apple is working faster and needs less time to adapt Tensorflow-Metal to every new Tensorflow version. It took Apple one month and a half for version 2.6 and one month for 2.7.
It seems that Apple is working faster now and can release its Tensorflow within two weeks of Google releasing Tensorflow.


I hope Apple can compile a compatible tensorflow-text soon.
 

Xiao_Xi

macrumors 68000
Oct 27, 2021
1,627
1,101
Pytorch seems to run faster than Tensorflow on M1 Macs.
 

Xiao_Xi

macrumors 68000
Oct 27, 2021
1,627
1,101
Is the node.ai shark proprietary?
I don't think so. You can check its repo.

They have shared better instructions for installing shark on Apple M1 Mac.
 

Xiao_Xi

macrumors 68000
Oct 27, 2021
1,627
1,101
Apple seems to be working on a solution to solve the problems that arise when a package uses Tensorflow-macos instead of Tensorflow. ??
[A] lot of the packages that check for Tensorflow do it against the package name reserved for the baseline TensorFlow called tensorflow, whereas the TensorFlow package on MacOS is tensorflow-macos. We are working on a generic solution that will fix this issue but it will take until TF2.9 timeline for that to take effect.
Source: https://developer.apple.com/forums/thread/701656
 
  • Like
Reactions: iDron
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.