bart icon indicating copy to clipboard operation
bart copied to clipboard

gpu_wrapper does not honor selected GPU

Open hcmh opened this issue 5 years ago • 1 comments

Hi,

when, for example, using pics -G1 -g ..., the following wrapping code will still try to initilize CUDA on other GPUs, not honoring my selected GPU:

https://github.com/mrirecon/bart/blob/dca1cd4c2a2d00cd33a59d5e2b7381d358db05a2/src/num/ops.c#L1140-L1143

This is unfortunate because it makes pics unusable on the GPU when CUDA is configured to only allow a single process per GPU.

hcmh avatar Mar 12 '19 15:03 hcmh

yes, this broke at some point (and letting the driver select was broken before). Here is the plan to fix it:

  • In gpuops.c: introduce a global bitmask gpu_allowed.
  • In src/num/gpuops.c: make 'cuda_init' fail if gpu is not allowed and 'cuda_init_memopt' select from allowed GPus
  • in src/num/ops.c: move gpu selection into a new function to src/num/gpuops.c which respect the bitmask (e.g. selects according to allowed gpus) and does nothing if bitmask is zero.
  • in src/num/init.c: add a new function num_init_multigpu: which takes a bitmask as argument and selects the first allowed GPU.
  • in src/pics.c: change command-line argument to take the bitmask and pass it on. default should be a bitmask of zero and a call to num_init_gpu which let's the driver decide.

uecker avatar Mar 12 '19 16:03 uecker

GPU selection is now implemented by the driver. Use the CUDA_VISIBLE_DEVICES variable to the selected GPUs. BART will then use the first available selected GPU.

mblum94 avatar Nov 15 '23 12:11 mblum94