snap-stanford / UCE

UCE is a zero-shot foundation model for single-cell gene expression data
MIT License
163 stars 26 forks source link

UCE using multi-gpu #49

Closed BioAmelie closed 4 days ago

BioAmelie commented 1 month ago

Hi @Yanay1

Do you know why UCE repotred the following error When I setted multi-gpu True. I had launched hugging face on command line: huggingface-cli login (scanpy) root@iZ1pp06g2kc1mpkdbn2uzzZ:/home/jinfang/backup/jinfang/songmf/007-uce/UCE# python eval_single_anndata.py --adata_path /home/jinfang/backup/jinfang/songmf/000-Data/HCC_snRNA/HCC_MET_KM.h5ad --dir /home/jinfang/backup/jinfang/songmf/007-uce/UCE/HCC_MET_KM --species human --model_loc /home/jinfang/backup/jinfang/songmf/007-uce/UCE/model_files/4layer_model.torch --batch_size 100 --multi_gpu True Proccessing HCC_MET_KM 8222.0 HCC_MET_KM (43574, 15502) Wrote Shapes Dict 15502 Max Code: 613 Loaded model: /home/jinfang/backup/jinfang/songmf/007-uce/UCE/model_files/4layer_model.torch 0%| | 0/436 [00:02<?, ?it/s] Traceback (most recent call last): File "/mnt/array3/jinfang/songmf/007-uce/UCE/eval_single_anndata.py", line 155, in <module> main(args, accelerator) File "/mnt/array3/jinfang/songmf/007-uce/UCE/eval_single_anndata.py", line 85, in main processor.run_evaluation() File "/mnt/array3/jinfang/songmf/007-uce/UCE/evaluate.py", line 145, in run_evaluation run_eval(self.adata, self.name, self.pe_idx_path, self.chroms_path, File "/mnt/array3/jinfang/songmf/007-uce/UCE/evaluate.py", line 239, in run_eval batch_sentences = model.module.pe_embedding(batch_sentences.long()) ^^^^^^^^^^^^ File "/bio/anaconda3/envs/scanpy/lib/python3.11/site-packages/torch/nn/modules/module.py", line 1614, in __getattr__ raise AttributeError("'{}' object has no attribute '{}'".format( AttributeError: 'TransformerModel' object has no attribute 'module'. Did you mean: 'modules'?

Yanay1 commented 1 month ago

When you use multi-gpu it has to be with hugging face accelerator. So it needs to be launched with accelerate rather than just python (see: https://huggingface.co/docs/accelerate/en/index)