[Guide] Using Faceswap on Nvidia RTX 30xx cards

Installing and setting up FaceSwap


Forum rules

Read the FAQs and search the forum before posting a new topic.

Please mark any answers that fixed your problems so others can find the solutions.

User avatar
torzdf
Posts: 1439
Joined: Fri Jul 12, 2019 12:53 am
Answers: 125
Has thanked: 48 times
Been thanked: 278 times

[Guide] Using Faceswap on Nvidia RTX 30xx cards

Post by torzdf »

Update: TF2.4 support has now been rolled into mainline. The tf2.4 branch has been removed, so you should now just stay on the Master branch

First up, this is entirely unsupported, and you are on your own. These instructions are here as a courtesy whilst we wait for upstream (Conda mainly) to update it's packages for the latest GPU support.

You will not receive official support for this kind of setup, so please don't ask for it. Official support will come when upstream catches up. You should keep all comments, feedback, bugs and suggestions to this thread in the hope that others will be able to help you and the devs can pick up on bugs.

This solution is not automatic, there will be manual and command line work involved. These instructions are untested and just reeled off from the top of my head. If you have suggestions for changes please post them.

Another thing to bear in mind is that officially the minimum Cuda version required for 30xx cards is 11.1 (https://www.phoronix.com/scan.php?page= ... 1-Released), however the latest Tensorflow version has been compiled for 11.0 (https://www.tensorflow.org/install/source#gpu). These instructions will allow you to run the 11.0 version of Tensorflow (as per the official release). This may or may not bring with it issues for 30xx cards. Please do report them here.

To use a version for Cuda 11.1 then you will need to compile Tensorflow yourself, which is well outside of the scope of these instructions. (Compiling Tensorflow from source: https://www.tensorflow.org/install/source). Alternatively you could try some pre-compiled wheels (Google is your friend. your mileage may vary), although we cannot vouch for 3rd party compiled versions of Tensorflow.

Setup

  1. Remove any and all versions of Cuda and cuDNN from your PC.
  2. Install Cuda Tool Kit 11.0 from https://developer.nvidia.com/cuda-11.0-download-archive.
  3. Install cuDNN 8.0 for Cuda Tool Kit 11.0 from https://developer.nvidia.com/cudnn-download-survey. (NB: I cannot provide a direct link as you need to log in, make sure you download the correct cuDNN version (8.0) for the correct Cuda version (11.0)).

Faceswap

  1. Download the latest Faceswap installer (do not try to upgrade your existing Faceswap install).
  2. Select "CPU" when asked which version of Faceswap you want to install. This is very important as it will ensure we use the Cuda version we installed in the last step.
  3. Run the installer and let it complete.
  4. Delete the file <faceswap folder>/config/.faceswap (alternatively you can edit this file and change the word cpu to nvidia)

Tensorflow

We have to remove the CPU version of Tensorflow we installed and replace it with a version compatible with 30xx cards. I will assume Linux users are comfortable with entering a Conda environment, so these instructions are for Windows:

  1. Go Start > Anaconda Prompt.
  2. Enter the following commands to activate the faceswap environment, remove Tensorflow cpu and install Tensorflow-GPU. (Change the name faceswap in the first command if you selected a different environment name when installing):

    Code: Select all

    conda activate faceswap
    conda remove tensorflow
    pip install tensorflow-gpu==2.4

We now have Faceswap, Cuda and Tensorflow installed. Opening Faceswap should see you running tf.2.4 for 30xx cards.

Please post issues and bugs here. We will not provide setup support, but bugs and issues will help us to remedy asap.

My word is final


Tags:

User avatar
tokafondo
Posts: 31
Joined: Mon Dec 16, 2019 1:43 pm
Has thanked: 10 times
Been thanked: 4 times

Re: [Guide] Using Faceswap on Nvidia RTX 30xx cards

Post by tokafondo »

Is there any advantage on going this route on a GTX1070 card? Something to be gained over the standard way? Thanks.


User avatar
bryanlyon
Site Admin
Posts: 625
Joined: Fri Jul 12, 2019 12:49 am
Answers: 41
Location: San Francisco
Has thanked: 3 times
Been thanked: 159 times
Contact:

Re: [Guide] Using Faceswap on Nvidia RTX 30xx cards

Post by bryanlyon »

No. DO NOT DO THIS IF YOU DON'T HAVE A 30xx CARD.

If you have any other card, use the normal installer.


User avatar
aostang
Posts: 1
Joined: Thu Dec 31, 2020 7:14 am

Re: [Guide] Using Faceswap on Nvidia RTX 30xx cards

Post by aostang »

All was fine until the last step. This is on a 100% fresh install on a new PC (Faceswap launched fine in CPU mode). Here is the console output:

** UPDATE** I was able to get past the "brotli" error by issuing this command from conda terminal:

conda install -c anaconda urllib3


Code: Select all

(base) C:\Users\aostang>conda activate faceswap

(faceswap) C:\Users\aostang>conda remove tensorflow
Collecting package metadata (repodata.json): done
Solving environment: done

## Package Plan ##

  environment location: C:\Users\aostang\miniconda3\envs\faceswap

  removed specs:
    - tensorflow


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    ffmpeg-4.2.2               |       he774522_0        17.6 MB
    ------------------------------------------------------------
                                           Total:        17.6 MB

The following packages will be REMOVED:

  _tflow_select-2.3.0-eigen
  absl-py-0.11.0-pyhd3eb1b0_1
  aiohttp-3.7.3-py38h2bbff1b_1
  astunparse-1.6.3-py_0
  async-timeout-3.0.1-py38_0
  attrs-20.3.0-pyhd3eb1b0_0
  blinker-1.4-py38_0
  brotlipy-0.7.0-py38h2bbff1b_1003
  cachetools-4.2.0-pyhd3eb1b0_0
  cffi-1.14.4-py38hcd4344a_0
  chardet-3.0.4-py38haa95532_1003
  click-7.1.2-py_0
  cryptography-2.9.2-py38h7a1dbc1_0
  gast-0.4.0-py_0
  google-auth-1.24.0-pyhd3eb1b0_0
  google-auth-oauthlib-0.4.2-pyhd3eb1b0_2
  google-pasta-0.2.0-py_0
  grpcio-1.31.0-py38he7da953_0
  h5py-2.10.0-py38h5e291fa_0
  hdf5-1.10.4-h7ebc959_0
  idna-2.10-py_0
  importlib-metadata-2.0.0-py_1
  keras-applications-1.0.8-py_1
  keras-preprocessing-1.1.0-py_1
  libprotobuf-3.13.0.1-h200bbdf_0
  markdown-3.3.3-py38haa95532_0
  multidict-4.7.6-py38he774522_1
  oauthlib-3.1.0-py_0
  opt_einsum-3.1.0-py_0
  protobuf-3.13.0.1-py38ha925a31_1
  pyasn1-0.4.8-py_0
  pyasn1-modules-0.2.8-py_0
  pycparser-2.20-py_2
  pyjwt-2.0.0-py38haa95532_0
  pyopenssl-20.0.1-pyhd3eb1b0_1
  pyreadline-2.1-py38_1
  pysocks-1.7.1-py38haa95532_0
  requests-2.25.1-pyhd3eb1b0_0
  requests-oauthlib-1.3.0-py_0
  rsa-4.6-py_0
  tensorboard-2.3.0-pyh4dce500_0
  tensorboard-plugin-wit-1.6.0-py_0
  tensorflow-2.3.0-mkl_py38h8c0d9a2_0
  tensorflow-base-2.3.0-eigen_py38h75a453f_0
  tensorflow-estimator-2.3.0-pyheb71bc4_0
  termcolor-1.1.0-py38_1
  typing-extensions-3.7.4.3-0
  typing_extensions-3.7.4.3-py_0
  urllib3-1.26.2-pyhd3eb1b0_0
  werkzeug-1.0.1-py_0
  win_inet_pton-1.1.0-py38haa95532_0
  wrapt-1.12.1-py38he774522_1
  yarl-1.5.1-py38he774522_0
  zipp-3.4.0-pyhd3eb1b0_0

The following packages will be SUPERSEDED by a higher-priority channel:

  ffmpeg               conda-forge::ffmpeg-4.3.1-ha925a31_0 --> pkgs/main::ffmpeg-4.2.2-he774522_0


Proceed ([y]/n)? y


Downloading and Extracting Packages
ffmpeg-4.2.2         | 17.6 MB   | #################################### | 100%
Preparing transaction: done
Verifying transaction: done
Executing transaction: done

(faceswap) C:\Users\aostang>pip install tensorflow-gpu==2.4
Traceback (most recent call last):
  File "C:\Users\aostang\miniconda3\envs\faceswap\Scripts\pip-script.py", line 10, in <module>
    sys.exit(main())
  File "C:\Users\aostang\miniconda3\envs\faceswap\lib\site-packages\pip\_internal\cli\main.py", line 73, in main
    command = create_command(cmd_name, isolated=("--isolated" in cmd_args))
  File "C:\Users\aostang\miniconda3\envs\faceswap\lib\site-packages\pip\_internal\commands\__init__.py", line 105, in create_command
    module = importlib.import_module(module_path)
  File "C:\Users\aostang\miniconda3\envs\faceswap\lib\importlib\__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1014, in _gcd_import
  File "<frozen importlib._bootstrap>", line 991, in _find_and_load
  File "<frozen importlib._bootstrap>", line 975, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 671, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 783, in exec_module
  File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
  File "C:\Users\aostang\miniconda3\envs\faceswap\lib\site-packages\pip\_internal\commands\install.py", line 17, in <module>
    from pip._internal.cli.req_command import RequirementCommand, with_cleanup
  File "C:\Users\aostang\miniconda3\envs\faceswap\lib\site-packages\pip\_internal\cli\req_command.py", line 18, in <module>
    from pip._internal.index.collector import LinkCollector
  File "C:\Users\aostang\miniconda3\envs\faceswap\lib\site-packages\pip\_internal\index\collector.py", line 14, in <module>
    from pip._vendor import html5lib, requests
  File "C:\Users\aostang\miniconda3\envs\faceswap\lib\site-packages\pip\_vendor\requests\__init__.py", line 43, in <module>
    from pip._vendor import urllib3
  File "C:\Users\aostang\miniconda3\envs\faceswap\lib\site-packages\pip\_vendor\urllib3\__init__.py", line 13, in <module>
    from .connectionpool import HTTPConnectionPool, HTTPSConnectionPool, connection_from_url
  File "C:\Users\aostang\miniconda3\envs\faceswap\lib\site-packages\pip\_vendor\urllib3\connectionpool.py", line 40, in <module>
    from .response import HTTPResponse
  File "C:\Users\aostang\miniconda3\envs\faceswap\lib\site-packages\pip\_vendor\urllib3\response.py", line 157, in <module>
    class HTTPResponse(io.IOBase):
  File "C:\Users\aostang\miniconda3\envs\faceswap\lib\site-packages\pip\_vendor\urllib3\response.py", line 390, in HTTPResponse
    DECODER_ERROR_CLASSES += (brotli.error,)
AttributeError: module 'brotli' has no attribute 'error'

(faceswap) C:\Users\aostang>
Last edited by aostang on Thu Dec 31, 2020 7:25 am, edited 1 time in total.

User avatar
torzdf
Posts: 1439
Joined: Fri Jul 12, 2019 12:53 am
Answers: 125
Has thanked: 48 times
Been thanked: 278 times

Re: [Guide] Using Faceswap on Nvidia RTX 30xx cards

Post by torzdf »

Yeah that "brotli" error is annoying and can happen with Conda. I'm not sure what triggers it, and have hit it once myself.

My personal solve was to update the base conda environment.

My word is final


User avatar
dlinkdnsnas
Posts: 8
Joined: Fri Jan 01, 2021 9:01 pm

Re: [Guide] Using Faceswap on Nvidia RTX 30xx cards

Post by dlinkdnsnas »

Thanks all for this I have a RTX 3070. Fresh build and have follwed everything in this Post. I am getting this
Setting Faceswap backend to NVIDIA
An unhandled exception occured loading pynvml. Original error: Uninitialized
No GPU detected. Switching to CPU mode
01/01/2021 21:00:07 INFO Log level set to: INFO

Any help would be greatly appericated maybe a new year gift:)


User avatar
torzdf
Posts: 1439
Joined: Fri Jul 12, 2019 12:53 am
Answers: 125
Has thanked: 48 times
Been thanked: 278 times

Re: [Guide] Using Faceswap on Nvidia RTX 30xx cards

Post by torzdf »

My word is final


User avatar
imllt
Posts: 2
Joined: Wed Jan 01, 2020 9:43 am

Re: [Guide] Using Faceswap on Nvidia RTX 30xx cards

Post by imllt »

i can't switch branch in GUI :ugeek: ,it send

Code: Select all

01/02/2021 13:01:34 INFO     Switching branch to 'dev-tf2.4'...
01/02/2021 13:01:35 ERROR    Unable to switch branch. return code: 128, message: error: unable to unlink old 'lib/cli/launcher.py': Invalid argument - error: unable to unlink old 'plugins/train/model/_base.py': Invalid argument - error: unable to unlink old 'requirements_cpu.txt': Invalid argument - error: unable to unlink old 'requirements_nvidia.txt': Invalid argument - fatal: unable to write new index file

User avatar
dlinkdnsnas
Posts: 8
Joined: Fri Jan 01, 2021 9:01 pm

Re: [Guide] Using Faceswap on Nvidia RTX 30xx cards

Post by dlinkdnsnas »

Thank you for your help with this and maybe not a bad idea to add to your how to guide not to upgrade to newer version of nvidia and stick to 457.51.

My output is now:

faceswap/faceswap.py" gui
Setting Faceswap backend to NVIDIA
01/02/2021 17:24:33 INFO Log level set to: INFO

Woah now cant wait to dig in.


User avatar
dlinkdnsnas
Posts: 8
Joined: Fri Jan 01, 2021 9:01 pm

Re: [Guide] Using Faceswap on Nvidia RTX 30xx cards

Post by dlinkdnsnas »

Sorry to be asking tomany questions. During extraction i have recived this error:

E tensorflow/stream_executor/cuda/cuda_blas.cc:226] failed to create cublas handle: CUBLAS_STATUS_ALLOC_FAILED

