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

gurobipy routine killed on macOS even though VM available

回答済み

コメント

7件のコメント

  • Riley Clement
    • Gurobi Staff

    Hi Giordano,

    Can you investigate whether this is specific to gurobipy with something like the following?

    import time
    import numpy as np
    arrays = []
    size_mb = 200 
    n = (size_mb * 1024 * 1024) // 8
    i = 0
    while True:
       print(f"{i=}")
       a = np.ones(n, dtype=np.float64)
       arrays.append(a)
       i += 1
       time.sleep(0.1)

    What version of gurobipy and Python are you using?

    - Riley

     

    0
  • Giordano Giambartolomei
    • Conversationalist
    • Curious

    Thank you, it is python 3.12 and gurobipy12.03 all in a conda environment. Your script gets killed by zsh at about 9GB of (compressed) virtual memory occupied (the parameter I=438 at this point). Does this mean that the issue is with the conda environment? Perhaps it interferes with the VMM in macOS…

    By the way it does not seems that, after zsh kills your script, the VM gets released. Could you share a way to do that?

    0
  • Riley Clement
    • Gurobi Staff

    Hi Giordano,

    My guess is that it is not conda and just how MacOS handles memory and processes.

    I also guess that although it appears that virtual memory is being consumed that this is not really an issue and it will be reclaimed when needed.

    - Riley

    0
  • Giordano Giambartolomei
    • Conversationalist
    • Curious

    Thanks, 

    that is what is odd though: macOS is supposed to use virtual memory until there is free space in disc, and on my disk there are still hundreds of GBs available as it is an almost empty 500GB ssd, with df -h displaying 360 GB available in the VM volume. Further, a similar code to yours with C++ can use far more virtual memory with macOS (130GB). If conda environments do not differ fundamentally from standard python venvs, could the problem be python itself then, and limitations within its garbage collector? I also find odd that while the gurobi code can reclaim up to 40GB of virtual memory, the script you wrote is killed after only 9GB of virtual memory…

     

    EDIT: it indeed macOS VMM, not conda, causing this, as you predicted. Essentially the documentation on macOS VMM does not tell the full story. I have been in conversation with engineers on the apple developer forum and I received confirmation that in addition to the vague description that the whole ssd can be used by swapfiles, the VMM manager put caps on each process available total memory. These caps are far less than the total available. I am now looking into how to bypass the VMM automatic swapping behaviour in order to allocate a swapfile to the process I want to be unconstrained by nothing other than my swapfile. I am not sure how to do this yet, as I am only familiar with Linux.

    0
  • Riley Clement
    • Gurobi Staff

    Thanks for posting the update Giordano!

    0
  • Giordano Giambartolomei
    • Conversationalist
    • Curious

    In conclusion, the only way to do this is to create a file of desired size (dd from dev/zero) and then use mmap to back the memory-consuming processes with this file, rather than leaving it to the VMM as by default. Is there a way in gurobipy, before doing model.optimize(), to set some parameters so that this mmapping is possible? Note that this may be different from saving nodefiles to disk by setting the corresponding parameter, since I think that way is cumulative only because it runs out of space faster, whereas the standard behaviour of gurobi is to save memory by deleting nodes that are fathomed as the bounds improve (I noticed many times memory freeing up by a couple of GBs as the optimisation proceeds).

    0
  • Riley Clement
    • Gurobi Staff

    Hi Giordano,

    Is there a way in gurobipy, before doing model.optimize(), to set some parameters so that this mmapping is possible?

    There isn't (or any of our other APIs).  If there was some way of doing this it would have to be done outside of Gurobi somehow.

    - Riley

    0

サインインしてコメントを残してください。