#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 26 of file get_nvidia_compute_capability.h.
References to_string().
Referenced by main().
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);