question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

*** numba.errors.TypingError: Failed in nopython mode pipeline (step: nopython frontend)

See original GitHub issue

I am having a problem with UMAP(...).transform(). I loaded the model with trans = pickle.load().

ipdb> trans                                                                                                                                 
UMAP(a=None, angular_rp_forest=False, b=None, init='spectral',
   learning_rate=1.0, local_connectivity=1.0, metric='correlation',
   metric_kwds=None, min_dist=0.5, n_components=3, n_epochs=None,
   n_neighbors=3, negative_sample_rate=5, random_state=None,
   repulsion_strength=1.0, set_op_mix_ratio=1.0, spread=1.0,
   target_metric='categorical', target_metric_kwds=None,
   target_n_neighbors=-1, target_weight=0.5, transform_queue_size=4.0,
   transform_seed=42, verbose=False)

As UMAP uses numba package, I got a problem with resolving types. Here is the error shown.

ipdb> trans.transform(X_test.reshape(X_test.shape[0], -1))                                                                                  
*** numba.errors.TypingError: Failed in nopython mode pipeline (step: nopython frontend)
Invalid use of type(CPUDispatcher(<function rdist at 0x7f36c7ce4e18>)) with parameters (array(float32, 1d, C), array(float64, 1d, C))
Known signatures:
 * (array(float32, 1d, A), array(float32, 1d, A)) -> float32
 * parameterized
[1] During: resolving callee type: type(CPUDispatcher(<function rdist at 0x7f36c7ce4e18>))
[2] During: typing of call at /home/infinity/anaconda3/envs/HFT/lib/python3.6/site-packages/umap/umap_.py (776)


