Unity-Technologies / ml-agents

The Unity Machine Learning Agents Toolkit (ML-Agents) is an open-source project that enables games and simulations to serve as environments for training intelligent agents using deep reinforcement learning and imitation learning.
https://unity.com/products/machine-learning-agents
Other
17.12k stars 4.15k forks source link

address already in use #5900

Closed nyck33 closed 1 year ago

nyck33 commented 1 year ago
        behavioral_cloning:     None
[INFO] 3DBall. Step: 12000. Time Elapsed: 18.479 s. Mean Reward: 1.163. Std of Reward: 0.687. Training.
Aborted

That was my first attempt at 3DBall following the tutorial. All subsequent attempts show

$ mlagents-learn config/ppo/3DBall.yaml --run-id=third3dballrun

            ┐  ╖
        ╓╖╬│╡  ││╬╖╖
    ╓╖╬│││││┘  ╬│││││╬╖
 ╖╬│││││╬╜        ╙╬│││││╖╖                               ╗╗╗
 ╬╬╬╬╖││╦╖        ╖╬││╗╣╣╣╬      ╟╣╣╬    ╟╣╣╣             ╜╜╜  ╟╣╣
 ╬╬╬╬╬╬╬╬╖│╬╖╖╓╬╪│╓╣╣╣╣╣╣╣╬      ╟╣╣╬    ╟╣╣╣ ╒╣╣╖╗╣╣╣╗   ╣╣╣ ╣╣╣╣╣╣ ╟╣╣╖   ╣╣╣
 ╬╬╬╬┐  ╙╬╬╬╬│╓╣╣╣╝╜  ╫╣╣╣╬      ╟╣╣╬    ╟╣╣╣ ╟╣╣╣╙ ╙╣╣╣  ╣╣╣ ╙╟╣╣╜╙  ╫╣╣  ╟╣╣
 ╬╬╬╬┐     ╙╬╬╣╣      ╫╣╣╣╬      ╟╣╣╬    ╟╣╣╣ ╟╣╣╬   ╣╣╣  ╣╣╣  ╟╣╣     ╣╣╣┌╣╣╜
 ╬╬╬╜       ╬╬╣╣      ╙╝╣╣╬      ╙╣╣╣╗╖╓╗╣╣╣╜ ╟╣╣╬   ╣╣╣  ╣╣╣  ╟╣╣╦╓    ╣╣╣╣╣
 ╙   ╓╦╖    ╬╬╣╣   ╓╗╗╖            ╙╝╣╣╣╣╝╜   ╘╝╝╜   ╝╝╝  ╝╝╝   ╙╣╣╣    ╟╣╣╣
   ╩╬╬╬╬╬╬╦╦╬╬╣╣╗╣╣╣╣╣╣╣╝
╫╣╣╣╣
      ╙╬╬╬╬╬╬╬╣╣╣╣╣╣╝╜
          ╙╬╬╬╣╣╣╜
             ╙

 Version information:
  ml-agents: 0.30.0,
  ml-agents-envs: 0.30.0,
  Communicator API: 1.5.0,
  PyTorch: 1.7.1+rocm3.8
[ERROR] UnityEnvironment worker 0: environment raised an unexpected exception.
Traceback (most recent call last):
  File "/home/nobu/miniconda3/envs/unityml/lib/python3.8/site-packages/mlagents_envs/rpc_communicator.py", line 87, in check_port
    s.bind(("localhost", port))
OSError: [Errno 98] Address already in use

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/nobu/miniconda3/envs/unityml/lib/python3.8/site-packages/mlagents/trainers/subprocess_env_manager.py", line 163, in worker
    env = env_factory(worker_id, side_channels)
  File "/home/nobu/miniconda3/envs/unityml/lib/python3.8/site-packages/mlagents/trainers/learn.py", line 187, in create_unity_environment
    return UnityEnvironment(
  File "/home/nobu/miniconda3/envs/unityml/lib/python3.8/site-packages/mlagents_envs/environment.py", line 189, in __init__
    self._communicator = self._get_communicator(worker_id, base_port, timeout_wait)
  File "/home/nobu/miniconda3/envs/unityml/lib/python3.8/site-packages/mlagents_envs/environment.py", line 267, in _get_communicator
    return RpcCommunicator(worker_id, base_port, timeout_wait)
  File "/home/nobu/miniconda3/envs/unityml/lib/python3.8/site-packages/mlagents_envs/rpc_communicator.py", line 51, in __init__
    self.create_server()
  File "/home/nobu/miniconda3/envs/unityml/lib/python3.8/site-packages/mlagents_envs/rpc_communicator.py", line 57, in create_server
    self.check_port(self.port)
  File "/home/nobu/miniconda3/envs/unityml/lib/python3.8/site-packages/mlagents_envs/rpc_communicator.py", line 89, in check_port
    raise UnityWorkerInUseException(self.worker_id)
mlagents_envs.exception.UnityWorkerInUseException: Couldn't start socket communication because worker number 0 is still in use. You may need to manually close a previously opened environment or use a different worker number.
[INFO] Learning was interrupted. Please wait while the graph is generated.
Traceback (most recent call last):
  File "/home/nobu/miniconda3/envs/unityml/lib/python3.8/site-packages/mlagents/trainers/subprocess_env_manager.py", line 92, in send
    self.conn.send(req)
  File "/home/nobu/miniconda3/envs/unityml/lib/python3.8/multiprocessing/connection.py", line 206, in send
    self._send_bytes(_ForkingPickler.dumps(obj))
  File "/home/nobu/miniconda3/envs/unityml/lib/python3.8/multiprocessing/connection.py", line 411, in _send_bytes
    self._send(header + buf)
  File "/home/nobu/miniconda3/envs/unityml/lib/python3.8/multiprocessing/connection.py", line 368, in _send
    n = write(self._handle, buf)
BrokenPipeError: [Errno 32] Broken pipe

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/nobu/miniconda3/envs/unityml/bin/mlagents-learn", line 8, in <module>
    sys.exit(main())
  File "/home/nobu/miniconda3/envs/unityml/lib/python3.8/site-packages/mlagents/trainers/learn.py", line 264, in main
    run_cli(parse_command_line())
  File "/home/nobu/miniconda3/envs/unityml/lib/python3.8/site-packages/mlagents/trainers/learn.py", line 260, in run_cli
    run_training(run_seed, options, num_areas)
  File "/home/nobu/miniconda3/envs/unityml/lib/python3.8/site-packages/mlagents/trainers/learn.py", line 136, in run_training
    tc.start_learning(env_manager)
  File "/home/nobu/miniconda3/envs/unityml/lib/python3.8/site-packages/mlagents_envs/timers.py", line 305, in wrapped
    return func(*args, **kwargs)
  File "/home/nobu/miniconda3/envs/unityml/lib/python3.8/site-packages/mlagents/trainers/trainer_controller.py", line 197, in start_learning    raise ex
  File "/home/nobu/miniconda3/envs/unityml/lib/python3.8/site-packages/mlagents/trainers/trainer_controller.py", line 172, in start_learning    self._reset_env(env_manager)
  File "/home/nobu/miniconda3/envs/unityml/lib/python3.8/site-packages/mlagents_envs/timers.py", line 305, in wrapped
    return func(*args, **kwargs)
  File "/home/nobu/miniconda3/envs/unityml/lib/python3.8/site-packages/mlagents/trainers/trainer_controller.py", line 105, in _reset_env
    env_manager.reset(config=new_config)
  File "/home/nobu/miniconda3/envs/unityml/lib/python3.8/site-packages/mlagents/trainers/env_manager.py", line 68, in reset
    self.first_step_infos = self._reset_env(config)
  File "/home/nobu/miniconda3/envs/unityml/lib/python3.8/site-packages/mlagents/trainers/subprocess_env_manager.py", line 440, in _reset_env    self.set_env_parameters(config)
  File "/home/nobu/miniconda3/envs/unityml/lib/python3.8/site-packages/mlagents/trainers/subprocess_env_manager.py", line 457, in set_env_parameters
    ew.send(EnvironmentCommand.ENVIRONMENT_PARAMETERS, config)
  File "/home/nobu/miniconda3/envs/unityml/lib/python3.8/site-packages/mlagents/trainers/subprocess_env_manager.py", line 94, in send
    raise UnityCommunicationException("UnityEnvironment worker: send failed.")
mlagents_envs.exception.UnityCommunicationException: UnityEnvironment worker: send failed.
miguelalonsojr commented 1 year ago

Please resubmit your bug report using our template. This will allow us to try to reproduce the error. Also, We are unable to help reproduce bugs with custom environments. Please attempt to reproduce your issue with one of the example environments, or provide a minimal patch to one of the environments needed to reproduce the issue.