Closed ZHEQIUSHUI closed 4 years ago
不会有影响的,根据TensorRT的官方文档:
Q: How do I use TensorRT on multiple GPUs? A: Each ICudaEngine object is bound to a specific GPU when it is instantiated, either by the builder or on deserialization. To select the GPU, use cudaSetDevice() before calling the builder or deserializing the engine. Each IExecutionContext is bound to the same GPU as the engine from which it was created. When calling execute() or enqueue(), ensure that the thread is associated with the correct device by calling cudaSetDevice() if necessary.
来源:https://docs.nvidia.com/deeplearning/sdk/tensorrt-developer-guide/index.html#faq
那我是不是需要修改Trt()的构造函数,然后在反序列化engine的之前就用setdevice,这样的话就会吧这个engine绑定对应的gpu?
构造函数源码不需要修改吧,创建类之后直接SetDivice就可以了
是否需要在CreateEngine之前SetDevice?例如以下代码
OpenPose::OpenPose(const std::string& prototxt,
const std::string& caffeModel,
const std::string& saveEngine,
const std::vector<std::string>& outputBlobName,
const std::vector<std::vector<float>>& calibratorData,
int maxBatchSize,
int runMode) {
mNet = new Trt();
mNet->SetDevice(device);//set gpu???
mNet->CreateEngine(prototxt, caffeModel, saveEngine, outputBlobName, calibratorData, maxBatchSize, runMode);
MallocExtraMemory();
}
这样就ok了
谢谢你!我把这个issue关了啊
我想请教一下 这里没看到和模型绑定的信息 那如果我实例了两个Openpose 每一个openpose设置的device不一样 会有什么影响么(主要是现在没有双GPU的机子来测试 老板又要我告诉他。。。拜托了)