Any ideas?


User avatar
dlinkdnsnas
Posts: 8
Joined: Fri Jan 01, 2021 9:01 pm

Re: [Guide] Using Faceswap on Nvidia RTX 30xx cards

Post by dlinkdnsnas »

ok managed to tick Allow growth which seam to work for extraction. During Training now getting:

E tensorflow/stream_executor/cuda/cuda_dnn.cc:336] Could not create cudnn handle: CUDNN_STATUS_NOT_INITIALIZED
2021-01-02 19:56:38.723463: E tensorflow/stream_executor/cuda/cuda_dnn.cc:340] Error retrieving driver version: Unimplemented: kernel reported driver version not implemented on Windows

Any help please on this? So close....


User avatar
elon
Posts: 8
Joined: Sat Jan 02, 2021 4:09 pm

CUDA Error with rtx3090

Post by elon »

2021-01-03 15:15:56.811830: E tensorflow/stream_executor/cuda/cuda_event.cc:29] Error polling for event status: failed to query event: CUDA_ERROR_LAUNCH_FAILED: unspecified launch failure
2021-01-03 15:15:56.811842: F tensorflow/stream_executor/cuda/cuda_dnn.cc:189] Check failed: status == CUDNN_STATUS_SUCCESS (7 vs. 0)Failed to set cuDNN stream.
2021-01-03 15:15:56.811938: F
------------------------------------------------------------

