Graylab / IgFold

Fast, accurate antibody structure prediction from deep learning on massive set of natural antibodies
Other
319 stars 60 forks source link

How to assign a different GPU? #60

Open TangYiChing opened 10 months ago

TangYiChing commented 10 months ago

Hi,

Due to the GPU-Out-Of-Memory problem, I have to change the default "cuda:0" to another empty GPU, Here's what I did to set the GPU device by changing cuda:0 to cuda:1:

vim igfold/IgFoldRunner.py 

device = torch.device(
"cuda:0" if torch.cuda.is_available() and try_gpu else "cpu")  
print(f"Using device: {device}")

However, I got this error: RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:1 and cuda:0! (when checking argument for argument index in method wrapper_CUDA__index_select)

Can you tell me how to assign a GPU appropriately? Thank you.

aozalevsky commented 9 months ago

@TangYiChing the easy hotfix is to:

  1. change the line

https://github.com/Graylab/IgFold/blob/85d9dcdbc7afb9c38c4427df656fc194a61bd6ee/igfold/IgFoldRunner.py#L61C35-L61C35

from cuda:1 to just cuda

  1. select just one cuda device with a few additional lines:
    import os
    os.enivron["CUDA_VISIBLE_DEVICES"]="0"

Here is an explanation of how this variable works.