Created
August 12, 2022 03:31
-
-
Save sandeepkumar-skb/a0e61dffaf672d9693964b4fc300977d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import onnxruntime as ort | |
import torch | |
from time import perf_counter | |
ort_session = ort.InferenceSession("resnet50.onnx", providers=["CPUExecutionProvider"]) | |
print(ort.get_device()) | |
inputs = {} | |
for inp in ort_session.get_inputs(): | |
inputs[inp.name] = torch.rand(inp.shape).numpy() | |
if torch.cuda.is_available(): | |
# ort_session.set_providers(['CUDAExecutionProvider']) | |
print("Switching to GPU") | |
start = perf_counter() | |
for _ in range(1000): | |
out = ort_session.run(None, inputs) | |
stop = perf_counter() | |
print(stop - start) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment