def memstr_to_kbytes(text):
    kilo = 1024
    units = dict(K=1, M=kilo, G=kilo ** 2)
    try:
        size = int(units[text[-1]] * float(text[:-1]))
    except (KeyError, ValueError):
        raise ValueError(
                "Invalid literal for size give: %s (type %s) should be "
                "alike '10G', '500M', '50K'." % (text, type(text))
                )
    return size
Convert a memory text to it's value in kilobytes.
dataset/ETHPy150Open scikit-learn/scikit-learn/sklearn/externals/joblib/disk.py/memstr_to_kbytes