Nvidia Driver 457.51

Cuda tool kit 11.0 only

CUdnn 8.0.5

Faceswap 2.4f installed CPU mode , changed to Nvidia Backend

TF 2.4 GPU

------------------------------------------------------------
Dfl-H128 model works well for while , but somtimes Cuda Error is occured.
or somtimes Freezing without Message

and also I tried
Unbalance/Dfl-sae/Dlight = Freezing with only 1~4 interation, without message ,also

HELP ME

Attachments
freezing.jpg
freezing.jpg (150.32 KiB) Viewed 17552 times

User avatar
elon
Posts: 8
Joined: Sat Jan 02, 2021 4:09 pm

Re: [Guide] Using Faceswap on Nvidia RTX 30xx cards

Post by elon »

dlinkdnsnas wrote: Sat Jan 02, 2021 7:58 pm

ok managed to tick Allow growth which seam to work for extraction. During Training now getting:

E tensorflow/stream_executor/cuda/cuda_dnn.cc:336] Could not create cudnn handle: CUDNN_STATUS_NOT_INITIALIZED
2021-01-02 19:56:38.723463: E tensorflow/stream_executor/cuda/cuda_dnn.cc:340] Error retrieving driver version: Unimplemented: kernel reported driver version not implemented on Windows

Any help please on this? So close....

do you use AMD CPU??

my cpu is 5900x + rtx 3900

and which window version? 12H1 12H2 ?


User avatar
dlinkdnsnas
Posts: 8
Joined: Fri Jan 01, 2021 9:01 pm

Re: [Guide] Using Faceswap on Nvidia RTX 30xx cards

Post by dlinkdnsnas »

do you use AMD CPU?? Yes

my cpu is 5900x + rtx 3900. My is AMD A8 9600 + RTX 3070

and which window version? 12H1 12H2 ? Windows 10 1809


User avatar
dlinkdnsnas
Posts: 8
Joined: Fri Jan 01, 2021 9:01 pm

Re: [Guide] Using Faceswap on Nvidia RTX 30xx cards

Post by dlinkdnsnas »

Ok figured it out under Trian = settings = orignal tick Allow growth. Seems to be processing will let you know the outcome.


User avatar
elon
Posts: 8
Joined: Sat Jan 02, 2021 4:09 pm

Re: [Guide] Using Faceswap on Nvidia RTX 30xx cards

Post by elon »

dlinkdnsnas wrote: Sun Jan 03, 2021 11:45 pm

Ok figured it out under Trian = settings = orignal tick Allow growth. Seems to be processing will let you know the outcome.

CUDA ERROR = I think it is VRAM problem. reduce batch size and input output size.
Try DFL H128. and do not any other program even Chrome.
and reduce batch size gain and agian

