主要问题是torchvision的问题
在122服务器上的scvi-env2环境中
import torch
import torch.nn as nnimport numpy as npfrom tqdm import tqdm
from torchvision.utils import save_image, make_grid
# Model Hyperparametersdataset_path = './datasets'cuda = True
DEVICE = torch.device("cuda" if cuda else "cpu")batch_size = 100x_dim = 784
hidden_dim = 400
latent_dim = 200lr = 1e-3epochs = 30from torchvision.datasets import MNIST
import torchvision.transforms as transforms
from torch.utils.data import DataLoadermnist_transform = transforms.Compose([transforms.ToTensor(),
])kwargs = {'num_workers': 1, 'pin_memory': True} train_dataset = MNIST(dataset_path, transform=mnist_transform, train=True, download=True)
test_dataset = MNIST(dataset_path, transform=mnist_transform, train=False, download=True)train_loader = DataLoader(dataset=train_dataset, batch_size=batch_size, shuffle=True, **kwargs)
test_loader = DataLoader(dataset=test_dataset, batch_size=batch_size, shuffle=False, **kwargs)
是可以正常运行的
但是如果换到下面的环境,就会报错
结果如下