#include <cassert>
#include <stdexcept>
#include <string>
#include <vector>
#include <cuda_runtime.h>
Go to the source code of this file.
std::vector<size_t> get_nvidia_compute_capability |
( |
| ) |
|
|
inline |
Definition at line 24 of file get_nvidia_compute_capability.h.
References to_string().
Referenced by main().
25 using namespace std::string_literals;
26 std::vector<size_t> ret;
29 cudaError_t error_id = cudaGetDeviceCount(&deviceCount);
31 if (error_id != cudaSuccess) {
32 throw std::runtime_error(
"cudaGetDeviceCount failed: "s +
std::to_string(error_id) +
33 ": "s + cudaGetErrorString(error_id));
36 for (
int dev = 0; dev < deviceCount; ++dev) {
38 cudaDeviceProp deviceProp;
39 cudaGetDeviceProperties(&deviceProp, dev);
41 if (deviceProp.major <= 0) {
42 throw std::runtime_error(
"unexpected cuda compute capability: major "s +
45 if (deviceProp.minor < 0) {
46 throw std::runtime_error(
"unexpected cuda compute capability: minor "s +
50 if (deviceProp.major >= 10) {
51 throw std::runtime_error(
"unexpected cuda compute capability: major "s +
54 if (deviceProp.minor >= 10) {
55 throw std::runtime_error(
"unexpected cuda compute capability: minor "s +
59 ret.push_back((deviceProp.major * 10U) + deviceProp.minor);