Freezing without no more interation Problem = I dont know the reason
Even, SAE,Dlight,Unbalance and many Model doesnt works

Before I buy rtx 3090 , I used 2080 ti x 3way = it worked well . almost perfect

all problem is occuerd after bought Rtx 3090

I already followed 3090 guide one by one.


and I used Nvidia driver 456.71 only , Check it please?


User avatar
elon
Posts: 8
Joined: Sat Jan 02, 2021 4:09 pm

Re: [Guide] Using Faceswap on Nvidia RTX 30xx cards

Post by elon »

bub.JPG
bub.JPG (165.86 KiB) Viewed 17432 times

Somtimes it works fine . more than few hours with H128 model

but sometimes, freezing In few second, or in Few minute.


User avatar
dlinkdnsnas
Posts: 8
Joined: Fri Jan 01, 2021 9:01 pm

Re: [Guide] Using Faceswap on Nvidia RTX 30xx cards

Post by dlinkdnsnas »

That is Crazy Speeds


User avatar
yking90
Posts: 17
Joined: Fri Jan 01, 2021 5:23 pm
Has thanked: 2 times

Re: [Guide] Using Faceswap on Nvidia RTX 30xx cards

Post by yking90 »

I can't wait for 30XX support... I'm certain the advantage and efficiency would help truck loads once it can truly take advantage.


