thrust icon indicating copy to clipboard operation
thrust copied to clipboard

Better error message for no GPU or incompatible GPU

Open dkolsen-pgi opened this issue 3 years ago • 1 comments

Given this small but useless test program:

#include <thrust/device_vector.h>
#include <thrust/sort.h>
int main() {
  thrust::device_vector<int> dv;
  thrust::sort(dv.begin(), dv.end());
}

When compiled with nvcc -arch=sm_80 tiny.cu and then run on a system that doesn't have any GPUs, the error message is:

terminate called after throwing an instance of 'thrust::system::system_error'
  what():  radix_sort: failed on 1st step: cudaErrorInvalidDevice: invalid device ordinal
Aborted

When run a system with a Volta GPU (sm_70), it fails with:

terminate called after throwing an instance of 'thrust::system::system_error'
  what():  radix_sort: failed on 1st step: cudaErrorInvalidDeviceFunction: invalid device function
Aborted

I don't expect either of those situations to work. The program should crash. What I would like is a better error message, one that gives a naive user some clue about what is happening. The first case should say something about no GPU being available, and the second should mention something about an incompatible GPU (saying that you are trying to run an sm_80 program on an sm_70 GPU would be awesome).

Making such a change will improve the user experience and make it easier for users to troubleshoot problems.

dkolsen-pgi avatar Aug 31 '22 22:08 dkolsen-pgi

I agree 100% with the request here.

The challenge is I don't think there is much we are going to be able to do in the immediate future. We are just forwarding what CUDA tells us and are beholden to the quality of the information it provides. Obviously there is a lot of room for improvement.

Granted, Thrust can (and should) go above and beyond to try and provide more contextual information to improve upon CUDA's lackluster error messages in the situations you reported as well as countless others. Making meaningful improvements here will be a significant undertaking.

jrhemstad avatar Sep 13 '22 23:09 jrhemstad