{macOS} Using GPU? (ANSWERED)

Moderators: Site Moderators, FAHC Science Team

asm
Posts: 10
Joined: Fri Mar 06, 2020 8:12 pm

{macOS} Using GPU? (ANSWERED)

Post by asm »

I have the client running on an iMac (Retina 5K, 27-inch, 2019).

My GPU is:

Code: Select all

Radeon Pro 580X:
  Chipset Model:	Radeon Pro 580X
  Type:	GPU
  Bus:	PCIe
  PCIe Lane Width:	x16
  VRAM (Total):	8 GB
  Vendor:	AMD (0x1002)
The log tells me OpenCL is not found:

Code: Select all

21:42:49:     OpenCL: Not detected: Failed to open dynamic library 'libOpenCL.dylib':
21:42:49:             dlopen(libOpenCL.dylib, 1): image not found
...but of course OpenCL exists:

Code: Select all

OpenCL:
  Version:	2.15.3
  Obtained from:	Apple
  Last Modified:	04-May-19, 05:13 AM
  Kind:	Intel
  64-Bit (Intel):	Yes
  Signed by:	Software Signing, Apple Code Signing Certification Authority, Apple Root CA
  Get Info String:	2.15.3, Copyright 2008-2018 Apple Inc.
  Location:	/System/Library/Frameworks/OpenCL.framework
  Private:	No
I tried adding a GPU slot in FAHControl but it tells me that no GPU is found.

How do I get the client to recognize & use my GPU?
Last edited by asm on Sat Mar 07, 2020 4:28 am, edited 1 time in total.
Joe_H
Site Admin
Posts: 7870
Joined: Tue Apr 21, 2009 4:41 pm
Hardware configuration: Mac Pro 2.8 quad 12 GB smp4
MacBook Pro 2.9 i7 8 GB smp2
Location: W. MA

Re: {macOS} Using GPU?

Post by Joe_H »

asm wrote:How do I get the client to recognize & use my GPU?
Unfortunately you can't. There is a long history behind that, but to summarize:

There was intent to support GPU's on OS X along with Windows and Linux.

They ran into a bug in Apple's OpenCL implementation, it took a couple years before Apple finally rolled out a fix. Without a usable OpenCL, no GPU folding core had been developed during this gap in time.

By that time there were very few usable GPU's installed in Mac's, and they had also moved heavily to integrated graphics on Intel processors installed in portable laptops or the Mini.

With the recent support for eGPU's and the use of discrete graphics in the recent model iMac's and Mac Pro this might change, no promises.

P.S. Some have worked around this by setting up Windows through Bootcamp, or installing Linux. But that is the only current method to use your Mac's GPU.
Image

iMac 2.8 i7 12 GB smp8, Mac Pro 2.8 quad 12 GB smp6
MacBook Pro 2.9 i7 8 GB smp3
rromanchuk
Posts: 2
Joined: Sun Mar 22, 2020 9:16 am

Re: {macOS} Using GPU? (ANSWERED)

Post by rromanchuk »

You cannot because....

They don't want to support it

That's the only correct answer. I keep running into these threads with replies in 2020 giving reasons that have not been been true for many years. It's time to change the messaging from "It's not supported for technical reason" to "It's not a priority for us at this time"
Joe_H
Site Admin
Posts: 7870
Joined: Tue Apr 21, 2009 4:41 pm
Hardware configuration: Mac Pro 2.8 quad 12 GB smp4
MacBook Pro 2.9 i7 8 GB smp2
Location: W. MA

Re: {macOS} Using GPU? (ANSWERED)

Post by Joe_H »

rromanchuk wrote:They don't want to support it
Limited developer resources and a limited number of additional processing resources gained by expending those development resources on getting support for OS X and testing a new core leading to the decision to go for what would return a greater return in ability to have their research work done is not the same as "don't want to support".
Image

iMac 2.8 i7 12 GB smp8, Mac Pro 2.8 quad 12 GB smp6
MacBook Pro 2.9 i7 8 GB smp3
marook
Posts: 3
Joined: Fri Mar 20, 2020 3:01 pm

Re: {macOS} Using GPU? (ANSWERED)

Post by marook »

Joe_H wrote:
rromanchuk wrote:They don't want to support it
Limited developer resources and a limited number of additional processing resources gained by expending those development resources on getting support for OS X and testing a new core leading to the decision to go for what would return a greater return in ability to have their research work done is not the same as "don't want to support".
I guess the right path on Mac OS, would be to support Metal, so you don't have to support the graphic cards directly, since Apple would make the layer between the framework and the hardware.
That would also automatically scale for the number of GPU's in the system.
bruce
Posts: 20910
Joined: Thu Nov 29, 2007 10:13 pm
Location: So. Cal.

