メインコンテンツへスキップ

Model Creation Hangs

回答済み

コメント

7件のコメント

  • 正式なコメント
    Simranjit Kaur
    • Gurobi Staff
    This post is more than three years old. Some information may not be up to date. For current information, please check the Gurobi Documentation or Knowledge Base. If you need more help, please create a new post in the community forum. Or why not try our AI Gurobot?.
  • Jaromił Najman
    • Gurobi Staff

    Hi Stuart,

    So you are saying that the code works well on your local machine but runs into some issues when run in sbatch mode on the cluster? Are you able to get more output from the batch script to see whether some error occurs?

    Could you try creating an environment and attaching your model to it

    myEnv = gp.Env()
    m = gp.Model("EPath", env=myEnv)

    Then, after the optimization is complete and you retrieved all information of interest, you have to dispose the model and the environment

    m.dispose()
    myEnv.dispose()

    Does this help?

    Could you try executing one of the Gurobi examples?

    Best regards,
    Jaromił

    0
  • Stuart Horine
    • Gurobi-versary
    • First Comment
    • First Question

    Hi Jaromił,

    Thanks very much for the tips. No joy. I have got further, however, and I am now stuck at a different place.

    It is now producing a solution, however, when I try to extract the value of my solution vector, and return it from the function back to the main program, it hangs. I have tried...

    solution=m.getAttr("x")
    solution=x.getAttr("x")
    solution=[v.x for v in m.getVars()]
    solution=x.x

    However, the function return never executes. I've tried to use gdb but it does not have the python add in so is only showing me the c frames and there is almost nothing to see. If, instead of trying to pass anything back, I print the solution e.g. simply print(x.x), it shows me the variables and the values they have and the function does return. So I know it's in there:)

    It feels like I am missing something that maybe obvious, like there is a particular method to use when you want to pass the solution out of a function call? 

    Any further help greatly appreciated.

    Stuart

    0
  • Jaromił Najman
    • Gurobi Staff

    Hi Stuart,

    Good to hear that you are making progress.

    What exactly do you mean by "it hangs"?

    All 4 ways of getting the solution vector you described should work and return a list of double values. You are saying that you are able to print it but it cannot be returned to another function correct? Could you provide a minimal working example? I tested a very basic function call and it works

    def test(model):
    solution = model.getAttr("x")
    return solution

    # construct and optimize model
    # [...]
    # get solution
    s = test(model)
    print(s)

    Best regards,
    Jaromił

     

    0
  • Stuart Horine
    • Gurobi-versary
    • First Comment
    • First Question

    Thanks so much for the replies and help, however, It seems it was all a red herring...

    I had tried to re-write things, for example, by saving the state to disc at a certain point and reloading and resuming in another script. When this also "hung", I walked away in frustration.... The next day, it had completed and generated the sequence I was hoping for.

    For some reason, I can't explain (and I am continuing to see this and other curiosities running code on SLURM), when a certain set of operations on large data are following, the logging stops at some previous point in the code, even in a previous function. I think the improvements I had made did allow it to complete more quickly which is why it was done the next day.

    Also just FYI - I also see huge pauses in the execution. Yesterday a "running" program seemed to wait for 8 hours. The optimisation had completed in seconds, but the message to report this was not logged for a further 8 hours. All the timestamps generated by the following code execution (including the resulting files written) suggest it just did nothing for that time.

    Anyway - thanks again for helping.

    0
  • Jaromił Najman
    • Gurobi Staff

    Hi Stuart,

    Good to hear that to were able to make some progress.

    Could you elaborate more on when exactly the logging stops? Do you have a log output you could share? Is it possible that the cluster you are using via slurm is full and the queueing kicks in resulting in your jobs having to wait for quite some time? After you have solved a model, do you dispose of the model and the environment?

    Best regards,
    Jaromił

    0
  • Wes Gurnee

    I had the same issue with Gurobi hanging on model creation when running on a SLURM cluster. The recommendation to do

    gp_env = gp.Env() 
    model = gp.Model(env=gp_env)

    (while also doing dispose()) fixed my problem.

    0

投稿コメントは受け付けていません。