当前位置:网站首页>darknet 硬件软件环境的设置和检测
darknet 硬件软件环境的设置和检测
2022-07-31 10:05:00 【Mr.Q】

1. 设置gpu卡号
cuda_set_device(gpu_index); // 通过给定gpu_index不同的值设置使用的显卡。
CHECK_CUDA(cudaSetDeviceFlags(cudaDeviceScheduleBlockingSync)); // 主机线程将阻塞,直到设备完成其工作。
/// <summary>
/// set the gpu used
/// </summary>
/// <param name="n">gpu index</param>
void cuda_set_device(int n)
{
gpu_index = n; // 全局变量
cudaError_t status = cudaSetDevice(n);
if(status != cudaSuccess) CHECK_CUDA(status);
}2. 检查cuda和cudnn版本并获取显卡个数
void show_cuda_cudnn_info()
{
int cuda_version = 0, cuda_driver_version = 0, device_count = 0; // 初始化值
CHECK_CUDA(cudaRuntimeGetVersion(&cuda_version)); // cuda version: 11.1. cuda_version = 11*1000+1*10 = 11010
CHECK_CUDA(cudaDriverGetVersion(&cuda_driver_version)); // cuda_driver_version: 11.6. 11060
fprintf(stderr, " CUDA-version: %d (%d)", cuda_version, cuda_driver_version);
if(cuda_version > cuda_driver_version) fprintf(stderr, "\n Warning: CUDA-version is higher than Driver-version! \n"); // 安装的cuda必须小于系统支持的版本。
#ifdef CUDNN
fprintf(stderr, ", cuDNN: %d.%d.%d", CUDNN_MAJOR, CUDNN_MINOR, CUDNN_PATCHLEVEL); // 8 0 5
#endif // CUDNN
#ifdef CUDNN_HALF // 构建Tensor核心
fprintf(stderr, ", CUDNN_HALF=1");
#endif // CUDNN_HALF
CHECK_CUDA(cudaGetDeviceCount(&device_count)); // 获取显卡设备个数device_count
fprintf(stderr, ", GPU count: %d ", device_count);
fprintf(stderr, " \n");
}
3. 检查opencv版本
show_opencv_info();
void show_opencv_info()
{
std::cerr << " OpenCV version: " << CV_VERSION_MAJOR << "." << CV_VERSION_MINOR << "." << CVAUX_STR(CV_VERSION_REVISION) OCV_D
<< std::endl;
}4. 检测gpu算力
char device_name[1024];
int compute_capability = get_gpu_compute_capability(net->gpu_index, device_name);
int get_gpu_compute_capability(int i, char *device_name)
{
typedef struct cudaDeviceProp cudaDeviceProp;
cudaDeviceProp prop;
cudaError_t status = cudaGetDeviceProperties(&prop, i);
CHECK_CUDA(status);
if (device_name) strcpy(device_name, prop.name); // gpu名称
int cc = prop.major * 100 + prop.minor * 10; // __CUDA_ARCH__ format. 8*100+6*10=860
return cc;
}
边栏推荐
猜你喜欢

如何在 TiDB Cloud 上使用 Databricks 进行数据分析 | TiDB Cloud 使用指南

nodeJs--url模块

【职场杂谈】售前工程师岗位的理解杂谈

浏览器使用占比js雷达图

Gradle series - Groovy overview, basic use (based on Groovy document 4.0.4) day2-1

Binary tree search and backtracking problem (leetcode)

可以用聚酯树脂将接线板密封接线盒吗?(接线盒灌封胶用哪种树脂)

Implement a thread pool

如何优雅的停止一个线程?

尚医通【预约挂号系统】总结
随机推荐
win10镜像下载
Business-(Course-Chapter-Subsection) + Course Publishing Some Business Ideas
The big-eyed Google Chrome has also betrayed, teach you a trick to quickly clear its own ads
解决rpc error: code = Unimplemented desc = method CheckLicense not implemented
浅谈Attention与Self-Attention,一起感受注意力之美
湖仓一体电商项目(二):项目使用技术及版本和基础环境准备
开放麒麟 openKylin 自动化开发者平台正式发布
Mybaits Frequently Asked Questions Explained
js department budget and expenditure radar chart
使用turtle画按钮
零代码工具推荐 八爪鱼采集器
乐观锁和悲观锁
我们能做出来数据库吗?
Progressive Web App(PWA)
前序、后序及层次遍历实现二叉树的序列化与反序列化
Web系统常见安全漏洞介绍及解决方案-CSRF攻击
Come n times with the sword--05. Replace spaces
数据中台建设(六):数据体系建设
【职场杂谈】售前工程师岗位的理解杂谈
Qt 编译错误:C2228: “.key”的左边必须有类/结构/联合