Hi, I met a bug in trtexec.cpp.
void doInference(ICudaEngine& engine)
{
IExecutionContext* context = engine.createExecutionContext();
std::cout<<"context created "<<std::endl;
SimpleProfiler profiler = SimpleProfiler("Profiler");
if (gParams.benchmarkLayers){
context->setProfiler(&profiler);
}
// input and output buffer pointers that we pass to the engine - the engine requires exactly IEngine::getNbBindings(),
// of these, but in this case we know that there is exactly one input and one output.
std::vector<void*> buffers(gParams.inputs.size() + gParams.outputs.size());
for (size_t i = 0; i < gParams.inputs.size(); i++)
createMemory(engine, buffers, gParams.inputs[i]);
for (size_t i = 0; i < gParams.outputs.size(); i++)
createMemory(engine, buffers, gParams.outputs[i]);
//void* buffers[gParams.inputs.size() + gParams.outputs.size()];
std::cout<<"memory create is completed"<<std::endl;
cudaStream_t stream;
CHECK(cudaStreamCreate(&stream));
cudaEvent_t start, end;
unsigned int cudaEventFlags = gParams.useSpinWait ? cudaEventDefault : cudaEventBlockingSync;
CHECK(cudaEventCreateWithFlags(&start, cudaEventFlags));
CHECK(cudaEventCreateWithFlags(&end, cudaEventFlags));
std::ofstream file;
initiateFile(file);
std::vector<float> timesGpu(gParams.avgRuns);
std::vector<float> timesHost(gParams.avgRuns);
for (int j = 0; j < gParams.iterations; j++)
{
float totalGpu{0}, totalHost{0}; // GPU and Host timers
for (int i = 0; i < gParams.avgRuns; i++)
{
auto tStart = std::chrono::high_resolution_clock::now();
cudaEventRecord(start, stream);
std::cout<<"enqueue starts"<<std::endl;
//context->enqueue(gParams.batchSize, &buffers[0], stream, nullptr);
//context->enqueue(gParams.batchSize, &buffers[0],&buffer[1]);
context->execute(gParams.batchSize, &buffers[0]);
//mTrtContext->execute(batchSize, &mTrtCudaBuffer[inputIndex]);
std::cout<<"enqueue ended here"<<std::endl;
cudaEventRecord(end, stream);
cudaEventSynchronize(end);
auto tEnd = std::chrono::high_resolution_clock::now();
timesHost[i] = std::chrono::duration<float, std::milli>(tEnd - tStart).count();
totalHost += timesHost[i];
float ms;
cudaEventElapsedTime(&ms, start, end);
timesGpu[i] = ms;
totalGpu += ms;
}
totalGpu /= gParams.avgRuns;
totalHost /= gParams.avgRuns;
std::cout << "Average over " << gParams.avgRuns << " runs is " << totalGpu << " ms (host walltime is " << totalHost
<< " ms, " << static_cast<int>(gParams.pct) << "\% percentile time is " << percentile(gParams.pct, timesGpu) << ")." << std::endl;
// calculate standard deviation
float stdGpu = stDev (timesGpu, totalGpu);
float stdHost = stDev (timesHost, totalHost);
file << totalGpu << "\t" << stdGpu << "\t" << totalHost << "\t" << stdHost << "\t" << percentile(gParams.pct, timesGpu) << "\n";
}
file << "\n";
if (gParams.benchmarkLayers)
{
file << profiler;
std::cout << profiler;
}
file.close();
cudaStreamDestroy(stream);
cudaEventDestroy(start);
cudaEventDestroy(end);
context->destroy();
}
I kept getting error as:
enqueue starts
engine.cpp (713) - Cuda Error in execute: 700 (an illegal memory access was encountered)
engine.cpp (713) - Cuda Error in execute: 700 (an illegal memory access was encountered)
enqueue ended here
enqueue starts
cuda/genericReformat.cu (1259) - Cuda Error in executeMemcpy: 700 (an illegal memory access was encountered)
cuda/genericReformat.cu (1259) - Cuda Error in executeMemcpy: 700 (an illegal memory access was encountered)
enqueue ended here
enqueue starts
cuda/genericReformat.cu (1259) - Cuda Error in executeMemcpy: 700 (an illegal memory access was encountered)
cuda/genericReformat.cu (1259) - Cuda Error in executeMemcpy: 700 (an illegal memory access was encountered)
enqueue ended here
enqueue starts
cuda/genericReformat.cu (1259) - Cuda Error in executeMemcpy: 700 (an illegal memory access was encountered)
cuda/genericReformat.cu (1259) - Cuda Error in executeMemcpy: 700 (an illegal memory access was encountered)
enqueue ended here
enqueue starts
cuda/genericReformat.cu (1259) - Cuda Error in executeMemcpy: 700 (an illegal memory access was encountered)
cuda/genericReformat.cu (1259) - Cuda Error in executeMemcpy: 700 (an illegal memory access was encountered)
enqueue ended here
enqueue starts
cuda/genericReformat.cu (1259) - Cuda Error in executeMemcpy: 700 (an illegal memory access was encountered)
cuda/genericReformat.cu (1259) - Cuda Error in executeMemcpy: 700 (an illegal memory access was encountered)
enqueue ended here
Average over 6 runs is 171.985 ms (host walltime is 191.573 ms, 99% percentile time is 1031.91).
enqueue starts
cuda/genericReformat.cu (1259) - Cuda Error in executeMemcpy: 700 (an illegal memory access was encountered)
cuda/genericReformat.cu (1259) - Cuda Error in executeMemcpy: 700 (an illegal memory access was encountered)
enqueue ended here
enqueue starts
cuda/genericReformat.cu (1259) - Cuda Error in executeMemcpy: 700 (an illegal memory access was encountered)
cuda/genericReformat.cu (1259) - Cuda Error in executeMemcpy: 700 (an illegal memory access was encountered)
enqueue ended here
enqueue starts
cuda/genericReformat.cu (1259) - Cuda Error in executeMemcpy: 700 (an illegal memory access was encountered)
cuda/genericReformat.cu (1259) - Cuda Error in executeMemcpy: 700 (an illegal memory access was encountered)
enqueue ended here
enqueue starts
cuda/genericReformat.cu (1259) - Cuda Error in executeMemcpy: 700 (an illegal memory access was encountered)
cuda/genericReformat.cu (1259) - Cuda Error in executeMemcpy: 700 (an illegal memory access was encountered)
enqueue ended here
enqueue starts
cuda/genericReformat.cu (1259) - Cuda Error in executeMemcpy: 700 (an illegal memory access was encountered)
cuda/genericReformat.cu (1259) - Cuda Error in executeMemcpy: 700 (an illegal memory access was encountered)
enqueue ended here
enqueue starts
cuda/genericReformat.cu (1259) - Cuda Error in executeMemcpy: 700 (an illegal memory access was encountered)
cuda/genericReformat.cu (1259) - Cuda Error in executeMemcpy: 700 (an illegal memory access was encountered)
enqueue ended here
Average over 6 runs is 4.2514e-41 ms (host walltime is 0.0303392 ms, 99% percentile time is 7.94116e-41).
enqueue starts
cuda/genericReformat.cu (1259) - Cuda Error in executeMemcpy: 700 (an illegal memory access was encountered)
cuda/genericReformat.cu (1259) - Cuda Error in executeMemcpy: 700 (an illegal memory access was encountered)
enqueue ended here
enqueue starts
cuda/genericReformat.cu (1259) - Cuda Error in executeMemcpy: 700 (an illegal memory access was encountered)
cuda/genericReformat.cu (1259) - Cuda Error in executeMemcpy: 700 (an illegal memory access was encountered)
enqueue ended here
enqueue starts
cuda/genericReformat.cu (1259) - Cuda Error in executeMemcpy: 700 (an illegal memory access was encountered)
cuda/genericReformat.cu (1259) - Cuda Error in executeMemcpy: 700 (an illegal memory access was encountered)
enqueue ended here
enqueue starts
cuda/genericReformat.cu (1259) - Cuda Error in executeMemcpy: 700 (an illegal memory access was encountered)
cuda/genericReformat.cu (1259) - Cuda Error in executeMemcpy: 700 (an illegal memory access was encountered)
enqueue ended here
enqueue starts
cuda/genericReformat.cu (1259) - Cuda Error in executeMemcpy: 700 (an illegal memory access was encountered)
cuda/genericReformat.cu (1259) - Cuda Error in executeMemcpy: 700 (an illegal memory access was encountered)
enqueue ended here
enqueue starts
cuda/genericReformat.cu (1259) - Cuda Error in executeMemcpy: 700 (an illegal memory access was encountered)
cuda/genericReformat.cu (1259) - Cuda Error in executeMemcpy: 700 (an illegal memory access was encountered)
enqueue ended here
Average over 6 runs is 2.39664e-41 ms (host walltime is 0.0171033 ms, 99% percentile time is 4.52213e-41).
Parameter check failed at: engine.cpp::terminateCommonContext::192, condition: cudaEventDestroy(context.start) failure.
Parameter check failed at: engine.cpp::terminateCommonContext::197, condition: cudaEventDestroy(context.stop) failure.
runtime.cpp (31) - Cuda Error in free: 700 (an illegal memory access was encountered)
terminate called after throwing an instance of 'nvinfer1::CudaError'
what(): std::exception
Abgebrochen (Speicherabzug geschrieben)
Is there anyone who can give me some hints?
Thanks in advance!