LivePortrait Installation Guide

This document provides detailed installation instructions for LivePortrait across different operating systems and environments.

Requirements

Before installation, ensure your system meets the following basic requirements:

Operating System: Linux (recommended), Windows 10/11, macOS (requires Apple Silicon)

Python Version: Python 3.10

Hardware Requirements: NVIDIA GPU (RTX 4090 or other CUDA-capable显卡 recommended), minimum 8GB VRAM

Storage Space: Minimum 20GB recommended for model weights and runtime environment

Basic Environment Setup

Checking CUDA Version

First, confirm your system's CUDA version to install the appropriate PyTorch version:

nvcc -V

Common CUDA versions include 11.1, 11.8, and 12.1. Based on the displayed version number, select the corresponding PyTorch installation command.

Installing PyTorch

Choose the appropriate PyTorch installation command based on your CUDA version:

For CUDA 11.1:

pip install torch==1.10.1+cu111 torchvision==0.11.2 torchaudio==0.10.1 -f https://download.pytorch.org/whl/cu111/torch_stable.html

For CUDA 11.8:

pip install torch==2.3.0 torchvision==0.18.0 torchaudio==2.3.0 --index-url https://download.pytorch.org/whl/cu118

For CUDA 12.1:

pip install torch==2.3.0 torchvision==0.18.0 torchaudio==2.3.0 --index-url https://download.pytorch.org/whl/cu121

If you only need to run Humans mode, you can skip the CUDA version check and install the latest PyTorch version directly.

Downloading Project Code

Clone the LivePortrait repository using Git:

git clone https://github.com/KlingTeam/LivePortrait
cd LivePortrait

Creating Python Environment

It is recommended to create an isolated Python environment using conda:

conda create -n LivePortrait python=3.10
conda activate LivePortrait

Or using venv:

python -m venv LivePortrait
# Linux/macOS
source LivePortrait/bin/activate
# Windows
LivePortrait\Scripts\activate

Installing Dependencies

Execute the following in the project root directory:

pip install -r requirements.txt

Downloading Pretrained Models

Pretrained models can be downloaded from HuggingFace. If your network has access to HuggingFace:

pip install -U "huggingface_hub[cli]"
huggingface-cli download KlingTeam/LivePortrait --local-dir pretrained_weights --exclude "*.git*" "README.md" "docs"

If you cannot access HuggingFace, use a mirror site:

export HF_ENDPOINT=https://hf-mirror.com
huggingface-cli download KlingTeam/LivePortrait --local-dir pretrained_weights --exclude "*.git*" "README.md" "docs"

Alternatively, download the complete model files from Google Drive or Baidu Netdisk, extract and place them in the ./pretrained_weights directory.

Verifying Installation

After installation, run the test script to verify the environment is configured correctly:

python inference.py

If everything works properly, you will see the generated output file in the animations directory.

Additional Installation Steps for Animal Models

Animal mode is only supported on Linux and Windows systems with NVIDIA GPUs.

Installing X-Pose Dependency

Animal mode requires the X-Pose project as a keypoint detection framework. First, navigate to the X-Pose directory:

cd src/utils/dependencies/XPose/models/UniPose/ops
python setup.py build install
cd -

Downloading Animal Models from HuggingFace

huggingface-cli download KlingTeam/LivePortrait --include "animal*" --local-dir pretrained_weights

Special Notes for Windows

On Windows systems, certain higher CUDA versions (such as 12.4, 12.6) may cause compatibility issues. It is recommended to downgrade CUDA to version 11.8 for better stability.

Windows users can also choose to download the one-click installer and run by double-clicking run_windows.bat after extraction:

# Download Windows one-click installer from HuggingFace
# Address: https://huggingface.co/cleardusk/LivePortrait-Windows

Special Notes for macOS

Apple Silicon macOS

For macOS users with Apple Silicon, use the special dependency file:

pip install -r requirements_macOS.txt

When running inference, set the environment variable:

PYTORCH_ENABLE_MPS_FALLBACK=1 python inference.py

Note: Running inference on Apple Silicon macOS may be approximately 20 times slower than on RTX 4090.

Intel Mac

Intel-based Macs have not been officially tested and may not run properly.

Animal Mode Limitation

Since the X-Pose dependency does not support macOS, Animal mode is unavailable on macOS. Only Human mode can be used.

Verifying Directory Structure

After installation, ensure the directory structure matches the following:

LivePortrait/
├── pretrained_weights/     # Pretrained model weights directory
├── assets/                 # Example materials directory
│   ├── examples/
│   │   ├── source/        # Source image/video
│   │   └── driving/       # Driving video
├── src/                    # Source code directory
├── inference.py           # Inference script
├── app.py                 # Gradio interface
└── requirements.txt       # Dependency list

Common Issues

If you encounter problems during installation, check the following:

CUDA unavailable: Confirm NVIDIA drivers are properly installed; run nvidia-smi to check driver status

Insufficient VRAM: Try using smaller input images or reducing batch size

Model download failure: Check network connection or use domestic mirror sites

Dependency conflicts: It is recommended to use a fresh Python environment to avoid conflicts with other projects