SpatialHackathon / SpaceHack2023

MIT No Attribution
16 stars 3 forks source link

SpiceMix GPU #225

Open Jieran-S opened 9 months ago

Jieran-S commented 9 months ago

https://github.com/SpatialHackathon/SpaceHack2023/blob/57c47102da861408f946d00ab9b611a2a77eced4/method/SpiceMix/SpiceMix.py#L163-L174

https://github.com/SpatialHackathon/SpaceHack2023/blob/57c47102da861408f946d00ab9b611a2a77eced4/method/SpiceMix/config/config_1.json#L1-L8

SpiceMix uses GPU (cuda) as device and it raises an error when running our pipeline atm as we don't have GPU access. I don't know much about GPU but I added the line below to make it work. It seems it runs slowly and returns me this warning (last code chunk). Does it make sense? Do you have any recommendations?

torch_context["device"] = device if torch.cuda.is_available() else 'cpu'

warning:

/home/jovyan/scratch/SpaceHack2/userfolders/jsun/workflow/SpaceHack2023/workflows/.snakemake/conda/397c14e72e8de8734c04bce3a0f813c6_/lib/python3.8/site-packages/popari/util.py:499: UserWarning: Creating a tensor from a list of numpy.ndarrays is extremely slow. Please consider converting the list to a single numpy.ndarray with numpy.array() before converting to a tensor. (Triggered internally at ../torch/csrc/utils/tensor_new.cpp:230.)
  i = torch.LongTensor(indices)

@alam-shahul (maybe you know)

niklasmueboe commented 9 months ago

Given that the warning is created inside popari I don't think we have much influence on that, unless we are passing "incorrrect" input, which I don't think is the case. So I guess we can ignore the warning for now.

alam-shahul commented 9 months ago

The warning is not that important and it might also trigger when using the GPU. It will be fixed in future versions of Popari.

More importantly, SpiceMix/Popari is designed to be used with a GPU; although it is possible to run with a CPU, this is computationally infeasible for any sizable spatial transcriptomics dataset.