onnxruntime: TensorRT backend not work when the device_id is greater than 0

Describe the issue

Cuda backend runs fine on multiple gpus, but TensorRT fails when the device_id is specified as a value greater than 0. One successful workaround I have tried so far is using multiple processes, and each using different environment variables CUDA_VISIBLE_DEVICES=device_id.

To reproduce

…

Urgency

Urgent, because the project is organized in multiple threads, and no workaround works.

Platform

Linux

OS Version

20.04

ONNX Runtime Installation

Released Package

ONNX Runtime Version or Commit ID

1.16.3 and 1.17.0

ONNX Runtime API

C++

Architecture

X64

Execution Provider

TensorRT

Execution Provider Library Version

TensorRT 8.6

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 16 (8 by maintainers)

Most upvoted comments

According to my test, the problem is indeed solved after add cudaSetDevice(device id in session options) in each running thread!