It might be not be the best solution, but you could do a look-up table where you do a relationship between CUDA versions and deprecated GPUs.
Then, using torch.cuda.get_device_name(torch.cuda.current_device()) you could check if the code should be executed on GPU or CPU.