Skip to content

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

Closed

Description

@dnpetrov

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

Activity

  1. lperron commented on May 10, 2024

    @lperron
    Collaborator
  2. nhuet commented on May 10, 2024

    @nhuet

    #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 ?

  3. nhuet commented on May 10, 2024

    @nhuet

    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

  4. lperron commented on May 10, 2024

    @lperron
    Collaborator
  5. nhuet commented on May 10, 2024

    @nhuet

    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 ?

  6. lperron commented on May 10, 2024

    @lperron
    Collaborator
  7. nhuet commented on May 10, 2024

    @nhuet

    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.

  8. lperron commented on May 10, 2024

    @lperron
    Collaborator
  9. jeremydover commented on May 20, 2024

    @jeremydover

    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.

  10. added a commit that references this issue on May 21, 2024
  11. lperron commented on Jun 3, 2024

    @lperron
    Collaborator

    Most likely this is fixed.

  12. added this to the v9.11 milestone on Jun 3, 2024
  13. RobinParmentier commented on Jun 12, 2024

    @RobinParmentier

    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?

  14. lperron commented on Jun 12, 2024

    @lperron
    Collaborator
  15. RobinParmentier commented on Jun 13, 2024

    @RobinParmentier

    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.

  16. walelo9787 commented on Jun 18, 2024

    @walelo9787

    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

  17. nhuet commented on Jun 20, 2024

    @nhuet

    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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions