Getting AssertionError in scv.pp.moments
hangnguyen229 opened this issue ยท 7 comments
Hello, thank you for very helpful tutorial, I am new to python so sorry if I ask very naive question.
I am following the tutorial step by step and getting errors in .pp.moments. Before that I also had an issue with cell ID but after modified the sample_obs csv file I was able to run it. Now I am facing another issue as you can see bellow. Please help me with it. Many thanks.
computing neighbors
AssertionError Traceback (most recent call last)
/opt/miniconda3/lib/python3.8/site-packages/numba/core/errors.py in new_error_context(fmt_, *args, **kwargs)
743 try:
--> 744 yield
745 except NumbaError as e:
/opt/miniconda3/lib/python3.8/site-packages/numba/core/lowering.py in lower_block(self, block)
229 loc=self.loc, errcls_=defaulterrcls):
--> 230 self.lower_inst(inst)
231 self.post_block(block)
/opt/miniconda3/lib/python3.8/site-packages/numba/core/lowering.py in lower_inst(self, inst)
327 val = self.lower_assign(ty, inst)
--> 328 self.storevar(val, inst.target.name)
329
/opt/miniconda3/lib/python3.8/site-packages/numba/core/lowering.py in storevar(self, value, name)
1277 name=name)
-> 1278 raise AssertionError(msg)
1279
AssertionError: Storing i64 to ptr of i32 ('dim'). FE type int32
During handling of the above exception, another exception occurred:
LoweringError Traceback (most recent call last)
in
----> 1 scv.pp.moments(sample_one)
/opt/miniconda3/lib/python3.8/site-packages/scvelo/preprocessing/moments.py in moments(data, n_neighbors, n_pcs, mode, method, use_rep, use_highly_variable, copy)
62
63 if n_neighbors is not None and n_neighbors > get_n_neighs(adata):
---> 64 neighbors(
65 adata,
66 n_neighbors=n_neighbors,
/opt/miniconda3/lib/python3.8/site-packages/scvelo/preprocessing/neighbors.py in neighbors(adata, n_neighbors, n_pcs, use_rep, use_highly_variable, knn, random_state, method, metric, metric_kwds, num_threads, copy)
161 warnings.simplefilter("ignore")
162 neighbors = Neighbors(adata)
--> 163 neighbors.compute_neighbors(
164 n_neighbors=n_neighbors,
165 knn=knn,
/opt/miniconda3/lib/python3.8/site-packages/scanpy/neighbors/init.py in compute_neighbors(self, n_neighbors, knn, n_pcs, use_rep, method, random_state, write_knn_indices, metric, metric_kwds)
748 # we need self._distances also for method == 'gauss' if we didn't
749 # use dense distances
--> 750 self._distances, self._connectivities = _compute_connectivities_umap(
751 knn_indices,
752 knn_distances,
/opt/miniconda3/lib/python3.8/site-packages/scanpy/neighbors/init.py in compute_connectivities_umap(knn_indices, knn_dists, n_obs, n_neighbors, set_op_mix_ratio, local_connectivity)
353 # umap 0.5.0
354 warnings.filterwarnings("ignore", message=r"Tensorflow not installed")
--> 355 from umap.umap import fuzzy_simplicial_set
356
357 X = coo_matrix(([], ([], [])), shape=(n_obs, 1))
/opt/miniconda3/lib/python3.8/site-packages/umap/init.py in
----> 1 from .umap_ import UMAP
2
3 # Workaround: numba/numba#3341
4 import numba
5
/opt/miniconda3/lib/python3.8/site-packages/umap/umap_.py in
52 from umap.spectral import spectral_layout
53 from umap.utils import deheap_sort, submatrix
---> 54 from umap.layouts import (
55 optimize_layout_euclidean,
56 optimize_layout_generic,
/opt/miniconda3/lib/python3.8/site-packages/umap/layouts.py in
37 },
38 )
---> 39 def rdist(x, y):
40 """Reduced Euclidean distance.
41
/opt/miniconda3/lib/python3.8/site-packages/numba/core/decorators.py in wrapper(func)
219 with typeinfer.register_dispatcher(disp):
220 for sig in sigs:
--> 221 disp.compile(sig)
222 disp.disable_compile()
223 return disp
/opt/miniconda3/lib/python3.8/site-packages/numba/core/dispatcher.py in compile(self, sig)
907 with ev.trigger_event("numba:compile", data=ev_details):
908 try:
--> 909 cres = self._compiler.compile(args, return_type)
910 except errors.ForceLiteralArg as e:
911 def folded(args, kws):
/opt/miniconda3/lib/python3.8/site-packages/numba/core/dispatcher.py in compile(self, args, return_type)
77
78 def compile(self, args, return_type):
---> 79 status, retval = self._compile_cached(args, return_type)
80 if status:
81 return retval
/opt/miniconda3/lib/python3.8/site-packages/numba/core/dispatcher.py in _compile_cached(self, args, return_type)
91
92 try:
---> 93 retval = self._compile_core(args, return_type)
94 except errors.TypingError as e:
95 self._failed_cache[key] = e
/opt/miniconda3/lib/python3.8/site-packages/numba/core/dispatcher.py in _compile_core(self, args, return_type)
104
105 impl = self._get_implementation(args, {})
--> 106 cres = compiler.compile_extra(self.targetdescr.typing_context,
107 self.targetdescr.target_context,
108 impl,
/opt/miniconda3/lib/python3.8/site-packages/numba/core/compiler.py in compile_extra(typingctx, targetctx, func, args, return_type, flags, locals, library, pipeline_class)
604 pipeline = pipeline_class(typingctx, targetctx, library,
605 args, return_type, flags, locals)
--> 606 return pipeline.compile_extra(func)
607
608
/opt/miniconda3/lib/python3.8/site-packages/numba/core/compiler.py in compile_extra(self, func)
351 self.state.lifted = ()
352 self.state.lifted_from = None
--> 353 return self._compile_bytecode()
354
355 def compile_ir(self, func_ir, lifted=(), lifted_from=None):
/opt/miniconda3/lib/python3.8/site-packages/numba/core/compiler.py in _compile_bytecode(self)
413 """
414 assert self.state.func_ir is None
--> 415 return self._compile_core()
416
417 def _compile_ir(self):
/opt/miniconda3/lib/python3.8/site-packages/numba/core/compiler.py in _compile_core(self)
393 self.state.status.fail_reason = e
394 if is_final_pipeline:
--> 395 raise e
396 else:
397 raise CompilerError("All available pipelines exhausted")
/opt/miniconda3/lib/python3.8/site-packages/numba/core/compiler.py in _compile_core(self)
384 res = None
385 try:
--> 386 pm.run(self.state)
387 if self.state.cr is not None:
388 break
/opt/miniconda3/lib/python3.8/site-packages/numba/core/compiler_machinery.py in run(self, state)
337 (self.pipeline_name, pass_desc)
338 patched_exception = self._patch_error(msg, e)
--> 339 raise patched_exception
340
341 def dependency_analysis(self):
/opt/miniconda3/lib/python3.8/site-packages/numba/core/compiler_machinery.py in run(self, state)
328 pass_inst = _pass_registry.get(pss).pass_inst
329 if isinstance(pass_inst, CompilerPass):
--> 330 self._runPass(idx, pass_inst, state)
331 else:
332 raise BaseException("Legacy pass in use")
/opt/miniconda3/lib/python3.8/site-packages/numba/core/compiler_lock.py in _acquire_compile_lock(*args, **kwargs)
33 def _acquire_compile_lock(*args, **kwargs):
34 with self:
---> 35 return func(*args, **kwargs)
36 return _acquire_compile_lock
37
/opt/miniconda3/lib/python3.8/site-packages/numba/core/compiler_machinery.py in _runPass(self, index, pss, internal_state)
287 mutated |= check(pss.run_initialization, internal_state)
288 with SimpleTimer() as pass_time:
--> 289 mutated |= check(pss.run_pass, internal_state)
290 with SimpleTimer() as finalize_time:
291 mutated |= check(pss.run_finalizer, internal_state)
/opt/miniconda3/lib/python3.8/site-packages/numba/core/compiler_machinery.py in check(func, compiler_state)
260
261 def check(func, compiler_state):
--> 262 mangled = func(compiler_state)
263 if mangled not in (True, False):
264 msg = ("CompilerPass implementations should return True/False. "
/opt/miniconda3/lib/python3.8/site-packages/numba/core/typed_passes.py in run_pass(self, state)
461
462 # TODO: Pull this out into the pipeline
--> 463 NativeLowering().run_pass(state)
464 lowered = state['cr']
465 signature = typing.signature(state.return_type, *state.args)
/opt/miniconda3/lib/python3.8/site-packages/numba/core/typed_passes.py in run_pass(self, state)
382 lower = lowering.Lower(targetctx, library, fndesc, interp,
383 metadata=metadata)
--> 384 lower.lower()
385 if not flags.no_cpython_wrapper:
386 lower.create_cpython_wrapper(flags.release_gil)
/opt/miniconda3/lib/python3.8/site-packages/numba/core/lowering.py in lower(self)
134 if self.generator_info is None:
135 self.genlower = None
--> 136 self.lower_normal_function(self.fndesc)
137 else:
138 self.genlower = self.GeneratorLower(self)
/opt/miniconda3/lib/python3.8/site-packages/numba/core/lowering.py in lower_normal_function(self, fndesc)
188 # Init argument values
189 self.extract_function_arguments()
--> 190 entry_block_tail = self.lower_function_body()
191
192 # Close tail of entry block
/opt/miniconda3/lib/python3.8/site-packages/numba/core/lowering.py in lower_function_body(self)
214 bb = self.blkmap[offset]
215 self.builder.position_at_end(bb)
--> 216 self.lower_block(block)
217 self.post_lower()
218 return entry_block_tail
/opt/miniconda3/lib/python3.8/site-packages/numba/core/lowering.py in lower_block(self, block)
228 with new_error_context('lowering "{inst}" at {loc}', inst=inst,
229 loc=self.loc, errcls_=defaulterrcls):
--> 230 self.lower_inst(inst)
231 self.post_block(block)
232
/opt/miniconda3/lib/python3.8/contextlib.py in exit(self, type, value, traceback)
129 value = type()
130 try:
--> 131 self.gen.throw(type, value, traceback)
132 except StopIteration as exc:
133 # Suppress StopIteration unless it's the same exception that
/opt/miniconda3/lib/python3.8/site-packages/numba/core/errors.py in new_error_context(fmt_, *args, **kwargs)
749 newerr = errcls(e).add_context(format_msg(fmt, args, kwargs))
750 tb = sys.exc_info()[2] if numba.core.config.FULL_TRACEBACKS else None
--> 751 raise newerr.with_traceback(tb)
752
753
LoweringError: Failed in nopython mode pipeline (step: nopython mode backend)
Storing i64 to ptr of i32 ('dim'). FE type int32
File "../../opt/miniconda3/lib/python3.8/site-packages/umap/layouts.py", line 52:
def rdist(x, y):
result = 0.0
dim = x.shape[0]
^
During: lowering "dim = static_getitem(value=$8load_attr.2, index=0, index_var=$const10.3, fn=)" at /opt/miniconda3/lib/python3.8/site-packages/umap/layouts.py (52)
I solved the issue by using docker. Thanks
I got the exact same error, but how did you solve this by using docker?
I experienced the same error but resolved it by installing an older version of numba (0.52.0). Hopefully that works for you!
I've also had this exact error. Downgrading numba from 0.53.1 to 0.52.0 solved it. Thanks michael-r-odea.
This worked for me as well. For those not familiar:
pip uninstall numba
pip install numba==0.52.0
This worked for me as well. For those not familiar:
pip uninstall numba
pip install numba==0.52.0
Many thanks @michael-r-odea and @ColeKeenum this worked for me - after installing scVelo and working through the the vignette, the lines:
scv.pp.filter_and_normalize(adata, min_shared_counts=20, n_top_genes=2000)
scv.pp.moments(adata, n_pcs=30, n_neighbors=30)
Triggered that error.. and downgrading numba to 0.52.0 resolved the issue.
Just wanted to chime in here. While this solution indeed works w/ Python 3.8, I could not get it to work w/ Python 3.9 due to llvmlite incompatibilities. I'm betting you're on Py 3.9 if you see the following:
pip3 install numba==0.52.0
ERROR: Could not find a version that satisfies the requirement numba==0.52.0 (from versions: 0.1, 0.2, 0.3, 0.5.0, 0.6.0, 0.7.0, 0.7.1, 0.7.2, 0.8.0, 0.8.1, 0.9.0, 0.10.0, 0.10.1, 0.11.0, 0.12.0, 0.12.1, 0.12.2, 0.13.0, 0.13.2, 0.13.3, 0.13.4, 0.14.0, 0.15.1, 0.16.0, 0.17.0, 0.18.1, 0.18.2, 0.19.1, 0.19.2, 0.20.0, 0.21.0, 0.22.0, 0.22.1, 0.23.0, 0.23.1, 0.24.0, 0.25.0, 0.26.0, 0.27.0, 0.28.1, 0.29.0, 0.30.0, 0.30.1, 0.31.0, 0.32.0, 0.33.0, 0.34.0, 0.35.0, 0.36.1, 0.36.2, 0.37.0, 0.38.0, 0.38.1, 0.39.0, 0.40.0, 0.40.1, 0.41.0, 0.42.0, 0.42.1, 0.43.0, 0.43.1, 0.44.0, 0.44.1, 0.45.0, 0.45.1, 0.46.0, 0.47.0, 0.48.0, 0.49.0, 0.49.1rc1, 0.49.1, 0.50.0rc1, 0.50.0, 0.50.1, 0.51.0rc1, 0.51.0, 0.51.1, 0.51.2, 0.52.0rc2, 0.53.0rc1.post1, 0.53.0rc2, 0.53.0rc3, 0.53.0, 0.53.1, 0.54.0rc2, 0.54.0rc3, 0.54.0)
ERROR: No matching distribution found for numba==0.52.0
I tried downgrading to numba versions 0.51.0, 0.51.1, 0.51.2, and 0.52.0rc2 in Python 3.9. None worked due to failed llvmlite installations. Lastly, installing a Py 3.9 "compatible" llvmlite + numba 0.5x.0 with --no-deps
also failed to resolve the issue. For instance:
pip3 install llvmlite==0.36.0rc1
pip3 install numba==0.51.2 --no-deps
These install, but perhaps incorrectly. I didn't bother look further into numba/llvm compatibility docs, so maybe there's an answer in there somewhere... I simply gave up and switched Python versions ๐