TensorRT|在多个GPU中指定推理设备

2023-08-03 13:46:49     来源 : 面包芯语


(相关资料图)

//查询设备数目intdeviceCount;cudaGetDeviceCount(&deviceCount);//遍历设备编号信息intdevice;for(device=0;device
// 设置当前设备为GPU 0cudaSetDevice(0);// 初始化TensorRTthis->runtime=createInferRuntime(gLogger);assert(this->runtime!=nullptr);this->engine=runtime->deserializeCudaEngine(trtModelStream,size);assert(this->engine!=nullptr);this->context=engine->createExecutionContext();assert(this->context!=nullptr);delete[]trtModelStream;// do more thing here// insert query input and output layers information//创建GPU显存输入/输出缓冲区std::cout<<"input/outpu:"<getNbBindings()<input_h*this->input_w*3*sizeof(float));cudaMalloc(&buffers[2],this->output_h*this->output_w*sizeof(float));cudaMalloc(&buffers[1],32*25600*sizeof(float));//创建临时缓存输出prob.resize(output_h*output_w);mprob.resize(32*25600);//创建cuda流cudaStreamCreate(&stream);
//初始化时间标记cudaEvent_tstart,stop;cudaEventCreate(&start);cudaEventCreate(&stop);cudaEventRecord(start,0);//查询设备数目intdeviceCount;cudaGetDeviceCount(&deviceCount);//遍历设备编号信息intdevice;for(device=0;device

参考资料:

扫码查看OpenCV+OpenVIO+Pytorch系统化学习路线图

标签:

推荐文章

X 关闭

最新资讯

X 关闭

Copyright ©  2015-2023 今日安防网版权所有  备案号:沪ICP备2023005074号-40   联系邮箱:5 85 59 73 @qq.com