Skip to content

KeyError: 'lengths' #4314

Closed
Closed

Description

@pseudotensor

Trying to find an older version of distributed that is not too buggy, having trouble.

rapids 0.14 pairs with 2.17 dask/disributed.

But 2.17 hits #3851

Tried 2.18 as suggested there, but 2.18 hits below even for most basic test when have 2 GPUs.

Any thoughts? I can't go to 2.27 used by rapids 0.14 because that causes many rapids tests to fail.

from dask.distributed import Client
from dask_cuda import LocalCUDACluster
from dask import dataframe as dd
import xgboost as xgb
def main(client):
    dask_df = dd.read_csv('creditcard.csv')
    target = 'default payment next month'
    y = dask_df['default payment next month']
    X = dask_df[dask_df.columns.difference([target])]
    dtrain = xgb.dask.DaskDMatrix(client, X, y)
    output = xgb.dask.train(client,
                            # Use GPU training algorithm
                            {'tree_method': 'gpu_hist'},
                            dtrain,
                            num_boost_round=100,
                            evals=[(dtrain, 'train')])
    booster = output['booster']  # booster is the trained model
    history = output['history']  # A dictionary containing evaluation results
    # Save the model to file
    booster.save_model('xgboost-model')
    print('Training evaluation history:', history)

    
if __name__ == '__main__':
    # `LocalCUDACluster` is used for assigning GPU to XGBoost 
    # processes. Here `n_workers` represents the number of GPUs 
    # since we use one GPU per worker process.
    with LocalCUDACluster(n_workers=2) as cluster:
        with Client(cluster) as client:
            main(client)
            

(base) jon@mr-dl10:/data/jon/h2oai.fullcondatest3$ python dask_cudf_example.py 
distributed.nanny - ERROR - Failed to start worker
Traceback (most recent call last):
  File "/home/jon/minicondadai/lib/python3.6/site-packages/distributed/nanny.py", line 758, in run
    await worker
  File "/home/jon/minicondadai/lib/python3.6/site-packages/distributed/core.py", line 236, in _
    await self.start()
  File "/home/jon/minicondadai/lib/python3.6/site-packages/distributed/worker.py", line 1085, in start
    await self._register_with_scheduler()
  File "/home/jon/minicondadai/lib/python3.6/site-packages/distributed/worker.py", line 811, in _register_with_scheduler
    types={k: typename(v) for k, v in self.data.items()},
  File "/home/jon/minicondadai/lib/python3.6/site-packages/distributed/worker.py", line 811, in <dictcomp>
    types={k: typename(v) for k, v in self.data.items()},
  File "/home/jon/minicondadai/lib/python3.6/_collections_abc.py", line 744, in __iter__
    yield (key, self._mapping[key])
  File "/home/jon/minicondadai/lib/python3.6/site-packages/dask_cuda/device_host_file.py", line 150, in __getitem__
    return self.host_buffer[key]
  File "/home/jon/minicondadai/lib/python3.6/site-packages/zict/buffer.py", line 78, in __getitem__
    return self.slow_to_fast(key)
  File "/home/jon/minicondadai/lib/python3.6/site-packages/zict/buffer.py", line 65, in slow_to_fast
    value = self.slow[key]
  File "/home/jon/minicondadai/lib/python3.6/site-packages/zict/func.py", line 38, in __getitem__
    return self.load(self.d[key])
  File "/home/jon/minicondadai/lib/python3.6/site-packages/distributed/protocol/serialize.py", line 505, in deserialize_bytes
    frames = merge_frames(header, frames)
  File "/home/jon/minicondadai/lib/python3.6/site-packages/distributed/protocol/utils.py", line 60, in merge_frames
    lengths = list(header["lengths"])
KeyError: 'lengths'

