FastSurferCNN.gpu_support¶
Explain why a GPU cannot be used, and what to use instead.
PyTorch either reports cuda as unavailable or fails at the first kernel with “no kernel image is available for execution on the device”. Neither tells the user that a different FastSurfer image or PyTorch build would run on their GPU. This names the cause: the GPU architecture is not compiled into this PyTorch build, the driver is too old for its CUDA version, the build has no CUDA at all, or the container was started without access to the GPU.
Run as a script, so run_fastsurfer.sh can check the device once per run:
python3 FastSurferCNN/gpu_support.py –device auto
Exit codes: 0 when the device can be used, 3 when “auto” found a GPU it cannot use and falls back to the cpu, 4 when “auto” falls back to the cpu for a reason that is only worth a note, 5 when a requested cuda device cannot be used. None of them is 1 or 2, which a crash or an argument error returns.
Imports torch only inside the functions that need it, so the rest can be tested without it.
- FastSurferCNN.gpu_support.cuda_problem(device_index=None)[source]¶
Find out why cuda cannot be used on this machine, if it cannot.
- Parameters:
- device_index
int,optional The cuda device to check, the current device by default.
- device_index
- Returns:
- FastSurferCNN.gpu_support.supports_capability(capability, arch_list)[source]¶
Whether a PyTorch build compiled for these architectures runs on a GPU of this capability.
A cubin (
sm_XY) runs on the same major architecture at an equal or higher minor version, so sm_120 also covers sm_121. PTX (compute_XY) is compiled by the driver for any GPU at or above it. Architecture specific variants such assm_90arun on exactly that architecture.