Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 3 additions & 17 deletions examples/instance_kind/model.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Copyright 2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# Copyright 2023-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions
Expand All @@ -24,8 +24,8 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

import numpy as np
import torch
from torchvision import models
import triton_python_backend_utils as pb_utils
from torch.utils.dlpack import to_dlpack

Expand All @@ -49,21 +49,7 @@ def initialize(self, args):
device = "cuda" if args["model_instance_kind"] == "GPU" else "cpu"
device_id = args["model_instance_device_id"]
self.device = f"{device}:{device_id}"
# This example is configured to work with torch=1.13
# and torchvision=0.14. Thus, we need to provide a proper tag `0.14.1`
# to make sure loaded Resnet50 is compatible with
# installed `torchvision`.
# Refer to README for installation instructions.
self.model = (
torch.hub.load(
"pytorch/vision:v0.14.1",
"resnet50",
weights="IMAGENET1K_V2",
skip_validation=True,
)
.to(self.device)
.eval()
)
self.model = models.resnet50(weights=models.ResNet50_Weights.IMAGENET1K_V2).to(self.device).eval()

def execute(self, requests):
"""
Expand Down
Loading