def parse_mem(mem):
    m = None
    try:
        m = int(mem)
    except:
        pass
    if m or m == 0:
        return m

    try:
        # check the memory patterns
        lc = mem[-1].upper()
        m = int(mem[:-1])
        if lc == "G":
            m = m * 1024
        elif lc == "K":
            m = m / 1024
        return m
    except:
        raise ValueError("Unable to parse %s to memory", mem)
Takse a string and parses a memory pattern. The supported suffixes are
dataset/ETHPy150Open thasso/pyjip/jip/utils.py/parse_mem