Using CVX with Apple Silicon

Dear all,

I understand that this is an old question asked seveal times on the forum, but with recent releases of native Apple Silicon binaries for MATLAB, Mosek, and Gurobi (and with my experimenting with SDPT3 at least working), I figured it might be worthwhile to perhaps again ask about it just in case.

So, basically, I have an M-series chip and so far CVX (with native SDPT3, with Mosek and Gurobi) has worked really well using the Rosetta translation layer. However, with MATLAB and Mosek now both supporting Apple Silicon, I’m thinking about whether I can get better calculation speed using native binaries with CVX.

I used the CVX2 version with only open-source solvers, and used the ARM version of MATLAB Coder to manually compile the MEX files (including cvx_bcompress and cvx_eliminate in cvx/lib, and the SDPT3 related ones in cvx/sdpt3/Solver/Mexfun) and it seems CVX is running just fine and the solutions are correct.

However, my question is, now if I want to use the other commercial solvers, particularly Mosek, cvx_setup doesn’t seem to see the Mosek installation (whether I include the path in MATLAB or directly put the dylib and mex files in the CVX directory), and it only sees SDPT3 and SeDuMi. I’m wondering if this has something to do with the open-source-solver CVX version has some kind of preference/manifest (e.g. in cvx_version or in cvx_prefs.mat) that only enumerates the two solver names and doesn’t include Mosek/Gurobi? If so, is there someway one can manually add the commercial solver names so that CVX searches for them?

Alternatively, I also tried to directly use CVX with commercial solvers and swapping out the dylib and mex files with ARM versions, but unfortuantely that doesn’t pass the check in cvx_setup:

UNEXPECTED ERROR: ------------------------------
Unrecognized function or variable ‘command_str’.
Error in cvx_license
Error in cvx_license
Error in cvx_version (line 309)
cvx_license( args{:} );
Error in cvx_setup (line 20)
cvx_version( ‘-install’, varargin{:} );

Looking forward to your thoughts! Thanks a lot.

Regards,
Mike

No dice. CVX is not under active development. There is virtually no chance a native M series version of CVX will ever be released.

Dear Dr. Stone,

Thanks a lot for the very timely response!

Yes, I do fully understand that likely wouldn’t be official M-series support for CVX (as I searched the forum first and also saw the previous posts with your and Dr. Adamaszek’s kind replies about it).

However, I guess I’m just wondering if there might be some simple workarounds/hack for it based on the current CVX release, if one already has the .mexmaca64 binaries for the solvers (like the new ARM release for Mosek, or a manual compilation for SDPT3), since I see CVX is mostly platform-independent .m scripts rather than binary files, except from the two functions cvx_eliminate and cvx_bcompress.

I mean…I did try compiling the above two functions and SDPT3 on Apple Silicon and technically did successfully get a working CVX setup running on the corresponding ARM version of MATLAB. It’s just that I cannot seem to get Mosek to work with it since cvx_setup doesn’t even search for it.

I wonder if there’s any simple way to just add the name of Mosek solver to some manifest/preference list of CVX for it to be searched in cvx_setup, or would it be much more complicated than that (In the commercial-solver version of CVX, I see in cvx/shims the cvx_sdpt3.m is a script, but cvx_mosek.p is a binary. I wonder if that might be relevant? If so, does that mean there’s no way to do the interfacing with Mosek without recompiling)?

Sorry if the above is a silly question, though. If there’s still no simple way, I guess as a Mac user we’d probably just have to live with Rosetta.

Thanks again!

Regards,
Mike

I will defer to @Michal_Adamaszek for any further thoughts on this, because I have no first hand knowledge of any of the Mac stuff.

I see. Sounds great! Thanks again for the kind help anyway!

Hi,

If you got CVX+SDPT3 to work then you got much further than anyone else. It is very interesting.

Could you package what you have now and write to the Mosek support email? I have some ideas and information we could discuss.

Michal

Dear Dr. Adamaszek,

Thanks a lot for the reply!

That sounds fantastic. Thanks for the interest! It’d be great if we can follow-up via email and see what we can try in setting up Mosek for CVX on native ARM.

I’ll be back in office on campus on Monday and I’ll zip the CVX+SDPT3 package with compiled ARM mex binaries to send to support@mosek.com and mention your name too.

Just in case, I think I’ll also try the compilation process via MATLAB coder again too with my current setup to record the reproducible steps and software versions (I compiled the native mex binaries almost a year ago hoping to use them on a previous project back then - I tried these binaries on my current Mac and they still work fine, though, it’s just that my MATLAB and C++ compiler versions have both changed since then so I want to test the compilation again).

Thanks!

Regards,
Mike

Update. There now is a native release of CVX for M1, as described, and with download link, in Announcement: CVX for Apple Silicon