New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mac M1 Support #1101
Comments
Hey @camaya7, can you share the full log when you attempt to run There shouldn't be any incompatibility with Ludwig and this version of TensorFlow. The issues are likely arising due to the way TensorFlow names their pip packages for specific hardware, which often conflict with the standard package names. It's usually something we can workaround by either letting Ludwig install first and installing TensorFlow afterwards, or (in the worse case) by installing Ludwig from source and removing the |
Hey @tgaddair, attached is the log, not sure if this is what you're looking for as it's a bit long. Tensorflow was installed as Tensorflow 2.4.0-rc0. For some time there I tried downloading Ludwig first and then TF but came around to the same problem with conflicting dependencies. Please let me know what you think here. In worst case I could try installing Ludwig from source without the tensorflow dependency per the requirements.txt file. |
Ludwig v0.3.3 supports tensorflow>=2.3.1 so in theory this should work, not really sure what is causing the issue. |
Hi @w4nderlust, I've tried the steps you suggested and got the following error message: This keeping in mind that the same Tensorflow version is active in the same virtual environment as Ludwig's. I also ran the install without the Tensorflow dependency and got a similar error: |
Hey @camaya7, you may want to try unpinning tfa-nightly and installing the latest version. It appears that specific version is not available with M1. |
Hey @tgaddair, I've unpinned tfa-nightly and have tried installing the latest version separately yet I keep running into the same error: |
@camaya7 debugging this is a bit tricky because of the specific machine, sorry about that. I'm wondering: can you, in general, independently of Ludwig, install a tf + tfa combination that works on M1? In case you can find such a combination, then you should be able to use that in Ludwig. Alternatively, you may remove the tfa dependency from Ludwig, as it is used specifically in a single module (sequence_decoders.py). This will make it so you won't be able to do sequence and text generation, but at least you may use all the other features of Ludwig. |
@w4nderlust it's okay, the tech needs to catch up. So far I've only found a TF build that works on M1 but not a tf + tfa combination. I'm going to continue searching for one so that I could use it with Ludwig--in that case would I just install Ludwig without the tf, tfa-nightly dependencies per the requirements.txt file? I'm also going to try to remove the tfa dependency altogether as I wouldn't need sequence and text gen for now either way. Hopefully this gets me some progress with the install. No worries, I look forward to seeing M1 improvements for TF and Ludwig. |
@camaya7 I have had the same pip behavior recently (cascading between different package versions and then ultimately failing). In my case there was some cache\temp corruption, and this fixed it |
@carlogrisetti Hi Carlo, thanks so much for the tip, you're the man. It installed Ludwig correctly for the most part. I'm dealing with with an "zsh: illegal hardware instruction" error whenever I try to run anything like |
This may help you |
@carlogrisetti thanks for the tips. In an attempt to resolve the previous issue, I uninstalled ludwig and haven't been able to get it up and running again. It seems my cache is corrupt and there are conflicts with Tensorflow and other packages. Tensorflow-2.4.0-rc0 throws "Could not find a version that satisfies the requirement" errors so I've removed it from the requirements.txt file although I don't know how this will affect running ludwig later as it happened before as mentioned above. Running |
Debugging package dependencies issues is always tricky. Would creating a new virtualenv an option? that may be the most straightforward way. |
@w4nderlust Thanks, I tried out a new virtualenv and it helped in installing ludwig and its packages but I'm still getting an "illegal hardware instruction" error once I try to train a model, even with TF correctly installed. I'm getting the feeling I'm going to have to use another machine... |
FWIW, here's how I set up my mac m1 for ludwig. |
@amholler Thanks for this, I'm going to give it a shot and report with results. |
Sounds good, @camaya7 . BTW, I updated the google doc to indicate that I just successfully got through the first epoch of |
Hmm, @camaya7 not sure what the issues are. Just to verify, you did the steps in my google doc |
@amholler, yeah, I followed the steps in setting up the conda environment and got to the "pip install ." step from the source tree. Then, that I ran into a bunch of errors from individual packages not installing correctly an so on. So, I installed all the ludwig reqs separately and ludwig installed all the way through. However, when I try to run a model, I'm now getting the error: "illegal hardware instruction ludwig train". I think it's a problem with TF. I'm checking but I can't find what I missed from your instructions. |
yeah, I believe that that means you are running the wrong version of TF. |
@amholler, I was pretty much running into the same errors as you so I followed through with your file, thanks so much for documenting it all. Ludwig is finally properly installed on my machine. |
I just noticed this on Anconda's blog re: Apple's M1 chip support. It was published yesterday, 15Jul. |
To be honest, I don't agree with that assessment. From the Ludwig point of view, we rely on tensorflow at the moment the tensor computation, so as soon as ARM support becomes a first class citizen in TF, the soon we'll be able to provide a seamless experience for those machines. Until then all we can do is sharing experience and workarounds like @amholler did, so that M1 (and ARM in general) users can use Ludwig. |
Out of curiosity, has anyone figured out a better way of building ludwig on an m1 at this point? I'm dealing with this same class of problems on other projects. |
Hi. Still having issues, I tried the process mentioned above in the DOCX file, but since Conda now uses TF2.6, there are conflicts with package versions for Ludwig… has anyone cracked the code on this? |
Hey @luisrh01, you can try using TF 2.6 with Ludwig, most things should work, though we ran into a few issues related to distributed training (so if you're not doing distributed training, it should be generally supported). We'll also be completing a migration to PyTorch in the next few weeks, which could help simplify things here as well. |
I managed to get (the newer, PyTorch-based) Ludwig going on my M1 Pro without too much trouble. The following assumes that you have a fully installed Xcode with command line tools setup and that you have Homebrew installed. First there are a couple of key libraries that you'll need to install:
Also, if you want to use the
You will also need to tell the Python packages where to find these libraries since they seem not to properly use pkgconfig:
You should then just be able to install Ludwig from source, ideally into a fresh venv since it requires older versions of some libraries such as
Note that most of the extra dependencies, including those for the different feature types, also require packages that are not yet available as binary wheels for the arm64 architecture and so will get built from source (which is fairly slow). Most of these extensions seem to work fine (for me at least), including
The dependencies for I have also been unable to build Hopefully as time goes by more people will start building Python wheels on ARM as well as Intel Macs and some of these troubles will go away in the future. Until then, I hope this helps! |
@nickovs thank you very much for sharing your solution! It's very very appreciated! |
Adding to the thread: the specified method above by @nickovs fails for me if I use python 3.9 on a M1. |
Building horovod for M1 works if you disable eigen vectorization:
I ran into this again trying to install the latest master on my M1. Related: #2282 |
Closing due to issue being resolved. Will add a docs page on how to set up Ludwig on M1 and will add a comment here linking to the doc. |
Any update on this? PyTorch seems to have better support for M1 now and it looks like it's activated when I checked: import torch
print(torch.backends.mps.is_available())
print(torch.backends.mps.is_built()) Is there some code needed in the if not torch.backends.mps.is_available():
if not torch.backends.mps.is_built():
print("MPS not available because the current PyTorch install was not "
"built with MPS enabled.")
else:
print("MPS not available because the current MacOS version is not 12.3+ "
"and/or you do not have an MPS-enabled device on this machine.")
else:
mps_device = torch.device("mps") Source of this code: https://pytorch.org/docs/stable/notes/mps.html |
When MPS is available as a backend for PyTorch, returns "mps" ludwig-ai#1101
I added the MPS device check to the code: master...rudolfolah:ludwig:patch-2 It ran in ~3.3 min using MPS, in contrast it was running in ~6.5 min when using CPU. Unfortunately, the issue I ran into is that the model did not work correctly. It returned a completely incorrect result and included
|
Thank for the update @rudolfolah . I guess we'll ned to just wait for the pytorch issue to be resolved unfortunately |
This could be a possibility, Apple has provided tools to convert already trained PyTorch models to CoreML: https://github.com/apple/coremltools This doesn't solve the issue when training a model but if testing out already trained models, it could be helpful as part of the pipeline for local development:
I don't think it's something Ludwig needs to support directly, though it could be mentioned in the documentation for Mac install instructions. |
Hi, I'm wondering if Ludwig currently has support for the Mac M1? I have tried to install it several times through the steps on the website and no luck.
I've downloaded Tensorflow 2.4.0-rc0 (the only one available for M1) separately as it wasn't getting anywhere through the "pip install ludwig" command. I kept getting dependency conflict errors and I corrected them for the most part but there seems to be no workaround for TF- see conflicts below.
The conflict is caused by:
ludwig 0.3.3 depends on tensorflow>=2.3.1
ludwig 0.3.2 depends on tensorflow>=2.3.1
ludwig 0.3.1 depends on tensorflow>=2.2
ludwig 0.3 depends on tensorflow>=2.2
ludwig 0.2.2.8 depends on tensorflow==1.15.3
ludwig 0.2.2.7 depends on tensorflow==1.15.3
ludwig 0.2.2.6 depends on tensorflow==1.15.2
ludwig 0.2.2.5 depends on tensorflow==1.15.2
ludwig 0.2.2.4 depends on tensorflow==1.15.2
ludwig 0.2.2.3 depends on tensorflow==1.15.2
ludwig 0.2.2.2 depends on tensorflow-gpu==1.15.2
ludwig 0.2.2 depends on tensorflow-gpu==1.15.2
ludwig 0.2.1 depends on tensorflow==1.14.0
ludwig 0.2 depends on tensorflow==1.14.0
ludwig 0.1.2 depends on tensorflow==1.13.1
ludwig 0.1.1 depends on tensorflow==1.13.1
ludwig 0.1.0 depends on tensorflow>=1.12
To fix this you could try to:
It seems M1's limited TF availability is not letting the Ludwig install get through the TF dependencies.
Expected behavior
Successfully install Ludwig.
Environment (please complete the following information):
Thanks
The text was updated successfully, but these errors were encountered: