I need help with loading dataset from other place than cache

Hi all,
I’m trying to run Alexnet but I don’t have enough space on C so I downloaded on D the ImageNet dataset.
How to point to it?

Device configuration

device = torch.device(‘cuda’ if torch.cuda.is_available() else ‘cpu’)

model = torch.hub.load(‘pytorch/vision:v0.10.0’, ‘alexnet’, pretrained=True)

from datasets import load_dataset
ds = load_dataset(“imagenet-1k”)
test_ds = ds[“test”]

dataloader = DataLoader(
batch_size=64, # may need to reduce this depending on your GPU
num_workers=0, # may need to reduce this depending on your num of CPUs and RAM

with torch.no_grad():
correct = 0
total = 0
for images, labels in dataloader:
images = images.to(device)
labels = labels.to(device)
outputs = model(images)
_, predicted = torch.max(outputs.data, 1)
total += labels.size(0)
correct += (predicted == labels).sum().item()
del images, labels, outputs

    print('Accuracy of the network on the {} test images: {} %'.format(total, 100 * correct / total))

I don’t know where this line of code is coming from:

from datasets import load_dataset

but if you use torchvision.datasets.ImageNet you can use the root argument to point to the root folder containing the class subfolders with the images.