NVIDIA-AI-IOT / nanosam

A distilled Segment Anything (SAM) model capable of running real-time with NVIDIA TensorRT
Apache License 2.0
616 stars 52 forks source link

RuntimeError: Numpy is not available #7

Open gyillikci opened 11 months ago

gyillikci commented 11 months ago

Hi, Thanks for the work. looks very promising

I am having some problem with basic example and actually with others as well. I get runtime error on Numpy as below

python3 examples/basic_usage.py \

--image_encoder="data/resnet18_image_encoder.engine" \
--mask_decoder="data/mobile_sam_mask_decoder.engine"

/home/dbox1028/.local/lib/python3.8/site-packages/torchvision/models/detection/anchor_utils.py:63: UserWarning: Failed to initialize NumPy: module compiled against API version 0x10 but this version of numpy is 0xd . Check the section C-API incompatibility at the Troubleshooting ImportError section at https://numpy.org/devdocs/user/troubleshooting-importerror.html#c-api-incompatibility for indications on how to solve this problem . (Triggered internally at /root/pytorch/torch/csrc/utils/tensor_numpy.cpp:84.) device: torch.device = torch.device("cpu"), Traceback (most recent call last): File "examples/basic_usage.py", line 38, in predictor.set_image(image) File "/home/dbox1028/nanosam/nanosam/utils/predictor.py", line 154, in set_image self.image_tensor = preprocess_image(image, self.image_encoder_size) File "/home/dbox1028/nanosam/nanosam/utils/predictor.py", line 84, in preprocess_image image_torch_resized = torch.from_numpy(image_np_resized).permute(2, 0, 1) RuntimeError: Numpy is not available

jaybdub commented 11 months ago

Hi @gyillikci ,

Thanks for reaching out.

While I haven't faced this issue, it's like an issue with the numpy version installed.

Could you try installing a different version of numpy? This post suggests pip install numpy==1.24.1.

Let me know if this works for you or you still face this issue.

Best, John

gyillikci commented 11 months ago

Thanks Jay, That works well.

Best, Giray