This forum uses cookies
This forum makes use of cookies to store your login information if you are registered, and your last visit if you are not. Cookies are small text documents stored on your computer; the cookies set by this forum can only be used on this website and pose no security risk. Cookies on this forum also track the specific topics you have read and when you last read them. Please confirm whether you accept or reject these cookies being set.

A cookie will be stored in your browser regardless of choice to prevent you being asked this question again. You will be able to change your cookie settings at any time using the link in the footer.

dlib 19.24.99 with CUDA
#1
Hello Selur,

   Since it seems that is very difficult do find a dlib version with CUDA support, I built the attached wheel.

   The dlib version is the official one 19.24.99: https://github.com/davisking/dlib
   The minimum CUDA requirement is: 11.4
   The minimum CUDA capability is: 8.0  (see: compute capability 8)
   Python version: 12.x 
   Platform: Windows 10/11
  

Dan

by Selur: wokring version later in this post


Attached Files
.zip   dlib-19.24.99-cp312-cp312-win_amd64.whl.zip (Size: 2,84 MB / Downloads: 54)
Reply
#2
Thanks a lot!
(will test later)
----
Dev versions are in the 'experimental'-folder of my GoogleDrive, which is linked on the download page.
Reply
#3
I called:
python -m pip install dlib
python -m pip install dlib-19.24.99-cp312-cp312-win_amd64.whl
it installed fine:
Processing f:\hybrid\64bit\vapoursynth\dlib-19.24.99-cp312-cp312-win_amd64.whl
Installing collected packages: dlib
Successfully installed dlib-19.24.99
but it does not work.
Using:
I get:
Python exception: cannot access local variable 'dlib' where it is not associated with a value

Traceback (most recent call last):
File "src\\cython\\vapoursynth.pyx", line 3365, in vapoursynth._vpy_evaluate
File "src\\cython\\vapoursynth.pyx", line 3366, in vapoursynth._vpy_evaluate
File "J:\tmp\tempPreviewVapoursynthFile14_49_39_867.vpy", line 42, in
clip = CodeFormer(clip=clip, upscale=1, detector=1, weight=1.000) # 640x352
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "F:\Hybrid\64bit\Vapoursynth\Lib\site-packages\torch\utils\_contextlib.py", line 115, in decorate_context
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "F:\Hybrid\64bit\Vapoursynth\Lib\site-packages\vscodeformer\__init__.py", line 103, in codeformer
FaceRestoreHelper(upscale, det_model=detection_model, use_parse=True, device=device) for _ in range(num_streams)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "F:\Hybrid\64bit\Vapoursynth\Lib\site-packages\vscodeformer\face_restoration_helper.py", line 113, in __init__
self.face_detector, self.shape_predictor_5 = self.init_dlib()
^^^^^^^^^^^^^^^^
File "F:\Hybrid\64bit\Vapoursynth\Lib\site-packages\vscodeformer\face_restoration_helper.py", line 173, in init_dlib
face_detector = dlib.cnn_face_detection_model_v1(detection_path)
^^^^
UnboundLocalError: cannot access local variable 'dlib' where it is not associated with a value

changing:
if 'ON' == 'ON':
    add_lib_to_dll_path('C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.4/lib/x64/cudnn.lib')
    add_lib_to_dll_path('C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.4/lib/x64/cudart.lib')
to
if 'OFF' == 'ON':
    add_lib_to_dll_path('')
    add_lib_to_dll_path('CUDA_CUDART_LIBRARY-NOTFOUND')
does not help. (CUDA/v11.4 seem to be wrong too)
Note that with R68, Hybrid does no longer add any dlls to the PATH (torch_dependencies are no longer used/needed)

Cu Selur
----
Dev versions are in the 'experimental'-folder of my GoogleDrive, which is linked on the download page.
Reply
#4
Please remove "manually" any dlib version do you have in the library package and reinstall the provided wheel.
On my PC which is using R68  CodeFormer is able to use dlib and it is fast.

Dan
Reply
#5
Star 
I called:
python -m pip uninstall dlib
python -m pip uninstall dlib-bin
I checked that the 'Vapoursynth\Lib\site-packages'-folder does not contain any dlib folders. (https://pastebin.com/E9ZJDZKq)
I called
python -m pip list[/list] (https://pastebin.com/MeJPA2Kq)
I then called 'python -m pip install dlib-19.24.99-cp312-cp312-win_amd64.whl'
[code]
Processing f:\hybrid\64bit\vapoursynth\dlib-19.24.99-cp312-cp312-win_amd64.whl
Installing collected packages: dlib
Successfully installed dlib-19.24.99'
Sadly, I still get:
2024-06-01 15:33:04.544
Failed to evaluate the script:
Python exception: cannot access local variable 'dlib' where it is not associated with a value

Traceback (most recent call last):
File "src\\cython\\vapoursynth.pyx", line 3365, in vapoursynth._vpy_evaluate
File "src\\cython\\vapoursynth.pyx", line 3366, in vapoursynth._vpy_evaluate
File "J:\tmp\tempPreviewVapoursynthFile15_33_02_257.vpy", line 42, in
clip = CodeFormer(clip=clip, upscale=1, detector=1) # 640x352
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "F:\Hybrid\64bit\Vapoursynth\Lib\site-packages\torch\utils\_contextlib.py", line 115, in decorate_context
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "F:\Hybrid\64bit\Vapoursynth\Lib\site-packages\vscodeformer\__init__.py", line 103, in codeformer
FaceRestoreHelper(upscale, det_model=detection_model, use_parse=True, device=device) for _ in range(num_streams)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "F:\Hybrid\64bit\Vapoursynth\Lib\site-packages\vscodeformer\face_restoration_helper.py", line 113, in __init__
self.face_detector, self.shape_predictor_5 = self.init_dlib()
^^^^^^^^^^^^^^^^
File "F:\Hybrid\64bit\Vapoursynth\Lib\site-packages\vscodeformer\face_restoration_helper.py", line 173, in init_dlib
face_detector = dlib.cnn_face_detection_model_v1(detection_path)
^^^^
UnboundLocalError: cannot access local variable 'dlib' where it is not associated with a value

I also uninstalled and reinstalled vscodeformer.
F:\Hybrid\64bit\Vapoursynth>python -m pip uninstall vscodeformer
Found existing installation: vscodeformer 1.0.1
Uninstalling vscodeformer-1.0.1:
  Would remove:
    f:\hybrid\64bit\vapoursynth\lib\site-packages\vscodeformer-1.0.1.dist-info\*
    f:\hybrid\64bit\vapoursynth\lib\site-packages\vscodeformer\*
Proceed (Y/n)?
  Successfully uninstalled vscodeformer-1.0.1

F:\Hybrid\64bit\Vapoursynth>python -m pip install vscodeformer
Collecting vscodeformer
  Using cached vscodeformer-1.0.1-py3-none-any.whl.metadata (3.3 kB)
Requirement already satisfied: numpy>=1.24.2 in f:\hybrid\64bit\vapoursynth\lib\site-packages (from vscodeformer) (1.26.4)
Requirement already satisfied: opencv-python>=4.7.0.72 in f:\hybrid\64bit\vapoursynth\lib\site-packages (from vscodeformer) (4.9.0.80)
Requirement already satisfied: requests>=2.28.2 in f:\hybrid\64bit\vapoursynth\lib\site-packages (from vscodeformer) (2.32.2)
Requirement already satisfied: torch>=1.13.1 in f:\hybrid\64bit\vapoursynth\lib\site-packages (from vscodeformer) (2.4.0.dev20240523+cu121)
Requirement already satisfied: torchvision>=0.14.1 in f:\hybrid\64bit\vapoursynth\lib\site-packages (from vscodeformer) (0.19.0.dev20240526+cu121)
Requirement already satisfied: tqdm>=4.65.0 in f:\hybrid\64bit\vapoursynth\lib\site-packages (from vscodeformer) (4.66.4)
Requirement already satisfied: vapoursynth>=55 in f:\hybrid\64bit\vapoursynth\lib\site-packages (from vscodeformer) (68)
Requirement already satisfied: charset-normalizer<4,>=2 in f:\hybrid\64bit\vapoursynth\lib\site-packages (from requests>=2.28.2->vscodeformer) (3.3.2)
Requirement already satisfied: idna<4,>=2.5 in f:\hybrid\64bit\vapoursynth\lib\site-packages (from requests>=2.28.2->vscodeformer) (3.7)
Requirement already satisfied: urllib3<3,>=1.21.1 in f:\hybrid\64bit\vapoursynth\lib\site-packages (from requests>=2.28.2->vscodeformer) (2.2.1)
Requirement already satisfied: certifi>=2017.4.17 in f:\hybrid\64bit\vapoursynth\lib\site-packages (from requests>=2.28.2->vscodeformer) (2024.2.2)
Requirement already satisfied: filelock in f:\hybrid\64bit\vapoursynth\lib\site-packages (from torch>=1.13.1->vscodeformer) (3.14.0)
Requirement already satisfied: typing-extensions>=4.8.0 in f:\hybrid\64bit\vapoursynth\lib\site-packages (from torch>=1.13.1->vscodeformer) (4.12.0)
Requirement already satisfied: sympy in f:\hybrid\64bit\vapoursynth\lib\site-packages (from torch>=1.13.1->vscodeformer) (1.12)
Requirement already satisfied: networkx in f:\hybrid\64bit\vapoursynth\lib\site-packages (from torch>=1.13.1->vscodeformer) (3.3)
Requirement already satisfied: jinja2 in f:\hybrid\64bit\vapoursynth\lib\site-packages (from torch>=1.13.1->vscodeformer) (3.1.4)
Requirement already satisfied: fsspec in f:\hybrid\64bit\vapoursynth\lib\site-packages (from torch>=1.13.1->vscodeformer) (2024.5.0)
Requirement already satisfied: mkl<=2021.4.0,>=2021.1.1 in f:\hybrid\64bit\vapoursynth\lib\site-packages (from torch>=1.13.1->vscodeformer) (2021.4.0)
Requirement already satisfied: pillow!=8.3.*,>=5.3.0 in f:\hybrid\64bit\vapoursynth\lib\site-packages (from torchvision>=0.14.1->vscodeformer) (10.1.0)
Requirement already satisfied: colorama in f:\hybrid\64bit\vapoursynth\lib\site-packages (from tqdm>=4.65.0->vscodeformer) (0.4.6)
Requirement already satisfied: intel-openmp==2021.* in f:\hybrid\64bit\vapoursynth\lib\site-packages (from mkl<=2021.4.0,>=2021.1.1->torch>=1.13.1->vscodeformer) (2021.4.0)
Requirement already satisfied: tbb==2021.* in f:\hybrid\64bit\vapoursynth\lib\site-packages (from mkl<=2021.4.0,>=2021.1.1->torch>=1.13.1->vscodeformer) (2021.12.0)
Requirement already satisfied: MarkupSafe>=2.0 in f:\hybrid\64bit\vapoursynth\lib\site-packages (from jinja2->torch>=1.13.1->vscodeformer) (2.1.5)
Requirement already satisfied: mpmath>=0.19 in f:\hybrid\64bit\vapoursynth\lib\site-packages (from sympy->torch>=1.13.1->vscodeformer) (1.3.0)
Using cached vscodeformer-1.0.1-py3-none-any.whl (42 kB)
Installing collected packages: vscodeformer

F:\Hybrid\64bit\Vapoursynth>python -m vscodeformer
codeformer.pth: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 359M/359M [00:28<00:00, 13.1MB/s]
detection_Resnet50_Final.pth: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 104M/104M [00:08<00:00, 13.1MB/s]
parsing_parsenet.pth: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 81.4M/81.4M [00:06<00:00, 13.1MB/s]
mmod_human_face_detector-4cb19393.dat: 100%|██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 713k/713k [00:00<00:00, 9.31MB/s]
shape_predictor_5_face_landmarks-c4b1e980.dat: 100%|████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 8.73M/8.73M [00:00<00:00, 12.8MB/s]
That didn't help either.

Cu Selur
----
Dev versions are in the 'experimental'-folder of my GoogleDrive, which is linked on the download page.
Reply
#6
If I remember previously it was necessary to include in the path the folder "torch_dependencies".
Probably on my PC is working because I have also the cuda 11.4 dll.
I have to check the thread on CodeFormer probably this issue was already covered in that post.

EDIT:

Same issue reported here: https://forum.selur.net/thread-3574-post...l#pid21272


On my side this code works

PS D:\Programs\Hybrid\64bit\Vapoursynth> .\python
Python 3.12.3 (tags/v3.12.3:f6650f9, Apr  9 2024, 14:05:25) [MSC v.1938 64 bit (AMD64)] on win32
>>> import dlib
>>> print('DLIB_USE_CUDA: ' + str(dlib.DLIB_USE_CUDA))
DLIB_USE_CUDA: True
>>> print('cuda.get_num_devices: ' + str(dlib.cuda.get_num_devices()))
cuda.get_num_devices: 1


Dan
Reply
#7
Loading torch dependencies was necessary since Vapoursynth prior R66 didn't properly install the Python environment.
All other filters work without having to use the torch_dependencies (which are not up-to-date with the versions used in the R68 environment).
cudart64_12.dll is present in "F:\Hybrid\64bit\Vapoursynth\Lib\site-packages\torchvision\"
cudnn64_8.dll is present in "F:\Hybrid\64bit\Vapoursynth\Lib\site-packages\torch\lib\"

python
Python 3.12.3 (tags/v3.12.3:f6650f9, Apr  9 2024, 14:05:25) [MSC v.1938 64 bit (AMD64)] on win32
>>> import dlib
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "F:\Hybrid\64bit\Vapoursynth\Lib\site-packages\dlib\__init__.py", line 20, in <module>
    from _dlib_pybind11 import *
ImportError: DLL load failed while importing _dlib_pybind11: Das angegebene Modul wurde nicht gefunden.

python312_.pth contains:
Scripts
Lib\site-packages
python312.zip
.
here.

Cu Selur
----
Dev versions are in the 'experimental'-folder of my GoogleDrive, which is linked on the download page.
Reply
#8
The last time the problem was solved in this way: https://forum.selur.net/thread-3574-post...l#pid21287

Dan

P.S.
Try to delete the file _dlib_pybind11.pyd is not necessary.
Reply
#9
But then this was needed for everything related to pytorch.
Collecting all torch related dlls and explicitly loading them should not be necessary anymore.
It deems strange that dlib is the only package that puts a pyd file in the sites-packages folder.
----
Dev versions are in the 'experimental'-folder of my GoogleDrive, which is linked on the download page.
Reply
#10
Quote:Try to delete the file _dlib_pybind11.pyd is not necessary.
Deleting 'Vapoursynth\Lib\site-packages\_dlib_pybind11.cp312-win_amd64.pyd' doesn't help
Deleting "_dlib_pybind11.cp312-win_amd64.pyd\_dlib_pybind11.py" doesn't help either.

The normal package also installs dlib-bin, yours does not, could that be a problem?
('python -m pip install dlib-bin' would install the old 'dlib_bin-19.24.2.post1-cp312-cp312-win_amd64.whl' again)

Cu Selur
----
Dev versions are in the 'experimental'-folder of my GoogleDrive, which is linked on the download page.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)