ray-project / tutorial

778 stars 212 forks source link

AttributeError: module 'msgpack' has no attribute 'dumps' #184

Open free-soellingeraj opened 4 years ago

free-soellingeraj commented 4 years ago

ray.version = '0.8.7'

# This function is a proxy for a more interesting and computationally
# intensive function.
@ray.remote
def slow_function(i):
    time.sleep(1)
    return i

# Sleep a little to improve the accuracy of the timing measurements below.
# We do this because workers may still be starting up in the background.
time.sleep(2.0)
start_time = time.time()

results = [slow_function.remote(i) for i in range(4)]

end_time = time.time()
duration = end_time - start_time

print('The results are {}. This took {} seconds. Run the next cell to see '
      'if the exercise was done correctly.'.format(results, duration))

yields error:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-12-642b7e800d47> in <module>
      4 start_time = time.time()
      5 
----> 6 results = [slow_function.remote(i) for i in range(4)]
      7 
      8 end_time = time.time()

<ipython-input-12-642b7e800d47> in <listcomp>(.0)
      4 start_time = time.time()
      5 
----> 6 results = [slow_function.remote(i) for i in range(4)]
      7 
      8 end_time = time.time()

/opt/conda/lib/python3.6/site-packages/ray/remote_function.py in _remote_proxy(*args, **kwargs)
     93         @wraps(function)
     94         def _remote_proxy(*args, **kwargs):
---> 95             return self._remote(args=args, kwargs=kwargs)
     96 
     97         self.remote = _remote_proxy

/opt/conda/lib/python3.6/site-packages/ray/remote_function.py in _remote(self, args, kwargs, num_return_vals, is_direct_call, num_cpus, num_gpus, memory, object_store_memory, resources, max_retries)
    216             invocation = self._decorator(invocation)
    217 
--> 218         return invocation(args, kwargs)

/opt/conda/lib/python3.6/site-packages/ray/remote_function.py in invocation(args, kwargs)
    206             object_refs = worker.core_worker.submit_task(
    207                 self._language, self._function_descriptor, list_args,
--> 208                 num_return_vals, resources, max_retries)
    209 
    210             if len(object_refs) == 1:

python/ray/_raylet.pyx in ray._raylet.CoreWorker.submit_task()

python/ray/_raylet.pyx in ray._raylet.CoreWorker.submit_task()

python/ray/_raylet.pyx in ray._raylet.prepare_args()

/opt/conda/lib/python3.6/site-packages/ray/serialization.py in serialize(self, value)
    390                 metadata = ray_constants.OBJECT_METADATA_TYPE_PYTHON
    391 
--> 392             return self._serialize_to_msgpack(metadata, value)
    393 
    394     def register_custom_serializer(self,

/opt/conda/lib/python3.6/site-packages/ray/serialization.py in _serialize_to_msgpack(self, metadata, value)
    358             return index
    359 
--> 360         msgpack_data = MessagePackSerializer.dumps(value, _python_serializer)
    361 
    362         if python_objects:

python/ray/includes/serialization.pxi in ray._raylet.MessagePackSerializer.dumps()

AttributeError: module 'msgpack' has no attribute 'dumps'
free-soellingeraj commented 4 years ago

I am not familiar with _raylet.so format enough to understand what this means. I am going to try to eliminate some possibilities by rebuilding a purpose driven version of my training env for RL with ray

amirebrahimi commented 4 months ago

I found this post while searching, so figured I'd update it with how to resolve the issue. I think this comes from having msgpack-python installed, which was the name of the package prior to version 0.5. There was another older dependency in our project that required this, which caused problems because you can't have msgpack and msgpack-python both installed. Even after removing msgpack-python the issue can still be there. So, the fix is to uninstall and reinstall msgpack.