jlubars / RL-MPC-LaneMerging

Combining Reinforcement Learning with Model Predictive Control for On-Ramp Merging
106 stars 18 forks source link

Permissionerror #3

Open zhouwy-lv opened 3 years ago

zhouwy-lv commented 3 years ago

Hi! Dear author When i run the code, i get the error: Traceback (most recent call last): File "E:/py_project/RL-MPC-LaneMerging-master/main.py", line 102, in do_task() File "E:/py_project/RL-MPC-LaneMerging-master/main.py", line 22, in do_task rainbow.train_rainbow_all_with_lr_drop(100) File "E:\py_project\RL-MPC-LaneMerging-master\rainbow.py", line 90, in train_rainbow_all_with_lr_drop RainbowAgent.train(num_frames) File "E:\py_project\RL-MPC-LaneMerging-master\rainbow.py", line 59, in train rmtree(default_log_dir) File "D:\Anaconda3\Anaconda3\envs\torch-gpu\lib\shutil.py", line 516, in rmtree return _rmtree_unsafe(path, onerror) File "D:\Anaconda3\Anaconda3\envs\torch-gpu\lib\shutil.py", line 400, in _rmtree_unsafe onerror(os.unlink, fullname, sys.exc_info()) File "D:\Anaconda3\Anaconda3\envs\torch-gpu\lib\shutil.py", line 398, in _rmtree_unsafe os.unlink(fullname) PermissionError: [WinError 32] The process cannot access the file because it is being used by another process: 'runs\_rainbow 2021 01 17 08 42 39 061952\events.out.tfevents.1610844159.DESKTOP-FR0HN55'

I found that the error come from: rmtree(default_log_dir) In the program, I just changed the number of training rounds for easy viewing of the code If I comment “copy_tree(default_log_dir, Settings.FULL_LOG_DIR) rmtree(default_log_dir)” out, the following error will appear: Traceback (most recent call last): File "E:/py_project/RL-MPC-LaneMerging-master/main.py", line 102, in do_task() File "E:/py_project/RL-MPC-LaneMerging-master/main.py", line 22, in do_task rainbow.train_rainbow_all_with_lr_drop(100) File "E:\py_project\RL-MPC-LaneMerging-master\rainbow.py", line 95, in train_rainbow_all_with_lr_drop RainbowAgent.resume_training(old_log_dir, num_frames) File "E:\py_project\RL-MPC-LaneMerging-master\rainbow.py", line 68, in resume_training q_dist_module = torch.load(os.path.join(path, "q_dist.pt"), map_location='cpu').to(rl_agent.device) File "D:\Anaconda3\Anaconda3\envs\torch-gpu\lib\site-packages\torch\serialization.py", line 581, in load with _open_file_like(f, 'rb') as opened_file: File "D:\Anaconda3\Anaconda3\envs\torch-gpu\lib\site-packages\torch\serialization.py", line 230, in _open_file_like return _open_file(name_or_buffer, mode) File "D:\Anaconda3\Anaconda3\envs\torch-gpu\lib\site-packages\torch\serialization.py", line 211, in init super(_open_file, self).init(open(name, mode)) FileNotFoundError: [Errno 2] No such file or directory: 'runs\last_run\q_dist.pt'

I am looking forward to your reply! Thanks very much!!!

jlubars commented 4 months ago

I'm super late, but when testing things this weekend I managed to reproduce this and it should be fixed in the latest commit.