User avatar
abigflea
Posts: 176
Joined: Sat Feb 22, 2020 10:59 pm
Answers: 2
Has thanked: 20 times
Been thanked: 53 times

Re: [Guide] Using Faceswap on Nvidia RTX 30xx cards

Post by abigflea »

write permissions error on second attempt after reinstalling miniconda.

Code: Select all

(faceswap) C:\Users\abigf>conda remove tensorflow
Collecting package metadata (repodata.json): done
Solving environment: done

## Package Plan ##

  environment location: C:\ProgramData\Miniconda3\envs\faceswap

  removed specs:
    - tensorflow


The following packages will be REMOVED:

  _tflow_select-2.3.0-eigen
  absl-py-0.11.0-pyhd3eb1b0_1
  aiohttp-3.7.3-py38h2bbff1b_1
  astunparse-1.6.3-py_0
  async-timeout-3.0.1-py38_0
  attrs-20.3.0-pyhd3eb1b0_0
  blinker-1.4-py38_0
  brotlipy-0.7.0-py38h2bbff1b_1003
  cachetools-4.2.0-pyhd3eb1b0_0
  cffi-1.14.4-py38hcd4344a_0
  chardet-3.0.4-py38haa95532_1003
  click-7.1.2-py_0
  cryptography-2.9.2-py38h7a1dbc1_0
  gast-0.4.0-py_0
  google-auth-1.24.0-pyhd3eb1b0_0
  google-auth-oauthlib-0.4.2-pyhd3eb1b0_2
  google-pasta-0.2.0-py_0
  grpcio-1.31.0-py38he7da953_0
  h5py-2.10.0-py38h5e291fa_0
  hdf5-1.10.4-h7ebc959_0
  idna-2.10-py_0
  importlib-metadata-2.0.0-py_1
  keras-applications-1.0.8-py_1
  keras-preprocessing-1.1.0-py_1
  libprotobuf-3.13.0.1-h200bbdf_0
  markdown-3.3.3-py38haa95532_0
  multidict-4.7.6-py38he774522_1
  oauthlib-3.1.0-py_0
  opt_einsum-3.1.0-py_0
  protobuf-3.13.0.1-py38ha925a31_1
  pyasn1-0.4.8-py_0
  pyasn1-modules-0.2.8-py_0
  pycparser-2.20-py_2
  pyjwt-2.0.0-py38haa95532_0
  pyopenssl-20.0.1-pyhd3eb1b0_1
  pyreadline-2.1-py38_1
  pysocks-1.7.1-py38haa95532_0
  requests-2.25.1-pyhd3eb1b0_0
  requests-oauthlib-1.3.0-py_0
  rsa-4.6-py_0
  tensorboard-2.3.0-pyh4dce500_0
  tensorboard-plugin-wit-1.6.0-py_0
  tensorflow-2.3.0-mkl_py38h8c0d9a2_0
  tensorflow-base-2.3.0-eigen_py38h75a453f_0
  tensorflow-estimator-2.3.0-pyheb71bc4_0
  termcolor-1.1.0-py38_1
  typing-extensions-3.7.4.3-0
  typing_extensions-3.7.4.3-py_0
  urllib3-1.26.2-pyhd3eb1b0_0
  werkzeug-1.0.1-py_0
  win_inet_pton-1.1.0-py38haa95532_0
  wrapt-1.12.1-py38he774522_1
  yarl-1.5.1-py38he774522_0
  zipp-3.4.0-pyhd3eb1b0_0

The following packages will be SUPERSEDED by a higher-priority channel:

  ffmpeg               conda-forge::ffmpeg-4.3.1-ha925a31_0 --> pkgs/main::ffmpeg-4.2.2-he774522_0


Proceed ([y]/n)? y

Preparing transaction: done
Verifying transaction: failed

EnvironmentNotWritableError: The current user does not have write permissions to the target environment.
  environment location: C:\ProgramData\Miniconda3\envs\faceswap

:o I dunno what I'm doing :shock:
RTX 3090 : RTX 3070 : RTX 3060 : RTX: 2070 : Ghetto 1060


Post Reply