Silence numpy deprecation warnings

How severe does this issue affect your experience of using Ray?

  • Medium: It contributes to significant difficulty to complete my task, but I can work around it.

I’m currently using Ray 1.9.2 with numpy 1.22 and my logs are flooded with deprecation warnings by numpy:

python3.8/site-packages/ray/rllib/utils/ DeprecationWarning: `np.object` is a deprecated alias for the builtin `object`. To silence this warning, use `object` by itself. Doing this will not modify any behavior and is safe. 

I saw this is fixed in the latest Ray 1.11 release. I plan to upgrade eventually, but I can’t do it right now. Is there any way to silence these warnings inside Ray?

I already have warnings.filterwarnings("ignore", category=DeprecationWarning) in my main script but it does not seem to work for the warnings inside ray.
Is there any config I can pass to ray to silence these warnings?

Maybe make this a feature request on GH?
I don’t know of any way to tell ray to silence external warnings.

A way this could work:

  1. Specify your filters as a dict resembling the argument names of warnings.filterwarnings()
    For example in your case: filter = {“action”: “ignore”, “category”:DeprecationWarning}
  2. Pass it to ray with something like {..., "_filter_warnings": [filter]}

The module warnings simply keeps a list of filter that basically consist of your input arguments.
So we might even be able read this list and paste it elsewhere I think.


In the short term…

  1. you can use ray.init(log_to_driver=False) and see if you like that a little better.
    I admit that it does not fully resolve your issue.
  2. you can try downgrading numpy
1 Like

Sorry, it took a while to come back to this.

I opened a feature request on GH: RLlib: Silence external warnings · Issue #24107 · ray-project/ray · GitHub
Unfortunately, I didn’t see any difference when using ray.init(log_to_driver=False).

Now, I’ll try to either downgrade numpy (I think it doesn’t work on M1) or upgrade Ray as soon as possible (takes a while since there are many breaking changes).

Anyways, thanks for your help! :slight_smile: