I have an issue in python FaceAlignment package usage

username: honest
cooked: <p>I am going to extract the face landmark using python FaceAlignment package.<br>
My OS is windows10 and i installed torch 1.4.0 and torchvision 0.5 and cuda version 10.1.<br>
I can get the face landmark with square image using get_landmarks() function.<br>
But when i use the not square image, i can’t get the result.<br>
Instead i get error as bellow:</p>
<p>Traceback (most recent call last):<br>
File “.\detlandmark\detlandmark.py”, line 12, in <br>
preds = fa.get_landmarks(input)<br>
File “C:\Users\user\Anaconda3\lib\site-packages\face_alignment\api.py”, line 141, in get_landmarks<br>
return self.get_landmarks_from_image(image_or_path, detected_faces)<br>
File “C:\Users\user\Anaconda3\lib\site-packages\face_alignment\api.py”, line 171, in get_landmarks_from_image<br>
detected_faces = self.face_detector.detect_from_image(image[…, ::-1].copy())<br>
File “C:\Users\user\Anaconda3\lib\site-packages\face_alignment\detection\sfd\sfd_detector.py”, line 51, in detect_from_image<br>
bboxlist = detect(self.face_detector, image, device=self.device)<br>
File “C:\Users\user\Anaconda3\lib\site-packages\face_alignment\detection\sfd\detect.py”, line 30, in detect<br>
olist = net(img)<br>
File “C:\Users\user\Anaconda3\lib\site-packages\torch\nn\modules\module.py”, line 532, in <strong>call</strong><br>
result = self.forward(*input, **kwargs)<br>
File “C:\Users\user\Anaconda3\lib\site-packages\face_alignment\detection\sfd\net_s3fd.py”, line 80, in forward<br>
h = F.relu(self.conv3_2(h))<br>
File “C:\Users\user\Anaconda3\lib\site-packages\torch\nn\modules\module.py”, line 532, in <strong>call</strong><br>
result = self.forward(*input, **kwargs)<br>
File “C:\Users\user\Anaconda3\lib\site-packages\torch\nn\modules\conv.py”, line 345, in forward<br>
return self.conv2d_forward(input, self.weight)<br>
File “C:\Users\user\Anaconda3\lib\site-packages\torch\nn\modules\conv.py”, line 342, in conv2d_forward<br>
self.padding, self.dilation, self.groups)<br>
RuntimeError: cuDNN error: CUDNN_STATUS_INTERNAL_ERROR</p>
<p>I want know the origin of my error.<br>
Please help me~!!!</p>

username: ptrblck
cooked: <p>Do you have a code snippet to reproduce this issue or some specific shape so that we could debug it, please?</p>
<p>As a workaround you could try to disable cudnn for now via <code>torch.backend.cudnn.enabled = False</code>, but I would like to figure out what’s going on.</p>

username: honest
cooked: <p>Thank you for your response, Mr ptrblck.<br>
This is code.<br>
import face_alignment<br>
from skimage import io<br>
import os<br>
import sys<br>
import glob<br>
import cv2<br>
import pickle</p>
<p>imgdir = sys.argv[1]</p>
<p>fa = face_alignment.FaceAlignment(face_alignment.LandmarksType._2D, flip_input=False)<br>
input = io.imread(imgdir)<br>
preds = fa.get_landmarks(input)<br>
for pred in preds:<br>
img = cv2.imread(imgdir)<br>
print(‘ldmk num:’, pred.shape[0])<br>
for i in range(pred.shape[0]):<br>
x, y = pred[i]<br>
cv2.circle(img,(x, y),1,(0,0,255),-1)<br>
cv2.imwrite(imgdir.replace(’.jpg’,’_draw.jpg’),img)<br>
pickle.dump(preds, open(imgdir.replace(’.jpg’,’.pickle’),‘wb’))<br>
cv2.imshow(’-’,img)<br>
cv2.waitKey(0)</p>
<p>I will wait your next response</p>

username: ptrblck
cooked: <p>Could you provide some dummy input shapes to reproduce this issue?<br>
I’m currently using <a href="https://github.com/1adrianb/face-alignment">this repository</a> with <code>torch==1.4.0</code>, <code>torchvision==0.5.0</code> and this dummy code, which works fine:</p>
<pre><code class="lang-python">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)
&gt; Warning: No faces were detected
</code></pre>
<p>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?</p>

username: honest
cooked: <p>Mr. ptrblck.<br>
Thanks again.<br>
Now GPU of my PC is RTX-8000.<br>
Best Regards.</p>

username: ptrblck
cooked: <p>I think we can solve this issue here in the forum. <img src="https://discuss.pytorch.org/images/emoji/apple/wink.png?v=9" title=":wink:" class="emoji" alt=":wink:"></p>
<p>I just retried my code snippet on a Quadro RTX 8000 with PyTorch master + CUDA10.2 and using the <code>1.4.0</code> binaries + CUDA10.1 and still cannot reproduce this issue.<br>
As said before, your code snippet doesn’t seem to use the GPU so are you sure this error is thrown using this code?<br>
Does my code snippet work on your system?</p>

username: honest
cooked: <p>Mr. ptrblck, did you use square image as an input?<br>
it works well when using the square image.<br>
But when using not square image, above error occurred.<br>
How do you think about it?</p>

username: ptrblck
cooked: <p>It also works with an input of e.g. <code>[224, 300, 3]</code>.<br>
Could you post a code snippet with a specific shape, which reproduces this error?</p>

username: honest
cooked: <p>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].<br>
As you told, if it works with an input of [224, 300, 3], why it doesn’t work in my pc?<br>
I installed cuda 10.1</p>

username: ptrblck
cooked: <p>This shape works on CUDA10.2 (PyTorch built from source) and CUDA10.1 (<code>1.4.0</code> PyTorch binaries).<br>
I get a “valid” result of “no faces were detected”. Do you get the same error running my code snippet?</p>
<pre><code class="lang-python">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)
&gt; Warning: No faces were detected.
</code></pre>

username: honest
cooked: <p>I also got the same result.</p>
<blockquote>
<p>Warning: No faces were detected.<br>
I got the that result because there are no face in the input image.<br>
x=np.random.randn(224, 300, 3)<br>
So i used face image as an input image. x= cv2.imread(“./face_img.jpg”)<br>
But I got the error as following:<br>
RuntimeError: cuDNN error: CUDNN_STATUS_INTERNAL_ERROR</p>
</blockquote>