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
#11
Please try to reinstall the provided wheel.
You can try to rename or delete the file _dlib_pybind11.py.
Then try to do an "import dlib" in python to see the problem is solved.

Dan
Reply
#12
Quote:Please try to reinstall the provided wheel.
python -m pip install dlib-19.24.99-cp312-cp312-win_amd64.whl --force
Processing f:\hybrid\64bit\vapoursynth\dlib-19.24.99-cp312-cp312-win_amd64.whl
Installing collected packages: dlib
  Attempting uninstall: dlib
    Found existing installation: dlib 19.24.99
    Uninstalling dlib-19.24.99:
      Successfully uninstalled dlib-19.24.99
Successfully installed dlib-19.24.99

Quote:You can try to rename or delete the file _dlib_pybind11.py.
F:\Hybrid\64bit\Vapoursynth\Lib\site-packages>ren _dlib_pybind11.py _dlib_pybind11.bak
Quote:Then try to do an "import dlib" in python to see the problem is solved.
F:\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
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.
=> not fixed

Cu Selur
Reply
#13
Hello Selur,

  try this version of dlib for python 3.12, built using CUDA 12.1 and cuDNN 8.9.7

Dan

P.S.
Remove any version before install the the attached wheel.
I changed the version number, to have more room to release other builds.
After the install clear the cache: dlib\__pycache__\__init__.cpython-312.pyc


Attached Files
.zip   dlib-19.24.93-cp312-cp312-win_amd64.whl.zip (Size: 2,84 MB / Downloads: 52)
Reply
#14
That version seems to work with codeformer. Smile
Reply
#15
Setting up a new environment using:
* created 'Vapoursynth'-folder
* downloaded 'Windows embeddable package (64-bit)' from https://www.python.org/downloads/release/python-3126/
* extracted it into the 'Vapoursynth'-folder
* downloaded 'VapourSynth64-Portable-R70' from https://github.com/vapoursynth/vapoursynth/releases
* extracted it into the 'Vapoursynth'-folder
* finished Vapoursynth portable installation:
  * adjusted `python312._pth` by adding:
  ```
  Scripts
  Lib\site-packages
  ```
  * installed pip:
    * download get-pip.py from https://bootstrap.pypa.io/get-pip.py into the 'Vapoursynth'-folder
    * `python get-pip.py`
  * `python -m pip install wheel\VapourSynth-70-cp312-cp312-win_amd64.whl`
* install vsrife dependencies, by calling:
  *  `python -m pip install -U packaging setuptools wheel`
  *  `python -m pip install -U torch torchvision torch_tensorrt --index-url https://download.pytorch.org/whl/nightly/cu124 --extra-index-url https://pypi.nvidia.com` (without '--pre')
* installed CodeFormer by calling:
  * `python -m pip install dlib-19.24.93-cp312-cp312-win_amd64` (from https://forum.selur.net/attachment.php?aid=2532)
  * `python -m pip install vscodeformer-1.0.2-py3-none-any.whl` (from https://forum.selur.net/attachment.php?aid=2552)
  * `python -m vscodeformer`
Using dlib fails:
2024-09-29 07:34:56.868
F:\workspace\Hybrid\debug\64bit\Vapoursynth\Lib\site-packages\vscodeformer\__init__.py:98: FutureWarning: You are using `torch.load` with `weights_only=False` (the current default value), which uses the default pickle module implicitly. It is possible to construct malicious pickle data which will execute arbitrary code during unpickling (See https://github.com/pytorch/pytorch/blob/main/SECURITY.md#untrusted-models for more details). In a future release, the default value for `weights_only` will be flipped to `True`. This limits the functions that could be executed during unpickling. Arbitrary objects will no longer be allowed to be loaded via this mode unless they are explicitly allowlisted by the user via `torch.serialization.add_safe_globals`. We recommend you start setting `weights_only=True` for any use case where you don't have full control of the loaded file. Please open an issue on GitHub for any issues related to this experimental feature.
module.load_state_dict(torch.load(model_path, map_location="cpu")["params_ema"])

F:\workspace\Hybrid\debug\64bit\Vapoursynth\Lib\site-packages\vscodeformer\__init__.py:98: FutureWarning: You are using `torch.load` with `weights_only=False` (the current default value), which uses the default pickle module implicitly. It is possible to construct malicious pickle data which will execute arbitrary code during unpickling (See https://github.com/pytorch/pytorch/blob/main/SECURITY.md#untrusted-models for more details). In a future release, the default value for `weights_only` will be flipped to `True`. This limits the functions that could be executed during unpickling. Arbitrary objects will no longer be allowed to be loaded via this mode unless they are explicitly allowlisted by the user via `torch.serialization.add_safe_globals`. We recommend you start setting `weights_only=True` for any use case where you don't have full control of the loaded file. Please open an issue on GitHub for any issues related to this experimental feature.
module.load_state_dict(torch.load(model_path, map_location="cpu")["params_ema"])

2024-09-29 07:34:57.135
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 3387, in vapoursynth._vpy_evaluate
File "src\\cython\\vapoursynth.pyx", line 3388, in vapoursynth._vpy_evaluate
File "J:\tmp\tempPreviewVapoursynthFile07_34_54_512.vpy", line 43, in
clip = CodeFormer(clip=clip, upscale=1, detector=1) # 640x352
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "F:\workspace\Hybrid\debug\64bit\Vapoursynth\Lib\site-packages\torch\utils\_contextlib.py", line 116, in decorate_context
return func(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^
File "F:\workspace\Hybrid\debug\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:\workspace\Hybrid\debug\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:\workspace\Hybrid\debug\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

Listing the installed packages using 'python -m pip list':
Package                  Version
------------------------ ------------------------
certifi                  2024.8.30
charset-normalizer       3.3.2
colorama                 0.4.6
dlib                     19.24.92
filelock                 3.13.1
fsspec                   2024.6.1
idna                     3.10
Jinja2                   3.1.4
MarkupSafe               2.1.5
mpmath                   1.3.0
networkx                 3.3
numpy                    1.26.4
nvidia-cuda-runtime-cu12 12.6.68
opencv-python            4.10.0.84
packaging                24.1
Pillow                   10.1.0
pip                      24.2
requests                 2.32.3
setuptools               75.1.0
sympy                    1.13.1
tensorrt-cu12            10.3.0
tensorrt-cu12_bindings   10.3.0
tensorrt-cu12_libs       10.3.0
torch                    2.6.0.dev20240928+cu124
torch_tensorrt           2.6.0.dev20240926+cu124
torchvision              0.20.0.dev20240928+cu124
tqdm                     4.66.5
typing_extensions        4.12.2
urllib3                  2.2.3
VapourSynth              70
vscodeformer             1.0.2
wheel                    0.44.0

Cu Selur
Reply
#16
I think that is the same problem observed with Pytorch-Correlation-extension package.
The last pytorch is not compatible. Try to use this version (at least to see if the problem is related to CUDA).

pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu121


Dan
Reply
#17
Will do some testing later and report back.
Working on making a public release atm. Smile

Cu Selur
Reply
#18
iirc cu124:
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu124
should work, but that installs torch 2.4.x which breaks vs-rife&co

Cu Selur
Reply
#19
using "python -m pip install dlib-bin" works, but is horribly slow compared to the cuda enabled version.
Reply
#20
There is a reason why there a few distributions of dblib with GPU enabled. 
The code is very old, was developed using a very old python version (still using egg containers) and adapt it to the last python and GPU version is very difficult.

Dan
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)