suppress_warnings.py 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. import logging
  2. import warnings
  3. def suppress_warnings():
  4. warnings.filterwarnings(
  5. "ignore",
  6. message="Using the update method is deprecated. Simply return a new object instead",
  7. )
  8. warnings.filterwarnings(
  9. "ignore",
  10. message="Trying to convert audio automatically from float32 to 16-bit int format.",
  11. )
  12. warnings.filterwarnings(
  13. "ignore",
  14. message="Trying to convert audio automatically from int32 to 16-bit int format.",
  15. )
  16. # UserWarning: torch.utils._pytree._register_pytree_node is deprecated. Please use torch.utils._pytree.register_pytree_node instead.
  17. warnings.filterwarnings(
  18. "ignore",
  19. message="torch.utils._pytree._register_pytree_node is deprecated. Please use torch.utils._pytree.register_pytree_node instead.",
  20. )
  21. # FutureWarning: transformers.deepspeed module is deprecated and will be removed in a future version. Please import deepspeed modules directly from transformers.integrations
  22. warnings.filterwarnings(
  23. "ignore",
  24. message="transformers.deepspeed module is deprecated and will be removed in a future version. Please import deepspeed modules directly from transformers.integrations",
  25. )
  26. # UserWarning: torch.nn.utils.weight_norm is deprecated in favor of torch.nn.utils.parametrizations.weight_norm.
  27. # warnings.warn("torch.nn.utils.weight_norm is deprecated in favor of torch.nn.utils.parametrizations.weight_norm.")
  28. warnings.filterwarnings(
  29. "ignore",
  30. message="torch.nn.utils.weight_norm is deprecated in favor of torch.nn.utils.parametrizations.weight_norm.",
  31. )
  32. # suppress warning from logging "A matching Triton is not available, some optimizations will not be enabled"
  33. # suppress warning from logging "Triton is not available, some optimizations will not be enabled."
  34. logging.getLogger("xformers").addFilter(
  35. lambda record: "Triton is not available" not in record.getMessage()
  36. )