Minor fix

This commit is contained in:
AlexeyAB 2020-05-07 18:41:43 +03:00
parent 1d95870468
commit 1f60ca57ad
3 changed files with 6 additions and 4 deletions

View File

@ -491,12 +491,13 @@ int get_number_of_blocks(int array_size, int block_size)
return array_size / block_size + ((array_size % block_size > 0) ? 1 : 0); return array_size / block_size + ((array_size % block_size > 0) ? 1 : 0);
} }
int get_gpu_compute_capability(int i) int get_gpu_compute_capability(int i, char *device_name)
{ {
typedef struct cudaDeviceProp cudaDeviceProp; typedef struct cudaDeviceProp cudaDeviceProp;
cudaDeviceProp prop; cudaDeviceProp prop;
cudaError_t status = cudaGetDeviceProperties(&prop, i); cudaError_t status = cudaGetDeviceProperties(&prop, i);
CHECK_CUDA(status); CHECK_CUDA(status);
if (device_name) strcpy(device_name, prop.name);
int cc = prop.major * 100 + prop.minor * 10; // __CUDA_ARCH__ format int cc = prop.major * 100 + prop.minor * 10; // __CUDA_ARCH__ format
return cc; return cc;
} }

View File

@ -79,7 +79,7 @@ extern "C" {
cudaStream_t get_cuda_stream(); cudaStream_t get_cuda_stream();
cudaStream_t get_cuda_memcpy_stream(); cudaStream_t get_cuda_memcpy_stream();
int get_number_of_blocks(int array_size, int block_size); int get_number_of_blocks(int array_size, int block_size);
int get_gpu_compute_capability(int i); int get_gpu_compute_capability(int i, char *device_name);
void show_cuda_cudnn_info(); void show_cuda_cudnn_info();
#ifdef CUDNN #ifdef CUDNN

View File

@ -1125,12 +1125,13 @@ void parse_net_options(list *options, network *net)
net->burn_in = option_find_int_quiet(options, "burn_in", 0); net->burn_in = option_find_int_quiet(options, "burn_in", 0);
#ifdef GPU #ifdef GPU
if (net->gpu_index >= 0) { if (net->gpu_index >= 0) {
int compute_capability = get_gpu_compute_capability(net->gpu_index); char device_name[1024];
int compute_capability = get_gpu_compute_capability(net->gpu_index, device_name);
#ifdef CUDNN_HALF #ifdef CUDNN_HALF
if (compute_capability >= 700) net->cudnn_half = 1; if (compute_capability >= 700) net->cudnn_half = 1;
else net->cudnn_half = 0; else net->cudnn_half = 0;
#endif// CUDNN_HALF #endif// CUDNN_HALF
fprintf(stderr, " compute_capability = %d, cudnn_half = %d \n", compute_capability, net->cudnn_half); fprintf(stderr, " %d : compute_capability = %d, cudnn_half = %d, GPU: %s \n", net->gpu_index, compute_capability, net->cudnn_half, device_name);
} }
else fprintf(stderr, " GPU isn't used \n"); else fprintf(stderr, " GPU isn't used \n");
#endif// GPU #endif// GPU