windows facefusion安装

windows FaceFusion安装

显卡安装cuda

1. 安装检测

在安装之前先打开CMD窗口,粘贴如下命令,查看您的系统中是否已安装CUDA。

nvcc -V

如果您的电脑中已安装过CUDA,将会看到如下提示:

C:\Users\guoyg>nvcc -V
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2024 NVIDIA Corporation
Built on Fri_Jun_14_16:44:19_Pacific_Daylight_Time_2024
Cuda compilation tools, release 12.6, V12.6.20
Build cuda_12.6.r12.6/compiler.34431801_0
2. 适配下载

在安装CUDA之前,我们应该先知道自己的电脑应该安装哪个版本的CUDA,因为新旧版本兼容性不同。

想查看自己应该安装的CUDA版本,先在CMD命令行中执行如下命令:

nvidia-smi

在执行完上述命令之后,将会自动弹出如下内容,我们只需要查看第一行中的CUDA Version: 12.6这一部分,这代表需要下载CUDA版本为12.1的安装程序。

C:\Users\guoyg>nvidia-smi
Thu Aug 29 09:12:15 2024
+-----------------------------------------------------------------------------------------+
| NVIDIA-SMI 560.76                 Driver Version: 560.76         CUDA Version: 12.6     |
|-----------------------------------------+------------------------+----------------------+
| GPU  Name                  Driver-Model | Bus-Id          Disp.A | Volatile Uncorr. ECC |
| Fan  Temp   Perf          Pwr:Usage/Cap |           Memory-Usage | GPU-Util  Compute M. |
|                                         |                        |               MIG M. |
|=========================================+========================+======================|
|   0  NVIDIA GeForce RTX 4060 Ti   WDDM  |   00000000:01:00.0  On |                  N/A |
|  0%   45C    P8             10W /  165W |     791MiB /  16380MiB |      2%      Default |
|                                         |                        |                  N/A |
+-----------------------------------------+------------------------+----------------------+

+-----------------------------------------------------------------------------------------+
| Processes:                                                                              |
|  GPU   GI   CI        PID   Type   Process name                              GPU Memory |
|        ID   ID                                                               Usage      |
|=========================================================================================|
|    0   N/A  N/A      2260    C+G   ...oogle\Chrome\Application\chrome.exe      N/A      |
|    0   N/A  N/A      2464    C+G   ....7122.0_x64__8wekyb3d8bbwe\Todo.exe      N/A      |
|    0   N/A  N/A      2916    C+G   ...siveControlPanel\SystemSettings.exe      N/A      |
|    0   N/A  N/A      7644    C+G   ...iversal\CtyunClouddeskUniversal.exe      N/A      |
|    0   N/A  N/A      7844    C+G   ...\bin-7.1.9\Nutstore.WindowsHook.exe      N/A      |
|    0   N/A  N/A      8736    C+G   D:\Typora\Typora.exe                        N/A      |
|    0   N/A  N/A      9364    C+G   C:\Windows\explorer.exe                     N/A      |
|    0   N/A  N/A      9816    C+G   ...nt.CBS_cw5n1h2txyewy\SearchHost.exe      N/A      |
|    0   N/A  N/A     10360    C+G   ...cal\Microsoft\OneDrive\OneDrive.exe      N/A      |
|    0   N/A  N/A     11316    C+G   ...2txyewy\StartMenuExperienceHost.exe      N/A      |
|    0   N/A  N/A     12640    C+G   ...les\AMD\CNext\CNext\AMDRSSrcExt.exe      N/A      |
|    0   N/A  N/A     12800    C+G   D:\PyCharm 2023.2.5\bin\pycharm64.exe       N/A      |
|    0   N/A  N/A     13356    C+G   ...ekyb3d8bbwe\PhoneExperienceHost.exe      N/A      |
|    0   N/A  N/A     14868    C+G   ...\AMD\CNext\CNext\RadeonSoftware.exe      N/A      |
|    0   N/A  N/A     15148    C+G   ...tstore\bin-7.1.9\NutstoreClient.exe      N/A      |
|    0   N/A  N/A     16112    C+G   ...5n1h2txyewy\ShellExperienceHost.exe      N/A      |
|    0   N/A  N/A     18308    C+G   ...__8wekyb3d8bbwe\WindowsTerminal.exe      N/A      |
+-----------------------------------------------------------------------------------------+
3. 下载地址

CUDA官网:CUDA Toolkit Archive | NVIDIA Developer

打开CUDA官网,在其中找到适合自己的版本,找到所需要的CUDA版本是12.6.0,所以直接点击CUDA Toolkit 12.6.0

在点击适合自己的CUDA版本之后,将会看到如下界面,我们按照自身的系统情况选择下载即可:

4. 安装教程

双击运行下载的CUDA EXE安装包文件,下载后打开将会看到如下界面,然后根据图片上方的文字提示操作即可。

参考文档:https://openai.wiki/cuda-windows-install.html

安装cuDNN

cuDNN(CUDA Deep Neural Network library)是由 NVIDIA 开发的一个加速深度神经网络的库,它为深度学习应用提供了 GPU 加速的功能。cuDNN 主要提供了深度神经网络的基本操作,例如卷积、池化、归一化等等,这些操作都可以在 GPU 上进行加速。在安装cuDNN之前,我们需要先安装Windows版本的CUDA

1. Nvidia|注册|登陆

值得注意的是在注册完善个人资料时要勾选加入NVIDIA开发人员计划,访问下载内容(如cuDNN)、操作视频等。选项,必须要勾选,否则注册后也无法下载cuDNN。

2. cuDNN|下载

请确保你已经完成了Nvidia账号的注册或登陆,否则无法下载下载。

点击此处前往cuDNN的下载页面,打开之后将会看到如下所示的内容,我们需要选择适合自己的版本。

每一个下载后面都会有2个版本号,【Download cuDNN v8.9.2 (June 1st, 2023), for CUDA 12.x】,第一个是cuDNN的版本,其次是CUDA的版本。CUDA版本为12.1,那么就可以下载CUDA 12.x的版本,因为这其中的x是通用的意思。

所以,如果你的CUDA版本是11.x,那么就下载第2个即可,其它同理。

点击该按钮之后将会自动展开该选项,这将会包含所有相关系统的cuDNN下载地址,我们选择Local Installer for Windows (Zip)按钮即可自动开始下载。

3. cuDNN配置

需要知道自己的CUDA安装位置,如果你不知道自己的CUDA安装在什么位置,可以在CMD中执行如下内容。

where nvcc

执行完上面的命令之后,将会自动获取CUDA的安装目录。

C:\Users\guoyg>where nvcc
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.6\bin\nvcc.exe

只要到版本号这一目录即可,也就是C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.6,后面的部分省略。

注意:每个人所获取到的版本可能不同,所以不要照抄,一定要自行获取。

此时将我们刚刚下载好的压缩包文件解压,然后将文件内的所有文件移动是我们获取到的目录内。(如果提示已存在,直接选择覆盖所有文件即可。)

4. 添加环境变量

我们完成上面的所有步骤之后,还需要将相关目录添加至系统环境变量内。

在安装CUDA时,应该在默认情况下已经添加了两个关于CUDA的环境变量,分为如下:

C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\CUDA版本\bin
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\CUDA版本\libnvvp

我们还需要添加额外两个,我们刚刚已经获取到了CUDA的安装目录,另外两个文件夹也位于该目录内,分别是include文件夹和lib文件夹。

C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.6\lib
C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.6\include
5. 验证安装

进入到C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.6\extras\demo_suite 目录中打开命令行窗口,然后执行如下命令:

bandwidthTest.exe

返回以下内容则代表配置成功:

C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.6\extras\demo_suite>bandwidthTest.exe
[CUDA Bandwidth Test] - Starting...
Running on...

 Device 0: NVIDIA GeForce RTX 4060 Ti
 Quick Mode

 Host to Device Bandwidth, 1 Device(s)
 PINNED Memory Transfers
   Transfer Size (Bytes)        Bandwidth(MB/s)
   33554432                     6493.7

 Device to Host Bandwidth, 1 Device(s)
 PINNED Memory Transfers
   Transfer Size (Bytes)        Bandwidth(MB/s)
   33554432                     6433.9

 Device to Device Bandwidth, 1 Device(s)
 PINNED Memory Transfers
   Transfer Size (Bytes)        Bandwidth(MB/s)
   33554432                     218805.8

Result = PASS

NOTE: The CUDA Samples are not meant for performance measurements. Results may vary when GPU Boost is enabled.

在执行如下命令:

deviceQuery.exe

返回以下内容则代表配置成功:

C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.6\extras\demo_suite>deviceQuery.exe
deviceQuery.exe Starting...

 CUDA Device Query (Runtime API) version (CUDART static linking)

Detected 1 CUDA Capable device(s)

