Rendering and Saving not working
I run the following command: python run_agent.py --envname='basketball' --episodes=500 --agent='sac' --rendering --entity juliusschellenberg
I get * as output. The program works fine, but doesnt create this directory. OSError: Cannot save file into a non-existent directory: 'savedagents/extracted_data' And the rendering does not start too...
wandb login --relogin
to force relogin)
wandb: wandb version 0.13.5 is available! To upgrade, please run:
wandb: $ pip install wandb --upgrade
wandb: Tracking run with wandb version 0.12.13
wandb: Run data is saved locally in /home/julius/Desktop/mlprakt/robot-science/wandb/run-20221129_132111-3fx1nj44
wandb: Run wandb offline
to turn off syncing.
wandb: Syncing run upbeat-field-15
wandb: ⭐ ️ View project at https://wandb.ai/juliusschellenberg/box-gym
wandb: 🚀 View run at https://wandb.ai/juliusschellenberg/box-gym/runs/3fx1nj44
/home/julius/Desktop/mlprakt/venv39/lib/python3.9/site-packages/gym/spaces/box.py:84: UserWarning: WARN: Box bound precision lowered by casting to float32
logger.warn(f"Box bound precision lowered by casting to {self.dtype}")
Using cpu device
wandb: WARNING Found log directory outside of given root_logdir, dropping given root_logdir for event file in results/temp/SAC_2
Logging to results/temp/SAC_2
Success! | Starting position: [16.0, 18.0] | Distance: 19.60 | Mass: 15.71
Success! | Starting position: [16.0, 18.0] | Distance: 19.60 | Mass: 15.71
Success! | Starting position: [16.0, 18.0] | Distance: 19.60 | Mass: 15.71
Success! | Starting position: [16.0, 18.0] | Distance: 19.60 | Mass: 15.71
Success! | Starting position: [16.0, 18.0] | Distance: 19.60 | Mass: 15.71
Success! | Starting position: [16.0, 18.0] | Distance: 19.60 | Mass: 15.71
Success! | Starting position: [16.0, 18.0] | Distance: 19.60 | Mass: 15.71
Success! | Starting position: [16.0, 18.0] | Distance: 19.60 | Mass: 15.71
Success! | Starting position: [16.0, 18.0] | Distance: 19.60 | Mass: 15.71
Success! | Starting position: [16.0, 18.0] | Distance: 19.60 | Mass: 15.71
Success! | Starting position: [16.0, 18.0] | Distance: 19.60 | Mass: 15.71
Success! | Starting position: [16.0, 18.0] | Distance: 19.60 | Mass: 15.71
Success! | Starting position: [16.0, 18.0] | Distance: 19.60 | Mass: 15.71
Success! | Starting position: [16.0, 18.0] | Distance: 19.60 | Mass: 15.71
Success! | Starting position: [16.0, 18.0] | Distance: 19.60 | Mass: 15.71
Success! | Starting position: [16.0, 18.0] | Distance: 19.60 | Mass: 15.71
Success! | Starting position: [16.0, 18.0] | Distance: 19.60 | Mass: 15.71
Success! | Starting position: [16.0, 18.0] | Distance: 19.60 | Mass: 15.71
Success! | Starting position: [16.0, 18.0] | Distance: 19.60 | Mass: 15.71
Success! | Starting position: [16.0, 18.0] | Distance: 19.60 | Mass: 15.71
Success! | Starting position: [16.0, 18.0] | Distance: 19.60 | Mass: 15.71
Success! | Starting position: [16.0, 18.0] | Distance: 19.60 | Mass: 15.71
Success! | Starting position: [16.0, 18.0] | Distance: 19.60 | Mass: 15.71
Success! | Starting position: [16.0, 18.0] | Distance: 19.60 | Mass: 15.71
/home/julius/Desktop/mlprakt/venv39/lib/python3.9/site-packages/stable_baselines3/common/evaluation.py:65: UserWarning: Evaluation environment is not wrapped with a Monitor
wrapper. This may result in reporting modified episode lengths and rewards, if other wrappers happen to modify these. Consider wrapping environment first with Monitor
wrapper.
warnings.warn(
Eval num_timesteps=500, episode_reward=10.00 +/- 0.00
Episode length: 1.00 +/- 0.00
python run_agent.py --envname='basketball' --episodes=500 --agent='sac' --rendering --entity juliusschellenberg
wandb: Currently logged in as: juliusschellenberg (use | eval/ | | | mean_ep_length | 1 | | mean_reward | 10 | | time/ | | | total timesteps | 500 | | train/ | | | actor_loss | -0.688 | | critic_loss | 539 | | ent_coef | 1.04 | | ent_coef_loss | -0.0898 | | learning_rate | 0.0001 | | n_updates | 399 |
New best mean reward!
| time/ | | | episodes | 500 | | fps | 2 | | time_elapsed | 205 | | total timesteps | 500 |
Success rate of test episodes: 500/500=100.00% Traceback (most recent call last): File "/home/julius/Desktop/mlprakt/robot-science/run_agent.py", line 263, in df.to_csv(f"savedagents/extracted_data/{args.path}.csv") File "/home/julius/Desktop/mlprakt/venv39/lib/python3.9/site-packages/pandas/core/generic.py", line 3551, in to_csv return DataFrameRenderer(formatter).to_csv( File "/home/julius/Desktop/mlprakt/venv39/lib/python3.9/site-packages/pandas/io/formats/format.py", line 1180, in to_csv csv_formatter.save() File "/home/julius/Desktop/mlprakt/venv39/lib/python3.9/site-packages/pandas/io/formats/csvs.py", line 241, in save with get_handle( File "/home/julius/Desktop/mlprakt/venv39/lib/python3.9/site-packages/pandas/io/common.py", line 697, in get_handle check_parent_directory(str(handle)) File "/home/julius/Desktop/mlprakt/venv39/lib/python3.9/site-packages/pandas/io/common.py", line 571, in check_parent_directory raise OSError(rf"Cannot save file into a non-existent directory: '{parent}'") OSError: Cannot save file into a non-existent directory: 'savedagents/extracted_data' ╭─────────────────────────────── Traceback (most recent call last) ────────────────────────────────╮ │ │ │ /home/julius/Desktop/mlprakt/robot-science/run_agent.py:263 in │ │ │ │ 260 │ │ │ # print(f"Saved replay buffer from training to location {args.location}_repl │ │ 261 │ │ │ │ 262 │ │ # save the csv file │ │ ❱ 263 │ │ df.to_csv(f"savedagents/extracted_data/{args.path}.csv") │ │ 264 │ │ │ │ 265 │ │ # Do the tracking of the CSV File │ │ 266 │ │ run = wandbCSVTracking(run, f"savedagents/extracted_data/{args.path}.csv", args) │ │ │ │ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │ │ │ annotations = {} │ │ │ │ builtins = <module 'builtins' (built-in)> │ │ │ │ cached = None │ │ │ │ doc = None │ │ │ │ file = '/home/julius/Desktop/mlprakt/robot-science/run_agent.py' │ │ │ │ loader = <_frozen_importlib_external.SourceFileLoader object at │ │ │ │ 0x7f7897be5c10> │ │ │ │ name = 'main' │ │ │ │ package = None │ │ │ │ spec = None │ │ │ │ A2C = <class 'stable_baselines3.a2c.a2c.A2C'> │ │ │ │ A2CAgent = <class 'agents.StableBaselinesAgents.A2CAgent.A2CAgent'> │ │ │ │ agent = SACAgent() │ │ │ │ argparse = <module 'argparse' from '/usr/lib/python3.9/argparse.py'> │ │ │ │ args = Namespace(envname='basketball', agent='sac', episodes=500, │ │ │ │ printevery=500, discount=0.99, trials=100, │ │ │ │ entity='juliusschellenberg', seed=42, threshold=20.1, dropout=0.2, │ │ │ │ lr=0.0001, rendering=True, overwriting=False, location='SAC_Model', │ │ │ │ reward_norm=False, disable_xvfb=False, normalize=False, │ │ │ │ path='results', test=False, mode=1, random_densities=False, │ │ │ │ random_boxsizes=False, placed=1, actions=1, sides=2, │ │ │ │ raw_pixels=False, random_density=False, random_ball_size=False, │ │ │ │ random_basket=False, random_ball_position=False, walls=0, │ │ │ │ random_planet_position=False, random_gravity=False, │ │ │ │ random_satellite_size=False, random_satellite_position=False, │ │ │ │ random_satellite_density=False) │ │ │ │ BasketballEnvironment = <class 'environments.BasketballEnvironment.BasketballEnvironment'> │ │ │ │ create_agent = <function create_agent at 0x7f781c9e2790> │ │ │ │ create_argparser = <function create_argparser at 0x7f781d3ffaf0> │ │ │ │ create_envs = <function create_envs at 0x7f781cca1f70> │ │ │ │ df = │ x-Position Ball y-Position Ball ... y-Position Basket │ │ │ │ Radius Basket │ │ │ │ 0 16.0 18.0 ... 18.0 │ │ │ │ 1.8 │ │ │ │ 1 16.0 18.0 ... 18.0 │ │ │ │ 1.8 │ │ │ │ 2 16.0 18.0 ... 18.0 │ │ │ │ 1.8 │ │ │ │ 3 16.0 18.0 ... 18.0 │ │ │ │ 1.8 │ │ │ │ 4 16.0 18.0 ... 18.0 │ │ │ │ 1.8 │ │ │ │ .. ... ... ... ... │ │ │ │ ... │ │ │ │ 495 16.0 18.0 ... 18.0 │ │ │ │ 1.8 │ │ │ │ 496 16.0 18.0 ... 18.0 │ │ │ │ 1.8 │ │ │ │ 497 16.0 18.0 ... 18.0 │ │ │ │ 1.8 │ │ │ │ 498 16.0 18.0 ... 18.0 │ │ │ │ 1.8 │ │ │ │ 499 16.0 18.0 ... 18.0 │ │ │ │ 1.8 │ │ │ │ │ │ │ │ [500 rows x 9 columns] │ │ │ │ Dict = <class 'gym.spaces.dict.Dict'> │ │ │ │ DummyVecEnv = <class 'stable_baselines3.common.vec_env.dummy_vec_env.DummyVecEnv'> │ │ │ │ get_env_dims = <function get_env_dims at 0x7f781c9e25e0> │ │ │ │ gym = <module 'gym' from │ │ │ │ '/home/julius/Desktop/mlprakt/venv39/lib/python3.9/site-packages/gy… │ │ │ │ GymEnv = <class 'environments.GymEnv.GymEnv'> │ │ │ │ HERAgent = <class 'agents.StableBaselinesAgents.HERAgent.HERAgent'> │ │ │ │ input_dim = (9,) │ │ │ │ install = <function install at 0x7f781d38b790> │ │ │ │ matplotlib = <module 'matplotlib' from │ │ │ │ '/home/julius/Desktop/mlprakt/venv39/lib/python3.9/site-packages/ma… │ │ │ │ OrbitEnvironment = <class 'environments.OrbitEnvironment.OrbitEnvironment'> │ │ │ │ output_dim = 2 │ │ │ │ pickle = <module 'pickle' from '/usr/lib/python3.9/pickle.py'> │ │ │ │ plot_rewards = <function plot_rewards at 0x7f781c9e2820> │ │ │ │ plot_test_rewards = <function plot_test_rewards at 0x7f781c9e28b0> │ │ │ │ plt = <module 'matplotlib.pyplot' from │ │ │ │ '/home/julius/Desktop/mlprakt/venv39/lib/python3.9/site-packages/ma… │ │ │ │ PPOAgent = <class 'agents.StableBaselinesAgents.PPOAgent.PPOAgent'> │ │ │ │ run = <wandb.sdk.wandb_run.Run object at 0x7f781c934910> │ │ │ │ SAC = <class 'stable_baselines3.sac.sac.SAC'> │ │ │ │ SACAgent = <class 'agents.StableBaselinesAgents.SACAgent.SACAgent'> │ │ │ │ Scale = <class 'ScaleEnvironment.Scale.Scale'> │ │ │ │ ScaleDraw = <class 'ScaleEnvironment.ScaleDraw.ScaleDraw'> │ │ │ │ ScaleExperiment = <class 'ScaleEnvironment.ScaleExperiment.ScaleExperiment'> │ │ │ │ set_random_seed = <function set_random_seed at 0x7f78227ff3a0> │ │ │ │ SRAgent = <class 'agents.OtherAgents.SRAgent.SRAgent'> │ │ │ │ start_time = 1669724470.9936879 │ │ │ │ test_env = <environments.BasketballEnvironment.BasketballEnvironment object at │ │ │ │ 0x7f781c9bf6d0> │ │ │ │ test_rewards = [ │ │ │ │ │ array([10.], dtype=float32), │ │ │ │ │ array([10.], dtype=float32), │ │ │ │ │ array([10.], dtype=float32), │ │ │ │ │ array([10.], dtype=float32), │ │ │ │ │ array([10.], dtype=float32), │ │ │ │ │ array([10.], dtype=float32), │ │ │ │ │ array([10.], dtype=float32), │ │ │ │ │ array([10.], dtype=float32), │ │ │ │ │ array([10.], dtype=float32), │ │ │ │ │ array([10.], dtype=float32), │ │ │ │ │ ... +490 │ │ │ │ ] │ │ │ │ time = <module 'time' (built-in)> │ │ │ │ train_env = <environments.BasketballEnvironment.BasketballEnvironment object at │ │ │ │ 0x7f781c9d8b50> │ │ │ │ vdisplay = <xvfbwrapper.Xvfb object at 0x7f789799df70> │ │ │ │ VecNormalize = <class │ │ │ │ 'stable_baselines3.common.vec_env.vec_normalize.VecNormalize'> │ │ │ │ wandb = <module 'wandb' from │ │ │ │ '/home/julius/Desktop/mlprakt/venv39/lib/python3.9/site-packages/wa… │ │ │ │ wandbCSVTracking = <function wandbCSVTracking at 0x7f781d3e8430> │ │ │ │ Xvfb = <class 'xvfbwrapper.Xvfb'> │ │ │ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │ │ /home/julius/Desktop/mlprakt/venv39/lib/python3.9/site-packages/pandas/core/generic.py:3551 in │ │ to_csv │ │ │ │ 3548 │ │ │ decimal=decimal, │ │ 3549 │ │ ) │ │ 3550 │ │ │ │ ❱ 3551 │ │ return DataFrameRenderer(formatter).to_csv( │ │ 3552 │ │ │ path_or_buf, │ │ 3553 │ │ │ line_terminator=line_terminator, │ │ 3554 │ │ │ sep=sep, │ │ │ │ ╭─────────────────────────────────────────── locals ───────────────────────────────────────────╮ │ │ │ chunksize = None │ │ │ │ columns = None │ │ │ │ compression = 'infer' │ │ │ │ date_format = None │ │ │ │ decimal = '.' │ │ │ │ df = │ x-Position Ball y-Position Ball ... y-Position Basket Radius │ │ │ │ Basket │ │ │ │ 0 16.0 18.0 ... 18.0 │ │ │ │ 1.8 │ │ │ │ 1 16.0 18.0 ... 18.0 │ │ │ │ 1.8 │ │ │ │ 2 16.0 18.0 ... 18.0 │ │ │ │ 1.8 │ │ │ │ 3 16.0 18.0 ... 18.0 │ │ │ │ 1.8 │ │ │ │ 4 16.0 18.0 ... 18.0 │ │ │ │ 1.8 │ │ │ │ .. ... ... ... ... │ │ │ │ ... │ │ │ │ 495 16.0 18.0 ... 18.0 │ │ │ │ 1.8 │ │ │ │ 496 16.0 18.0 ... 18.0 │ │ │ │ 1.8 │ │ │ │ 497 16.0 18.0 ... 18.0 │ │ │ │ 1.8 │ │ │ │ 498 16.0 18.0 ... 18.0 │ │ │ │ 1.8 │ │ │ │ 499 16.0 18.0 ... 18.0 │ │ │ │ 1.8 │ │ │ │ │ │ │ │ [500 rows x 9 columns] │ │ │ │ doublequote = True │ │ │ │ encoding = None │ │ │ │ errors = 'strict' │ │ │ │ escapechar = None │ │ │ │ float_format = None │ │ │ │ formatter = <pandas.io.formats.format.DataFrameFormatter object at 0x7f781c9bf4c0> │ │ │ │ header = True │ │ │ │ index = True │ │ │ │ index_label = None │ │ │ │ line_terminator = None │ │ │ │ mode = 'w' │ │ │ │ na_rep = '' │ │ │ │ path_or_buf = 'savedagents/extracted_data/results.csv' │ │ │ │ quotechar = '"' │ │ │ │ quoting = None │ │ │ │ self = │ x-Position Ball y-Position Ball ... y-Position Basket Radius │ │ │ │ Basket │ │ │ │ 0 16.0 18.0 ... 18.0 │ │ │ │ 1.8 │ │ │ │ 1 16.0 18.0 ... 18.0 │ │ │ │ 1.8 │ │ │ │ 2 16.0 18.0 ... 18.0 │ │ │ │ 1.8 │ │ │ │ 3 16.0 18.0 ... 18.0 │ │ │ │ 1.8 │ │ │ │ 4 16.0 18.0 ... 18.0 │ │ │ │ 1.8 │ │ │ │ .. ... ... ... ... │ │ │ │ ... │ │ │ │ 495 16.0 18.0 ... 18.0 │ │ │ │ 1.8 │ │ │ │ 496 16.0 18.0 ... 18.0 │ │ │ │ 1.8 │ │ │ │ 497 16.0 18.0 ... 18.0 │ │ │ │ 1.8 │ │ │ │ 498 16.0 18.0 ... 18.0 │ │ │ │ 1.8 │ │ │ │ 499 16.0 18.0 ... 18.0 │ │ │ │ 1.8 │ │ │ │ │ │ │ │ [500 rows x 9 columns] │ │ │ │ sep = ',' │ │ │ │ storage_options = None │ │ │ ╰──────────────────────────────────────────────────────────────────────────────────────────────╯ │ │ │ │ /home/julius/Desktop/mlprakt/venv39/lib/python3.9/site-packages/pandas/io/formats/format.py:1180 │ │ in to_csv │ │ │ │ 1177 │ │ │ storage_options=storage_options, │ │ 1178 │ │ │ formatter=self.fmt, │ │ 1179 │ │ ) │ │ ❱ 1180 │ │ csv_formatter.save() │ │ 1181 │ │ │ │ 1182 │ │ if created_buffer: │ │ 1183 │ │ │ assert isinstance(path_or_buf, StringIO) │ │ │ │ ╭──────────────────────────────────────── locals ─────────────────────────────────────────╮ │ │ │ chunksize = None │ │ │ │ columns = None │ │ │ │ compression = 'infer' │ │ │ │ created_buffer = False │ │ │ │ csv_formatter = <pandas.io.formats.csvs.CSVFormatter object at 0x7f781c8c0e20> │ │ │ │ CSVFormatter = <class 'pandas.io.formats.csvs.CSVFormatter'> │ │ │ │ date_format = None │ │ │ │ doublequote = True │ │ │ │ encoding = None │ │ │ │ errors = 'strict' │ │ │ │ escapechar = None │ │ │ │ index_label = None │ │ │ │ line_terminator = None │ │ │ │ mode = 'w' │ │ │ │ path_or_buf = 'savedagents/extracted_data/results.csv' │ │ │ │ quotechar = '"' │ │ │ │ quoting = None │ │ │ │ self = <pandas.io.formats.format.DataFrameRenderer object at 0x7f781b5123d0> │ │ │ │ sep = ',' │ │ │ │ storage_options = None │ │ │ ╰─────────────────────────────────────────────────────────────────────────────────────────╯ │ │ │ │ /home/julius/Desktop/mlprakt/venv39/lib/python3.9/site-packages/pandas/io/formats/csvs.py:241 in │ │ save │ │ │ │ 238 │ │ Create the writer & save. │ │ 239 │ │ """ │ │ 240 │ │ # apply compression and byte/text conversion │ │ ❱ 241 │ │ with get_handle( │ │ 242 │ │ │ self.filepath_or_buffer, │ │ 243 │ │ │ self.mode, │ │ 244 │ │ │ encoding=self.encoding, │ │ │ │ ╭─────────────────────────────── locals ────────────────────────────────╮ │ │ │ self = <pandas.io.formats.csvs.CSVFormatter object at 0x7f781c8c0e20> │ │ │ ╰───────────────────────────────────────────────────────────────────────╯ │ │ │ │ /home/julius/Desktop/mlprakt/venv39/lib/python3.9/site-packages/pandas/io/common.py:697 in │ │ get_handle │ │ │ │ 694 │ │ │ 695 │ # Only for write methods │ │ 696 │ if "r" not in mode and is_path: │ │ ❱ 697 │ │ check_parent_directory(str(handle)) │ │ 698 │ │ │ 699 │ if compression: │ │ 700 │ │ if compression != "zstd": │ │ │ │ ╭────────────────────────────────────── locals ───────────────────────────────────────╮ │ │ │ compression = None │ │ │ │ compression_args = {} │ │ │ │ encoding = 'utf-8' │ │ │ │ errors = 'strict' │ │ │ │ handle = 'savedagents/extracted_data/results.csv' │ │ │ │ handles = [] │ │ │ │ ioargs = IOArgs( │ │ │ │ │ filepath_or_buffer='savedagents/extracted_data/results.csv', │ │ │ │ │ encoding='utf-8', │ │ │ │ │ mode='w', │ │ │ │ │ compression={'method': None}, │ │ │ │ │ should_close=False │ │ │ │ ) │ │ │ │ is_path = True │ │ │ │ is_text = True │ │ │ │ memory_map = False │ │ │ │ mode = 'w' │ │ │ │ path_or_buf = 'savedagents/extracted_data/results.csv' │ │ │ │ storage_options = None │ │ │ ╰─────────────────────────────────────────────────────────────────────────────────────╯ │ │ │ │ /home/julius/Desktop/mlprakt/venv39/lib/python3.9/site-packages/pandas/io/common.py:571 in │ │ check_parent_directory │ │ │ │ 568 │ """ │ │ 569 │ parent = Path(path).parent │ │ 570 │ if not parent.is_dir(): │ │ ❱ 571 │ │ raise OSError(rf"Cannot save file into a non-existent directory: '{parent}'") │ │ 572 │ │ 573 │ │ 574 @overload │ │ │ │ ╭───────────────────── locals ──────────────────────╮ │ │ │ parent = PosixPath('savedagents/extracted_data') │ │ │ │ path = 'savedagents/extracted_data/results.csv' │ │ │ ╰───────────────────────────────────────────────────╯ │ ╰──────────────────────────────────────────────────────────────────────────────────────────────────╯ OSError: Cannot save file into a non-existent directory: 'savedagents/extracted_data'
wandb: Waiting for W&B process to finish... (failed 1). Press Control-C to abort syncing.
wandb:
wandb:
wandb: Run history:
wandb: eval/mean_ep_length ▁
wandb: eval/mean_reward ▁
wandb: global_step ▁
wandb: test_rewards ▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁▁
wandb: test_success_rate ▁
wandb: time/fps ▁
wandb: train/actor_loss ▁
wandb: train/critic_loss ▁
wandb: train/ent_coef ▁
wandb: train/ent_coef_loss ▁
wandb: train/learning_rate ▁
wandb:
wandb: Run summary:
wandb: eval/mean_ep_length 1.0
wandb: eval/mean_reward 10.0
wandb: global_step 500
wandb: test_rewards 10.0
wandb: test_success_rate 1.0
wandb: time/fps 2.0
wandb: train/actor_loss -0.68808
wandb: train/critic_loss 538.83875
wandb: train/ent_coef 1.03898
wandb: train/ent_coef_loss -0.08977
wandb: train/learning_rate 0.0001
wandb:
wandb: Synced upbeat-field-15: https://wandb.ai/juliusschellenberg/box-gym/runs/3fx1nj44
wandb: Synced 5 W&B file(s), 0 media file(s), 0 artifact file(s) and 2 other file(s)
wandb: Find logs at: ./wandb/run-20221129_132111-3fx1nj44/logs