create commit message "@@ -132,8 +132,6 @@ std::vector<cv::Mat>…
- User
create commit message "@@ -132,8 +132,6 @@ std::vectorcv::Mat Segmentator::process(std::vectorcv::Mat &frames) std::vectorcv::Mat masksOut; masksOut.reserve(frames.size()); int imgNum {0};
-
int n_streams = frames.size();
-
streamAlloc(n_streams); for(cv::Mat& image : frames) { //resize input image to the size required by neural net @@ -150,10 +148,10 @@ std::vectorcv::Mat Segmentator::process(std::vectorcv::Mat &frames) cv::resize(image, image_resized, cv::Size(w_, h_)); }
-
NV_CUDA_CHECK(cudaStreamCreate(&(stream_[imgNum])));
-
NV_CUDA_CHECK(cudaStreamCreate(&stream_)); //transfer the image to GPU
-
NV_CUDA_CHECK(cudaMemcpyAsync(inputGpu_, inputCpu_, h_ * w_ * 3 * sizeof(unsigned char), cudaMemcpyHostToDevice, stream_[imgNum]));
-
NV_CUDA_CHECK(cudaMemcpyAsync(inputGpu_, inputCpu_, h_ * w_ * 3 * sizeof(unsigned char), cudaMemcpyHostToDevice, stream_)); //normalize image and reshape it such that it has channels-first format (required by neural net) NV_CUDA_CHECK(preprocessOnGpuWrapper(inputGpu_, inputCfGpu_, h_, w_, coef_, mean_[0], mean_[1], mean_[2], std_[0], std_[1], std_[2]));
@@ -163,10 +161,9 @@ std::vectorcv::Mat Segmentator::process(std::vectorcv::Mat &frames) buffers_[1] = outputRawGpu_; context_->getBindingDimensions(0);
-
context_->enqueueV2((void **)buffers_, stream_[imgNum], nullptr);
-
context_->enqueueV2((void **)buffers_, stream_, nullptr);
-
NV_CUDA_CHECK(cudaStreamSynchronize(stream_[imgNum])); -
NV_CUDA_CHECK(cudaDeviceSynchronize());
-
NV_CUDA_CHECK(cudaStreamSynchronize(stream_)); //compute segmentation masks from raw neural net ouput NV_CUDA_CHECK(computeOutputOnGpuWrapper(outputRawGpu_, outputMaskGpu_, h_, w_, numClasses_, threshold_));
-
- Assistant
Remove multi-stream support and simplify CUDA stream usage in Segmentator::process - Removed streamAlloc and the stream_ array that managed multiple CUDA streams. - Switched to creating, using, and destroying a single CUDA stream per process call. - Updated cudaMemcpyAsync, enqueueV2, cudaStreamSynchronize, and cudaStreamDestroy calls to use the single stream. - This change reduces complexity and resource allocation, as the multi-stream approach was not required or was causing issues.