Skip to content

Commit

Permalink
chore: set stream when new stream is acquired
Browse files Browse the repository at this point in the history
  • Loading branch information
keehyuna committed Sep 27, 2024
1 parent 43eb560 commit 691cf1e
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions core/runtime/execute_engine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -305,6 +305,7 @@ std::vector<at::Tensor> execute_engine(std::vector<at::Tensor> inputs, c10::intr
if (compiled_engine->engine_stream == c10::cuda::getDefaultCUDAStream(current_device_id)) {
// Create a new stream if the engine stream is the default stream
compiled_engine->engine_stream = c10::cuda::getStreamFromPool(false, current_device_id);
c10::cuda::setCurrentCUDAStream(compiled_engine->engine_stream);
} else {
compiled_engine->engine_stream = compiled_engine->caller_stream;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from tempfile import tempdir
from typing import Any, Dict, List, Optional, Sequence, Tuple

import tensorrt as trt
import torch
import torch_tensorrt
from torch.nn import Module
Expand All @@ -19,8 +20,6 @@
multi_gpu_device_check,
)

import tensorrt as trt

logger = logging.getLogger(__name__)


Expand Down Expand Up @@ -372,6 +371,7 @@ def forward(self, *inputs: torch.Tensor) -> torch.Tensor | Tuple[torch.Tensor, .
or self._engine_stream is None
):
self._engine_stream = torch.cuda.Stream()
torch.cuda.set_stream(self._engine_stream)
else:
self._engine_stream = self._caller_stream

Expand Down

0 comments on commit 691cf1e

Please sign in to comment.