Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

How can i use Ml-Agents training on my CPU?

Discussion in 'ML-Agents' started by nitagas, Jul 16, 2021.

  1. nitagas

    nitagas

    Joined:
    Jul 16, 2021
    Posts:
    1
    Hi, I have a problem with agent training. I wrote the command
    mlagents-learn config / ppo / 3DBall.yaml --run-id = first3DBallRun
    in the console, but the training did not start and an error occurred.


    Version information:
    ml-agents: 0.27.0,
    ml-agents-envs: 0.27.0,
    Communicator API: 1.5.0,
    PyTorch: 1.7.1+cu110
    C:\Users\Admin\AppData\Roaming\Python\Python39\site-packages\torch\cuda\__init__.py:52: UserWarning: CUDA initialization: Found no NVIDIA driver on your system. Please check that you have an NVIDIA GPU and installed a driver from http://www.nvidia.com/Download/index.aspx (Triggered internally at ..\c10\cuda\CUDAFunctions.cpp:100.)
    return torch._C._cuda_getDeviceCount() > 0
    [INFO] Listening on port 5004. Start training by pressing the Play button in the Unity Editor.
    Traceback (most recent call last):
    File "c:\program files\python39\lib\runpy.py", line 197, in _run_module_as_main
    return _run_code(code, main_globals, None,
    File "c:\program files\python39\lib\runpy.py", line 87, in _run_code
    exec(code, run_globals)
    File "C:\Users\Admin\AppData\Roaming\Python\Python39\Scripts\mlagents-learn.exe\__main__.py", line 7, in <module>
    File "C:\Users\Admin\AppData\Roaming\Python\Python39\site-packages\mlagents\trainers\learn.py", line 250, in main
    run_cli(parse_command_line())
    File "C:\Users\Admin\AppData\Roaming\Python\Python39\site-packages\mlagents\trainers\learn.py", line 246, in run_cli
    run_training(run_seed, options)
    File "C:\Users\Admin\AppData\Roaming\Python\Python39\site-packages\mlagents\trainers\learn.py", line 125, in run_training
    tc.start_learning(env_manager)
    File "C:\Users\Admin\AppData\Roaming\Python\Python39\site-packages\mlagents_envs\timers.py", line 305, in wrapped
    return func(*args, **kwargs)
    File "C:\Users\Admin\AppData\Roaming\Python\Python39\site-packages\mlagents\trainers\trainer_controller.py", line 173, in start_learning
    self._reset_env(env_manager)
    File "C:\Users\Admin\AppData\Roaming\Python\Python39\site-packages\mlagents_envs\timers.py", line 305, in wrapped
    return func(*args, **kwargs)
    File "C:\Users\Admin\AppData\Roaming\Python\Python39\site-packages\mlagents\trainers\trainer_controller.py", line 105, in _reset_env
    env_manager.reset(config=new_config)
    File "C:\Users\Admin\AppData\Roaming\Python\Python39\site-packages\mlagents\trainers\env_manager.py", line 68, in reset
    self.first_step_infos = self._reset_env(config)
    File "C:\Users\Admin\AppData\Roaming\Python\Python39\site-packages\mlagents\trainers\subprocess_env_manager.py", line 333, in _reset_env
    ew.previous_step = EnvironmentStep(ew.recv().payload, ew.worker_id, {}, {})
    File "C:\Users\Admin\AppData\Roaming\Python\Python39\site-packages\mlagents\trainers\subprocess_env_manager.py", line 98, in recv
    raise env_exception
    mlagents_envs.exception.UnityTimeOutException: The Unity environment took too long to respond. Make sure that :
    The environment does not need user interaction to launch
    The Agents' Behavior Parameters > Behavior Type is set to "Default"
    The environment and the Python interface have compatible versions.



    As I understand it, I need to install the NVIDIA drivers.

    But my laptop has the following GPU installed:
    image.PNG

    Therefore, I thought that I would not be able to train agents on my GPU. But I don't know how to train them on my CPU.

    Are there any options for solving this problem?
     
  2. ervteng_unity

    ervteng_unity

    Unity Technologies

    Joined:
    Dec 6, 2018
    Posts:
    150
    You should be able to train on CPU. I think the Unity environment isn't starting. Does a little window pop up with some agents in it?

    Actually just re-read your post. You'll need to open the Unity editor and hit the play button shortly after running the python command.
     
  3. Ahmar1911

    Ahmar1911

    Joined:
    Jan 30, 2023
    Posts:
    4
    I have the same problem
     
  4. hughperkins

    hughperkins

    Joined:
    Dec 3, 2022
    Posts:
    191
    this is a 1.5 year old thread :D The versions of torch and everything are likely completely different. I feel you might consider creating a brand new thread tbh, but at a minimum share full details of your own problem, similar to the original poster, but for your own machine and environment now.
     
    Ahmar1911 likes this.
  5. Ahmar1911

    Ahmar1911

    Joined:
    Jan 30, 2023
    Posts:
    4
    I am new to this platform and dont know how to make a new thread

    I am trying to train the 3D Ball environment in Unity but according to the guide it only trains with GPU

    This is the guide im using: https://github.com/Unity-Technologies/ml-agents/blob/develop/docs/Getting-Started.md




    This is the command I run: mlagents-learn config/ppo/3DBall.yaml --run-id=first3DBallRun


    This is the error Im getting:

    C:\Users\hussa\python-envs\sample-env\lib\site-packages\torch\cuda\__init__.py:52: UserWarning: CUDA initialization: Found no NVIDIA driver on your system. Please check that you have an NVIDIA GPU and installed a driver from http://www.nvidia.com/Download/index.aspx (Triggered internally at ..\c10\cuda\CUDAFunctions.cpp:100.)
    return torch._C._cuda_getDeviceCount() > 0
    Traceback (most recent call last):
    File "C:\Users\hussa\python-envs\sample-env\lib\site-packages\mlagents\trainers\cli_utils.py", line 306, in load_config
    with open(config_path) as data_file:
    FileNotFoundError: [Errno 2] No such file or directory: 'config/ppo/3DBall.yaml'
    During handling of the above exception, another exception occurred:
    Traceback (most recent call last):
    File "C:\Users\hussa\python-envs\sample-env\Scripts\mlagents-learn-script.py", line 33, in <module>
    sys.exit(load_entry_point('mlagents==0.30.0', 'console_scripts', 'mlagents-learn')())
    File "C:\Users\hussa\python-envs\sample-env\lib\site-packages\mlagents\trainers\learn.py", line 264, in main
    run_cli(parse_command_line())
    File "C:\Users\hussa\python-envs\sample-env\lib\site-packages\mlagents\trainers\learn.py", line 56, in parse_command_line
    return RunOptions.from_argparse(args)
    File "C:\Users\hussa\python-envs\sample-env\lib\site-packages\mlagents\trainers\settings.py", line 899, in from_argparse
    configured_dict.update(load_config(config_path))
    File "C:\Users\hussa\python-envs\sample-env\lib\site-packages\mlagents\trainers\cli_utils.py", line 310, in load_config
    raise TrainerConfigError(f"Config file could not be found at {abs_path}.")
    mlagents.trainers.exception.TrainerConfigError: Config file could not be found at C:\Users\hussa\python-envs\sample-env\Scripts\config\ppo\3DBall.yaml.
     
  6. hughperkins

    hughperkins

    Joined:
    Dec 3, 2022
    Posts:
    191
  7. Ahmar1911

    Ahmar1911

    Joined:
    Jan 30, 2023
    Posts:
    4
    I already have this file from the github repo that I cloned. Does it have to be in that location specified in the error?

    This is the github repo i cloned:
    git clone --branch release_19 https://github.com/Unity-Technologies/ml-agents.git

    and I guess the problem is that it requires a GPU to be trained, dont you think so?
     
  8. hughperkins

    hughperkins

    Joined:
    Dec 3, 2022
    Posts:
    191
    > and I guess the problem is that it requires a GPU to be trained, dont you think so?

    That's not what the error message says. And no, GPU is not required, to use mlagents.

    > I already have this file from the github repo that I cloned. Does it have to be in that location specified in the error?

    Yup. Or give the correct full path to where it really is, on the commandline.
     
  9. Ahmar1911

    Ahmar1911

    Joined:
    Jan 30, 2023
    Posts:
    4
    yep you were right, thanks for all the help it works now
     
    hughperkins likes this.