mirror of
https://github.com/lordmathis/CUDANet.git
synced 2025-11-07 10:14:27 +00:00
26 lines
585 B
Plaintext
26 lines
585 B
Plaintext
#include <cuda_runtime.h>
|
|
|
|
#include <cstdio>
|
|
#include <cstdlib>
|
|
|
|
#include "cuda_helper.cuh"
|
|
|
|
cudaDeviceProp initializeCUDA() {
|
|
int deviceCount;
|
|
CUDA_CHECK(cudaGetDeviceCount(&deviceCount));
|
|
|
|
if (deviceCount == 0) {
|
|
std::fprintf(stderr, "No CUDA devices found. Exiting.\n");
|
|
std::exit(EXIT_FAILURE);
|
|
}
|
|
|
|
int device = 0;
|
|
CUDA_CHECK(cudaSetDevice(device));
|
|
|
|
cudaDeviceProp deviceProp;
|
|
CUDA_CHECK(cudaGetDeviceProperties(&deviceProp, device));
|
|
|
|
std::printf("Using CUDA device %d: %s\n", device, deviceProp.name);
|
|
|
|
return deviceProp;
|
|
} |