Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at id.unity.com during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.


    Read our full announcement for more information and let us know if you have any questions.

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>