File "../../../anaconda3/envs/HFT/lib/python3.6/site-packages/umap/umap_.py", line 776:
def optimize_layout(
    <source elided>

                dist_squared = rdist(current, other)
                ^

This is not usually a problem with Numba itself but instead often caused by
the use of unsupported features or an issue in resolving types.

To see Python/NumPy features supported by the latest release of Numba visit:
http://numba.pydata.org/numba-doc/dev/reference/pysupported.html
and
http://numba.pydata.org/numba-doc/dev/reference/numpysupported.html

For more information about typing errors and how to debug them visit:
http://numba.pydata.org/numba-doc/latest/user/troubleshoot.html#my-code-doesn-t-compile

If you think your code should work with Numba, please report the error message
and traceback, along with a minimal reproducer at:
https://github.com/numba/numba/issues/new

Here is a X_test sample :

array([[[-7.84867750e-05, -3.92410776e-05, -1.17713994e-04, ...,
          0.00000000e+00,  0.00000000e+00, -5.88910810e-05],
        [ 0.00000000e+00,  0.00000000e+00,  0.00000000e+00, ...,
          3.22361913e+01,  3.36224857e+01,  0.00000000e+00],
        [-1.17741714e-04, -1.56979711e-04,  0.00000000e+00, ...,
         -3.22361913e+01, -3.36224857e+01, -2.35599012e-04],
        ...,
        [ 0.00000000e+00,  0.00000000e+00,  0.00000000e+00, ...,
          0.00000000e+00,  0.00000000e+00,  3.92395378e-05],
        [ 0.00000000e+00,  0.00000000e+00,  0.00000000e+00, ...,
          0.00000000e+00,  0.00000000e+00,  0.00000000e+00],
        [ 0.00000000e+00,  0.00000000e+00,  0.00000000e+00, ...,
          0.00000000e+00,  0.00000000e+00,  0.00000000e+00]],

       [[ 0.00000000e+00,  0.00000000e+00,  7.98615775e-04, ...,
          0.00000000e+00,  0.00000000e+00, -2.66778461e-04],
        [ 0.00000000e+00,  0.00000000e+00,  0.00000000e+00, ...,
          0.00000000e+00,  0.00000000e+00,  0.00000000e+00],
        [ 1.10377388e-03,  1.86421709e-03,  3.04066897e-04, ...,
          0.00000000e+00,  0.00000000e+00,  5.52533571e-04],
        ...,
        [ 0.00000000e+00,  1.14074947e-04,  3.80220908e-05, ...,
          0.00000000e+00,  0.00000000e+00,  0.00000000e+00],
        [-1.36996749e-03, -4.18338442e-04, -4.18322533e-04, ...,
          0.00000000e+00,  0.00000000e+00, -1.21918711e-03],
        [-3.80814562e-05, -1.10373187e-03, -3.80380000e-05, ...,
          0.00000000e+00,  0.00000000e+00, -1.90615976e-05]]])

X.shape is (5839, 45, 41)

How can I solve that type error?

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
ghostcommented, Dec 11, 2018

I found the solution.

model.embedding_ = model.embedding_.astype(np.float32, order='A')

I had to place the above code just after pickle.load(open("model.pkl", 'rb')), because you defined rdist() with f4(f4[], f4[]).

0reactions
AlouiAminecommented, Sep 7, 2020

I have the same issue with umap, but when i load it using joblib.load. anyone has an idea how to solve the issue!!?

File “competitors_inference_script.py”, line 71, in <module> umap_model = joblib.load(“competitors_analysis_model/umap_model.jb”)

File “/azureml-envs/azureml_60f3017dd63e10f820ba175f00b1e121/lib/python3.7/site-packages/joblib/numpy_pickle.py”, line 585, in load obj = _unpickle(fobj, filename, mmap_mode) File “/azureml-envs/azureml_60f3017dd63e10f820ba175f00b1e121/lib/python3.7/site-packages/joblib/numpy_pickle.py”, line 504, in unpickle obj = unpickler.load() File “/azureml-envs/azureml_60f3017dd63e10f820ba175f00b1e121/lib/python3.7/pickle.py”, line 1085, in load dispatchkey[0] File “/azureml-envs/azureml_60f3017dd63e10f820ba175f00b1e121/lib/python3.7/site-packages/joblib/numpy_pickle.py”, line 329, in load_build Unpickler.load_build(self) File “/azureml-envs/azureml_60f3017dd63e10f820ba175f00b1e121/lib/python3.7/pickle.py”, line 1549, in load_build setstate(state) File "/azureml-envs/azureml_60f3017dd63e10f820ba175f00b1e121/lib/python3.7/site-packages/pynndescent/pynndescent.py", line 1028, in setstate self._rp_forest = tuple([renumbaify_tree(tree) for tree in d[“rp_forest"]]) File "/azureml-envs/azureml_60f3017dd63e10f820ba175f00b1e121/lib/python3.7/site-packages/pynndescent/pynndescent.py”, line 1028, in <listcomp> self._rp_forest = tuple([renumbaify_tree(tree) for tree in d[“_rp_forest”]]) File “/azureml-envs/azureml_60f3017dd63e10f820ba175f00b1e121/lib/python3.7/site-packages/pynndescent/rp_trees.py”, line 1178, in renumbaify_tree hyperplanes.extend(tree.hyperplanes) File “/azureml-envs/azureml_60f3017dd63e10f820ba175f00b1e121/lib/python3.7/site-packages/numba/typed/typedlist.py”, line 366, in extend return _extend(self, iterable) File “/azureml-envs/azureml_60f3017dd63e10f820ba175f00b1e121/lib/python3.7/site-packages/numba/core/dispatcher.py”, line 415, in _compile_for_args error_rewrite(e, ‘typing’) File “/azureml-envs/azureml_60f3017dd63e10f820ba175f00b1e121/lib/python3.7/site-packages/numba/core/dispatcher.py”, line 358, in error_rewrite reraise(type(e), e, None) File “/azureml-envs/azureml_60f3017dd63e10f820ba175f00b1e121/lib/python3.7/site-packages/numba/core/utils.py”, line 80, in reraise raise value.with_traceback(tb) numba.core.errors.TypingError: Failed in nopython mode pipeline (step: nopython frontend)

  • Resolution failure for literal arguments: No implementation of function Function(<function impl_extend at 0x7fbe848f8598>) found for signature:
Read more comments on GitHub >

github_iconTop Results From Across the Web

numba.errors.TypingError: Failed in nopython mode pipeline ...
I am having a problem using @jit(nopython = True). I guess the reason is the package named "Tasmanian", which is used to apply...
Read more >
TypingError: Failed in nopython mode pipeline (step
It seems that at some point (as input or an array created later) does not have all it values of the same type....
Read more >
Troubleshooting and tips — Numba 0.50.1 documentation
Trying to execute this function, errors out as follows: TypingError: Failed at nopython (nopython frontend) Can't unify return type from the following ...
Read more >
Np.copy(): numba.core.errors.Failed in nopython mode pipeline
TypingError : Failed in nopython mode pipeline (step: nopython frontend) non-precise type ... I face the following error: “numba.core.errors.
Read more >
(完全解决)(numba)TypingError: Failed in nopython mode ...
numba.errors.TypingError: Failed in nopython mode pipeline (step: nopython frontend) Invalid use of Function(<class 'str'>) with argument(s) ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found