4

I am struggling with a python reproducibility problem across different machines. I have two machines: an older server with SSE4_2 and a newer desktop with AVX. Running the same python script on both machines results in different outputs (I made sure both virtualenvs were exactly the same).

I actually found one solution: I figured the problem was due to the difference in instruction set thanks to these posts:

They suggested that I use MKL to force which instruction set is used by setting os.environ['MKL_CBWR'] = 'SSE4_2'. I uninstalled numpy and installed intel-numpy (numpy built with mkl) so that I could set os.environ['MKL_CBWR'] = 'SSE4_2'. Now the output of the script is the same for both machines.

However, even though the results match, they do not match the result pre mkl (using plain numpy). It would help me a lot to be able to use intel-numpy to reproduce the old results from the server; I have a lot of experiments that took over a week to run, and I would like to be able to use those results without rerunning them.

Edits: I've done some more research and I think the problem may be in the Lapack and Blas implementation. I think that MKL and OpenBlas (which is what my default numpy uses) have different implementations which results in different order of operations. So maybe my solution is to continue to use the default numpy, but force the instruction set to be SSE4_2 on my desktop. Is there a way to force the use of "SSE4_2" without using MKL?

Do I need to compile numpy from source and compile openblas from source and make sure they have avx disabled? If so, could anyone point me in the right direction to get started? I have found a few sources, but there seems to be a lot of ways to compile from source.

If my question is not clear, let me know and I will try to clarify.

Additional details: When I run np.__config__.show() using default numpy (not intel-numpy) I get:

lapack_opt_info:
    libraries = ['openblas', 'openblas']
    library_dirs = ['/usr/local/lib']
    define_macros = [('HAVE_CBLAS', None)]
    language = c
blas_opt_info:
    libraries = ['openblas', 'openblas']
    library_dirs = ['/usr/local/lib']
    define_macros = [('HAVE_CBLAS', None)]
    language = c
openblas_info:
    libraries = ['openblas', 'openblas']
    library_dirs = ['/usr/local/lib']
    define_macros = [('HAVE_CBLAS', None)]
    language = c
blis_info:
  NOT AVAILABLE
openblas_lapack_info:
    libraries = ['openblas', 'openblas']
    library_dirs = ['/usr/local/lib']
    define_macros = [('HAVE_CBLAS', None)]
    language = c
lapack_mkl_info:
  NOT AVAILABLE
blas_mkl_info:
  NOT AVAILABLE

When I run np.__config__.show() with intel-numpy I get:

lapack_opt_info:
    libraries = ['mkl_rt', 'pthread']
    library_dirs = ['/opt/anaconda1anaconda2anaconda3/lib']
    define_macros = [('SCIPY_MKL_H', None), ('HAVE_CBLAS', None)]
    include_dirs = ['/opt/anaconda1anaconda2anaconda3/include']
blas_opt_info:
    libraries = ['mkl_rt', 'pthread']
    library_dirs = ['/opt/anaconda1anaconda2anaconda3/lib']
    define_macros = [('SCIPY_MKL_H', None), ('HAVE_CBLAS', None)]
    include_dirs = ['/opt/anaconda1anaconda2anaconda3/include']
lapack_mkl_info:
    libraries = ['mkl_rt', 'pthread']
    library_dirs = ['/opt/anaconda1anaconda2anaconda3/lib']
    define_macros = [('SCIPY_MKL_H', None), ('HAVE_CBLAS', None)]
    include_dirs = ['/opt/anaconda1anaconda2anaconda3/include']
blas_mkl_info:
    libraries = ['mkl_rt', 'pthread']
    library_dirs = ['/opt/anaconda1anaconda2anaconda3/lib']
    define_macros = [('SCIPY_MKL_H', None), ('HAVE_CBLAS', None)]
    include_dirs = ['/opt/anaconda1anaconda2anaconda3/include']
mkl_info:
    libraries = ['mkl_rt', 'pthread']
    library_dirs = ['/opt/anaconda1anaconda2anaconda3/lib']
    define_macros = [('SCIPY_MKL_H', None), ('HAVE_CBLAS', None)]
    include_dirs = ['/opt/anaconda1anaconda2anaconda3/include']

Running lshw on each machine results in:

OLD SERVER:

    description: Computer

        width: 64 bits

        capabilities: vsyscall32

    *-core
       description: Motherboard
       physical id: 0
     *-memory
          description: System memory
          physical id: 0
          size: 47GiB
     *-cpu:0
          product: Intel(R) Xeon(R) CPU           X5650  @ 2.67GHz
          vendor: Intel Corp.
          physical id: 1
          bus info: cpu@0
          width: 64 bits
          capabilities: fpu fpu_exception wp vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp x86-64 constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm pcid dca sse4_1 sse4_2 popcnt aes lahf_lm pti tpr_shadow vnmi flexpriority ept vpid dtherm ida arat
     *-cpu:1
          product: Intel(R) Xeon(R) CPU           X5650  @ 2.67GHz
          vendor: Intel Corp.
          physical id: 2
          bus info: cpu@1
          width: 64 bits
          capabilities: fpu fpu_exception wp vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp x86-64 constant_tsc arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 cx16 xtpr pdcm pcid dca sse4_1 sse4_2 popcnt aes lahf_lm pti tpr_shadow vnmi flexpriority ept vpid dtherm ida arat
     *-pci:0
          description: Host bridge
          product: 5500 I/O Hub to ESI Port
          vendor: Intel Corporation
          physical id: 100
          bus info: pci@0000:00:00.0
          version: 13
          width: 32 bits
          clock: 33MHz

NEW DESKTOP:

    width: 64 bits

    capabilities: vsyscall32

    *-core
       description: Motherboard
       physical id: 0
     *-memory
          description: System memory
          physical id: 0
          size: 31GiB
     *-cpu
          product: Intel(R) Core(TM) i5-6600 CPU @ 3.30GHz
          vendor: Intel Corp.
          physical id: 1
          bus info: cpu@0
          size: 1250MHz
          capacity: 3900MHz
          width: 64 bits
          capabilities: fpu fpu_exception wp vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp x86-64 constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf tsc_known_freq pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault epb invpcid_single pti ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid fsgsbase tsc_adjust bmi1 hle avx2 smep bmi2 erms invpcid rtm mpx rdseed adx smap clflushopt intel_pt xsaveopt xsavec xgetbv1 xsaves dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp flush_l1d cpufreq
     *-pci
          description: Host bridge
          product: Sky Lake Host Bridge/DRAM Registers
          vendor: Intel Corporation
          physical id: 100
          bus info: pci@0000:00:00.0
          version: 07
          width: 32 bits
          clock: 33MHz
          configuration: driver=skl_uncore
          resources: irq:0
ej_01
  • 51
  • 4

0 Answers0