Skip to content
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

Wrong folder for PULP_CBC_CMD on OSX arm64 #802

Open
3 of 15 tasks
ianlokh opened this issue Feb 22, 2025 · 6 comments
Open
3 of 15 tasks

Wrong folder for PULP_CBC_CMD on OSX arm64 #802

ianlokh opened this issue Feb 22, 2025 · 6 comments

Comments

@ianlokh
Copy link

ianlokh commented Feb 22, 2025

Details for the issue

What did you do?

Run pulp with PULP_CBC_CMD

What did you expect to see?

Solver executing successfully

What did you see instead?

I got the following error:
"Traceback (most recent call last): File "/Users/ianlo/PycharmProjects/optimizer/main.py", line 100, in <module> prob.solve(pulp.PULP_CBC_CMD(msg=True, timeLimit=300, threads=6, gapRel=0.05)) File "/opt/homebrew/Caskroom/miniforge/base/envs/torch_py311/lib/python3.11/site-packages/pulp/pulp.py", line 1996, in solve status = solver.actualSolve(self, **kwargs) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ File "/opt/homebrew/Caskroom/miniforge/base/envs/torch_py311/lib/python3.11/site-packages/pulp/apis/coin_api.py", line 354, in actualSolve raise PulpSolverError( pulp.apis.core.PulpSolverError: PULP_CBC_CMD: Not Available (check permissions on /opt/homebrew/Caskroom/miniforge/base/envs/torch_py311/lib/python3.11/site-packages/pulp/solverdir/cbc/osx/arm64/cbc) "

Useful extra information

The info below often helps, please fill it out if you're able to. :)

What operating system are you using?

  • Windows: ( version: ___ )
  • Linux: ( distro: ___ )
  • Mac OS: ( _version:15.3.1 (24D70) )
  • Other: ___

I'm using python version:

  • 3.7
  • 3.8
  • 3.9
  • 3.10
  • 3.11
  • Other: ___

I installed PuLP via:

Did you also

@ianlokh
Copy link
Author

ianlokh commented Feb 22, 2025

Hi

I realised that this was a directory name issue. On my Mac the install was:
"/opt/homebrew/Caskroom/miniforge/base/envs/torch_py311/lib/python3.11/site-packages/pulp/solverdir/cbc/osx/64/cbc"

However the code was trying to call
"/opt/homebrew/Caskroom/miniforge/base/envs/torch_py311/lib/python3.11/site-packages/pulp/solverdir/cbc/osx/arm64/cbc"

So when I renamed the directory, I could run the solver.

Looks like an installation / setup issue?

@ngast
Copy link

ngast commented Feb 25, 2025

Hi,

I am having the same issue here: Macos 15.3.1 with python 3.13 and pulp freshly installed with pip: pulp does not find the solver but if I rename "...solverdir/cbc/osx/64/cbc" into "...solverdir/cbc/osx/arm64/cbc" then the code works.

@pchtsp
Copy link
Collaborator

pchtsp commented Feb 25, 2025

As I understand this is exactly the symmetric problem. Maybe we're detecting the architecture wrong.
Can you check the file:

pulp/pulp/apis/core.py

Lines 152 to 184 in 7c8aa93

PULPCFGFILE = "pulp.cfg"
is_64bits = sys.maxsize > 2**32
if is_64bits:
arch = "64"
if platform.machine().lower() in ["aarch64", "arm64"]:
arch = "arm64"
else:
arch = "32"
operating_system = None
if sys.platform in ["win32", "cli"]:
operating_system = "win"
PULPCFGFILE += ".win"
elif sys.platform in ["darwin"]:
operating_system = "osx"
PULPCFGFILE += ".osx"
else:
operating_system = "linux"
PULPCFGFILE += ".linux"
DIRNAME = os.path.dirname(__file__)
config_filename = os.path.normpath(os.path.join(DIRNAME, "..", PULPCFGFILE))
(
cplex_dll_path,
ilm_cplex_license,
ilm_cplex_license_signature,
coinMP_path,
gurobi_path,
cbc_path,
glpk_path,
pulp_cbc_path,
scip_path,
fscip_path,
) = initialize(config_filename, operating_system, arch)

In particular, this is how we find out the path to the binary:

impor sys
import platform

is_64bits = sys.maxsize > 2**32
if is_64bits:
    arch = "64"
    if platform.machine().lower() in ["aarch64", "arm64"]:
        arch = "arm64"
else:
    arch = "32"

In any case, you can always run the COIN_CMD and passing the path to the binary via the path argument.
See here:
https://coin-or.github.io/pulp/technical/solvers.html#pulp.apis.COIN_CMD

@ngast
Copy link

ngast commented Feb 25, 2025

I think that it is the same problem: pulp looks for the cbc in the directory "arm64" but it was installed in the directory "64".

Note that on my machine, your code sets the variable arch to 'arm64' (macbook pro M4).

@davidggphy
Copy link
Contributor

davidggphy commented Feb 26, 2025

Having the same problem here.
Apple M3 Pro
macOS 15.3.1 (24D70)
Python 3.11
Pulp 3.0.2

This is, running a "pip install pulp" installs CBC at
~/miniconda3/envs/conda_env/lib/python3.11/site-packages/pulp/solverdir/cbc/osx/64

But the code @pchtsp posted returns arch="arm64", making pulp look for CBC at

import pulp
pulp.pulp_cbc_path

~/miniconda3/envs/conda_env/lib/python3.11/site-packages/pulp/solverdir/cbc/osx/arm64/cbc which is unexistent

Indicating the correct path when setting the solver:

# Resolver el problema
solver = pulp.PULP_CBC_CMD(
    path=pulp.pulp_cbc_path.replace("arm64", "64"),
    msg=True, 
)
model.solve(solver)

Does not solve the problem (it still looks for the default path with arm64):

PulpSolverError: PULP_CBC_CMD: Not Available (check permissions on ~/miniconda3/envs/conda_env/lib/python3.11/site-packages/pulp/solverdir/cbc/osx/arm64/cbc)

@sebastian-correa
Copy link

sebastian-correa commented Feb 26, 2025

Having the same problem with PuLP 3.0.2 (but not with 2.9.0) in a Mac M1 (15.1 (24B83)) with Python 3.10 (Python 3.10.15 (main, Jan 22 2025, 10:10:59) [Clang 16.0.0 (clang-1600.0.26.4)]).

❯ eza .venv/lib/python3.10/site-packages/pulp/solverdir/cbc/osx
64

So no arm64 directory there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants