Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Numpy operations appear slow

Tags:

python

numpy

I am trying to see how fast I can invert a large matrix through numpy and am facing a rather weird conundrum. The test code is very simple:

file invert.py
from numpy.linalg import inv
import time

def invert():
 a=np.random.rand(10000,10000)
 s = time.time()
 b=inv(a)
 print time.time()-s

I am using a Windows machine so that I can run this test either through the Windows command prompt or through something like cygwin. The commands I use are exactly the same in either case:

python
import invert
invert.invert()

However when I issue the command from the win command prompt I get an elapsed time of ~30 seconds. When I do it through cygwin I get an elapsed time of ~1700 seconds! I am also trying to run the same test on a cluster node (linux) and get very slow results (~1600 seconds). I am quite baffled with this. Issuing the same python commands from the command prompt appears to be working massively faster than issuing them through cygwin. This makes no sense to me. Can someone shed some light on why this may be happening?

Thanks,

like image 991
user2874390 Avatar asked Mar 07 '14 23:03

user2874390


1 Answers

Thanks for the answers. Although I haven't completely figured out why this is happening Craig's answer has been helpful. When I give the numpy.show_config() command from win cmd I get info about the blas and lapack libraries. However when I give the same command from cygwin I don't get that info. I can only assume that running python through cygwin is somehow not aware of where the libraries are.

like image 141
user2874390 Avatar answered Oct 31 '22 11:10

user2874390