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

TypeError: expected np.ndarray (got numpy.ndarray) #344

Open
AyushSomani001 opened this issue Oct 1, 2024 · 3 comments
Open

TypeError: expected np.ndarray (got numpy.ndarray) #344

AyushSomani001 opened this issue Oct 1, 2024 · 3 comments

Comments

@AyushSomani001
Copy link

The code from the Notebook (notebooks/image_predictor_example.ipynb) works fine in Google Collab:

image

But, when I'm trying to run in the server (NVIDIA A100-SXM4-40GB; CUDA Version: 12.5), there's a image processing issue.

image

I did check the version and passing implicitly with numpy.array(), especially numpy versions are the same. I'm not sure why the issue persist!

@ronghanghu
Copy link
Contributor

ronghanghu commented Oct 2, 2024

Hi @AyushSomani001, I think this is likely because you have a numpy installation or a PIL installation that is not compatible with your local PyTorch installation.

Could you try the following and see if it works?

import numpy as np
import torch

torch.from_numpy(np.zeros((3, 1024, 1024), dtype=np.float32))

It should be resolved by reinstalling numpy and pytorch with versions that match each other

@seandkim
Copy link

It should be resolved by reinstalling numpy and pytorch with versions that match each other

How do I find out which numpy version matches with a specific pytorch version? I am currently using pytorch 2.5.1

@seandkim
Copy link

@AyushSomani001 I was able to get it working by downgrading numpy=1.26.4

I am still curious what is the best way to find the matching version, I was only able to find it through this stackoverflow post

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

3 participants