Search Unity

  1. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice
  2. Unity is excited to announce that we will be collaborating with TheXPlace for a summer game jam from June 13 - June 19. Learn more.
    Dismiss Notice
  3. Dismiss Notice

Question How can I run mlagents on the GPU?

Discussion in 'ML-Agents' started by ratdox, Dec 26, 2020.

  1. ratdox

    ratdox

    Joined:
    Dec 17, 2020
    Posts:
    12
    I've been trying to figure out how to run mlagents on the GPU, since colab runs it on the K80 and has significantly better performance than on my local machine running it on my CPU.

    Pytorch says that cuda is available but I haven't been able to find any resources telling me how I can enable it.


    Any ideas?
     
    orhun868 likes this.
  2. akTwelve

    akTwelve

    Joined:
    Oct 7, 2013
    Posts:
    8
    The mlagents-learn command (from an Anaconda terminal) seems to use GPU by default. You can see the CUDA activity in the Task Manager on Windows. The command I used to get the following screenshot was essentially
    mlagents-learn path/to/MyConfig.yaml --run-id run_01

    mla-cuda-screenshot.png
     
    EarthHobbit likes this.
  3. ratdox

    ratdox

    Joined:
    Dec 17, 2020
    Posts:
    12
    Interesting, something has to be badly set-up on my end then because as you can see, there's 0 CUDA utilization.

    Both PPO and SAC behave the same way. :(
     

    Attached Files:

  4. ratdox

    ratdox

    Joined:
    Dec 17, 2020
    Posts:
    12
    Okay, so I don't know if my problem was related to release-10 or my conda env, but I installed release 12 in a new conda environment and now torch shows up as 1.7.0+cu110 as opposed to 1.7.0+CPU. I most probably bonked something during the install of the previous release.

    EDIT: Cuda performance is much better than using just the CPU, I'm now starting to wonder if the people claiming that GPU training is slower or about the same as CPU were infact training using multiple environments or just the one in their unity editor.
     
    Last edited: Dec 27, 2020
  5. Gatsby17

    Gatsby17

    Joined:
    Feb 5, 2024
    Posts:
    1
    Do you figure it out bro