Device 0: "NVIDIA GeForce RTX 4060 Ti"
  CUDA Driver Version / Runtime Version          12.6 / 12.6
  CUDA Capability Major/Minor version number:    8.9
  Total amount of global memory:                 16379 MBytes (17175019520 bytes)
MapSMtoCores for SM 8.9 is undefined.  Default to use 128 Cores/SM
MapSMtoCores for SM 8.9 is undefined.  Default to use 128 Cores/SM
  (34) Multiprocessors, (128) CUDA Cores/MP:     4352 CUDA Cores
  GPU Max Clock rate:                            2565 MHz (2.57 GHz)
  Memory Clock rate:                             9001 Mhz
  Memory Bus Width:                              128-bit
  L2 Cache Size:                                 33554432 bytes
  Maximum Texture Dimension Size (x,y,z)         1D=(131072), 2D=(131072, 65536), 3D=(16384, 16384, 16384)
  Maximum Layered 1D Texture Size, (num) layers  1D=(32768), 2048 layers
  Maximum Layered 2D Texture Size, (num) layers  2D=(32768, 32768), 2048 layers
  Total amount of constant memory:               zu bytes
  Total amount of shared memory per block:       zu bytes
  Total number of registers available per block: 65536
  Warp size:                                     32
  Maximum number of threads per multiprocessor:  1536
  Maximum number of threads per block:           1024
  Max dimension size of a thread block (x,y,z): (1024, 1024, 64)
  Max dimension size of a grid size    (x,y,z): (2147483647, 65535, 65535)
  Maximum memory pitch:                          zu bytes
  Texture alignment:                             zu bytes
  Concurrent copy and kernel execution:          Yes with 1 copy engine(s)
  Run time limit on kernels:                     Yes
  Integrated GPU sharing Host Memory:            No
  Support host page-locked memory mapping:       Yes
  Alignment requirement for Surfaces:            Yes
  Device has ECC support:                        Disabled
  CUDA Device Driver Mode (TCC or WDDM):         WDDM (Windows Display Driver Model)
  Device supports Unified Addressing (UVA):      Yes
  Device supports Compute Preemption:            Yes
  Supports Cooperative Kernel Launch:            Yes
  Supports MultiDevice Co-op Kernel Launch:      No
  Device PCI Domain ID / Bus ID / location ID:   0 / 1 / 0
  Compute Mode:
     < Default (multiple host threads can use ::cudaSetDevice() with device simultaneously) >

deviceQuery, CUDA Driver = CUDART, CUDA Driver Version = 12.6, CUDA Runtime Version = 12.6, NumDevs = 1, Device0 = NVIDIA GeForce RTX 4060 Ti
Result = PASS

安装FaceFusion

打开官网https://docs.facefusion.io/installation,Installation 选择Windows然后执行对应的命令即可

1. Prepare Your Platform

GIT
winget install -e --id Git.Git
Conda
winget install -e --id Anaconda.Miniconda3 --override "/AddToPath=1"
FFmpeg
winget install -e --id Gyan.FFmpeg
Codec
winget install -e --id CodecGuide.K-LiteCodecPack.Basic

2. Prepare Your Environment

Installation
conda init --all
conda create --name facefusion python=3.10
Usage
conda activate facefusion

3. Install Your Accelerator

CUDA

conda install conda-forge::cuda-runtime=12.4.1 cudnn=8.9.2.26 conda-forge::gputil=1.4.0
conda install conda-forge::zlib-wapi

OpenVINO ⁿᵉˣᵗ

conda install conda-forge::openvino=2024.2.0

4. Download Your Copy

Clone the repository:

git clone https://github.com/facefusion/facefusion

Ensure to enter the directory:

cd facefusion

5. Install The Application

python install.py

6. Done

Finally, run the command:

python run.py

注意:第一次启动会自动下载模型,耗时巨长,可以自行下载好模型后再启动

直接访问对应的url下载后将模型放到models文件夹下即可

可能出现的错误

启动后,上传照片后执行换脸时报错

[Could not locate zlibwapi.dll. Please make sure it is in your library path](https://stackoverflow.com/questions/72356588/could-not-locate-zlibwapi-dll-please-make-sure-it-is-in-your-library-path)

解决方案

进入目录C:\Program Files\NVIDIA Corporation\Nsight Systems 2024.4.2\host-windows-x64可以找到zlib.dll文件,将其复制为C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.8\bin\zlibwapi.dll即可

参考文档:https://stackoverflow.com/questions/72356588/could-not-locate-zlibwapi-dll-please-make-sure-it-is-in-your-library-path