Deploy a Framework-prequantized Model error: expected text format semantic version, found a Token

I’m using tvm on Windows x64. Running the original codes to check the installation:

import tvm
from tvm import relay

import numpy as np

from tvm.contrib.download import download_testdata

# PyTorch imports
import torch
import torchvision

import time


model_name = "resnet18"
model = getattr(torchvision.models, model_name)(pretrained=True)
model = model.eval()

# We grab the TorchScripted model via tracing
input_shape = [1, 3, 224, 224]
input_data = torch.randn(input_shape)
scripted_model = torch.jit.trace(model, input_data).eval()

from PIL import Image

img_url = "https://github.com/dmlc/mxnet.js/blob/main/data/cat.png?raw=true"
img_path = download_testdata(img_url, "cat.png", module="data")
img = Image.open(img_path).resize((224, 224))

# Preprocess the image and convert to tensor
from torchvision import transforms

my_preprocess = transforms.Compose(
    [
        transforms.Resize(256),
        transforms.CenterCrop(224),
        transforms.ToTensor(),
        transforms.Normalize(mean=[0.485, 0.456, 0.406], std=[0.229, 0.224, 0.225]),
    ]
)
img = my_preprocess(img)
img = np.expand_dims(img, 0)


input_name = "input0"
shape_list = [(input_name, img.shape)]
func, params = relay.frontend.from_pytorch(scripted_model, shape_list)

When running to the final statement, func, params = relay.frontend.from_pytorch(scripted_model, shape_list), an error accurs:

file:1:1: parse error: expected text format semantic version, found a  Token(span=Span(SourceName(D:\myTVM\venv\lib\site-packages\tvm\relay\std/prelude.rly, 000002E9033840F0), 1, 1, 1, 2), token_type=EndOfFile, data=(nullptr))you can annotate it as #[version = "0.0.5"]

What does this mean, how to slove the error?

@masahi Hello, when I ran this code, I also encountered an error :sob:.when I debug, I found that this api relay.frontend.from_pytorch reported an error. The error is as follows.:

How can I solve it please? I am very sorry because I am very anxious to solve it. please help me,thanks!!

@masahi Can you provide me with some ideas please? thank you very much!!!

this is an unrelated error, it means there are some error when loading prelude.rly (Relay’s predefined library) file, I’m not sure why this happened

Thank you very much, Is there any way to solve it please?

Does it have anything to do with the high version of pytorch? my pytorch is 1.9.0+cpu

@masahi Sorry to bother you, can you please take a look at my mistake,thank you very much!

It’s possible that Relay parser is having a trouble parsing a Windows path or your user name 田田. Unfortunately I don’t have a solution.