0

I have a GAN model that I developed for signal generation. This was trained on an external Windows GPU server, which has Pytorch 1.6 installed on it. However, when I try to load the model to quantise it gives me the error in the image below, saying that the Pytorch installation might be too old. I checked the packages installed on the vitis-ai-cpu and they have Pytorch 1.4 there, so I thought I should train my model on the same Pytorch version but unfortunately the 1.4 version does not have the GPU version anymore. I tried to do that in multiple ways, but I only found the CPU verison of Pytorch 1.4. Can you please tell me how I can solve this error? Shall I downgrade the Pytorch version or can I solve this in a different way? Thank you

This is the code that I want to run in the vitis-ai environment:

import torch
import torch.nn as nn
import torch.optim as optim
from torch.utils.data import DataLoader
import torch.nn.functional as F
from pytorch_nndct.apis import torch_quantizer, dump_xmodel

from GAN_arh import *
PATH = 'Generator_copy_2000e.pth'
num_classes = 3
embed_size = 750
in_channels=2
out_channels=2

device='cpu'
generator = UNet1D(in_channels, out_channels, num_classes, embed_size).to(device)
generator.load_state_dict(torch.load(PATH), map_location='cpu') # here is where I get the error

quantizer = torch_quantizer(quant_mode=quant_mode, model=generator, device='cpu')
quant_model = quantizer.quant_model
quantized_model.save('generator_quantitized.pth')

This is the error: enter image description here

I tried to change the Pytorch version to an older one (from pytorch 1.6.0 -> 1.4.0), hoping that this would solve the error. However, Pytorch 1.4.0 does not have the gpu version ofthe package anymore. Moreover, I tried to downgrade the Pytorch to 1.13 version, but I had the same error come up when I try to load the model.

0 Answers0