snap-stanford / UCE

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

How to Use Multi-GPU to Inference the Embeddings #31

Closed KatarinaYuan closed 2 months ago

KatarinaYuan commented 3 months ago

I tried to add --multi_gpu for eval_single_anndata.py, but an error jumps out:

Using sample 4 layer model
generalization_splitted_cellxgene_leave_out_122123_134708_valid_celltype_adata_uce already processed. Skipping
PE Idx, Chrom and Starts files already created
Loaded model:
./model_files/4layer_model.torch
  0%|                                                                                                                                          | 0/19473 [00:01<?, ?it/s]
Traceback (most recent call last):
  File "/lustre06/project/6000167/xxx/UCE/eval_single_anndata.py", line 155, in <module>
    main(args, accelerator)
  File "/lustre06/project/6000167/xxx/UCE/eval_single_anndata.py", line 85, in main
    processor.run_evaluation()
  File "/lustre06/project/6000167/xxx/UCE/evaluate.py", line 145, in run_evaluation
    run_eval(self.adata, self.name, self.pe_idx_path, self.chroms_path,
  File "/lustre06/project/6000167/xxx/UCE/evaluate.py", line 239, in run_eval
    batch_sentences = model.module.pe_embedding(batch_sentences.long())
  File "/home/xxx/projects/base_env/lib/python3.9/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'
Yanay1 commented 3 months ago

What is the command you are running? Are you launching with hugging face accelerate?