Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SpiceMix GPU #225

Open
Jieran-S opened this issue Feb 23, 2024 · 2 comments
Open

SpiceMix GPU #225

Jieran-S opened this issue Feb 23, 2024 · 2 comments

Comments

@Jieran-S
Copy link
Member

Jieran-S commented Feb 23, 2024

device = config.pop("device", "cpu")
dtype = config.pop("dtype", "float32")
if dtype == "float32":
dtype = torch.float32
elif dtype == "float64":
dtype = torch.float64
torch_context = {
"device": device,
"dtype": dtype,
}

{
"K": 15,
"lambda_Sigma_x_inv": 1e-4,
"device": "cuda:0",
"dtype": "float64",
"num_preiterations": 5,
"num_iterations": 200
}

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)

@Jieran-S Jieran-S mentioned this issue Feb 26, 2024
@niklasmueboe
Copy link
Collaborator

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
Copy link
Contributor

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.

@peicai peicai mentioned this issue Jun 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants