Issue with cupyx
Closed this issue · 4 comments
jindalk commented
Hi, I'm running the model.fit()
command with gpu and am getting the following error:
File /ref/smlab/software/jindalk/.conda/envs/sc_env/lib/python3.10/site-packages/SEACells/core.py:574, in SEACells.fit(self, max_iter, min_iter, initial_archetypes)
572 if max_iter < min_iter:
573 raise ValueError("The maximum number of iterations specified is lower than the minimum number of iterations specified.")
--> 574 self._fit(max_iter=max_iter, min_iter=min_iter, initial_archetypes=initial_archetypes, initial_assignments=None)
File /ref/smlab/software/jindalk/.conda/envs/sc_env/lib/python3.10/site-packages/SEACells/core.py:531, in SEACells._fit(self, max_iter, min_iter, initial_archetypes, initial_assignments)
519 def _fit(self, max_iter: int = 50, min_iter:int=10, initial_archetypes=None, initial_assignments=None):
520 """
521 Compute archetypes and loadings given kernel matrix K. Iteratively updates A and B matrices until maximum
522 number of iterations or convergence has been achieved.
(...)
529
530 """
--> 531 self.initialize(initial_archetypes=initial_archetypes, initial_assignments=initial_assignments)
533 converged = False
534 n_iter = 0
File /ref/smlab/software/jindalk/.conda/envs/sc_env/lib/python3.10/site-packages/SEACells/core.py:172, in SEACells.initialize(self, initial_archetypes, initial_assignments)
170 A = np.random.random((k, n))
171 A /= A.sum(0)
--> 172 A = self._updateA(B, A)
174 if self.verbose:
175 print('Randomly initialized A matrix.')
File /ref/smlab/software/jindalk/.conda/envs/sc_env/lib/python3.10/site-packages/SEACells/core.py:335, in SEACells._updateA(self, B, A_prev)
329 t = 0 # current iteration (determine multiplicative update)
332 if self.gpu:
333 # Use the GPU version of the update step
--> 335 K = cupyx.scipy.sparse.csc_matrix(self.K)
337 Ag = cp.array(A)
338 Kg = K
NameError: name 'cupyx' is not defined
I do have cupyx installed and working, so I think for some reason the model is not loading cupyx despite use_gpu
being set as True
Thanks!
AlinaKurjan commented
have you tried importing cupyx separately?
sitarapersad commented
Hi, sorry! The GPU version is still a WIP and gives trouble on some machines. Please let me know if you are able to sucessfully import cupyx, but in the meanwhile the non-GPU version should work, albeit a bit more slowly.
jaredtumiel commented
Importing cupyx
and cupy as cp
at the top of ../SEACells/core.py
seemed to do the trick as a temporary fix
jindalk commented
Yes! We ended up adding the import statements to core.py to fix the issue. Thanks!