You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
安装 cudnn:
将cudnn 文件夹下的lib、bin、include 文件夹复制到 CUDA11.8 文件夹下(默认为C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.8)
Copy the lib, bin, include folders from the cudnn folder to the CUDA11.8 folder (C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.8)
Copy the include folder in TensorRT-8.6.1.6 to the include folder in CUDA11.8
Copy the *dll file from the lib folder in the TensorRT-8.6.1.6 folder to the bin of the CUDA11.8 folder
Copy the *lib file in the lib folder in TensorRT-8.6.1.6 to the x64 folder under the lib subfiles in the CUDA11.8 folder
pip 安装 onnxruntime-gpu
cd build\Release\Release\dist
pip install onnxruntime_gpu-1.17.0-cp310-cp310-win_amd64.whl
开始测试
python run.py
错误1:
about error1:
Error CUDA 11.8.props” was not found.
Just copy all files from this path (depends on the path you installed CUDA in)
从这个文件夹复制所有文件到下面文件夹内
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.8\extras\visual_studio_integration\MSBuildExtensions
about error4:(infer)
Traceback (most recent call last):
File "D:\ZHY_Pro\FasterLivePortrait\run.py", line 44, in
save_dir = f"./results/{datetime.datetime.now().strftime('%Y-%m-%d-%s')}"
ValueError: Invalid format string
chage: run.py line 44(%s to %S)
save_dir = f"./results/{datetime.datetime.now().strftime('%Y-%m-%d-%s')}"
%s to %S
save_dir = f"./results/{datetime.datetime.now().strftime('%Y-%m-%d-%S')}"
注意:
2. 每一次报错,解决之后;需要 清空build 文件夹,重新以管理员身份打开 x64 Native Tools Command Prompt for VS 2022 cmd 进行编译(重复上面的编译步骤)
windows 安装教程:
0. 环境:
win10 cuda11.8 VS 2022 Community RTX3090
cudnn:cudnn-windows-x86_64-8.9.7.29_cuda11-archive
https://developer.nvidia.com/downloads/compute/cudnn/secure/8.9.7/local_installers/11.x/cudnn-windows-x86_64-8.9.7.29_cuda11-archive.zip/
TensorRT:TensorRT-8.6.1.6.Windows10.x86_64.cuda-11.8
https://developer.nvidia.com/downloads/compute/machine-learning/tensorrt/secure/8.6.1/zip/TensorRT-8.6.1.6.Windows10.x86_64.cuda-11.8.zip
安装 cudnn:
将cudnn 文件夹下的lib、bin、include 文件夹复制到 CUDA11.8 文件夹下(默认为C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.8)
Copy the lib, bin, include folders from the cudnn folder to the CUDA11.8 folder (C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.8)
安装 TensorRT
将TensorRT 文件夹下 include 文件复制到 CUDA11.8 文件夹下include 文件夹内
将TensorRT 文件夹下 lib 文件夹下 所有的dll文件复制到 CUDA11.8 文件夹下bin 文件夹内
将TensorRT 文件夹下 lib 文件夹下 所有的lib文件复制到 CUDA11.8 文件夹下lib下子文件x64 文件夹内
Copy the include folder in TensorRT-8.6.1.6 to the include folder in CUDA11.8
Copy the *dll file from the lib folder in the TensorRT-8.6.1.6 folder to the bin of the CUDA11.8 folder
Copy the *lib file in the lib folder in TensorRT-8.6.1.6 to the x64 folder under the lib subfiles in the CUDA11.8 folder
拉取代码,构建基本环境
git clone https://github.com/warmshao/FasterLivePortrait
cd FasterLivePortrait
conda create -n FasterLivePortrait python=3.10
conda activate FasterLivePortrait
pip install -r requirements.txt
拉取特定版本 onnxruntime,进行编译
git clone https://github.com/microsoft/onnxruntime
cd onnxruntime
git submodule update --init --recursive
git checkout liqun/ImageDecoder-cuda
编译步骤(可能需要重复多次)
管理员身份运行 这个 cmd
C:\ProgramData\Microsoft\Windows\Start Menu\Programs\Visual Studio 2022\Visual Studio Tools\VC\x64 Native Tools Command Prompt for VS 2022
d:
cd D:\ZHY_Pro\FasterLivePortrait\onnxruntime
conda activate fasterliveportrait
set CudaToolkitDir=C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.8
.\build.bat --config Release --build_dir .\build --build_shared_lib --parallel 4 --nvcc_threads 1 --build_wheel --cmake_generator "Visual Studio 17 2022" --use_cuda --cuda_version 11.8 --cuda_home "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.8" --cudnn_home "C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.8" --cmake_extra_defines CMAKE_CUDA_ARCHITECTURES="60;70;75;80;86" --cmake_extra_defines onnxruntime_BUILD_UNIT_TESTS=OFF --skip_tests
results:
removing build\bdist.win-amd64\wheel
2024-07-23 10:50:04,589 build [INFO] - Build complete
cd build\Release\Release\dist
pip install onnxruntime_gpu-1.17.0-cp310-cp310-win_amd64.whl
python run.py
错误1:
about error1:
Error CUDA 11.8.props” was not found.
Just copy all files from this path (depends on the path you installed CUDA in)
从这个文件夹复制所有文件到下面文件夹内
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.8\extras\visual_studio_integration\MSBuildExtensions
to this path:
C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\BuildCustomizations
错误2:
about error2:
error C1189: #error: -- unsupported Microsoft Visual Studio version! Only the versions between 2017 and 2022 (inclusive) are supported!
find C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.8\include\crt\host_config.h this file,
chage #if _MSC_VER < 1910 || _MSC_VER >= 1940 to #if _MSC_VER < 1910 || _MSC_VER >= 2000 ( 如果不能保存,拷贝出来这个文件修改完成进行替换)
错误3:(推理时候出现)
about error3(about infer error):
ImportError: DLL load failed while importing onnxruntime_pybind11_state: 动态链接库(DLL)初始化例程失败。
update runtime version:
conda install conda-forge::vs2015_runtime
about error4:(infer)
Traceback (most recent call last):
File "D:\ZHY_Pro\FasterLivePortrait\run.py", line 44, in
save_dir = f"./results/{datetime.datetime.now().strftime('%Y-%m-%d-%s')}"
ValueError: Invalid format string
chage: run.py line 44(%s to %S)
save_dir = f"./results/{datetime.datetime.now().strftime('%Y-%m-%d-%s')}"
%s to %S
save_dir = f"./results/{datetime.datetime.now().strftime('%Y-%m-%d-%S')}"
注意:
2. 每一次报错,解决之后;需要 清空build 文件夹,重新以管理员身份打开 x64 Native Tools Command Prompt for VS 2022 cmd 进行编译(重复上面的编译步骤)
cd D:\ZHY_Pro\FasterLivePortrait
git clone https://github.com/SeanWangJS/grid-sample3d-trt-plugin
cd grid-sample3d-trt-plugin
打开 CMakeLists.txt 修改两个地方:(open CMakeLists.txt file)
chage “89” to "60;70;75;80;86"
set_target_properties(${PROJECT_NAME} PROPERTIES CUDA_ARCHITECTURES "60;70;75;80;86")
去掉关于 test的编译(Remove compilation about test)
#add_subdirectory(test)
#enable_testing()
mkdir build && cd build
cmake .. -DTensorRT_ROOT="I:\path to\TensorRT-8.6.1.6" -G "Visual Studio 17 2022"
用 VS2022 打开 grid_sample_3d_plugin.sln
然后选择 release 进行编译即可.
在 build\Release 文件夹中获得
grid_sample_3d_plugin.dll 文件
复制 grid_sample_3d_plugin.dll 文件到 checkpoints 内
修改两处 代码:
scripts/onnx2trt.py
src/models/predictor.py
替换:/opt/grid-sample3d-trt-plugin/build/libgrid_sample_3d_plugin.so 为 ./checkpoints/grid_sample_3d_plugin.dll
ctypes.CDLL("/opt/grid-sample3d-trt-plugin/build/libgrid_sample_3d_plugin.so", mode=ctypes.RTLD_GLOBAL)
9.trt 测试:
9.1 安装 python版本的 trt (打开前面TensorRT 文件,找到python文件夹,安装对应版本的 tensorrt:tensorrt-8.6.1-cp310-none-win_amd64.whl )
conda activate fasterliveportrait
pip install pip install path to\TensorRT-8.6.1.6\python\tensorrt-8.6.1-cp310-none-win_amd64.whl
9.2转换模型为 trt:
python scripts/onnx2trt.py -o ./checkpoints/liveportrait_onnx/warping_spade-fix.onnx
python scripts/onnx2trt.py -o ./checkpoints/liveportrait_onnx/landmark.onnx
python scripts/onnx2trt.py -o ./checkpoints/liveportrait_onnx/motion_extractor.onnx -p fp32
python scripts/onnx2trt.py -o ./checkpoints/liveportrait_onnx/retinaface_det_static.onnx
python scripts/onnx2trt.py -o ./checkpoints/liveportrait_onnx/face_2dpose_106_static.onnx
python scripts/onnx2trt.py -o ./checkpoints/liveportrait_onnx/appearance_feature_extractor.onnx
python scripts/onnx2trt.py -o ./checkpoints/liveportrait_onnx/stitching.onnx
python scripts/onnx2trt.py -o ./checkpoints/liveportrait_onnx/stitching_eye.onnx
python scripts/onnx2trt.py -o ./checkpoints/liveportrait_onnx/stitching_lip.onnx
9.3 python run.py --cfg configs/trt_infer.yaml
It's OK
附件 我的 文件:
https://huggingface.co/zhangxioais/fasterliveportrait_onnxgpu_dll_trt
The text was updated successfully, but these errors were encountered: