Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x= x.cpu() in retrival.py (around line 636)get error with nontype #14

Open
Chaoran-F opened this issue Jul 20, 2023 · 0 comments
Open

Comments

@Chaoran-F
Copy link

Chaoran-F commented Jul 20, 2023

I printed x after the for image, label in dataloader: line and the for loop line were completed, and I got the result of None, and I found that for image, label in dataloader: did not start the loop, so what is the reason, I Try to check the dataloader, there is an output, but the for loop is not started.

error:
x = x.cpu()
AttributeError: 'NoneType' object has no attribute 'cpu'

code:
print('dataset_this_rank',dataset_this_rank)
dataloader = DataLoader(dataset_this_rank, **kwargs)
x = None
y_np = []
idx = 0
print('dataloader',dataloader)
print('before: ', x)

for image, label in dataloader:
    print('entry!')
    image = image.cuda()
    embedding = model(image)
    embedding_size: int = embedding.size(1)
    if x is None:
        print(x)
        size = [len(dataset_this_rank), embedding_size]
        x = torch.zeros(*size, device=image.device)
    print('!',x)
    x[idx:idx + embedding.size(0)] = embedding
    y_np.append(np.array(label))
    idx += embedding.size(0)
print('after: ', x)
x = x.cpu()

dataset: own food dataset, use sop loading style
envs: torch:1.12.1,cuda:11.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant