Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Question Couldn't start socket communication because worker number 0 is still in use

Discussion in 'ML-Agents' started by icecoldt, Jul 8, 2023.

  1. icecoldt

    icecoldt

    Joined:
    Nov 16, 2022
    Posts:
    1
    Hi everyone, I am a beginner to using ML Agents to simulate an environment for DL

    I am trying to trial runs by tinkering through different values between the action space and keep encountering this issue when attempting to run a new trial. I've tried mlagents-learn --force and mlagents-learn --run-id=newtest but both prompt the same error message. Using linux, I am aware of a similar bug occuring in older versions (https://github.com/Unity-Technologies/ml-agents/issues/1505) but solutions didn't fix it. Tried restarting everything but still The error message reads:

    mlagents_envs.exception.UnityWorkerInUseException: Couldn't start socket communication because worker number 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. is still in use. You may need to manually close a previously opened environment or use a different worker number.

    Couldn't connect to trainer on port 5004 using API version 1.5.0. Will perform inference instead.
    UnityEngine.Debug:Log (object)
    Unity.MLAgents.Academy:InitializeEnvironment () (at Library/PackageCache/com.unity.ml-agents@2.0.1/Runtime/Academy.cs:459)

    Please let me know how I can fix this!
     
  2. Luke-Houlihan

    Luke-Houlihan

    Joined:
    Jun 26, 2007
    Posts:
    303
    This is an identified issue with how sockets are assigned by linux. ML Agents cant close the open socket connection (for whatever reason, I'm not sure exactly why) so you'll have to wait for the connection to time out or restart the machine in order to use the same port again.
     
  3. Luke-Houlihan

    Luke-Houlihan

    Joined:
    Jun 26, 2007
    Posts:
    303
    There's probably a group of services you can restart if you don't want to do a full reboot, but I've never been bothered by the issue enough to look into it.