IntelPython / sdc

Numba extension for compiling Pandas data frames, Intel® Scalable Dataframe Compiler
https://intelpython.github.io/sdc-doc/
BSD 2-Clause "Simplified" License
646 stars 61 forks source link

calc pi example fails #31

Open petacube opened 6 years ago

petacube commented 6 years ago

calc_pi.py

import hpat import numpy as np import time

@hpat.jit def calc_pi(n):

t1 = time.time()
x = 2 * np.random.ranf(n) - 1
y = 2 * np.random.ranf(n) - 1
pi = 4 * np.sum(x**2 + y**2 < 1) / n
print("Execution time:", time.time()-t1, "\nresult:", pi)
return pi

calc_pi(2 * 10**8)

python calc_pi.py Traceback (most recent call last): File "calc_pi.py", line 15, in calc_pi(2 * 10**8) File "/anaconda3/lib/python3.5/site-packages/numba/dispatcher.py", line 360, in _compile_for_args raise e File "/anaconda3/lib/python3.5/site-packages/numba/dispatcher.py", line 311, in _compile_for_args return self.compile(tuple(argtypes)) File "/anaconda3/lib/python3.5/site-packages/numba/dispatcher.py", line 618, in compile cres = self._compiler.compile(args, return_type) File "/anaconda3/lib/python3.5/site-packages/numba/dispatcher.py", line 83, in compile pipeline_class=self.pipeline_class) File "/anaconda3/lib/python3.5/site-packages/numba/compiler.py", line 871, in compile_extra return pipeline.compile_extra(func) File "/anaconda3/lib/python3.5/site-packages/numba/compiler.py", line 365, in compile_extra return self._compile_bytecode() File "/anaconda3/lib/python3.5/site-packages/numba/compiler.py", line 802, in _compile_bytecode return self._compile_core() File "/anaconda3/lib/python3.5/site-packages/numba/compiler.py", line 789, in _compile_core res = pm.run(self.status) File "/anaconda3/lib/python3.5/site-packages/numba/compiler.py", line 251, in run raise patched_exception File "/anaconda3/lib/python3.5/site-packages/numba/compiler.py", line 243, in run stage() File "/anaconda3/lib/python3.5/site-packages/hpat-0.22-py3.5-macosx-10.6-x86_64.egg/hpat/compiler.py", line 209, in stage_distributed_pass dist_pass.run() File "/anaconda3/lib/python3.5/site-packages/hpat-0.22-py3.5-macosx-10.6-x86_64.egg/hpat/distributed.py", line 92, in run self.func_ir.blocks = self._run_dist_pass(self.func_ir.blocks) File "/anaconda3/lib/python3.5/site-packages/hpat-0.22-py3.5-macosx-10.6-x86_64.egg/hpat/distributed.py", line 225, in _run_dist_pass new_body += self._gen_barrier() File "/anaconda3/lib/python3.5/site-packages/hpat-0.22-py3.5-macosx-10.6-x86_64.egg/hpat/distributed.py", line 1954, in _gen_barrier self.typemap, self.calltypes).blocks File "/anaconda3/lib/python3.5/site-packages/numba/ir_utils.py", line 1445, in compile_to_numba_ir f_ir = get_ir_of_code(glbls, code) File "/anaconda3/lib/python3.5/site-packages/numba/ir_utils.py", line 1490, in get_ir_of_code if co_varnames[0] == ".0": IndexError: Failed at hpat (convert to distributed) list index out of range

ehsantn commented 6 years ago

Could you try Python 3.6?

petacube commented 6 years ago

this is python 3.6. - clean install from conda to replicate conda install -n py36 python=3.6 conda install -f requirements.txt python setup.py install

source activate py36 (py36) python calc_pi.py Traceback (most recent call last): File "calc_pi.py", line 1, in import hpat File "/anaconda3/envs/py36/lib/python3.6/site-packages/hpat-0.22-py3.6-macosx-10.7-x86_64.egg/hpat/init.py", line 5, in import hpat.dict_ext File "/anaconda3/envs/py36/lib/python3.6/site-packages/hpat-0.22-py3.6-macosx-10.7-x86_64.egg/hpat/dict_ext.py", line 9, in from hpat.str_ext import string_type File "/anaconda3/envs/py36/lib/python3.6/site-packages/hpat-0.22-py3.6-macosx-10.7-x86_64.egg/hpat/str_ext.py", line 14, in import hstr_ext ImportError: dlopen(/anaconda3/envs/py36/lib/python3.6/site-packages/hpat-0.22-py3.6-macosx-10.7-x86_64.egg/hstr_ext.cpython-36m-darwin.so, 2): Symbol not fo\ und: __ZNK5boost16re_detail_10640031cpp_regex_traits_implementationIcE17transformprimaryEPKcS4 Referenced from: /anaconda3/envs/py36/lib/python3.6/site-packages/hpat-0.22-py3.6-macosx-10.7-x86_64.egg/hstr_ext.cpython-36m-darwin.so Expected in: /usr/local/lib/libboost_regex.dylib in /anaconda3/envs/py36/lib/python3.6/site-packages/hpat-0.22-py3.6-macosx-10.7-x86_64.egg/hstr_ext.cpython-36m-darwin.so

ehsantn commented 6 years ago

could you paste the output of conda list?

petacube commented 6 years ago

(py36) conda list

packages in environment at /anaconda3/envs/py36:

#

Name Version Build Channel

ca-certificates 2018.4.16 0 conda-forge certifi 2018.4.16 py36_0 conda-forge hpat 0.22 libcxx 4.0.1 h579ed51_0
libcxxabi 4.0.1 hebd6815_0
libedit 3.1.20170329 hb402a30_2
libffi 3.2.1 h475c297_4
libgfortran 3.0.0 0 conda-forge llvmlite 0.23.2 mpi 1.0 mpich conda-forge mpich 3.2.1 h26a2512_4 conda-forge ncurses 6.1 h0a44026_0
numba 0.38.1 numpy 1.14.5 openssl 1.0.2o 0 conda-forge pandas 0.23.1 pip 10.0.1 py36_0
python 3.6.6 hc167b69_0
python-dateutil 2.7.3 pytz 2018.5 readline 7.0 hc1231fa_4
scipy 1.1.0 setuptools 39.2.0 py36_0
six 1.11.0 sqlite 3.24.0 ha441bb4_0
tk 8.6.7 h35a86e2_3
wheel 0.31.1 py36_0
xz 5.2.4 h1de35cc_4
zlib 1.2.11 hf3cbc9b_2

ehsantn commented 6 years ago

boost is missing and Numba is also old (0.39 is needed). Why are you not using our conda install command? conda create -n HPAT -c ehsantn -c numba -c anaconda -c conda-forge hpat

petacube commented 6 years ago

ok requirements file has line numba >=0.38

boost i had installed with brew brew install boost Warning: boost 1.67.0_1 is already installed and up-to-date To reinstall 1.67.0_1, run brew reinstall boost

petacube commented 6 years ago

i am able to run examples when create new py36 virtual env. i follow your instructions for using custom channels. i am still curious though why my libboost did not work with clean python 3.6 and brew installed libboost. i can see that hpat extension also installs libboost of its own and contains relative reference to its own instlalled version.

ehsantn commented 6 years ago

hpat 0.22 in the channel is built with default Anaconda's Boost, which is 1.65 and is built with GCC 7.2. Anything other than this can fail. If you want to use another boost version, you have to build every package that depends on boost from source (HPAT, pyarrow, etc.). Going out of Conda environment can cause a lot of issues...