@@ -603,3 +603,37 @@ def should_collect_more_steps(
603603 "The unit of the `train_freq` must be either TrainFrequencyUnit.STEP "
604604 f"or TrainFrequencyUnit.EPISODE not '{ train_freq .unit } '!"
605605 )
606+
607+ def get_system_info (print_info : bool = True ) -> tuple [dict [str , str ], str ]:
608+ """
609+ Retrieve system and python env info for the current system.
610+
611+ :param print_info: Whether to print or not those infos
612+ :return: Dictionary summing up the version for each relevant package
613+ and a formatted string.
614+ """
615+ env_info = {
616+ # In OS, a regex is used to add a space between a "#" and a number to avoid
617+ # wrongly linking to another issue on GitHub. Example: turn "#42" to "# 42".
618+ "OS" : re .sub (r"#(\d)" , r"# \1" , f"{ platform .platform ()} { platform .version ()} " ),
619+ "Python" : platform .python_version (),
620+ "Stable-Baselines3" : sb3 .__version__ ,
621+ "PyTorch" : th .__version__ ,
622+ "GPU Enabled" : str (th .cuda .is_available ()),
623+ "Numpy" : np .__version__ ,
624+ "Cloudpickle" : cloudpickle .__version__ ,
625+ "Gymnasium" : gym .__version__ ,
626+ }
627+ try :
628+ import gym as openai_gym
629+
630+ env_info .update ({"OpenAI Gym" : openai_gym .__version__ })
631+ except ImportError :
632+ pass
633+
634+ env_info_str = ""
635+ for key , value in env_info .items ():
636+ env_info_str += f"- { key } : { value } \n "
637+ if print_info :
638+ print (env_info_str )
639+ return env_info , env_info_str
0 commit comments