Skip to content

About installation err on python 3.13 and multiprocessing problem #1520

@112292454

Description

@112292454

Describe the bug

  1. When installing version 3.13, an error occurred in a suspected .so library (resolved, only reported)

First of all, using the installation script in release (python=3.13, no problem when switching to 3.10 installation), the following first error appears. This error is from pip itself, which will cause this error to appear for any package in pip install (pip list shows only packaging=25.0, pip=25.3)
I checked the LD_LIBRARY_PATH mentioned in some related posts, and whether this .so has wrong soft links, but there are none.
The final solution is simple: change from pip to conda install expat, and then rerun setup.py

I have this error when installing on several different servers (with different .so files in the lib directory, but the user directory and conda environment are interconnected by nfs). I don't know if it's my conda problem or what, the report here is for reference only

  1. When extracting, the second paragraph of the log below appears, and multi-threaded CUDA fails.

The environment is created using the above script and modification process (if set python=3.10 to install, there will be no above error, but it will still cause this multiprocessing problem)
Finally, I modified scripts/extract.py line140, disabled the process logic that avoids memory leaks, and can run directly by calling else.

To Reproduce
see above

Screenshots
1.

(base) gzy@gamma-4090-48:~$ bash faceswap_setup_x64.sh
                         001
                        11 10  010
               @@@@      10
            @@@@@@@@         00     1
          @@@@@@@@@@  1  1            0
        @@@@@@@@    0000 01111
       @@@@@@@@@@    01  110 01  1
      @@@@@@@@@@@@ 111    010    0
      @@@@@@@@@@@@@@@@  10    0
      @@@@@@@@@@@@@   0010   1
      @@@@@@@@@  @@@   100         1
      @@@@@@@ .@@@@  10       1
       #@@@@@@@@@@@  001       0
         @@@@@@@@@@@  ,
         @@@@@@@@  @@@@@
        @@@@@@@@ @@@@@@@@
       @@@@@@@@@,@@@@@@@@  / _|
       %@@@@@@@@@@@@@@@@@ | |_  ___
           @@@@@@@@@@@@@@ |  _|/ __|
            @@@@@@@@@@@@  | |  \__ \
             @@@@@@@@@@(  |_|  |___/
                @@@@@@
                 @@@@

================ Welcome to the Linux Faceswap Installer ================
INFO    To get setup we need to gather some information about where you
INFO    would like Faceswap and Conda to be installed.
INFO    To accept the default values just hit the 'ENTER' key for each
INFO    option. You will have an opportunity to review your responses prior
INFO    to commencing the install.

INFO    IMPORTANT: Make sure that the user 'gzy' has full
INFO    permissions for all of the destinations that you select.
Press 'ENTER' to continue with the setup...

================================= CONDA =================================
INFO    Faceswap uses Conda as it handles the installation of all
INFO    prerequisites.
INFO    Found existing conda install at: /home/gzy/miniconda3
Use the pre installed conda? [YES/no]:
INFO    Using Conda install at /home/gzy/miniconda3

INFO    Faceswap will be installed inside a Conda Environment. If an
INFO    environment already exists with the name specified then it will
INFO    be deleted.
Please specify a name for the Faceswap Conda Environment [default: 'faceswap']:

================================ FACESWAP ================================
INFO    Faceswap will be installed in the given location. If a folder exists
INFO    at the location you specify, then it will be deleted.
Please specify a location for Faceswap [default: '/home/gzy/faceswap']:

INFO    Faceswap can be run on NVIDIA or AMD GPUs or on CPU. You should make
INFO    sure that you have the latest graphics card drivers installed from
INFO    the relevant vendor. Please select the version of Faceswap you wish
INFO    to install.
Select: 1: NVIDIA
        2: AMD (ROCm)
        3: CPU
[default: 1]:
INFO    Depending on your GPU a different version of Cuda may be
INFO    required. Please select the generation of Nvidia GPU you use below.
Select: 1: RTX 20xx ->
        2: GTX 9xx - GTX 10xx
        3: GTX 7xx - GTX 9xx
[default: 1]:

========================= Review install options =========================
INFO    Please review the selected installation options before proceeding:

        - Existing Conda install at '/home/gzy/miniconda3' will be used
yes        - Conda Environment 'faceswap' will be created.
        - Existing Faceswap folder '/home/gzy/faceswap' will be removed
        - Faceswap will be installed in '/home/gzy/faceswap'
        - Installing for 'nvidia'
        - Cuda version 13 will be used
Do you wish to continue? [yes/NO]:
INFO    Creating Conda Virtual Environment...
Collecting package metadata (current_repodata.json): ...working... done
Solving environment: ...working... done

## Package Plan ##

  environment location: /home/gzy/miniconda3/envs/faceswap

  added / updated specs:
    - python=3.13


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    _libgcc_mutex-0.1          |      conda_forge           3 KB  conda-forge
    _openmp_mutex-4.5          |            2_gnu          23 KB  conda-forge
    bzip2-1.0.8                |       hda65f42_8         254 KB  conda-forge
    ca-certificates-2026.1.4   |       hbd8a1cb_0         143 KB  conda-forge
    ld_impl_linux-64-2.45      |default_hbd61a6d_105         714 KB  conda-forge
    libexpat-2.7.3             |       hecca717_0          75 KB  conda-forge
    libffi-3.5.2               |       h9ec8514_0          56 KB  conda-forge
    libgcc-15.2.0              |      he0feb66_16        1018 KB  conda-forge
    libgomp-15.2.0             |      he0feb66_16         589 KB  conda-forge
    liblzma-5.8.1              |       hb9d3cd8_2         110 KB  conda-forge
    libmpdec-4.0.0             |       hb9d3cd8_0          89 KB  conda-forge
    libsqlite-3.51.1           |       h0c1763c_1         919 KB  conda-forge
    libuuid-2.41.3             |       h5347b49_0          39 KB  conda-forge
    libzlib-1.3.1              |       hb9d3cd8_2          60 KB  conda-forge
    ncurses-6.5                |       h2d0b736_3         871 KB  conda-forge
    openssl-3.6.0              |       h26f9b46_0         3.0 MB  conda-forge
    pip-25.3                   |     pyh145f28c_0         1.1 MB  conda-forge
    python-3.13.11             |hc97d973_100_cp313        35.5 MB  conda-forge
    python_abi-3.13            |          8_cp313           7 KB  conda-forge
    readline-8.3               |       h853b02a_0         337 KB  conda-forge
    tk-8.6.13                  |noxft_ha0e22de_103         3.1 MB  conda-forge
    tzdata-2025c               |       hc9c84f9_1         116 KB  conda-forge
    zstd-1.5.7                 |       hb78ec9c_6         587 KB  conda-forge
    ------------------------------------------------------------
                                           Total:        48.6 MB

The following NEW packages will be INSTALLED:

  _libgcc_mutex      conda-forge/linux-64::_libgcc_mutex-0.1-conda_forge
  _openmp_mutex      conda-forge/linux-64::_openmp_mutex-4.5-2_gnu
  bzip2              conda-forge/linux-64::bzip2-1.0.8-hda65f42_8
  ca-certificates    conda-forge/noarch::ca-certificates-2026.1.4-hbd8a1cb_0
  ld_impl_linux-64   conda-forge/linux-64::ld_impl_linux-64-2.45-default_hbd61a6d_105
  libexpat           conda-forge/linux-64::libexpat-2.7.3-hecca717_0
  libffi             conda-forge/linux-64::libffi-3.5.2-h9ec8514_0
  libgcc             conda-forge/linux-64::libgcc-15.2.0-he0feb66_16
  libgomp            conda-forge/linux-64::libgomp-15.2.0-he0feb66_16
  liblzma            conda-forge/linux-64::liblzma-5.8.1-hb9d3cd8_2
  libmpdec           conda-forge/linux-64::libmpdec-4.0.0-hb9d3cd8_0
  libsqlite          conda-forge/linux-64::libsqlite-3.51.1-h0c1763c_1
  libuuid            conda-forge/linux-64::libuuid-2.41.3-h5347b49_0
  libzlib            conda-forge/linux-64::libzlib-1.3.1-hb9d3cd8_2
  ncurses            conda-forge/linux-64::ncurses-6.5-h2d0b736_3
  openssl            conda-forge/linux-64::openssl-3.6.0-h26f9b46_0
  pip                conda-forge/noarch::pip-25.3-pyh145f28c_0
  python             conda-forge/linux-64::python-3.13.11-hc97d973_100_cp313
  python_abi         conda-forge/noarch::python_abi-3.13-8_cp313
  readline           conda-forge/linux-64::readline-8.3-h853b02a_0
  tk                 conda-forge/linux-64::tk-8.6.13-noxft_ha0e22de_103
  tzdata             conda-forge/noarch::tzdata-2025c-hc9c84f9_1
  zstd               conda-forge/linux-64::zstd-1.5.7-hb78ec9c_6


Preparing transaction: ...working... done
Verifying transaction: ...working... done
Executing transaction: ...working... done
INFO    Installing Git...
Collecting package metadata (current_repodata.json): ...working... done
Solving environment: ...working... unsuccessful initial attempt using frozen solve. Retrying with flexible solve.
Collecting package metadata (repodata.json): ...working... done
Solving environment: ...working... done

## Package Plan ##

  environment location: /home/gzy/miniconda3/envs/faceswap

  added / updated specs:
    - git[version='<2.45']


The following packages will be downloaded:

    package                    |            build
    ---------------------------|-----------------
    c-ares-1.34.5              |       hef5626c_0         216 KB
    ca-certificates-2025.12.2  |       h06a4308_0         125 KB
    curl-8.16.0                |       he2463ab_0         173 KB
    expat-2.7.3                |       h3385a95_0         167 KB
    gettext-0.19.8.1           |       h9b4dc7a_1         2.9 MB
    git-2.40.1                 | pl5340h9abc3c3_4         9.9 MB
    libcurl-8.16.0             |       heebcbe5_0         458 KB
    libgcc-15.2.0              |       h69a1729_7         806 KB
    libgcc-ng-15.2.0           |       h166f726_7          28 KB
    libgomp-15.2.0             |       h4751f2c_7         436 KB
    libidn2-2.3.4              |       hb25bd0a_1          72 KB
    libnghttp2-1.57.0          |       h2d74bed_0         674 KB
    libssh2-1.11.1             |       h251f7ec_0         308 KB
    libstdcxx-15.2.0           |       h39759b7_7         3.7 MB
    libstdcxx-ng-15.2.0        |       hc03a8fd_7          28 KB
    libunistring-1.3           |       hb25bd0a_0         721 KB
    libzlib-1.3.1              |       hb25bd0a_0          59 KB
    pcre2-10.42                |       hebb0a14_1         1.3 MB
    perl-5.42.0                | 0_h47b2149_perl5        16.4 MB
    zlib-1.3.1                 |       hb25bd0a_0          96 KB
    ------------------------------------------------------------
                                           Total:        38.4 MB

The following NEW packages will be INSTALLED:

  c-ares             pkgs/main/linux-64::c-ares-1.34.5-hef5626c_0
  curl               pkgs/main/linux-64::curl-8.16.0-he2463ab_0
  expat              pkgs/main/linux-64::expat-2.7.3-h3385a95_0
  gettext            pkgs/main/linux-64::gettext-0.19.8.1-h9b4dc7a_1
  git                pkgs/main/linux-64::git-2.40.1-pl5340h9abc3c3_4
  libcurl            pkgs/main/linux-64::libcurl-8.16.0-heebcbe5_0
  libev              pkgs/main/linux-64::libev-4.33-h7f8727e_1
  libgcc-ng          pkgs/main/linux-64::libgcc-ng-15.2.0-h166f726_7
  libidn2            pkgs/main/linux-64::libidn2-2.3.4-hb25bd0a_1
  libnghttp2         pkgs/main/linux-64::libnghttp2-1.57.0-h2d74bed_0
  libssh2            pkgs/main/linux-64::libssh2-1.11.1-h251f7ec_0
  libstdcxx          pkgs/main/linux-64::libstdcxx-15.2.0-h39759b7_7
  libstdcxx-ng       pkgs/main/linux-64::libstdcxx-ng-15.2.0-hc03a8fd_7
  libunistring       pkgs/main/linux-64::libunistring-1.3-hb25bd0a_0
  pcre2              pkgs/main/linux-64::pcre2-10.42-hebb0a14_1
  perl               pkgs/main/linux-64::perl-5.42.0-0_h47b2149_perl5
  zlib               pkgs/main/linux-64::zlib-1.3.1-hb25bd0a_0

The following packages will be UPDATED:

  _openmp_mutex        conda-forge::_openmp_mutex-4.5-2_gnu --> pkgs/main::_openmp_mutex-5.1-1_gnu

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

  _libgcc_mutex      conda-forge::_libgcc_mutex-0.1-conda_~ --> pkgs/main::_libgcc_mutex-0.1-main
  ca-certificates    conda-forge/noarch::ca-certificates-2~ --> pkgs/main/linux-64::ca-certificates-2025.12.2-h06a4308_0
  libgcc             conda-forge::libgcc-15.2.0-he0feb66_16 --> pkgs/main::libgcc-15.2.0-h69a1729_7
  libgomp            conda-forge::libgomp-15.2.0-he0feb66_~ --> pkgs/main::libgomp-15.2.0-h4751f2c_7
  libzlib             conda-forge::libzlib-1.3.1-hb9d3cd8_2 --> pkgs/main::libzlib-1.3.1-hb25bd0a_0


Preparing transaction: ...working... done
Verifying transaction: ...working... done
Executing transaction: ...working... done
INFO    Removing Faceswap folder: '/home/gzy/faceswap'
INFO    Downloading Faceswap...
正克隆到 '/home/gzy/faceswap'...
remote: Enumerating objects: 1865, done.
remote: Counting objects: 100% (1865/1865), done.
remote: Compressing objects: 100% (1489/1489), done.
remote: Total 1865 (delta 984), reused 864 (delta 348), pack-reused 0 (from 0)
接收对象中: 100% (1865/1865), 90.02 MiB | 6.64 MiB/s, 完成.
处理 delta 中: 100% (984/984), 完成.
INFO    Setting up Faceswap...
INFO     Setup in Linux 6.8.0-90-generic
INFO     Running as User
INFO     Running in Conda
INFO     Running in a Virtual Environment
INFO     Encoding: UTF-8
INFO     Pip version: 25.3
INFO     Faceswap config written to: /home/gzy/faceswap/config/.faceswap
INFO     Keras config written to: /home/gzy/.keras/keras.json
INFO     Installing required package...
INFO       Packaging
INFO     Installing Conda packages...
INFO       Tk, Git, Xorg-Libxft
INFO     Installing Python packages...
INFO       Tqdm, Psutil, Numexpr, Numpy, Opencv-Python, Pillow, Scikit-Learn,
INFO       Fastcluster, Matplotlib, Imageio, Imageio-Ffmpeg, Ffmpy,
INFO       Torchvision, Tensorboard, Keras, Nvidia-Ml-Py, Torch
WARNING  Unable to install Python packages: Tqdm, Psutil, Numexpr, Numpy, Opencv-Python, Pillow, Scikit-Learn, Fastcluster, Matplotlib, Imageio, Imageio-Ffmpeg, Ffmpy, Torchvision, Tensorboard, Keras, Nvidia-Ml-Py, Torch. Please install these packages manually
ERROR    Some packages failed to install. Further information can be found in 'faceswap_setup.log'. The following output shows specific error(s) that were collected:
         Traceback (most recent call last):
         File "<frozen runpy>", line 198, in _run_module_as_main
         File "<frozen runpy>", line 88, in _run_code
         File "/home/gzy/miniconda3/envs/faceswap/lib/python3.13/site-packages/pip/__main__.py", line 24, in <module>
         sys.exit(_main())
         ~~~~~^^
         File "/home/gzy/miniconda3/envs/faceswap/lib/python3.13/site-packages/pip/_internal/cli/main.py", line 78, in main
         command = create_command(cmd_name, isolated=("--isolated" in cmd_args))
         File "/home/gzy/miniconda3/envs/faceswap/lib/python3.13/site-packages/pip/_internal/commands/__init__.py", line 121, in create_command
         module = importlib.import_module(module_path)
         File "/home/gzy/miniconda3/envs/faceswap/lib/python3.13/importlib/__init__.py", line 88, in import_module
         return _bootstrap._gcd_import(name[level:], package, level)
         ~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         File "<frozen importlib._bootstrap>", line 1387, in _gcd_import
         File "<frozen importlib._bootstrap>", line 1360, in _find_and_load
         File "<frozen importlib._bootstrap>", line 1331, in _find_and_load_unlocked
         File "<frozen importlib._bootstrap>", line 935, in _load_unlocked
         File "<frozen importlib._bootstrap_external>", line 1023, in exec_module
         File "<frozen importlib._bootstrap>", line 488, in _call_with_frames_removed
         File "/home/gzy/miniconda3/envs/faceswap/lib/python3.13/site-packages/pip/_internal/commands/install.py", line 22, in <module>
         import pip._internal.self_outdated_check  # noqa: F401
         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         File "/home/gzy/miniconda3/envs/faceswap/lib/python3.13/site-packages/pip/_internal/self_outdated_check.py", line 21, in <module>
         from pip._internal.index.package_finder import PackageFinder
         File "/home/gzy/miniconda3/envs/faceswap/lib/python3.13/site-packages/pip/_internal/index/package_finder.py", line 38, in <module>
         from pip._internal.req import InstallRequirement
         File "/home/gzy/miniconda3/envs/faceswap/lib/python3.13/site-packages/pip/_internal/req/__init__.py", line 8, in <module>
         from pip._internal.cli.progress_bars import BarType, get_install_progress_renderer
         File "/home/gzy/miniconda3/envs/faceswap/lib/python3.13/site-packages/pip/_internal/cli/progress_bars.py", line 23, in <module>
         from pip._internal.req.req_install import InstallRequirement
         File "/home/gzy/miniconda3/envs/faceswap/lib/python3.13/site-packages/pip/_internal/req/req_install.py", line 37, in <module>
         from pip._internal.operations.install.wheel import install_wheel
         File "/home/gzy/miniconda3/envs/faceswap/lib/python3.13/site-packages/pip/_internal/operations/install/wheel.py", line 33, in <module>
         from pip._vendor.distlib.scripts import ScriptMaker
         File "/home/gzy/miniconda3/envs/faceswap/lib/python3.13/site-packages/pip/_vendor/distlib/scripts.py", line 16, in <module>
         from .compat import sysconfig, detect_encoding, ZipFile
         File "/home/gzy/miniconda3/envs/faceswap/lib/python3.13/site-packages/pip/_vendor/distlib/compat.py", line 81, in <module>
         import xmlrpc.client as xmlrpclib
         File "/home/gzy/miniconda3/envs/faceswap/lib/python3.13/xmlrpc/client.py", line 138, in <module>
         from xml.parsers import expat
         File "/home/gzy/miniconda3/envs/faceswap/lib/python3.13/xml/parsers/expat.py", line 4, in <module>
         from pyexpat import *
         ImportError: /home/gzy/miniconda3/envs/faceswap/lib/python3.13/lib-dynload/pyexpat.cpython-313-x86_64-linux-gnu.so: undefined symbol: XML_SetAllocTrackerActivationThreshold
INFO    Faceswap installation is complete!
> python /home/gzy/fs/faceswap.py extract -aIP -i ~/fs/data/blue/xhs/sum -o /home/gzy/fs/data/blue/extract/p -D s3fd -A fan -M bisenet-fp -O hist -R 1 -m 20 -l 0.6 -z 512 -N 1 -v 0 -X 0 -L INFO

.........

01/09/2026 04:44:56 INFO     Initializing S3FD (Detect)...
Process Process-1:
Traceback (most recent call last):
  File "/home/gzy/miniconda3/envs/faceswap/lib/python3.13/multiprocessing/process.py", line 313, in _bootstrap
    self.run()
    ~~~~~~~~^^
  File "/home/gzy/miniconda3/envs/faceswap/lib/python3.13/multiprocessing/process.py", line 108, in run
    self._target(*self._args, **self._kwargs)
    ~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gzy/faceswap/scripts/extract.py", line 704, in process
    self._run_extraction()
    ~~~~~~~~~~~~~~~~~~~~^^
  File "/home/gzy/faceswap/scripts/extract.py", line 724, in _run_extraction
    self._extractor.launch()
    ~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/gzy/faceswap/plugins/extract/pipeline.py", line 252, in launch
    self._launch_plugin(phase)
    ~~~~~~~~~~~~~~~~~~~^^^^^^^
  File "/home/gzy/faceswap/plugins/extract/pipeline.py", line 777, in _launch_plugin
    plugin.initialize(**kwargs)
    ~~~~~~~~~~~~~~~~~^^^^^^^^^^
  File "/home/gzy/faceswap/plugins/extract/_base.py", line 517, in initialize
    self.init_model()
    ~~~~~~~~~~~~~~~^^
  File "/home/gzy/faceswap/plugins/extract/detect/s3fd.py", line 47, in init_model
    self.model = S3fd(self.model_path, self.batchsize, confidence)
                 ~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/gzy/faceswap/plugins/extract/detect/s3fd.py", line 242, in __init__
    self._model = self._load_model(weights_path)
                  ~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^
  File "/home/gzy/faceswap/plugins/extract/detect/s3fd.py", line 329, in _load_model
    var_x = self.conv_block(input_, 64, 1, 2)
  File "/home/gzy/faceswap/plugins/extract/detect/s3fd.py", line 276, in conv_block
    var_x = Conv2D(filters,
    ...<2 lines>...
                   activation="relu",
                   name=rec_name)(var_x)
  File "/home/gzy/miniconda3/envs/faceswap/lib/python3.13/site-packages/keras/src/utils/traceback_utils.py", line 122, in error_handler
    raise e.with_traceback(filtered_tb) from None
  File "/home/gzy/miniconda3/envs/faceswap/lib/python3.13/site-packages/torch/_dynamo/eval_frame.py", line 1048, in _fn
    _maybe_set_eval_frame(prior)
    ~~~~~~~~~~~~~~~~~~~~~^^^^^^^
  File "/home/gzy/miniconda3/envs/faceswap/lib/python3.13/site-packages/torch/cuda/__init__.py", line 398, in _lazy_init
    raise RuntimeError(
    ...<2 lines>...
    )
RuntimeError: Cannot re-initialize CUDA in forked subprocess. To use CUDA with multiprocessing, you must use the 'spawn' start method

Desktop (please complete the following information):

  • OS: Linux 6.8.0-90-generic ~22.04.1-Ubuntu
  • Python Version 3.13
  • Conda Version 23.9.0
  • Commit ID 342e19d

Additional context
Add any other context about the problem here.

Crash Report
The crash report generated in the root of your Faceswap folder

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions