24 #include <cuda_runtime.h>
27 using namespace std::string_literals;
28 std::vector<size_t> ret;
31 cudaError_t error_id = cudaGetDeviceCount(&deviceCount);
33 if (error_id != cudaSuccess) {
34 throw std::runtime_error(
"cudaGetDeviceCount failed: "s +
std::to_string(error_id) +
35 ": "s + cudaGetErrorString(error_id));
38 for (
int dev = 0; dev < deviceCount; ++dev) {
40 cudaDeviceProp deviceProp;
41 cudaGetDeviceProperties(&deviceProp, dev);
43 if (deviceProp.major <= 0) {
44 throw std::runtime_error(
"unexpected cuda compute capability: major "s +
47 if (deviceProp.minor < 0) {
48 throw std::runtime_error(
"unexpected cuda compute capability: minor "s +
52 if (deviceProp.major >= 10) {
53 throw std::runtime_error(
"unexpected cuda compute capability: major "s +
56 if (deviceProp.minor >= 10) {
57 throw std::runtime_error(
"unexpected cuda compute capability: minor "s +
61 ret.push_back((deviceProp.major * 10U) + deviceProp.minor);
std::vector< size_t > get_nvidia_compute_capability()