Re: {macOS} Using GPU? (ANSWERED)

Post by bruce »

FACT: Apple spent many years delivering broken/unsupportable versions of OpenCL Apparently they finally overcame those problems, but FAH spent a lot of development time and money trying to get a FAHCore that worked. Their patience ran out.

Then, too, most Apple hardware (as well as many Windows laptops) are limited in their ability to dissipate the heat of continuous heavy compute loads.
unsatchmo
Posts: 4
Joined: Tue Mar 24, 2020 5:33 pm

Re: {macOS} Using GPU? (ANSWERED)

Post by unsatchmo »

Reading the logs:

Code: Select all

21:42:49:     OpenCL: Not detected: Failed to open dynamic library 'libOpenCL.dylib':
21:42:49:             dlopen(libOpenCL.dylib, 1): image not found
Suggests that this is an issue with the the Gromacs code. They are using the old method of opening libOpenCL on macOS, the new method would be to dlopen '/System/Library/Frameworks/OpenCL.framework/Versions/A/OpenCL'

It also suggests a workaround:

Code: Select all

sudo cp /System/Library/Frameworks/OpenCL.framework/Versions/A/OpenCL /usr/local/lib/libOpenCL.dylib
sudo install_name_tool -id /usr/local/lib/libOpenCL.dylib /usr/local/lib/libOpenCL.dylib
finally, you'll need to edit the arguments passed to FAHClient in the launchd job:

Code: Select all

❯ cat /Library/LaunchDaemons/org.foldingathome.fahclient.plist                      
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>GroupName</key>
	<string>nobody</string>
	<key>KeepAlive</key>
	<true/>
	<key>Label</key>
	<string>org.foldingathome.fahclient</string>
	<key>LowPriorityIO</key>
	<true/>
	<key>ProcessType</key>
	<string>Interactive</string>
	<key>ProgramArguments</key>
	<array>
	  <string>/usr/local/bin/FAHClient</string>
          <string>--gpu=true</string>
          <string>--smp=true</string>
	</array>
	<key>RunAtLoad</key>
	<true/>
	<key>SessionCreate</key>
	<true/>
	<key>StandardOutPath</key>
	<string>/dev/null</string>
	<key>Umask</key>
	<integer>18</integer>
	<key>UserName</key>
	<string>nobody</string>
	<key>WorkingDirectory</key>
	<string>/Library/Application Support/FAHClient</string>
</dict>
</plist>
then either

Code: Select all

sudo launchctl unload /Library/LaunchDaemons/org.foldingathome.fahclient.plist

sudo launchctl load /Library/LaunchDaemons/org.foldingathome.fahclient.plist
or just reboot. Works for me!
unsatchmo
Posts: 4
Joined: Tue Mar 24, 2020 5:33 pm

Re: {macOS} Using GPU? (ANSWERED)

Post by unsatchmo »

I got this working. Here's what I did:

1) Copy the OpenCL lib into the location that gromacs is attempting to open

Code: Select all

sudo cp /System/Library/Frameworks/OpenCL.framework/Versions/A/OpenCL /usr/local/lib/libOpenCL.dylib
2) Fix the install-name of the new libOpenCL.dylib library (so that dyld recognizes it as libOpenCL.dylib)

Code: Select all

sudo install_name_tool -id /usr/local/lib/libOpenCL.dylib /usr/local/lib/libOpenCL.dylib
3) Add the --gpu=true flag to the invocation of the FAHClient tool (use your favorite editor)

Code: Select all

cat /Library/LaunchDaemons/org.foldingathome.fahclient.plist                            
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
	<key>GroupName</key>
	<string>nobody</string>
	<key>KeepAlive</key>
	<true/>
	<key>Label</key>
	<string>org.foldingathome.fahclient</string>
	<key>LowPriorityIO</key>
	<true/>
	<key>ProcessType</key>
	<string>Interactive</string>
	<key>ProgramArguments</key>
	<array>
	  <string>/usr/local/bin/FAHClient</string>
          <string>--gpu=true</string>
          <string>--smp=true</string>
	</array>
	<key>RunAtLoad</key>
	<true/>
	<key>SessionCreate</key>
	<true/>
	<key>StandardOutPath</key>
	<string>/dev/null</string>
	<key>Umask</key>
	<integer>18</integer>
	<key>UserName</key>
	<string>nobody</string>
	<key>WorkingDirectory</key>
	<string>/Library/Application Support/FAHClient</string>
</dict>
</plist>
4) Reboot

You should now see a GPU worker in the FAHClient. Haven't been assigned any work items yet for the gpu, hopefully that happens soon.
Dr._Rek
Posts: 6
Joined: Tue Mar 24, 2020 5:54 pm

