0

Hi I'm trying to do some matrix calculations using python. The problem is there seems to be a limit of how much CPU will the process consume (about 13% of my Core i7).

Is there a way I can make it use more resources?

SadStudent
  • 287
  • 1
  • 4
  • 16
  • I think there is no way of doing that, thru python, although I also belive there is no limitations on CPU usage. *(try to get in an infinite loop, and your CPU usage will be 100%)* But, if you need more power, think about implementing your algorythm in `Cython`. – Peter Varo Jun 14 '13 at 09:31
  • I think you run on a single core, and you use it at 100%. Try to go multithread. – Guillaume Lemaître Jun 14 '13 at 09:35
  • 3
    how do you define 13% CPU usage, is that 13% of one core or 13% of your 4+4 cores (because 1/8 = 0.125...)... the python interpeter is running in one thread so you can't (to m knowlenge) get higher than 100% of 1 core... you can however gain a speed up of 10-100 if you use numpy for matrix calcuations :) – jcr Jun 14 '13 at 09:36
  • @azorius as process explorer defines it.. I've just looked at the CPU column there... – SadStudent Jun 14 '13 at 09:38
  • try to do: "while True: x = 1+1" if this goes to 100% then your arrays are io limited, if this also goes to 13% then you can only get faster by a) using threads b) using numpy c) writing a c extention d) other fancy stuff – jcr Jun 14 '13 at 09:43
  • 4
    i7 is probably a quad-core with hyperthreading, which amounts to 8 cores, 1 / 8 = 0.125 ~= 13%. You are definitely running one a single core. If possible you should take a look at multiprocessing. – Blubber Jun 14 '13 at 09:47
  • @Blubber oh snap didn't think about the HT 'cores' lol now the 13% does makes sense and yes the endless loop consumed 13% as well. – SadStudent Jun 14 '13 at 09:51

1 Answers1

1

As people in the comments pointed out, you're running only on one of your 8 (4 physical, 4 virtual) cores.

If you aren't doing this for a programming exercise but instead you're really interested in numerical programming or data analysis in python, you might want to take a close look at numpy. That package provides fast array/vector/matrix types and operations them, and (supposedly) can do multi threaded dot products (see multithreaded blas in python/numpy ).

Community
  • 1
  • 1
Piotr99
  • 531
  • 3
  • 12