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

Python: CP-SAT tutorial example crashes on Windows with 9.10.4067 #4227

Closed
dnpetrov opened this issue May 10, 2024 · 16 comments
Closed

Python: CP-SAT tutorial example crashes on Windows with 9.10.4067 #4227

dnpetrov opened this issue May 10, 2024 · 16 comments
Assignees
Labels
Help Needed Modeling/Usage problem Lang: Python Python wrapper issue Solver: CP-SAT Solver Relates to the CP-SAT solver
Milestone

Comments

@dnpetrov
Copy link

What version of OR-Tools and what language are you using?
Version: 9.10.4067
Language: Python

Which solver are you using (e.g. CP-SAT, Routing Solver, GLOP, BOP, Gurobi)
CP-SAT

What operating system (Linux, Windows, ...) and version?
Windows 10 Pro, 10.0.19045 build 19045

What did you do?
Run tutorial example https://developers.google.com/optimization/cp/cp_example

What did you expect to see

What did you see instead?
Process finished with exit code -1073741819 (0xC0000005)

Make sure you include information that can help us debug (full error message, model Proto).

Anything else we should know about your project / environment
9.9.3963: works as expected, prints a list of solutions

@lperron
Copy link
Collaborator

lperron commented May 10, 2024

@nhuet
Copy link

nhuet commented May 10, 2024

#4225 has been closed as solved. But the issue remains. The tutorial example is still crashing on windows with 9.10 + python3.11. Perhaps an error of compilation in python wheel on pypi ?

@nhuet
Copy link

nhuet commented May 10, 2024

With both python 3.11 and 3.12 + ortools 9.10.4067 + Windows 11 Pro, i got

Segmentation fault

(And the computation succeeds with ortools 9.9.3963)

More precisely, the python versions i tried: python 3.11.0 and 3.12.2

@lperron
Copy link
Collaborator

lperron commented May 10, 2024 via email

@nhuet
Copy link

nhuet commented May 10, 2024

I do not have visual studio.
We need to install visual studio to make ortools work ? I never needed it for previous versions yet.
As i am using the wheel from PyPi, i was rather expecting that no c++ library was needed to make it work ?

@lperron
Copy link
Collaborator

lperron commented May 10, 2024 via email

@nhuet
Copy link

nhuet commented May 10, 2024

You always need the visual studio redistributable libraries

As I said, the previous release of ortools worked fine for me without installing anything. But indeed i think i have the redistributable libraries preinstalled. I tried to update them using the link https://aka.ms/vs/17/release/vc_redist.x64.exe found on https://learn.microsoft.com/fr-fr/cpp/windows/latest-supported-vc-redist?view=msvc-170, but it changed nothing for me.

My "ultimate" goal is to make ortools 9.10 work for me on github runners "windows-latest" because i have unit tests using ortools in my ci-cd workflow. If you know the command to update their redistributable libraries on it, i would greatly appreciate it.

@lperron
Copy link
Collaborator

lperron commented May 10, 2024

it works fine: https://github.com/google/or-tools/actions/runs/8998718133

Oops: it does not test the right thing.

nhuet added a commit to nhuet/discrete-optimization that referenced this issue May 14, 2024
ortools 9.10 results in segmentation fault on github runner
windows-latest.
Could maybe be solved by updating Microsoft Visual C++ Redistributable
google/or-tools#4227
nhuet added a commit to nhuet/discrete-optimization that referenced this issue May 14, 2024
ortools 9.10 results in segmentation fault on github runner
windows-latest.
Could maybe be solved by updating Microsoft Visual C++ Redistributable
google/or-tools#4227
@lperron
Copy link
Collaborator

lperron commented May 16, 2024

@jeremydover
Copy link

I experienced this error on upgrading to ortools version 9.10, and upgrading the Virtual Studio C++ redistributable at the link above (https://aka.ms/vs/17/release/vc_redist.x64.exe) fixed the problem for me.

g-poveda pushed a commit to airbus/discrete-optimization that referenced this issue May 21, 2024
ortools 9.10 results in segmentation fault on github runner
windows-latest.
Could maybe be solved by updating Microsoft Visual C++ Redistributable
google/or-tools#4227
@lperron
Copy link
Collaborator

lperron commented Jun 3, 2024

Most likely this is fixed.

@lperron lperron closed this as completed Jun 3, 2024
@Mizux Mizux added Help Needed Modeling/Usage problem Lang: Python Python wrapper issue Solver: CP-SAT Solver Relates to the CP-SAT solver labels Jun 3, 2024
@Mizux Mizux added this to the v9.11 milestone Jun 3, 2024
@RobinParmentier
Copy link

RobinParmentier commented Jun 12, 2024

Hey, I was having the same problem. Windows 11, python 3.12, ortools 9.10.4067.
For my future use I'll just use ortools 9.9 since that seems to work fine.
While I was trying to find a solution I also noticed a similar issue with another python example from the documentation:

from ortools.init.python import init
from ortools.linear_solver import pywraplp

def main():
    print("Google OR-Tools version:", init.OrToolsVersion.version_string())

    # Create the linear solver with the GLOP backend.
    solver = pywraplp.Solver.CreateSolver("GLOP")
    if not solver:
        print("Could not create solver GLOP")
        return

    # Create the variables x and y.
    x_var = solver.NumVar(0, 1, "x")
    y_var = solver.NumVar(0, 2, "y")

    print("Number of variables =", solver.NumVariables())

    infinity = solver.infinity()
    # Create a linear constraint, x + y <= 2.
    constraint = solver.Constraint(-infinity, 2, "ct")
    constraint.SetCoefficient(x_var, 1)
    constraint.SetCoefficient(y_var, 1)

    print("Number of constraints =", solver.NumConstraints())

    # Create the objective function, 3 * x + y.
    objective = solver.Objective()
    objective.SetCoefficient(x_var, 3)
    objective.SetCoefficient(y_var, 1)
    objective.SetMaximization()

    print(f"Solving with {solver.SolverVersion()}")
    result_status = solver.Solve()

    print(f"Status: {result_status}")
    if result_status != pywraplp.Solver.OPTIMAL:
        print("The problem does not have an optimal solution!")
        if result_status == pywraplp.Solver.FEASIBLE:
            print("A potentially suboptimal solution was found")
        else:
            print("The solver could not solve the problem.")
            return

    print("Solution:")
    print("Objective value =", objective.Value())
    print("x =", x_var.solution_value())
    print("y =", y_var.solution_value())

    print("Advanced usage:")
    print(f"Problem solved in {solver.wall_time():d} milliseconds")
    print(f"Problem solved in {solver.iterations():d} iterations")

if __name__ == "__main__":
    init.CppBridge.init_logging("basic-example.py")
    cpp_flags = init.CppFlags()
    cpp_flags.stderrthreshold = True
    cpp_flags.log_prefix = False
    init.CppBridge.set_flags(cpp_flags)
    main()

In this example the line
init.CppBridge.init_logging("basic-example.py")
never finishes and the program crashes silently.
The code works fine for ortools 9.9 with no other changes so it seems to me both these problems are related.

I did try to fix the problem with visual studio installer but this did not work for me.
What exactly are the requirements of visual studio for ortools?

@lperron
Copy link
Collaborator

lperron commented Jun 12, 2024 via email

@RobinParmentier
Copy link

I tried using the link that was posted here earlier (https://aka.ms/vs/17/release/vc_redist.x64.exe) but this didn't work for me.

@walelo9787
Copy link

Same for me, the solver crashes even though I have the latest vcredist: Microsoft Visual C++ 2015-2022 Redistributable (x64) - 14.40.33810.
Env:
OS: win 11 Entreprise
Code: jdk21

@nhuet
Copy link

nhuet commented Jun 20, 2024

FYI, I still did not succeed in making it work (and actually stopped trying, simply freezing for now ortools version). And github windows runner have recently upgraded their Microsoft Visual C++ 2015-2022 Redistributable and the example still crashes on it with ortools 9.10.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Help Needed Modeling/Usage problem Lang: Python Python wrapper issue Solver: CP-SAT Solver Relates to the CP-SAT solver
Projects
None yet
Development

No branches or pull requests

7 participants