Re: {macOS} Using GPU? (ANSWERED)

Post by Dr._Rek »

I run into the same problem and found my answer here, it's unfortunate at this point in time.
However I was able to get my Mac Pro 2010 with an RX 580 to support GPU FAH using a Windows 10 bootcamp partition.

Unfortunately my work iMac Pro can't run Windows 10, so no GPU can be donated there for now.

I second the motion that support for Metal would mean GPU support future forward for Mac OS users.
Now would be a great time to donate some development time towards that goal.

Thank you so much everyone who has donated to this project.
=)
Dr._Rek
Posts: 6
Joined: Tue Mar 24, 2020 5:54 pm

{Mac OS} Metal support

Post by Dr._Rek »

Hello!
I just setup FAH on my Apple computers today and found out through the forum about the history of Open CL and Mac OS preventing GPU usage.
In another thread, a user named marook suggested supporting Metal.

Would this ever be possible?
I would guesstimate it would make GPU support on Mac OS possible future forward if implemented, as Apple has been all in on Metal for some time now.

Are there any FAH developers that could donate time to this?

Thank you so much to everyone that has donated to this project.

Humanitarian Superpowers!!

:D
bruce
Posts: 20910
Joined: Thu Nov 29, 2007 10:13 pm
Location: So. Cal.

Re: {Mac OS} Metal support

Post by bruce »

I consider support of Metal to be highly unlikely especially since FAHCore_2* works nicely with OpenCL on Windows and Liinux. The development and support costs of debugging/fixing an OpenCL core for OS-X would probably be a lot less than for Metal and the results would be equal.

You should search for discussions about porting the existing FAHCore to OS-X.
Joe_H
Site Admin
Posts: 7870
Joined: Tue Apr 21, 2009 4:41 pm
Hardware configuration: Mac Pro 2.8 quad 12 GB smp4
MacBook Pro 2.9 i7 8 GB smp2
Location: W. MA

Re: {macOS} Using GPU? (ANSWERED)

Post by Joe_H »

unsatchmo wrote:You should now see a GPU worker in the FAHClient. Haven't been assigned any work items yet for the gpu, hopefully that happens soon.
As long as you are running macOS, you will not get any GPU work. Your requests will be redirected to a non-assigning net address. There is no GPU folding core distributed by F@h that will work on macOS and process a WU. Please remove any GPU slot you set up this way.

What you posted may be useful in the future if they ever reopen folding core development for macOS as it does provide information on some of what may need to be installed or set up on a Mac to have it work. But for right now it does not get GPU folding to work in the F@h context.
Image

iMac 2.8 i7 12 GB smp8, Mac Pro 2.8 quad 12 GB smp6
MacBook Pro 2.9 i7 8 GB smp3
Dr._Rek
Posts: 6
Joined: Tue Mar 24, 2020 5:54 pm

Re: {macOS} Using GPU? (ANSWERED)

Post by Dr._Rek »

Exciting updates! I hope this can help push Open CL or Metal working on Mac OS in FAH someday soon. :D
unsatchmo
Posts: 4
Joined: Tue Mar 24, 2020 5:33 pm

Re: {macOS} Using GPU? (ANSWERED)

Post by unsatchmo »

As long as you are running macOS, you will not get any GPU work. Your requests will be redirected to a non-assigning net address. There is no GPU folding core distributed by F@h that will work on macOS and process a WU. Please remove any GPU slot you set up this way.

What you posted may be useful in the future if they ever reopen folding core development for macOS as it does provide information on some of what may need to be installed or set up on a Mac to have it work. But for right now it does not get GPU folding to work in the F@h context.
Well that's disappointing. I've removed the GPU slots as you suggested (they never received any work anyway).

I would be willing to chip in on getting this working. Obviously Metal would be nicer, but I have no idea if Metal can do the exact kind of GPGPU stuff that OpenCL does for FAH. Probably best just to get OpenCL working for now, especially since OpenCL is actually still supported (it still ships with the OS). In the meantime, is there a development landing page for folks like me that would like to help get stuff working? The main blocker seems easy, but the fact that FAH is so finicky when it comes to which GPU's are supported (and the fact that Mac GPU's are hard blocked) suggests that just turning on OpenCL for Mac clients is not as straight forward as just getting the FAHClient to load OpenCL.
JimboPalmer
Posts: 2573
Joined: Mon Feb 16, 2009 4:12 am
Location: Greenwood MS USA

Re: {macOS} Using GPU? (ANSWERED)

Post by JimboPalmer »

The science code that has to be the problem, is OpenMM.

http://openmm.org/about.html
Tsar of all the Rushers
I tried to remain childlike, all I achieved was childish.
A friend to those who want no friends
Post Reply