Find the answer to your Linux question:
Results 1 to 4 of 4
Hi, So far I have tried all the available utilities to find the exact number of physical cpus on Linux but never succeeded. I have used /proc/cpuinfo file but the ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Dec 2007
    Posts
    1

    How to get number of physical processors/cores on Linux


    Hi,
    So far I have tried all the available utilities to find the exact number of physical cpus on Linux but never succeeded.
    I have used /proc/cpuinfo file but the combination seems to work for one hosts but not for other and situation gets even worse while dealing different processors from same/different vendors like Intel , AMD etc.

    Is there any c-code or utility availble which can provide this information correctly ?

    Thanks
    --Servesh

  2. #2
    Linux Engineer RobinVossen's Avatar
    Join Date
    Aug 2007
    Location
    The Netherlands
    Posts
    1,429
    Conky works fine with me.
    I hope it can do what you want..
    Also cat /proc/cpuinfo | grep processor works perfectly.
    Cheers,
    Robin
    New Users, please read this..
    Google first, then ask..

  3. #3
    oz
    oz is offline
    forum.guy
    Join Date
    May 2004
    Location
    arch linux
    Posts
    18,733
    This works pretty well for me:

    Code:
    grep cores /proc/cpuinfo
    oz

  4. #4
    Just Joined!
    Join Date
    Jun 2008
    Location
    North East U.S.
    Posts
    30
    In a C program, I use the following as a more portable mechanism:

    numCPUs = sysconf(_SC_NPROCESSORS_ONLN);


    my biggest problem with this is that when Hyper Threading is enabled, that reports twice as many CPUs as I would like to see being reported.

    -Brion

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •