RuntimeError: Numpy is not available
toti-bz opened this issue · 1 comments
toti-bz commented
using python 3.10.1, torch: 1.11.0+cu113 and numpy 1.21.6, the following error occurs:
C:\Users\PICO\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\_masked\__init__.py:223: UserWarning: Failed to initialize NumPy: module compiled against API version 0xf but this version of numpy is 0xe (Triggered internally at ..\torch\csrc\utils\tensor_numpy.cpp:68.)
example_input = torch.tensor([[-3, -2, -1], [0, 1, 2]])
Traceback (most recent call last):
File "d:\Thesis-Batoul\Face-Mask-Detection-using-FAN\main.py", line 7, in <module>
preds = fa.get_landmarks(input)
File "C:\Users\PICO\AppData\Local\Programs\Python\Python310\lib\site-packages\face_alignment\api.py", line 110, in get_landmarks
return self.get_landmarks_from_image(image_or_path, detected_faces, return_bboxes, return_landmark_score)
File "C:\Users\PICO\AppData\Local\Programs\Python\Python310\lib\site-packages\torch\autograd\grad_mode.py", line 27, in decorate_context
return func(*args, **kwargs)
File "C:\Users\PICO\AppData\Local\Programs\Python\Python310\lib\site-packages\face_alignment\api.py", line 141, in get_landmarks_from_image
detected_faces = self.face_detector.detect_from_image(image.copy())
File "C:\Users\PICO\AppData\Local\Programs\Python\Python310\lib\site-packages\face_alignment\detection\sfd\sfd_detector.py", line 45, in detect_from_image
bboxlist = detect(self.face_detector, image, device=self.device)[0]
File "C:\Users\PICO\AppData\Local\Programs\Python\Python310\lib\site-packages\face_alignment\detection\sfd\detect.py", line 15, in detect
img = torch.from_numpy(img.copy()).to(device, dtype=torch.float32)
RuntimeError: Numpy is not available
I figured that the error is due to incompatible versions of python, pytorch and numpy:
Numba needs NumPy 1.21 or less
pytorch 1.11 needs NumPy 1.22
so I need to downgrade all my packages in order to run the pretrained model code
is there any update concerning this problem?
1adrianb commented
While I haven't tested, it doesn't look like pytorch enforces explicitly 1.22 for numpy (https://github.com/pytorch/pytorch/blob/master/requirements.txt). If downgrading numpy to 1.21 doesn't work, you can either a) disable numba in the source code -- this will results in slightly slower execution or b) create a new environment with a older config.