0

I observed a significant difference in performance between my local Python (2.7) and a virtual environment (on the same machine).

I tested the following script:

import numpy as np
import time

A = np.random.rand(500, 3000)
B = np.random.rand(5000, 3000)

tic = time.time()
p = np.dot(A, B.T)
toc = time.time()
print toc - tic

It was ~20 times faster in the local environment.

What could be the reasons? (Maybe there is a package that accelerates vectorized operations installed in the my local Python but not on the virtual environment?)

Thank you in advance for any suggestions.

Khue
  • 1,224
  • 18
  • 31
  • Is there a difference in the numpy versions? – Martin Konecny Jan 20 '16 at 22:32
  • Likewise, is the same version of python running in the virtual environment? – Gil Hamilton Jan 20 '16 at 22:44
  • Thanks, @MartinKonecny and Gil. The versions are indeed different (2.7.6 vs 2.7.11). I'll upgrade and check again. – Khue Jan 20 '16 at 23:05
  • More important than the numpy version is the BLAS implementation, http://stackoverflow.com/questions/26511430/performance-of-numpy-with-different-blas-implementations. Do you know which BLAS version (if any) is being used by each numpy? – Bi Rico Jan 20 '16 at 23:09
  • Yes, @BiRico, this was indeed the reason. I do not have BLAS or LAPACK in my virtual environment. My local Python is from Anaconda and it has everything in it. – Khue Jan 20 '16 at 23:25

1 Answers1

1

As suggested by @BiRico, I checked the version of Linear Algebra libraries such as BLAS and LAPACK using the command:

python -c 'import numpy; numpy.show_config()'

and surprised, I do not have any of these installed.

Khue
  • 1,224
  • 18
  • 31