Skip to content

Commit c05c216

Browse files
authored
Merge pull request #544 from abergeron/check_cc
Check compute capability of the GPU on context creation.
2 parents 1c1e068 + 90f7f60 commit c05c216

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

src/gpuarray_buffer_cuda.c

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,13 +219,31 @@ cuda_context *cuda_make_ctx(CUcontext ctx, gpucontext_props *p) {
219219
cache *mem_cache;
220220
const char *cache_path;
221221
void *pp;
222+
CUdevice dev;
222223
CUresult err;
224+
int cc_major, cc_minor;
223225
int e;
224226

225227
e = setup_lib();
226228
if (e != GA_NO_ERROR)
227229
return NULL;
228230

231+
err = cuCtxGetDevice(&dev);
232+
if (err != CUDA_SUCCESS) {
233+
error_cuda(global_err, "cuCtxGetDevice", err);
234+
return NULL;
235+
}
236+
237+
e = get_cc(dev, &cc_major, &cc_minor, global_err);
238+
if (e != GA_NO_ERROR)
239+
return NULL;
240+
241+
if ((major >= 9 && cc_major <= 2) || (major >= 7 && cc_major <= 1)) {
242+
error_set(global_err, GA_UNSUPPORTED_ERROR,
243+
"GPU is too old for CUDA version");
244+
return NULL;
245+
}
246+
229247
res = calloc(1, sizeof(*res));
230248
if (res == NULL) {
231249
error_sys(global_err, "calloc");

0 commit comments

Comments
 (0)