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

High CPU Usage!

Discussion in 'Linux' started by Scellow, Aug 26, 2015.

  1. Deleted User

    Deleted User

    Guest

    I'm using Arch + KDE, Unity 5.4.0b16 stand alone version.
    Still having this issue, it's very annoying, 100% CPU usage.
    On Windows 10, the CPU usage is amazingly low T-T :oops:
     
    kmare likes this.
  2. Nagodar

    Nagodar

    Joined:
    May 7, 2016
    Posts:
    2
    anyone has found a solution for this? I'm exactly with the same problem, once I run unity it eats up one core of my laptop

    Build #2016050301 5.3.4f1 version
     
  3. Nagodar

    Nagodar

    Joined:
    May 7, 2016
    Posts:
    2
    Confirmed it happens in Ubuntu 14.04 and Ubuntu 12.04. Very easy to reproduce:
    - Install Ubuntu Desktop (14.04 or 12.04)
    - Install Unity - tested 5.4.0b16 and 5.3.4.f1( Build #2016050301 and #Build #2016031701)
    - Launch Unity, it will eat up one whole core.
     
    kmare likes this.
  4. malegretti

    malegretti

    Joined:
    Feb 15, 2016
    Posts:
    8
    Also happening here, Ubuntu 16.04
     
  5. ichbinder23

    ichbinder23

    Joined:
    Feb 15, 2016
    Posts:
    1
    I have the same problem. My system: ThinkPad x220, Fedora 23, Unity v 5.4.0b16.
    My Laptop burnt :) ca. 85 degree in idle mode.
     
  6. smekras

    smekras

    Joined:
    May 17, 2016
    Posts:
    1
    Same problem here, both on my personal PC and the company ones. We've tried it on Fedora/Red Hat, OpenSuse, and Ubuntu, every time having at least one CPU at 100%.
    We like Unity, but with this issue, we're considering switching to one of the alternatives (likely Unreal Engine).
     
    ma1onso and kmare like this.
  7. mosaic_school

    mosaic_school

    Joined:
    Dec 12, 2012
    Posts:
    74
    Same on Ubuntu 16.04
     
  8. ReaktorDave

    ReaktorDave

    Joined:
    May 8, 2014
    Posts:
    139
  9. malegretti

    malegretti

    Joined:
    Feb 15, 2016
    Posts:
    8
    Can anyone confirm if the issue remains in the recently released 5.3.5f1?

    I am satisfied with 5.3.4, but if the update fixed this it will certainly be worth it.
     
  10. Odd-Redesign

    Odd-Redesign

    Joined:
    Jul 26, 2013
    Posts:
    134
    Nope, I just installed 5.3.5 on Ubuntu 16.04 and it's still using one full core on idle.

    It works good, though, even on an 8 year old dual core laptop.
     
    malegretti likes this.
  11. Bartwillemsen

    Bartwillemsen

    Joined:
    Apr 13, 2016
    Posts:
    5
    Same here. Running the just released 5.3.5 release and one core is used for 100%.
     
    malegretti likes this.
  12. ReaktorDave

    ReaktorDave

    Joined:
    May 8, 2014
    Posts:
    139
    Would love an ETA on this.
     
    BestCommie and kmare like this.
  13. BestCommie

    BestCommie

    Joined:
    Sep 28, 2015
    Posts:
    8
    For the $*%$&%$*^%$ This bug is first reported 26/05/2015 and it's still here almost a year. OK it's not breaking developing but how hard can it be to solve??!!?! It's not present at windows but it is here meaning that in the windows build the solution exists!!! Fix it already please :(
     
    kmare likes this.
  14. sarmadka

    sarmadka

    Joined:
    Sep 22, 2015
    Posts:
    1
    The strange thing is that when you start your app (by clicking the play button) CPU usage drops to around 40% (from 100%). So, Unity takes LESS cpu running your game than it takes doing nothing!
     
  15. manau

    manau

    Joined:
    Nov 2, 2013
    Posts:
    4
    Also happening to me, on Arch.
     
  16. Deleted User

    Deleted User

    Guest

    Same here!
    Ubuntu 16.04, Unity Editor v5.3.5f
     
  17. staffanp

    staffanp

    Joined:
    Jun 12, 2016
    Posts:
    3
    Hope it will be fixed (16.04 - 5.3.5)
    I made a small bash script that I'm using to quickly be able to switch on and off the cpulimit solution:
    Code (CSharp):
    1. #!/bin/bash
    2. unitypid=$(ps -ef | grep "Unity$" | grep -o [0-9]* | head -1)
    3. if [ -z ${unitypid} ]; then
    4.   echo "Unity not running?"
    5. else
    6.    echo "Unity found: Limiting cpu"
    7.    cpulimit -p ${unitypid} -l 50
    8. fi
    use it if you want to :)
     
  18. staffanp

    staffanp

    Joined:
    Jun 12, 2016
    Posts:
    3
    I ended up making a script to run in the background, I noticed that compiz got a much higher cpu when running the game than when unity was idle so it as a hint to know that I should stop limiting the unity process and vice versa, it works quite well after tuning the ...CPU_BEGIN / ...CPU_END params in the script

    Code (CSharp):
    1. #!/bin/bash
    2.  
    3. HINT_PROC_NAME="compiz"
    4. HINT_PROC_CPU_BEGIN=20
    5. HINT_PROC_CPU_END=6
    6.  
    7. function findPID() {
    8.     local pidId=$(ps -ef | grep -v "grep" | grep "$1" | grep -o [0-9]* | head -1)
    9.     echo ${pidId}
    10. }
    11.  
    12. function findCPU() {
    13.     local cpuUsage=$(top -b -n1 -p $1 | tail -1 | sed 's/  */ /g' | cut -d' ' -f10 | cut -d',' -f1)
    14.     echo ${cpuUsage}
    15. }
    16.  
    17. while true; do
    18.     unityPid=$(findPID Unity$)
    19.  
    20.     if ! [[ -z "${unityPid}" ]]; then
    21.  
    22.         hintPid=$(findPID ${HINT_PROC_NAME})
    23.         hintCpu=$(findCPU ${hintPid})
    24.         cpulimitPid=$(findPID cpulimit)
    25.        
    26.         if [ ${hintCpu} -gt ${HINT_PROC_CPU_BEGIN} ]; then
    27.             if ! [ -z ${cpulimitPid} ]; then
    28.                 echo "Stop cpulimit (Unity entered GAME MODE)"
    29.                 kill -9 ${cpulimitPid}
    30.             fi
    31.         elif [ ${hintCpu} -lt ${HINT_PROC_CPU_END} ]; then
    32.             if [ -z ${cpulimitPid} ]; then
    33.                echo "Start cpulimit (Unity is IDLE)"
    34.                cpulimit -p ${unityPid} -l 50 &
    35.             fi
    36.         fi
    37.     else
    38.         echo "Unity not running?"
    39.     fi
    40.    
    41.     sleep 1
    42. done
     
  19. BestCommie

    BestCommie

    Joined:
    Sep 28, 2015
    Posts:
    8
    It's even worse for me at 5.4.0b23 Linux Mint 17.3 Rosa. On starting Unity it rests at 50%. If i hit the play button and stop anytime after it it rests @ 100%(a bit less but it would if it could). Dual Core system.

    Can anyone with more than 2 cores confirm if this happens gradually in their system or all 4+ cores max out at once? IF it would be gradual i guess it would mean that a thread is spawned (every time play or stop is pressed)and not controlled after that(killed and what not).
     
  20. Kennnnny

    Kennnnny

    Joined:
    Oct 6, 2012
    Posts:
    2
    If I run this script, it throws an error for line 24 and line 29: integer expression expected.
    I would really like to use this script because this bug is extremely annoying.

    Thanks for your effort so far.

     
  21. staffanp

    staffanp

    Joined:
    Jun 12, 2016
    Posts:
    3
    I fixed one problem with quotes in the script below (not sure how they disappeared), can you try it again? If it still doesn't work, uncomment set -x, run it and post the print out here

    Code (CSharp):
    1.  
    2. #!/bin/bash
    3. #set -x
    4.  
    5. HINT_PROC_NAME="compiz"
    6. HINT_PROC_CPU_BEGIN=20
    7. HINT_PROC_CPU_END=6
    8.  
    9. function findPID() {
    10.     local pidId=$(ps -ef | grep -v "grep" | grep "$1" | grep -o "[0-9]*" | head -1)
    11.     echo ${pidId}
    12. }
    13.  
    14. function findCPU() {
    15.     local cpuUsage=$(top -b -n1 -p $1 | tail -1 | sed 's/  */ /g' | cut -d' ' -f10 | cut -d',' -f1)
    16.     echo ${cpuUsage}
    17. }
    18.  
    19. while true; do
    20.     unityPid=$(findPID Unity$)
    21.     if ! [[ -z "${unityPid}" ]]; then
    22.         hintPid=$(findPID ${HINT_PROC_NAME})
    23.         hintCpu=$(findCPU ${hintPid})
    24.         cpulimitPid=$(findPID cpulimit)
    25.      
    26.         if [ ${hintCpu} -gt ${HINT_PROC_CPU_BEGIN} ]; then
    27.             if ! [ -z ${cpulimitPid} ]; then
    28.                 echo "Stop cpulimit (Unity entered GAME MODE)"
    29.                 kill -9 ${cpulimitPid}
    30.             fi
    31.         elif [ ${hintCpu} -lt ${HINT_PROC_CPU_END} ]; then
    32.             if [ -z ${cpulimitPid} ]; then
    33.                echo "Start cpulimit (Unity is IDLE)"
    34.                cpulimit -p ${unityPid} -l 50 &
    35.             fi
    36.         fi
    37.     else
    38.         echo "Unity not running?"
    39.     fi
    40.  
    41.     sleep 1
    42. done
    43.  
    44.  

     
  22. Deleted User

    Deleted User

    Guest

    Any answer from any Unity Developer?
    Still happening.
     
    kmare likes this.
  23. aroskuski

    aroskuski

    Joined:
    Sep 9, 2015
    Posts:
    7
    The post got sort of lost in the forum rollback, but this was posted a week ago:
    I tried the more involved workaround in that linked blogpost myself and it seems to work much more elegantly than the cpulimit method.

    Also might give some insight to devs on exactly what is wrong.
     
  24. Tak

    Tak

    Joined:
    Mar 8, 2010
    Posts:
    1,001
    This is currently a known issue.
     
  25. laurentroyer

    laurentroyer

    Joined:
    Feb 11, 2016
    Posts:
    1
    This known issue is still there in 5.4.0rc1 .
    I personally regard the (non) fix delay as unacceptable.
     
  26. DenisRusskih

    DenisRusskih

    Joined:
    Jul 18, 2016
    Posts:
    7
    This is currently a respectable wise old issue, it is an unique architectural monument on its way to UNESCO list, so it will never be fixed. :)
     
    Deleted User likes this.
  27. Deleted User

    Deleted User

    Guest

    Hi Tak,

    I already know this, because you posted the same answer on Aug 27, ---2015---
    I just wanted to know if theres any news on when this bug will be fixed. :D

    I love Unity and just wanted be able to use on linux.
    And make me sad, because a bug like this would be fixed really fast on Windows...
     
    LeonH likes this.
  28. arcooke

    arcooke

    Joined:
    Sep 1, 2014
    Posts:
    29
    Thanks a lot for the acknowledgement, that goes a long way. Hope to see this fixed soon.. definitely the biggest showstopper currently.
     
  29. thiagomaia

    thiagomaia

    Joined:
    Sep 4, 2016
    Posts:
    5
    A workaround on linux, at least to stop burning the fingers.
    sudo apt-get install cpulimit
    run "top" to find the unity process id, let says the process is 1234
    cpulimit -p 1234 -l 50
    it will make it use just 50% of cpu, and so far it seems working well even with the limitation
     
  30. aroskuski

    aroskuski

    Joined:
    Sep 9, 2015
    Posts:
    7
    This blog post contains a much more elegant workaround than using cpulimit
     
    thiagomaia likes this.
  31. thiagomaia

    thiagomaia

    Joined:
    Sep 4, 2016
    Posts:
    5
    ahhh.. you made my day.
    thanks
     
  32. kmare

    kmare

    Joined:
    Jan 30, 2016
    Posts:
    34
    so did anyone try the latest 5.4 build or 5.5 beta regarding the cpu load? is the bug still there?
     
  33. dirtycoder

    dirtycoder

    Joined:
    Jul 13, 2016
    Posts:
    9
    As long as it's listed in the Known Issues (here) it's still there.

    That being said, with the merge in the main code base I think they are in a better position to fix this bug now.
    Looking forward to this, it's the only bug that stops me from using Unity on Linux. :)
     
  34. JonSWEDEN

    JonSWEDEN

    Joined:
    Jan 30, 2016
    Posts:
    11
    It's a showstopper for me too. Until this one i resolved I can't use the Linux version for my bigger projects.
     
  35. df3852

    df3852

    Joined:
    Sep 28, 2016
    Posts:
    6
    I made a quick and easy workaround, based on the fact that CPU usage is normal if the "About Unity" window is shown.

    Paste the following code into a CPUWorkaround.cs file somewhere in your project.
    Code (CSharp):
    1. using UnityEditor;
    2. using UnityEngine;
    3.  
    4. public class CPUWorkaround : EditorWindow
    5. {
    6.     [MenuItem("Window/CPU Workaround")]
    7.     public static void ShowWindow()
    8.     {
    9.         EditorWindow.GetWindow<CPUWorkaround>("100% CPU Workaround", true, typeof(EditorWindow)).minSize = Vector2.zero;
    10.     }
    11.     void OnGUI()
    12.     {
    13.         this.Repaint ();
    14.     }
    15. }
    Then open this window from the Window tab. You can now dock it by dragging the title of the window to any window that's permanently in view (I use the Hierarchy window). You can then resize it to take almost no space, like below.
    It's not ideal, and given how easy it seems to fix, there really should be an official bug fix. But until that time, this is a good and minimally intrusive workaround.
     
    JonSWEDEN likes this.
  36. dirtycoder

    dirtycoder

    Joined:
    Jul 13, 2016
    Posts:
    9
    I could have misunderstood the release notes but I think this may started to be addressed, here:
    "First pass at update frequency throttling"

    If I misunderstood it, sorry! :(
     
  37. kmare

    kmare

    Joined:
    Jan 30, 2016
    Posts:
    34
    yeah, I saw it too. Hopefully it's the fix we've been waiting for. Unfortunately I can't test for a few days, but if anyone can, please share the results!
     
  38. dirtycoder

    dirtycoder

    Joined:
    Jul 13, 2016
    Posts:
    9
    Yeah, probably not *the* fix, but at least a start.
     
  39. df3852

    df3852

    Joined:
    Sep 28, 2016
    Posts:
    6
    I can confirm the new version works, at least for me (Ubuntu 16.04 x64). Right when I made a nice workaround, they've fixed it, lol.

    Anyway, great that Unity finally works well on linux. Thanks, developers :)
     
    Joe-Abd-Halim, JonSWEDEN and kmare like this.
  40. vitodtagliente

    vitodtagliente

    Joined:
    Oct 2, 2016
    Posts:
    1
    Yeah, finally I dont need to switch to Windows. Nice work
     
  41. kmare

    kmare

    Joined:
    Jan 30, 2016
    Posts:
    34
    It truly works for me as well with the latest beta 5.5b5! Thank you for the fix!
     
  42. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    Ooooo... Maybe I should upgrade now. :D
    I also have had this issue for ages, and aside from making my laptop a bit hot, it also cut the battery life in half doing so.
    I guess for now, it's stick to 5.3.5f1 + that window repaint script until 5.5 gets a final release. (I don't really trust beta versions of unity tbh)
     
  43. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    Just here to say thank you for that odd, but battery-saving workaround. :)
    Of course, once I upgrade to 5.5 proper a bit later, I can ditch this for the fix...
     
  44. radubb

    radubb

    Joined:
    Mar 10, 2016
    Posts:
    1
    On ubuntu 16.10 it does not seem to be fixed (at least for me) :(
     
  45. u_rs

    u_rs

    Joined:
    Jan 5, 2016
    Posts:
    147
    Ridiculous !!! Under last linux build what can we see - the only known problem is dependency issues.
    Isn't 100% CPU known issue ?
     
    Last edited: Nov 17, 2016
  46. Bartwillemsen

    Bartwillemsen

    Joined:
    Apr 13, 2016
    Posts:
    5
    Well it's apparantly fixed in the newest beta, so if you need it you can run that. I don't thing the fix will be backported to the current stable release. In the meantime, keeping the "about" dialog open in the background works pretty well for me! Also, it's already noted as a known issue in the very first post of the threath with the builds.
     
  47. FuzzyQuills

    FuzzyQuills

    Joined:
    Jun 8, 2013
    Posts:
    2,871
    Welp...
    I haven't tried it yet, but I finally have a means of trying the 5.5 beta without breaking my stuff. (Finally on 5.4.2)
     
  48. u_rs

    u_rs

    Joined:
    Jan 5, 2016
    Posts:
    147
    It's not fixed in latest beta (why would I wrote here about it then ?), it starts f*ck CPU from login screen.
    But thanks for advice.
     
    Last edited: Nov 18, 2016
  49. Hoogin

    Hoogin

    Joined:
    Jul 27, 2015
    Posts:
    38
    I'm using 5.5.0b5 and I can confirm it's using a lot of CPU from login screen and beyond.
    This is just from idling at login screen.
    cpu_login.png

    *EDIT*
    Here I'm idling in my project.
    idle_later.png
     
    Last edited: Nov 19, 2016
  50. _jp

    _jp

    Joined:
    Feb 10, 2015
    Posts:
    4
    Arch Linux user here.
    Can confirm that:
    - in Unity 5.5.0b5+20160927-1 the CPU bug was NOT present
    - in latest "stable" release (5.5.0f3+20161125-1) the CPU bug IS present

    I thought that 5.5 Linux version had been integrated with the main one, so it surprises me that this bug is back.