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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

CPU vs GPU

Discussion in 'ML-Agents' started by James_Initus, Jun 24, 2020.

  1. James_Initus

    James_Initus

    Joined:
    May 26, 2015
    Posts:
    75
    Hi, looking at resource utilization it seems my CPU is highly taces versus my GPU?

    I am not specifying CPU use and GPU, my understanding is that by default it uses the GPU.

    Is this normal?

    Here are some details.






    C:\mlagents>mlagents-learn config/EnemyAI.yaml --run-id=EnemyBehavior
    WARNING:tensorflow:From c:\users\james\appdata\local\programs\python\python36\lib\site-packages\tensorflow_core\python\compat\v2_compat.py:65: disable_resource_variables (from tensorflow.python.ops.variable_scope) is deprecated and will be removed in a future version.
    Instructions for updating:
    non-resource variables are not supported in the long term


    ▄▄▄▓▓▓▓
    ╓▓▓▓▓▓▓█▓▓▓▓▓
    ,▄▄▄m▀▀▀' ,▓▓▓▀▓▓▄ ▓▓▓ ▓▓▌
    ▄▓▓▓▀' ▄▓▓▀ ▓▓▓ ▄▄ ▄▄ ,▄▄ ▄▄▄▄ ,▄▄ ▄▓▓▌▄ ▄▄▄ ,▄▄
    ▄▓▓▓▀ ▄▓▓▀ ▐▓▓▌ ▓▓▌ ▐▓▓ ▐▓▓▓▀▀▀▓▓▌ ▓▓▓ ▀▓▓▌▀ ^▓▓▌ ╒▓▓▌
    ▄▓▓▓▓▓▄▄▄▄▄▄▄▄▓▓▓ ▓▀ ▓▓▌ ▐▓▓ ▐▓▓ ▓▓▓ ▓▓▓ ▓▓▌ ▐▓▓▄ ▓▓▌
    ▀▓▓▓▓▀▀▀▀▀▀▀▀▀▀▓▓▄ ▓▓ ▓▓▌ ▐▓▓ ▐▓▓ ▓▓▓ ▓▓▓ ▓▓▌ ▐▓▓▐▓▓
    ^█▓▓▓ ▀▓▓▄ ▐▓▓▌ ▓▓▓▓▄▓▓▓▓ ▐▓▓ ▓▓▓ ▓▓▓ ▓▓▓▄ ▓▓▓▓`
    '▀▓▓▓▄ ^▓▓▓ ▓▓▓ └▀▀▀▀ ▀▀ ^▀▀ `▀▀ `▀▀ '▀▀ ▐▓▓▌
    ▀▀▀▀▓▄▄▄ ▓▓▓▓▓▓, ▓▓▓▓▀
    `▀█▓▓▓▓▓▓▓▓▓▌
    ¬`▀▀▀█▓


    Version information:
    ml-agents: 0.17.0,
    ml-agents-envs: 0.17.0,
    Communicator API: 1.0.0,
    TensorFlow: 2.0.0
    WARNING:tensorflow:From c:\users\james\appdata\local\programs\python\python36\lib\site-packages\tensorflow_core\python\compat\v2_compat.py:65: disable_resource_variables (from tensorflow.python.ops.variable_scope) is deprecated and will be removed in a future version.
    Instructions for updating:
    non-resource variables are not supported in the long term
    2020-06-24 09:32:53 INFO [environment.py:199] Listening on port 5004. Start training by pressing the Play button in the Unity Editor.
    2020-06-24 09:32:55 INFO [environment.py:108] Connected to Unity environment with package version 1.0.2 and communication version 1.0.0
    2020-06-24 09:32:55 INFO [environment.py:265] Connected new brain:
    EnemyBehavior?team=0
    2020-06-24 09:32:55.536552: I tensorflow/core/platform/cpu_feature_guard.cc:142] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2
    2020-06-24 09:32:55 INFO [stats.py:130] Hyperparameters for behavior name EnemyBehavior:
    trainer_type: ppo
    hyperparameters:
    batch_size: 4024
    buffer_size: 40240
    learning_rate: 0.0003
    beta: 0.007
    epsilon: 0.2
    lambd: 0.95
    num_epoch: 5
    learning_rate_schedule: linear
    network_settings:
    normalize: True
    hidden_units: 512
    num_layers: 8
    vis_encode_type: simple
    memory: None
    reward_signals:
    extrinsic:
    gamma: 0.995
    strength: 1.0
    init_path: None
    keep_checkpoints: 5
    checkpoint_interval: 500000
    max_steps: 50000000
    time_horizon: 1000
    summary_freq: 30000
    threaded: True
    self_play: None
    behavioral_cloning: None
     
  2. MrWetsnow

    MrWetsnow

    Joined:
    Jan 5, 2020
    Posts:
    60
    By default, for training, it will use CPU. Based on the recommendations in other threads on this subject, you are better off using your CPU for training. It will be faster in most cases.
     
  3. James_Initus

    James_Initus

    Joined:
    May 26, 2015
    Posts:
    75
  4. James_Initus

    James_Initus

    Joined:
    May 26, 2015
    Posts:
    75
  5. ervteng_unity

    ervteng_unity

    Unity Technologies

    Joined:
    Dec 6, 2018
    Posts:
    150
    There was once a CLI flag that let you force CPU, but it was removed. Whether or not ML-Agents uses CPU depends on the build of TensorFlow installed - there is one for CPU and one for GPU. See TF's guide here: https://www.tensorflow.org/install/pip
    If you have the GPU build of TF installed and want to use CPU, you can set an environment variable before the ml-agents command. e.g.:
    CUDA_VISIBLE_DEVICES=0 mlagents-learn <other flags>