Activity

  1. pseudotensor commented on Dec 4, 2020

    @pseudotensor
    Author

    I'm going to try 2.19, but I'm running out of options.

  2. pseudotensor commented on Dec 4, 2020

    @pseudotensor
    Author

    I guess general question, that I can't infer, is should I be able to use latest dask/distributed with old rapids 0.14? Are there breaking changes so that rapids would no longer work? Was I just horribly unlucky with rapids0.15's dask/distributed 2.27?

  3. quasiben commented on Dec 4, 2020

    @quasiben
    Member

    What prevents you from going to latest releases of Dask/Distributed/RAPIDS ?

  4. mrocklin commented on Dec 4, 2020

    @mrocklin
    Member

    Trying to find a version of distributed that is not too buggy, having trouble.

    Hi @pseudotensor ! Thanks for your issue, I'm glad to see that RAPIDS folks have found it and are responding.

    Also, while I'm sure it wasn't intentional, comments like these can come across with a negative tone. As I'm sure you know, Dask is maintained by a broad set of people, many of whom work for free. Negative comments on public/free issue trackers are a common source of maintainer burnout. Again, I'm sure that this wasn't intentional, but it's maybe something to be aware of in the future.

    Cheers!

  5. pseudotensor commented on Dec 4, 2020

    @pseudotensor
    Author

    What prevents you from going to latest releases of Dask/Distributed/RAPIDS ?

    Can't use python 3.8 yet, and building rapiids stuff from scratch is not actually easy.

  6. pseudotensor commented on Dec 4, 2020

    @pseudotensor
    Author

    Trying to find a version of distributed that is not too buggy, having trouble.

    Hi @pseudotensor ! Thanks for your issue, I'm glad to see that RAPIDS folks have found it and are responding.

    Also, while I'm sure it wasn't intentional, comments like these can come across with a negative tone. As I'm sure you know, Dask is maintained by a broad set of people, many of whom work for free. Negative comments on public/free issue trackers are a common source of maintainer burnout. Again, I'm sure that this wasn't intentional, but it's maybe something to be aware of in the future.

    Cheers!

    Why would it be surprising that old versions of dask have bugs? Every software has bugs. I was quite explicit in my goal, to use an old version of distributed that avoided particular errors. I gave a full repro for my case (which means 2.18 as far as local cluster is not workable at all unlike 2.17 that only has issues with pickle with large data), and also explained my reasoning regarding breaking changes and wondering if I could just use latest without concerns.

  7. quasiben commented on Dec 4, 2020

    @quasiben
    Member

    Can't use python 3.8 yet, and building rapiids stuff from scratch is not actually easy.

    There is broad support for Python 3.7. Are pinned to something earlier ?

  8. pseudotensor commented on Dec 4, 2020

    @pseudotensor
    Author

    Can't use python 3.8 yet, and building rapiids stuff from scratch is not actually easy.

    There is broad support for Python 3.7. Are pinned to something earlier ?

    Yes, sorry, I should be explicit. We are using python 3.6. We plan to update to 3.8 soon, but it's taking time as many things have to change (3.7 wouldn't help in that regard).

  9. quasiben commented on Dec 4, 2020

    @quasiben
    Member

    To answer your question:

    should I be able to use latest dask/distributed with old rapids 0.14?

    I would not expect latest dask/distributed to work that far back as a lot of changes occurred in the serialization layers between Dask and RAPIDS. The errors you posted a probably a result of those changes. @jakirkham do you have any thoughts here ?

  10. pseudotensor commented on Dec 4, 2020

    @pseudotensor
    Author

    Ok thanks. I only encounter it with >=2 GPUs BTW. On single GPU system never happens.

    Is it possible I could patch 2.17 to avoid the original #3851 problem? I only encounter it when data gets large than about 2GB. I'm guessing that distributed switches to protocol 5 and that's when one hits that error. I see some work-around in the issue #3851 (comment), which I can try. I'm happy to also patch things if it's clear how to just fix that buffers problem.

    I can hunt through the PRs etc. for the fix, but any guidance is welcome.

    Thanks!

  11. pseudotensor commented on Dec 4, 2020

    @pseudotensor
    Author

    Thanks @quasiben for being super responsive and helpful!

  12. jakirkham commented on Dec 4, 2020

    @jakirkham
    Member

    To answer your question:

    should I be able to use latest dask/distributed with old rapids 0.14?

    I would not expect latest dask/distributed to work that far back as a lot of changes occurred in the serialization layers between Dask and RAPIDS. The errors you posted a probably a result of those changes. @jakirkham do you have any thoughts here ?

    There were a lot of changes related to cuDF serialization that didn't land until RAPIDS 0.15. So an older version may work, but also wouldn't be surprised to see issues crop up.

    Is there a reason that upgrading is not an option?

  13. pseudotensor commented on Dec 4, 2020

    @pseudotensor
    Author

    To answer your question:

    should I be able to use latest dask/distributed with old rapids 0.14?

    I would not expect latest dask/distributed to work that far back as a lot of changes occurred in the serialization layers between Dask and RAPIDS. The errors you posted a probably a result of those changes. @jakirkham do you have any thoughts here ?

    There were a lot of changes related to cuDF serialization that didn't land until RAPIDS 0.15. So an older version may work, but also wouldn't be surprised to see issues crop up.

    Is there a reason that upgrading is not an option?

    Ya I mentioned above I cannot upgrade yet. I'm on python 3.6 etc. see above.

    Main question is if the buffers issue in 2.17 can be patched or worked around. Otherwise 2.17 has been quite stable with rapids 0.14

  14. quasiben commented on Dec 4, 2020

    @quasiben
    Member

    I think it would be a large undertaking to patch/work around

  15. jakirkham commented on Dec 4, 2020

    @jakirkham
    Member

    Maybe one way around this would be to copy these two files from 0.15 into 0.14 in cuDF. I think that should work, but won't make any promises here.

    https://github.com/rapidsai/cudf/blob/v0.15.0/python/cudf/cudf/core/abc.py
    https://github.com/rapidsai/cudf/blob/v0.15.0/python/cudf/cudf/core/buffer.py

    Would be good to understand whether bumping the Python version could be an option for you or what may block it.

  16. 11 remaining items

  17. pseudotensor commented on Dec 5, 2020

    @pseudotensor
    Author

    @jakirkham Here is repro:

    rapidsai/dask-cuda#467

    If you can tell where "storage" is coming from and why this is requiring "buffers" code path that would be good. The cache file is only 88MB, so it's not a size issue.

    But in general, what packages are conditionally required by dask/distributed for some code paths? You seem to be saying above I need pickle5 or python 3.8 instead, which would be news to me regarding dask/distributed/rapids requirements.

  18. pseudotensor commented on Dec 5, 2020

    @pseudotensor
    Author

    If buffers is not dask_cuda issue, what do I need to make sure distributed works? pickle5 did not work, and is that really a requirement that is not explicit for dask/distributed? i.e. some package you should install if you want to do big data? Did I not RTFM? I real alot of dask docs etc. and I never noticed.

  19. pseudotensor commented on Dec 5, 2020

    @pseudotensor
    Author

    Here is debug view of the variable state. It shows the pickler was pickle, there just is 2 buffers. The pickle.py pickle dumps must be doing something wrong in distributed sometimes.

    image

    i.e. how can distributed be using pickle yet have a buffer "count" of 2? That will cause the buffers to be passed.

  20. pseudotensor commented on Dec 5, 2020

    @pseudotensor
    Author

    E.g. this function:

    
    def pickle_dumps(x):
        header = {"serializer": "pickle"}
        frames = [None]
        buffer_callback = lambda f: frames.append(memoryview(f))
        frames[0] = pickle.dumps(x, buffer_callback=buffer_callback)
        return header, frames
    

    seems to append frames if memoryview(f) call_back gives non-None result, which it must have.

    And then pickle.py dumps() must have not cleared the buffer. FYI the bare exceptions are pretty bad in that function:

    def dumps(x, *, buffer_callback=None):
        """ Manage between cloudpickle and pickle
    
        1.  Try pickle
        2.  If it is short then check if it contains __main__
        3.  If it is long, then first check type, then check __main__
        """
        buffers = []
        dump_kwargs = {"protocol": HIGHEST_PROTOCOL}
        if HIGHEST_PROTOCOL >= 5 and buffer_callback is not None:
            dump_kwargs["buffer_callback"] = buffers.append
        try:
            buffers.clear()
            result = pickle.dumps(x, **dump_kwargs)
            if len(result) < 1000:
                if b"__main__" in result:
                    buffers.clear()
                    result = cloudpickle.dumps(x, **dump_kwargs)
            elif not _always_use_pickle_for(x) and b"__main__" in result:
                buffers.clear()
                result = cloudpickle.dumps(x, **dump_kwargs)
        except Exception:
            try:
                buffers.clear()
                result = cloudpickle.dumps(x, **dump_kwargs)
            except Exception as e:
                logger.info("Failed to serialize %s. Exception: %s", x, e)
                raise
        if buffer_callback is not None:
            for b in buffers:
                buffer_callback(b)
        return result
    
  21. pseudotensor commented on Dec 5, 2020

    @pseudotensor
    Author

    FYI if I replace all instances of pickle package imports (i.e. import pickle or from pickle import ...) with import pickle5 as pickle etc. then I get different error:

        value = self.slow[key]
      File "/home/jon/minicondadai/lib/python3.6/site-packages/zict/func.py", line 38, in __getitem__
        return self.load(self.d[key])
      File "/home/jon/minicondadai/lib/python3.6/site-packages/distributed/protocol/serialize.py", line 502, in deserialize_bytes
        return deserialize(header, frames)
      File "/home/jon/minicondadai/lib/python3.6/site-packages/distributed/protocol/serialize.py", line 302, in deserialize
        return loads(header, frames)
      File "/home/jon/minicondadai/lib/python3.6/site-packages/distributed/protocol/serialize.py", line 64, in pickle_loads
        return pickle.loads(x, buffers=buffers)
      File "/home/jon/minicondadai/lib/python3.6/site-packages/distributed/protocol/pickle.py", line 64, in loads
        return pickle.loads(x, buffers=buffers)
    _pickle.UnpicklingError: pickle data 
    

    At least in 2.17, I don't see handling of pickle5, only native pickle that would only apply for python 3.8

  22. jakirkham commented on Dec 7, 2020

    @jakirkham
    Member

    Would make sure that Dask and Distributed are up-to-date. Also would make sure a recent version of Cloudpickle is installed. Finally would double check that the environment used by the Client, Workers, and Scheduler all have Cloudpickle and Pickle5. After doing all of that, it may be worth running client.get_versions(check=True) just to make sure everything is installed as expected.

  23. pseudotensor commented on Dec 7, 2020

    @pseudotensor
    Author

    As I mentioned import pickle is still in 2.17 code importing old pickle, not pickle5. Only later does distributed try import pickle5, so installing pickle5 has no effect.

    (base) jon@pseudotensor:~/h2oai.fullcondatest$ python
    Python 3.6.10 | packaged by conda-forge | (default, Apr 24 2020, 16:44:11) 
    [GCC 7.3.0] on linux
    Type "help", "copyright", "credits" or "license" for more information.
    >>> from dask.distributed import Client
    >>> client = Client()
    >>> client.get_versions(check=True)
    {'scheduler': {'host': {'python': '3.6.10.final.0', 'python-bits': 64, 'OS': 'Linux', 'OS-release': '5.4.0-56-generic', 'machine': 'x86_64', 'processor': 'x86_64', 'byteorder': 'little', 'LC_ALL': 'None', 'LANG': 'en_US.UTF-8'}, 'packages': {'python': '3.6.10.final.0', 'dask': '2.17.0', 'distributed': '2.17.0', 'msgpack': '1.0.0', 'cloudpickle': '1.6.0', 'tornado': '6.0.4', 'toolz': '0.11.1', 'numpy': '1.18.5', 'lz4': None, 'blosc': None}}, 'workers': {'tcp://127.0.0.1:34443': {'host': {'python': '3.6.10.final.0', 'python-bits': 64, 'OS': 'Linux', 'OS-release': '5.4.0-56-generic', 'machine': 'x86_64', 'processor': 'x86_64', 'byteorder': 'little', 'LC_ALL': 'None', 'LANG': 'en_US.UTF-8'}, 'packages': {'python': '3.6.10.final.0', 'dask': '2.17.0', 'distributed': '2.17.0', 'msgpack': '1.0.0', 'cloudpickle': '1.6.0', 'tornado': '6.0.4', 'toolz': '0.11.1', 'numpy': '1.18.5', 'lz4': None, 'blosc': None}}, 'tcp://127.0.0.1:35603': {'host': {'python': '3.6.10.final.0', 'python-bits': 64, 'OS': 'Linux', 'OS-release': '5.4.0-56-generic', 'machine': 'x86_64', 'processor': 'x86_64', 'byteorder': 'little', 'LC_ALL': 'None', 'LANG': 'en_US.UTF-8'}, 'packages': {'python': '3.6.10.final.0', 'dask': '2.17.0', 'distributed': '2.17.0', 'msgpack': '1.0.0', 'cloudpickle': '1.6.0', 'tornado': '6.0.4', 'toolz': '0.11.1', 'numpy': '1.18.5', 'lz4': None, 'blosc': None}}, 'tcp://127.0.0.1:40115': {'host': {'python': '3.6.10.final.0', 'python-bits': 64, 'OS': 'Linux', 'OS-release': '5.4.0-56-generic', 'machine': 'x86_64', 'processor': 'x86_64', 'byteorder': 'little', 'LC_ALL': 'None', 'LANG': 'en_US.UTF-8'}, 'packages': {'python': '3.6.10.final.0', 'dask': '2.17.0', 'distributed': '2.17.0', 'msgpack': '1.0.0', 'cloudpickle': '1.6.0', 'tornado': '6.0.4', 'toolz': '0.11.1', 'numpy': '1.18.5', 'lz4': None, 'blosc': None}}, 'tcp://127.0.0.1:42655': {'host': {'python': '3.6.10.final.0', 'python-bits': 64, 'OS': 'Linux', 'OS-release': '5.4.0-56-generic', 'machine': 'x86_64', 'processor': 'x86_64', 'byteorder': 'little', 'LC_ALL': 'None', 'LANG': 'en_US.UTF-8'}, 'packages': {'python': '3.6.10.final.0', 'dask': '2.17.0', 'distributed': '2.17.0', 'msgpack': '1.0.0', 'cloudpickle': '1.6.0', 'tornado': '6.0.4', 'toolz': '0.11.1', 'numpy': '1.18.5', 'lz4': None, 'blosc': None}}}, 'client': {'host': {'python': '3.6.10.final.0', 'python-bits': 64, 'OS': 'Linux', 'OS-release': '5.4.0-56-generic', 'machine': 'x86_64', 'processor': 'x86_64', 'byteorder': 'little', 'LC_ALL': 'None', 'LANG': 'en_US.UTF-8'}, 'packages': {'python': '3.6.10.final.0', 'dask': '2.17.0', 'distributed': '2.17.0', 'msgpack': '1.0.0', 'cloudpickle': '1.6.0', 'tornado': '6.0.4', 'toolz': '0.11.1', 'numpy': '1.18.5', 'lz4': None, 'blosc': None}}}
    
  24. jakirkham commented on Dec 7, 2020

    @jakirkham
    Member

    Sorry I don't follow. Thought distributed was being updated to a newer version. If not, I don't see a path forward here.

  25. pseudotensor commented on Dec 7, 2020

    @pseudotensor
    Author

    Sorry I don't follow. Thought distributed was being updated to a newer version. If not, I don't see a path forward here.

    rapids 0.14 was released with dask/distributed 2.17, but I guess it's possible it never worked, yes.

    I would still be interested to know why distributed or cudf is sending buffers. I don't think rapids 0.16 setup with newer dask has pickle5 as dependency, so then only python 3.8 would work OOTB.

  26. jakirkham commented on Dec 7, 2020

    @jakirkham
    Member

    Well it was released with 2.15+. Maybe trying one of the older versions works for you?

  27. quasiben commented on Dec 8, 2020

    @quasiben
    Member

    I think what we are seeing here is that it is indeed challenging to find patched version of dask/distributed working with an older version of RAPIDS. If you want to test exactly what was available during the 0.14 release you should use the 0.14 docker image . There you'll find dask/distributed 2.20.0

    I'm not exactly sure where to go from here. Happy to find 30 minutes for us to chat so I/we can better understand what you are trying to accomplish but it's unlikely that we can help you find a patch for an older version of RAPIDS

  28. pseudotensor commented on Dec 8, 2020

    @pseudotensor
    Author

    I'm just asking how things work. I think the dask_cuda is using a spill-over to pickle and then dask is reading those files in, and distributed fails because dask_cuda wrote to disk files that inside have extra frames distributed interprets as buffers. That's what I have seen. In that case, it doesn't matter what version of distributed is used, even latest only tries pickle5 if it exists, and pickle5 is not a requirement OOTB AFAIK. Only python 3.8 would allow distributed to use protocol5.

  29. pseudotensor commented on Dec 9, 2020

    @pseudotensor
    Author

    I think what we are seeing here is that it is indeed challenging to find patched version of dask/distributed working with an older version of RAPIDS. If you want to test exactly what was available during the 0.14 release you should use the 0.14 docker image . There you'll find dask/distributed 2.20.0

    I'm not exactly sure where to go from here. Happy to find 30 minutes for us to chat so I/we can better understand what you are trying to accomplish but it's unlikely that we can help you find a patch for an older version of RAPIDS

    Thanks @quasiben for pointing out docker was using 2.20.

  30. pseudotensor commented on Dec 9, 2020

    @pseudotensor
    Author

    I'll try to learn about the spill over myself since I understand people are busy. I know it happens when I use bigger data, and I'll just assume you guys hope it's fixed in later rapids/dask/distributed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions