Announcement: CVX for Apple Silicon

An unofficial native CVX 2.2 package for Apple Sillicon (M1, M2, etc., Matlab architecture MACA64) is available. With this package it is possible to use CVX directly in the Matlab releases for Apple Sillicon (starting R2023b), without having to use the Intel version through the Rosetta emulator.

The package can be downloaded from:

cvx-maca64.zip cvx-maca64.tar.gz

The package is the work of @mikewong (Dr. Wenyuan (Mike) Wang, who was the main driving force behind this project) and myself, and we publish it with the kind permission of @mcg. It contains only the smallest amount of formal modifications of the publicly available CVX 2.2 needed to get it to work; all algorithms and internals of CVX are unchanged. Installation and usage are the same as always.

Some remarks: it worked for us but testing was scarce; there are no guarantees of any kind; we do not have the capacity to provide support; SeDuMi and SDPT3 are included, MOSEK has to be installed separately the way one normally uses an external MOSEK; to our best knowledge recent versions of GUROBI were incompatible with CVX already for a while and this does not change here; all usage is at your own risk.

@mikewong reports a considerable speedup compared to running the Intel version via Rosetta on his problems. Again, we can make no general promises.

We hope this can be useful for CVX users on MAC.

Michal, Mike

2 Likes

Thanks for the effort in making this available. I’ve downloaded and installed the package. It took about 10 attempts running cvx_setup to set the individual security authorisations for each of the mex files. And a couple more running some code with found some mex code not exercised in the cvx_setup procedure.

But after doing this it works very well. My experience is also that it is significantly faster. I’ve also simultaneously upgraded to R2023b from R2020b and that may have also had an effect. I haven’t run any comprehensive timing tests though.

Cheers, Roy

Some installation instructions:

  1. Download cvx from the link and extract it
  2. Go to the cvx folder from MATLAB directory (do cd ~/Downloads/cvx if you extracted into the Downloads folder)
  3. Run cvx_setup command in MATLAB terminal => you will most likely get an error
  4. Go to mac system settings → privacy and click on ‘Allow anyway’ under the security section
  5. Repeat step 3 and 4 around 10 times until no error is thrown
  6. Type cvx_solver into the MATLAB terminal to check if everything is working correctly

I used to have the following tricks to quickly bypass the security issues:

  • either download the package in the command line with curl instead of through a browser,
  • or if already downloaded remove the quarantine attribute from the whole folder at once:
    xattr -d com.apple.quarantine cvx,
  • or try both to be sure.

But that was back in the days when the security hocus pocus just started; I am unable to say if any of this works just as well today.

If you do not plan to use Sedumi and/or SDPT3 you can also remove their folders in advance. That should save cvx_setup.m a lot of mex files to load.

Has anybody figured out how to run gurobi with this installation package? Or does it still seem to be incompatible

Ok thank you. Excuse my possible lack of understanding, the zip file in this unofficial package for Apple Silicon attached, doesn’t have the CVX bundle with the gurobi package incorporated. From my understanding of reading threads, the CVX bundle with the gurobi package 9.0 still works, but this bundle is incompatibly with native CVX for apple silicon. Is there something I can do to get the CVX bundle with gurobi 9.0 running on my M3 apple chip?

If you want the official CVX package to work you have to install the Matlab release for the Intel chip (OSX Intel) and run the official CVX in it. It will run through the Rosetta emulator. In other words exactly how you would do it before we made this unofficial package, or before Matlab for M1,2,3 became available. Due to emulation it is simply not as efficient as the native one.

@mcg intends to open-source CVX. Then everybody will be able to go in and fix the Gurobi-CVX interface to make it compatible with the current Gurobi Toolbox for Matlab and make Gurobi work again.

Official word from @mcg

Thanks for cross-posting @Mark_L_Stone . The bundles currently being built over at Releases · cvxr/CVX · GitHub do include macOS Apple Silicon builds, but they do not yet have Mosek or Gurobi shims. Once we get the open-source versions of those shims in there, I think we’ll be in a good place for people to start relying on that bundle as the true, official release.

NOTE NOTE NOTE: This homebrew release is now superseded by the official CVX from @mcg :