I have an issue in python FaceAlignment package usage

I am going to extract the face landmark using python FaceAlignment package.
My OS is windows10 and i installed torch 1.4.0 and torchvision 0.5 and cuda version 10.1.
I can get the face landmark with square image using get_landmarks() function.
But when i use the not square image, i can’t get the result.
Instead i get error as bellow:

Traceback (most recent call last):
File “.\detlandmark\detlandmark.py”, line 12, in
preds = fa.get_landmarks(input)
File “C:\Users\user\Anaconda3\lib\site-packages\face_alignment\api.py”, line 141, in get_landmarks
return self.get_landmarks_from_image(image_or_path, detected_faces)
File “C:\Users\user\Anaconda3\lib\site-packages\face_alignment\api.py”, line 171, in get_landmarks_from_image
detected_faces = self.face_detector.detect_from_image(image[…, ::-1].copy())
File “C:\Users\user\Anaconda3\lib\site-packages\face_alignment\detection\sfd\sfd_detector.py”, line 51, in detect_from_image
bboxlist = detect(self.face_detector, image, device=self.device)
File “C:\Users\user\Anaconda3\lib\site-packages\face_alignment\detection\sfd\detect.py”, line 30, in detect
olist = net(img)
File “C:\Users\user\Anaconda3\lib\site-packages\torch\nn\modules\module.py”, line 532, in call
result = self.forward(*input, **kwargs)
File “C:\Users\user\Anaconda3\lib\site-packages\face_alignment\detection\sfd\net_s3fd.py”, line 80, in forward
h = F.relu(self.conv3_2(h))
File “C:\Users\user\Anaconda3\lib\site-packages\torch\nn\modules\module.py”, line 532, in call
result = self.forward(*input, **kwargs)
File “C:\Users\user\Anaconda3\lib\site-packages\torch\nn\modules\conv.py”, line 345, in forward
return self.conv2d_forward(input, self.weight)
File “C:\Users\user\Anaconda3\lib\site-packages\torch\nn\modules\conv.py”, line 342, in conv2d_forward
self.padding, self.dilation, self.groups)
RuntimeError: cuDNN error: CUDNN_STATUS_INTERNAL_ERROR

I want know the origin of my error.
Please help me~!!!

Do you have a code snippet to reproduce this issue or some specific shape so that we could debug it, please?

As a workaround you could try to disable cudnn for now via torch.backend.cudnn.enabled = False, but I would like to figure out what’s going on.

Thank you for your response, Mr ptrblck.
This is code.
import face_alignment
from skimage import io
import os
import sys
import glob
import cv2
import pickle

imgdir = sys.argv[1]

fa = face_alignment.FaceAlignment(face_alignment.LandmarksType._2D, flip_input=False)
input = io.imread(imgdir)
preds = fa.get_landmarks(input)
for pred in preds:
img = cv2.imread(imgdir)
print(‘ldmk num:’, pred.shape[0])
for i in range(pred.shape[0]):
x, y = pred[i]
cv2.circle(img,(x, y),1,(0,0,255),-1)
cv2.imwrite(imgdir.replace(’.jpg’,’_draw.jpg’),img)
pickle.dump(preds, open(imgdir.replace(’.jpg’,’.pickle’),‘wb’))
cv2.imshow(’-’,img)
cv2.waitKey(0)

I will wait your next response

Could you provide some dummy input shapes to reproduce this issue?
I’m currently using this repository with torch==1.4.0, torchvision==0.5.0 and this dummy code, which works fine:

fa = face_alignment.FaceAlignment(face_alignment.LandmarksType._2D, flip_input=False, device='cuda')
x = np.random.randn(224, 224, 3)
out = fa.get_landmarks(x)
> Warning: No faces were detected

It seems you are not using the GPU in your example, so I’m wondering, if the cudnn error is raised by some other code?

Mr. ptrblck.
Thanks again.
Now GPU of my PC is RTX-8000.
Best Regards.

I think we can solve this issue here in the forum. :wink:

I just retried my code snippet on a Quadro RTX 8000 with PyTorch master + CUDA10.2 and using the 1.4.0 binaries + CUDA10.1 and still cannot reproduce this issue.
As said before, your code snippet doesn’t seem to use the GPU so are you sure this error is thrown using this code?
Does my code snippet work on your system?

Mr. ptrblck, did you use square image as an input?
it works well when using the square image.
But when using not square image, above error occurred.
How do you think about it?

It also works with an input of e.g. [224, 300, 3].
Could you post a code snippet with a specific shape, which reproduces this error?

It works with an input of e.g. [224,224,3], but it does not work with an input of e.g. [224,300,3].
As you told, if it works with an input of [224, 300, 3], why it doesn’t work in my pc?
I installed cuda 10.1

This shape works on CUDA10.2 (PyTorch built from source) and CUDA10.1 (1.4.0 PyTorch binaries).
I get a “valid” result of “no faces were detected”. Do you get the same error running my code snippet?

import torch
import face_alignment
import numpy as np
fa = face_alignment.FaceAlignment(face_alignment.LandmarksType._2D, flip_input=False, device='cuda')
x = np.random.randn(224, 300, 3)
out = fa.get_landmarks(x)
> Warning: No faces were detected.

I also got the same result.

Warning: No faces were detected.
I got the that result because there are no face in the input image.
x=np.random.randn(224, 300, 3)
So i used face image as an input image. x= cv2.imread("./face_img.jpg")
But I got the error as following:
RuntimeError: cuDNN error: CUDNN_STATUS_INTERNAL_ERROR