OpenCL on Apple M1

i’ve got a vega64, so i’d likely be in the same boat. i mean i’m looking to get a new apple silicon mac anyway, but it would solidify the decision if i could do an apples to apples comparison of the performance boost offered over the amd card (and i could still use it as a backup machine)

The latest Metal patch requires macOS 12.0, which is more likely the source of the “too old compiler version” message. AMD and Intel GPUs are enabled, but I don’t know how well they work.

3 Likes

Where did you pull the build from, the “Patch” section? Or did you compile it yourself?

Thanks.

I applied the patch that currently gets reviewed and turned on cycles for macOS in space_userpref.py. And I had to add a compiler flag in some of the Cmake files (I just do not remember which, i am on mobile now), where you turn on CUDA and OPTIX in the same way.

To build it for Intel a minimal deployment target of 10.14 is needed to avoid some compiler warnings, but my setup fails anyway as shown above. Sadly I can not upgrade my Intel Mac to Monterrey ATM for testing.

5 Likes

Ah, thanks for the info. Sounds pretty technical with the work arounds for getting it compiled, right now; more than I could manage anyways.

I think I’ll wait for the first official test build.
Thanks for putting out the numbers with your machine. :metal:t2:

I’ve got Cycles Metal working on my M1 Max (32 core). It’s rather impressive as well.

I built Blender from source on my MBP15 i9 with VEGA 20 dGPU and applied the diff for the unreviewed patch. That gave me an X86 build of Blender that showed the Metal GPU options on the Intel Mac but alas didn’t render (kernel internal error).

I then tried to set the ARM flag to compile again but that didn’t work.

So as a last ditch I took the built X86 version over to my M1 Max and low and behold it renders on the GPU.

BMW in 43 seconds on the 32 core GPU - so not 30% faster than the 24 core version but it is an X86 build.

However, every scene I tried the live viewport performance is rather wonderful.

I’d never built Blender from source until today. I’ll keep this build now to play with until the proper one lands.

The only slightly difficult bit was getting the new patch added, which I did like this:
patch -p1 < ~/Developer/D13423.diff [downloaded the RAW file from the Dev site]

Then ran make again and that was it basically.

7 Likes

Wow, this is rather amazing. It means that the feature is pretty darn close.
Here’s crossing fingers that the AMD Macs do get a fully featured pass too (i.e. MetalRT and all the Metal crunchies)

Certainly does. I read the diffs yesterday and the code committed seemed total genius and I couldn’t but help think… this looks like it might be very close indeed.

3 Likes

Absolutely can’t wait to have Metal support!

3 Likes

Trying to compile it with the patch applied but I keep getting errors any ideas why ?


You need to set WITH_METAL compile flag

not sure I understand, I think I managed to add it to “make config” and it is on, but still does not work.

Yes i thought i found the easy fix … Sorry for giving you hope … it also not workng for me .

No worries, I guess we will just have to wait.

Yes Christmas is coming :wink:

1 Like

I just tested the refactored patch and it still works, after some fiddling. So for the impatient people, here is a small guide to build it.

  1. Download the latest revision off the .diff-file (in Safari by right-clicking, otherwise the patch can get defective).
  2. in the terminal apply the patch, like so (including a successful output message):
bash-3.2$ patch -p1 <  ~/Downloads/D13423 
patching file intern/cycles/blender/CMakeLists.txt
patching file intern/cycles/blender/addon/engine.py
patching file intern/cycles/blender/addon/properties.py
patching file intern/cycles/blender/addon/ui.py
patching file intern/cycles/blender/device.cpp
patching file intern/cycles/blender/python.cpp
patching file intern/cycles/bvh/CMakeLists.txt
patching file intern/cycles/bvh/bvh.cpp
patching file intern/cycles/bvh/metal.h
patching file intern/cycles/bvh/metal.mm
patching file intern/cycles/cmake/external_libs.cmake
patching file intern/cycles/device/CMakeLists.txt
patching file intern/cycles/device/device.h
patching file intern/cycles/device/device.cpp
patching file intern/cycles/device/memory.h
patching file intern/cycles/device/metal/bvh.h
patching file intern/cycles/device/metal/bvh.mm
patching file intern/cycles/device/metal/device.h
patching file intern/cycles/device/metal/device.mm
patching file intern/cycles/device/metal/device_impl.h
patching file intern/cycles/device/metal/device_impl.mm
patching file intern/cycles/device/metal/kernel.h
patching file intern/cycles/device/metal/kernel.mm
patching file intern/cycles/device/metal/queue.h
patching file intern/cycles/device/metal/queue.mm
patching file intern/cycles/device/metal/util.h
patching file intern/cycles/device/metal/util.mm
patching file intern/cycles/device/multi/device.cpp
patching file intern/cycles/kernel/device/gpu/kernel.h
patching file intern/cycles/util/math.h
patching file intern/cycles/util/path.h
patching file intern/cycles/util/path.cpp
  1. In blender/CMakeLists.txt add i.e. after the CUDA/OPTIX-section:
if(APPLE)
option(WITH_CYCLES_DEVICE_METAL       "Enable Cycles APPLE METAL compute support" ON)
endif()
  1. In blender/release/scripts/startup/bl_ui/space_userpref.py

Search and delete:
and sys.platform != "darwin"

  1. In blender/cycles/CMakeList.txt add somewhere:
if(WITH_CYCLES_DEVICE_METAL)
  add_definitions(-DWITH_METAL)
endif()

I hope, this post will get obsolete soon and we will see it in the main repo. It looks really good to me.

7 Likes

that mod works before it keeping crashing when trying to render thanks :blush:

Great guide Staars thank you for posting. That is exactly what I did except for No 5. I’m actually skeptical No 4 is necessary as I tried it both ways and it worked for both!

The guide certainly works on the X86 build for me and when run under Rosetta 2 on M1 Max GPU rendering works.

I had a really good attempt at getting the ARM native version to build and ultimately failed but I got close. All of those errors Steve-Hanff are from the ARM build as I saw them on that build.

I managed to get the ARM Darwin Libs to download and set the CMake arch to arm64 and it gets so far into the build but still fails. I only tried building using an i9 Intel chip which definitely can compile for ARM.

There is a bug in 3.1 (even the daily X86 and ARM builds) where you can’t select anything reliably in the viewport. If I spot the viewport object selection bug being fixed in the 3.1 master I’ll re-compile again but hopefully by then the Metal patches will have also landed in the daily anyway.

3 Likes

Just followed the entire thread on the blenderArtists forum! The work you guys have done is amazing! Thanks for getting some numbers out so I do some preliminary testing on my current system and benchmark against it :wink: (GTX 1660 Super, Ryzen 5 3600, 32GB RAM).
Will post my results here shortly :slight_smile:

I’m back.
GTX 1660 Super, BMW27.
Blender 3.0.
40s