BayraktarLab / cell2location

Comprehensive mapping of tissue cell architecture via integrated single cell and spatial transcriptomics (cell2location model)
https://cell2location.readthedocs.io/en/latest/
Apache License 2.0
321 stars 58 forks source link

`MPSAccelerator` can not run on your system since the accelerator is not available. The following accelerator(s) is available and can be passed into `accelerator` argument of `Trainer`: ['cpu'] #252

Open AdrianaLecourieux opened 1 year ago

AdrianaLecourieux commented 1 year ago

Hello,

I was doing your tutorial (lymph node cell types) and I have an issue when we train the model to estimate the reference cell type signatures. mod.train(max_epochs=250, use_gpu=True)

This code return an error : MPSAccelerator can not run on your system since the accelerator is not available. The following accelerator(s) is available and can be passed into accelerator argument of Trainer: ['cpu'].

I saw that is an error obtained with Mac computer but I'm not on it.

I tried : os.environ["THEANO_FLAGS"] = 'device=cuda,floatX=float32,force_device=True' And : data_type = 'float32' os.environ["THEANO_FLAGS"] = 'device=cuda0,floatX=' + data_type + ',force_device=True'

Before import cell2location, but this didn't work.

Do you have any solution ?

Thanks by advance (I'm new in this field)

vitkl commented 1 year ago

Hi @AdrianaLecourieux

Please make sure that you are using latest cell2location and other dependencies. It would be easiest to recreate conda environment from scratch and see if you have the same issue.

THEANO_FLAGS options are not relevant for latest versions of the package (since mid 2021).

Are you using the mac M1/M2? There are other threads about this - it's not fully supported by pytorch.

AdrianaLecourieux commented 1 year ago

Hi,

Thanks for your answer. I'm using the version 0.1.3. Is it the last one ? I will try to recreate new environment.

No, I'm on a VM with Ubuntu.

AdrianaLecourieux commented 1 year ago

Hello,

So I recreated conda environment and I still have the same issue.

WenqinXie commented 1 year ago

Thank you for doing such great work for us to analyze the spatial transcriptome, I followed your tutorial (Mapping human lymph node cell types to 10X Visium with Cell2location) to do the analysis, also encountered the same problem, I want to know how we can solve it, thank you very much !

vitkl commented 1 year ago

Did reinstalling the packages help? You can also try running scVI (scRNA integration method) and if you see the same error you can report it on scverse/scvi-tools.

ArcherGX commented 1 year ago

I also suffer this issue. I perfomed this analysis on a server without GPU. Thus, the model will be falling back to CPU. However, the function ".run_cell2location" in utils.R, at 225 line: res_py <- c(res_py, "adata_snrna_raw = mod.export_posterior(adata_snrna_raw, sample_kwargs={'num_samples': 1000, 'batch_size': 2500, 'use_gpu': True})") This command force to use GPU, leading to this error. I set use_gpu=False, and it works. I think add a parameter for "use_gpu", maybe better

vitkl commented 1 year ago

Are you running this on M1/M2 mac?