Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    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