{"id":1631,"date":"2025-11-12T14:10:53","date_gmt":"2025-11-12T14:10:53","guid":{"rendered":"https:\/\/zahiralam.com\/blog\/?p=1631"},"modified":"2025-12-04T06:18:49","modified_gmt":"2025-12-04T06:18:49","slug":"the-ultimate-guide-get-liveportrait-your-ai-talking-avatar-working-on-runpod","status":"publish","type":"post","link":"https:\/\/zahiralam.com\/blog\/the-ultimate-guide-get-liveportrait-your-ai-talking-avatar-working-on-runpod\/","title":{"rendered":"The Ultimate Guide: Get LivePortrait (Your AI Talking Avatar) Working on RunPod"},"content":{"rendered":"\n<h2 class=\"wp-block-heading\">1) Choosing the Right RunPod Template<\/h2>\n\n\n\n<p>To successfully install LivePortrait, we need a specific environment with the correct versions of Python, CUDA, and development tools. Starting with the right template saves a huge amount of setup time and prevents common errors.\n\n\n\n<p>After reviewing LivePortrait&#8217;s requirements, we selected the following template as the best starting point:\n\n\n\n<p><strong>Template Selected:<\/strong>&nbsp;<code>runpod\/pytorch:2.1.0-py3.10-cuda11.8.0-devel-ubuntu22.04<\/code>\n\n\n\n<p>Here is a breakdown of why this template is the ideal choice:\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Matches Python 3.10:<\/strong>&nbsp;LivePortrait is specifically designed and tested to work with Python 3.10. This template comes with it preinstalled.<\/li>\n\n\n\n<li><strong>Includes CUDA 11.8:<\/strong>&nbsp;The LivePortrait documentation explicitly recommends CUDA 11.8. This template provides the correct drivers and libraries, which is crucial for compatibility.<\/li>\n\n\n\n<li><strong>Provides a&nbsp;<code>-devel<\/code>&nbsp;Environment:<\/strong>&nbsp;The&nbsp;<code>-devel<\/code>&nbsp;tag means it includes essential compilers and development libraries (like&nbsp;<code>build-essential<\/code>). This is&nbsp;<strong>not optional<\/strong> &#8211; these tools are required to build custom operations for LivePortrait, such as the X-Pose ops needed for the &#8220;Animals&#8221; mode.<\/li>\n\n\n\n<li><strong>Reduces Setup Time:<\/strong>&nbsp;By providing PyTorch and other common GPU tools out of the box, we can get started much faster. (Note: We will upgrade PyTorch in the next step, but having the base installation is helpful).<\/li>\n\n\n\n<li><strong>Ensures Stability:<\/strong>&nbsp;Using the exact versions (Py 3.10, CUDA 11.8) recommended by the LivePortrait developers significantly reduces the risk of version-mismatch errors.<\/li>\n<\/ul>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">2) Why upgrade PyTorch (we upgraded from 2.1.0 \u2192 2.3.0)<\/h2>\n\n\n\n<p>We upgraded to&nbsp;<strong>PyTorch 2.3.0 (cu118)<\/strong>&nbsp;because:\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>LivePortrait tests &amp; recommendations<\/strong>: the project README \/ docs reference PyTorch 2.3.0 for CUDA 11.8 and CUDA 12.1 in examples. Using the recommended PyTorch reduces runtime issues.<\/li>\n\n\n\n<li><strong><code>torch.compile<\/code>&nbsp;\/ performance<\/strong>: LivePortrait offers&nbsp;<code>--flag_do_torch_compile<\/code>&nbsp;to gain 20\u201330% speedups.&nbsp;<code>torch.compile<\/code>&nbsp;and certain optimizations are more stable and performant on newer PyTorch 2.3.0 builds.<\/li>\n\n\n\n<li><strong>Bug fixes &amp; compatibility<\/strong>: newer PyTorch has compatibility fixes for CUDA\/cuDNN interactions and for compiled ops used by LivePortrait.<\/li>\n\n\n\n<li><strong>Minimal risk<\/strong>: CUDA (11.8) matched the wheel we install so the upgrade is straightforward.<\/li>\n<\/ul>\n\n\n\n<p><strong>Install command used<\/strong>\n\n\n\n<div class=\"code-block-container\">\n                        <pre class=\"wp-block-code\"><code id=\"code-1\">pip install torch==2.3.0 torchvision==0.18.0 torchaudio==2.3.0 --index-url https:\/\/download.pytorch.org\/whl\/cu118<\/code><\/pre>\n                        <amp-iframe sandbox=\"allow-scripts\" width=\"94\" height=\"72\" frameborder=\"0\" \n                                    src=\"https:\/\/zahiralam.com\/blog\/wp-content\/plugins\/amp-copy-code-button\/copier.html#pip%20install%20torch%3D%3D2.3.0%20torchvision%3D%3D0.18.0%20torchaudio%3D%3D2.3.0%20--index-url%20https%3A%2F%2Fdownload.pytorch.org%2Fwhl%2Fcu118\">\n                            <button class=\"copy-button\" data-label=\"pip install torch==2.3.0 torchvision==0.18.0 torchaudio==2.3.0 --index-url https:\/\/download.pytorch.org\/whl\/cu118\"  placeholder disabled>Copy<\/button>\n                        <\/amp-iframe>\n                    <\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">3) Full step-by-step commands (what we ran)<\/h2>\n\n\n\n<p>Run these in your RunPod terminal after the pod starts:\n\n\n\n<h3 class=\"wp-block-heading\">(A) Optional: update system packages and install FFmpeg<\/h3>\n\n\n\n<p>FFmpeg is required for reading\/writing videos :\n\n\n\n<div class=\"code-block-container\">\n                        <pre class=\"wp-block-code\"><code id=\"code-2\">sudo apt update -y\nsudo apt install -y ffmpeg git wget build-essential<\/code><\/pre>\n                        <amp-iframe sandbox=\"allow-scripts\" width=\"94\" height=\"72\" frameborder=\"0\" \n                                    src=\"https:\/\/zahiralam.com\/blog\/wp-content\/plugins\/amp-copy-code-button\/copier.html#sudo%20apt%20update%20-y%0Asudo%20apt%20install%20-y%20ffmpeg%20git%20wget%20build-essential\">\n                            <button class=\"copy-button\" data-label=\"sudo apt update -y\nsudo apt install -y ffmpeg git wget build-essential\"  placeholder disabled>Copy<\/button>\n                        <\/amp-iframe>\n                    <\/div>\n\n\n\n<h3 class=\"wp-block-heading\">(B) Clone repo and create Python environment<\/h3>\n\n\n\n<p>(You can use conda or venv. The image may already include conda.)\n\n\n\n<div class=\"code-block-container\">\n                        <pre class=\"wp-block-code\"><code id=\"code-3\">git clone https:\/\/github.com\/KwaiVGI\/LivePortrait.git\ncd LivePortrait\n\n# If you have conda:\nconda create -n liveportrait python=3.10 -y\nconda activate liveportrait\n\n# If you prefer venv:\n# python -m venv liveportrait\n# source liveportrait\/bin\/activate\n# pip install -U pip setuptools<\/code><\/pre>\n                        <amp-iframe sandbox=\"allow-scripts\" width=\"94\" height=\"72\" frameborder=\"0\" \n                                    src=\"https:\/\/zahiralam.com\/blog\/wp-content\/plugins\/amp-copy-code-button\/copier.html#git%20clone%20https%3A%2F%2Fgithub.com%2FKwaiVGI%2FLivePortrait.git%0Acd%20LivePortrait%0A%0A%23%20If%20you%20have%20conda%3A%0Aconda%20create%20-n%20liveportrait%20python%3D3.10%20-y%0Aconda%20activate%20liveportrait%0A%0A%23%20If%20you%20prefer%20venv%3A%0A%23%20python%20-m%20venv%20liveportrait%0A%23%20source%20liveportrait%2Fbin%2Factivate%0A%23%20pip%20install%20-U%20pip%20setuptools\">\n                            <button class=\"copy-button\" data-label=\"git clone https:\/\/github.com\/KwaiVGI\/LivePortrait.git\ncd LivePortrait\n\n# If you have conda:\nconda create -n liveportrait python=3.10 -y\nconda activate liveportrait\n\n# If you prefer venv:\n# python -m venv liveportrait\n# source liveportrait\/bin\/activate\n# pip install -U pip setuptools\"  placeholder disabled>Copy<\/button>\n                        <\/amp-iframe>\n                    <\/div>\n\n\n\n<h3 class=\"wp-block-heading\">(C) (Optional) Upgrade PyTorch to recommended version (cu118)<\/h3>\n\n\n\n<p>We replaced preinstalled torch with the 2.3.0 cu118 wheel:\n\n\n\n<div class=\"code-block-container\">\n                        <pre class=\"wp-block-code\"><code id=\"code-4\">pip install -U pip\npip install torch==2.3.0 torchvision==0.18.0 torchaudio==2.3.0 --index-url https:\/\/download.pytorch.org\/whl\/cu118<\/code><\/pre>\n                        <amp-iframe sandbox=\"allow-scripts\" width=\"94\" height=\"72\" frameborder=\"0\" \n                                    src=\"https:\/\/zahiralam.com\/blog\/wp-content\/plugins\/amp-copy-code-button\/copier.html#pip%20install%20-U%20pip%0Apip%20install%20torch%3D%3D2.3.0%20torchvision%3D%3D0.18.0%20torchaudio%3D%3D2.3.0%20--index-url%20https%3A%2F%2Fdownload.pytorch.org%2Fwhl%2Fcu118\">\n                            <button class=\"copy-button\" data-label=\"pip install -U pip\npip install torch==2.3.0 torchvision==0.18.0 torchaudio==2.3.0 --index-url https:\/\/download.pytorch.org\/whl\/cu118\"  placeholder disabled>Copy<\/button>\n                        <\/amp-iframe>\n                    <\/div>\n\n\n\n<h3 class=\"wp-block-heading\">(D) Install python dependencies for LivePortrait<\/h3>\n\n\n\n<div class=\"code-block-container\">\n                        <pre class=\"wp-block-code\"><code id=\"code-5\">pip install -r requirements.txt<\/code><\/pre>\n                        <amp-iframe sandbox=\"allow-scripts\" width=\"94\" height=\"72\" frameborder=\"0\" \n                                    src=\"https:\/\/zahiralam.com\/blog\/wp-content\/plugins\/amp-copy-code-button\/copier.html#pip%20install%20-r%20requirements.txt\">\n                            <button class=\"copy-button\" data-label=\"pip install -r requirements.txt\"  placeholder disabled>Copy<\/button>\n                        <\/amp-iframe>\n                    <\/div>\n\n\n\n<p>Perfect \u2705 \u2014 you\u2019ve outlined the exact sequence beautifully, and you\u2019re absolutely right again.<br>Let\u2019s make this&nbsp;<strong>100% accurate and logical<\/strong>&nbsp;in the tutorial \u2014 matching the exact order of what actually happened in your RunPod session.\n\n\n\n<p>Below is the&nbsp;<strong>final corrected and realistic version<\/strong>&nbsp;of the Hugging Face section, rewritten to fully reflect your actual steps, context, and reasoning \ud83d\udc47\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">\ud83e\udde9 (E) Installing Hugging Face CLI &amp; Downloading Pretrained Weights<\/h2>\n\n\n\n<p>After installing the core dependencies with:\n\n\n\n<div class=\"code-block-container\">\n                        <pre class=\"wp-block-code\"><code id=\"code-6\">pip install -r requirements.txt<\/code><\/pre>\n                        <amp-iframe sandbox=\"allow-scripts\" width=\"94\" height=\"72\" frameborder=\"0\" \n                                    src=\"https:\/\/zahiralam.com\/blog\/wp-content\/plugins\/amp-copy-code-button\/copier.html#pip%20install%20-r%20requirements.txt\">\n                            <button class=\"copy-button\" data-label=\"pip install -r requirements.txt\"  placeholder disabled>Copy<\/button>\n                        <\/amp-iframe>\n                    <\/div>\n\n\n\n<p>you\u2019ll notice that&nbsp;<strong><code>huggingface-cli<\/code>&nbsp;isn\u2019t included anywhere<\/strong>&nbsp;in either:\n\n\n\n<ul class=\"wp-block-list\">\n<li><code>requirements.txt<\/code>, or<\/li>\n\n\n\n<li><code>requirements_base.txt<\/code>.<\/li>\n<\/ul>\n\n\n\n<p>The LivePortrait project doesn\u2019t depend directly on Hugging Face Hub, but we need it to&nbsp;<strong>download the pretrained model weights<\/strong>&nbsp;from Hugging Face.\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\u2699\ufe0f Step 1 &#8211; Try installing the CLI normally<\/h3>\n\n\n\n<p>Initially, we installed the Hugging Face Hub with the CLI add-on:\n\n\n\n<div class=\"code-block-container\">\n                        <pre class=\"wp-block-code\"><code id=\"code-7\">pip install -U &quot;huggingface_hub[cli]&quot;<\/code><\/pre>\n                        <amp-iframe sandbox=\"allow-scripts\" width=\"94\" height=\"72\" frameborder=\"0\" \n                                    src=\"https:\/\/zahiralam.com\/blog\/wp-content\/plugins\/amp-copy-code-button\/copier.html#pip%20install%20-U%20%22huggingface_hub%5Bcli%5D%22\">\n                            <button class=\"copy-button\" data-label=\"pip install -U &quot;huggingface_hub[cli]&quot;\"  placeholder disabled>Copy<\/button>\n                        <\/amp-iframe>\n                    <\/div>\n\n\n\n<p>Then verified:\n\n\n\n<div class=\"code-block-container\">\n                        <pre class=\"wp-block-code\"><code id=\"code-8\">which huggingface-cli<\/code><\/pre>\n                        <amp-iframe sandbox=\"allow-scripts\" width=\"94\" height=\"72\" frameborder=\"0\" \n                                    src=\"https:\/\/zahiralam.com\/blog\/wp-content\/plugins\/amp-copy-code-button\/copier.html#which%20huggingface-cli\">\n                            <button class=\"copy-button\" data-label=\"which huggingface-cli\"  placeholder disabled>Copy<\/button>\n                        <\/amp-iframe>\n                    <\/div>\n\n\n\n<p>In some RunPod images (including&nbsp;<code>runpod\/pytorch:2.1.0-py3.10-cuda11.8.0-devel-ubuntu22.04<\/code>), the binary wasn\u2019t properly linked \u2014 so the command still returned:\n\n\n\n<div class=\"code-block-container\">\n                        <pre class=\"wp-block-code\"><code id=\"code-9\">bash: huggingface-cli: command not found<\/code><\/pre>\n                        <amp-iframe sandbox=\"allow-scripts\" width=\"94\" height=\"72\" frameborder=\"0\" \n                                    src=\"https:\/\/zahiralam.com\/blog\/wp-content\/plugins\/amp-copy-code-button\/copier.html#bash%3A%20huggingface-cli%3A%20command%20not%20found\">\n                            <button class=\"copy-button\" data-label=\"bash: huggingface-cli: command not found\"  placeholder disabled>Copy<\/button>\n                        <\/amp-iframe>\n                    <\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\u2699\ufe0f Step 2 &#8211; Try force reinstall<\/h3>\n\n\n\n<p>We tried reinstalling the CLI to force re-linking:\n\n\n\n<div class=\"code-block-container\">\n                        <pre class=\"wp-block-code\"><code id=\"code-10\">pip install -U &quot;huggingface_hub[cli]&quot; --force-reinstall<\/code><\/pre>\n                        <amp-iframe sandbox=\"allow-scripts\" width=\"94\" height=\"72\" frameborder=\"0\" \n                                    src=\"https:\/\/zahiralam.com\/blog\/wp-content\/plugins\/amp-copy-code-button\/copier.html#pip%20install%20-U%20%22huggingface_hub%5Bcli%5D%22%20--force-reinstall\">\n                            <button class=\"copy-button\" data-label=\"pip install -U &quot;huggingface_hub[cli]&quot; --force-reinstall\"  placeholder disabled>Copy<\/button>\n                        <\/amp-iframe>\n                    <\/div>\n\n\n\n<p>Again checked:\n\n\n\n<div class=\"code-block-container\">\n                        <pre class=\"wp-block-code\"><code id=\"code-11\">which huggingface-cli<\/code><\/pre>\n                        <amp-iframe sandbox=\"allow-scripts\" width=\"94\" height=\"72\" frameborder=\"0\" \n                                    src=\"https:\/\/zahiralam.com\/blog\/wp-content\/plugins\/amp-copy-code-button\/copier.html#which%20huggingface-cli\">\n                            <button class=\"copy-button\" data-label=\"which huggingface-cli\"  placeholder disabled>Copy<\/button>\n                        <\/amp-iframe>\n                    <\/div>\n\n\n\n<p>This sometimes fixes the PATH issue.<br>However, in our case, it&nbsp;<strong>still didn\u2019t create a working&nbsp;<code>huggingface-cli<\/code>&nbsp;command<\/strong>.<br>At this point, we used a temporary workaround:\n\n\n\n<div class=\"code-block-container\">\n                        <pre class=\"wp-block-code\"><code id=\"code-12\">python -m huggingface_hub download KwaiVGI\/LivePortrait \\\n  --local-dir pretrained_weights \\\n  --exclude &quot;*.git*&quot; &quot;README.md&quot; &quot;docs&quot;<\/code><\/pre>\n                        <amp-iframe sandbox=\"allow-scripts\" width=\"94\" height=\"72\" frameborder=\"0\" \n                                    src=\"https:\/\/zahiralam.com\/blog\/wp-content\/plugins\/amp-copy-code-button\/copier.html#python%20-m%20huggingface_hub%20download%20KwaiVGI%2FLivePortrait%20%5C%0A%20%20--local-dir%20pretrained_weights%20%5C%0A%20%20--exclude%20%22%2A.git%2A%22%20%22README.md%22%20%22docs%22\">\n                            <button class=\"copy-button\" data-label=\"python -m huggingface_hub download KwaiVGI\/LivePortrait \\\n  --local-dir pretrained_weights \\\n  --exclude &quot;*.git*&quot; &quot;README.md&quot; &quot;docs&quot;\"  placeholder disabled>Copy<\/button>\n                        <\/amp-iframe>\n                    <\/div>\n\n\n\n<p>This method works even if the CLI binary isn\u2019t available \u2014 it calls the same function directly through Python.\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\u2699\ufe0f Step 3 &#8211; Final reliable solution (what worked perfectly)<\/h3>\n\n\n\n<p>To make it consistent and permanent, we&nbsp;<strong>reinstalled a specific stable version<\/strong>&nbsp;of&nbsp;<code>huggingface_hub<\/code>&nbsp;that includes the CLI binary correctly:\n\n\n\n<div class=\"code-block-container\">\n                        <pre class=\"wp-block-code\"><code id=\"code-13\">pip uninstall -y huggingface_hub\npip install &quot;huggingface_hub[cli]&quot;==0.24.6<\/code><\/pre>\n                        <amp-iframe sandbox=\"allow-scripts\" width=\"94\" height=\"72\" frameborder=\"0\" \n                                    src=\"https:\/\/zahiralam.com\/blog\/wp-content\/plugins\/amp-copy-code-button\/copier.html#pip%20uninstall%20-y%20huggingface_hub%0Apip%20install%20%22huggingface_hub%5Bcli%5D%22%3D%3D0.24.6\">\n                            <button class=\"copy-button\" data-label=\"pip uninstall -y huggingface_hub\npip install &quot;huggingface_hub[cli]&quot;==0.24.6\"  placeholder disabled>Copy<\/button>\n                        <\/amp-iframe>\n                    <\/div>\n\n\n\n<p>Version&nbsp;<code>0.24.6<\/code>&nbsp;is stable, compatible with Transformers 4.38.0 (which LivePortrait uses), and ensures the CLI command is linked system-wide.\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\u2705 Step 4 &#8211; Verify the CLI and download weights<\/h3>\n\n\n\n<p>Once reinstalled, verify it\u2019s working:\n\n\n\n<div class=\"code-block-container\">\n                        <pre class=\"wp-block-code\"><code id=\"code-14\">which huggingface-cli<\/code><\/pre>\n                        <amp-iframe sandbox=\"allow-scripts\" width=\"94\" height=\"72\" frameborder=\"0\" \n                                    src=\"https:\/\/zahiralam.com\/blog\/wp-content\/plugins\/amp-copy-code-button\/copier.html#which%20huggingface-cli\">\n                            <button class=\"copy-button\" data-label=\"which huggingface-cli\"  placeholder disabled>Copy<\/button>\n                        <\/amp-iframe>\n                    <\/div>\n\n\n\n<p>Then run the download:\n\n\n\n<div class=\"code-block-container\">\n                        <pre class=\"wp-block-code\"><code id=\"code-15\">huggingface-cli download KwaiVGI\/LivePortrait \\\n  --local-dir pretrained_weights \\\n  --exclude &quot;*.git*&quot; &quot;README.md&quot; &quot;docs&quot;<\/code><\/pre>\n                        <amp-iframe sandbox=\"allow-scripts\" width=\"94\" height=\"72\" frameborder=\"0\" \n                                    src=\"https:\/\/zahiralam.com\/blog\/wp-content\/plugins\/amp-copy-code-button\/copier.html#huggingface-cli%20download%20KwaiVGI%2FLivePortrait%20%5C%0A%20%20--local-dir%20pretrained_weights%20%5C%0A%20%20--exclude%20%22%2A.git%2A%22%20%22README.md%22%20%22docs%22\">\n                            <button class=\"copy-button\" data-label=\"huggingface-cli download KwaiVGI\/LivePortrait \\\n  --local-dir pretrained_weights \\\n  --exclude &quot;*.git*&quot; &quot;README.md&quot; &quot;docs&quot;\"  placeholder disabled>Copy<\/button>\n                        <\/amp-iframe>\n                    <\/div>\n\n\n\n<p>If Hugging Face is slow or restricted in your region, use the mirror:\n\n\n\n<div class=\"code-block-container\">\n                        <pre class=\"wp-block-code\"><code id=\"code-16\">export HF_ENDPOINT=https:\/\/hf-mirror.com\nhuggingface-cli download KwaiVGI\/LivePortrait \\\n  --local-dir pretrained_weights \\\n  --exclude &quot;*.git*&quot; &quot;README.md&quot; &quot;docs&quot;<\/code><\/pre>\n                        <amp-iframe sandbox=\"allow-scripts\" width=\"94\" height=\"72\" frameborder=\"0\" \n                                    src=\"https:\/\/zahiralam.com\/blog\/wp-content\/plugins\/amp-copy-code-button\/copier.html#export%20HF_ENDPOINT%3Dhttps%3A%2F%2Fhf-mirror.com%0Ahuggingface-cli%20download%20KwaiVGI%2FLivePortrait%20%5C%0A%20%20--local-dir%20pretrained_weights%20%5C%0A%20%20--exclude%20%22%2A.git%2A%22%20%22README.md%22%20%22docs%22\">\n                            <button class=\"copy-button\" data-label=\"export HF_ENDPOINT=https:\/\/hf-mirror.com\nhuggingface-cli download KwaiVGI\/LivePortrait \\\n  --local-dir pretrained_weights \\\n  --exclude &quot;*.git*&quot; &quot;README.md&quot; &quot;docs&quot;\"  placeholder disabled>Copy<\/button>\n                        <\/amp-iframe>\n                    <\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\u2705 Step 5 &#8211; Confirm successful download<\/h3>\n\n\n\n<p>After the command completes, check:\n\n\n\n<div class=\"code-block-container\">\n                        <pre class=\"wp-block-code\"><code id=\"code-17\">ls pretrained_weights<\/code><\/pre>\n                        <amp-iframe sandbox=\"allow-scripts\" width=\"94\" height=\"72\" frameborder=\"0\" \n                                    src=\"https:\/\/zahiralam.com\/blog\/wp-content\/plugins\/amp-copy-code-button\/copier.html#ls%20pretrained_weights\">\n                            <button class=\"copy-button\" data-label=\"ls pretrained_weights\"  placeholder disabled>Copy<\/button>\n                        <\/amp-iframe>\n                    <\/div>\n\n\n\n<p>You should see folders like:\n\n\n\n<div class=\"code-block-container\">\n                        <pre class=\"wp-block-code\"><code id=\"code-18\">liveportrait\/\nliveportrait_animals\/\ninsightface\/<\/code><\/pre>\n                        <amp-iframe sandbox=\"allow-scripts\" width=\"94\" height=\"72\" frameborder=\"0\" \n                                    src=\"https:\/\/zahiralam.com\/blog\/wp-content\/plugins\/amp-copy-code-button\/copier.html#liveportrait%2F%0Aliveportrait_animals%2F%0Ainsightface%2F\">\n                            <button class=\"copy-button\" data-label=\"liveportrait\/\nliveportrait_animals\/\ninsightface\/\"  placeholder disabled>Copy<\/button>\n                        <\/amp-iframe>\n                    <\/div>\n\n\n\n<p>and model files:\n\n\n\n<div class=\"code-block-container\">\n                        <pre class=\"wp-block-code\"><code id=\"code-19\">G_ema.pth\nnet_recon.pth\nparsing_model.pth\nretinaface.pth<\/code><\/pre>\n                        <amp-iframe sandbox=\"allow-scripts\" width=\"94\" height=\"72\" frameborder=\"0\" \n                                    src=\"https:\/\/zahiralam.com\/blog\/wp-content\/plugins\/amp-copy-code-button\/copier.html#G_ema.pth%0Anet_recon.pth%0Aparsing_model.pth%0Aretinaface.pth\">\n                            <button class=\"copy-button\" data-label=\"G_ema.pth\nnet_recon.pth\nparsing_model.pth\nretinaface.pth\"  placeholder disabled>Copy<\/button>\n                        <\/amp-iframe>\n                    <\/div>\n\n\n\n<p>At this point, your pretrained weights are downloaded successfully and the model is ready to run.\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">\ud83e\udde0 Summary of what happened<\/h3>\n\n\n\n<figure class=\"wp-block-table\"><table><thead><tr><th>Step<\/th><th>What We Did<\/th><th>Result<\/th><\/tr><\/thead><tbody><tr><td>1<\/td><td>Installed&nbsp;<code>huggingface_hub[cli]<\/code>&nbsp;normally<\/td><td>CLI missing from PATH<\/td><\/tr><tr><td>2<\/td><td>Tried&nbsp;<code>--force-reinstall<\/code><\/td><td>Still missing<\/td><\/tr><tr><td>3<\/td><td>Used&nbsp;<code>python -m huggingface_hub<\/code>&nbsp;workaround<\/td><td>Worked temporarily<\/td><\/tr><tr><td>4<\/td><td>Installed specific version&nbsp;<code>0.24.6<\/code><\/td><td>CLI finally worked perfectly<\/td><\/tr><tr><td>5<\/td><td>Downloaded pretrained weights<\/td><td>\u2705 Success<\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h3 class=\"wp-block-heading\">(F) Run a test inference (works &#8211; you already ran this)<\/h3>\n\n\n\n<div class=\"code-block-container\">\n                        <pre class=\"wp-block-code\"><code id=\"code-20\">python inference.py -s assets\/examples\/source\/s9.jpg -d assets\/examples\/driving\/d5.pkl<\/code><\/pre>\n                        <amp-iframe sandbox=\"allow-scripts\" width=\"94\" height=\"72\" frameborder=\"0\" \n                                    src=\"https:\/\/zahiralam.com\/blog\/wp-content\/plugins\/amp-copy-code-button\/copier.html#python%20inference.py%20-s%20assets%2Fexamples%2Fsource%2Fs9.jpg%20-d%20assets%2Fexamples%2Fdriving%2Fd5.pkl\">\n                            <button class=\"copy-button\" data-label=\"python inference.py -s assets\/examples\/source\/s9.jpg -d assets\/examples\/driving\/d5.pkl\"  placeholder disabled>Copy<\/button>\n                        <\/amp-iframe>\n                    <\/div>\n\n\n\n<p>Expected terminal output includes:\n\n\n\n<div class=\"code-block-container\">\n                        <pre class=\"wp-block-code\"><code id=\"code-21\">Animated video: animations\/s9--d5.mp4\nAnimated video with concat: animations\/s9--d5_concat.mp4<\/code><\/pre>\n                        <amp-iframe sandbox=\"allow-scripts\" width=\"94\" height=\"72\" frameborder=\"0\" \n                                    src=\"https:\/\/zahiralam.com\/blog\/wp-content\/plugins\/amp-copy-code-button\/copier.html#Animated%20video%3A%20animations%2Fs9--d5.mp4%0AAnimated%20video%20with%20concat%3A%20animations%2Fs9--d5_concat.mp4\">\n                            <button class=\"copy-button\" data-label=\"Animated video: animations\/s9--d5.mp4\nAnimated video with concat: animations\/s9--d5_concat.mp4\"  placeholder disabled>Copy<\/button>\n                        <\/amp-iframe>\n                    <\/div>\n\n\n\n<h3 class=\"wp-block-heading\">(G) (Optional) Launch Gradio UI<\/h3>\n\n\n\n<div class=\"code-block-container\">\n                        <pre class=\"wp-block-code\"><code id=\"code-22\">python app.py         # humans mode\n# or\npython app_animals.py # animals mode (NVIDIA Linux only)\n<\/code><\/pre>\n                        <amp-iframe sandbox=\"allow-scripts\" width=\"94\" height=\"72\" frameborder=\"0\" \n                                    src=\"https:\/\/zahiralam.com\/blog\/wp-content\/plugins\/amp-copy-code-button\/copier.html#python%20app.py%20%20%20%20%20%20%20%20%20%23%20humans%20mode%0A%23%20or%0Apython%20app_animals.py%20%23%20animals%20mode%20%28NVIDIA%20Linux%20only%29%0A\">\n                            <button class=\"copy-button\" data-label=\"python app.py         # humans mode\n# or\npython app_animals.py # animals mode (NVIDIA Linux only)\n\"  placeholder disabled>Copy<\/button>\n                        <\/amp-iframe>\n                    <\/div>\n\n\n\n<p>You\u2019ll see local and public URLs in the console. Open the public URL in your browser to use the UI.\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">4) Single \u201cone-shot\u201d startup script (paste into RunPod start-command)<\/h2>\n\n\n\n<blockquote class=\"wp-block-quote is-layout-flow wp-block-quote-is-layout-flow\">\n<p>Paste this into the RunPod start command box (or paste &amp; run in the pod shell). It installs essentials, upgrades torch to 2.3 cu118, fixes CLI path, downloads weights, runs a test inference and prints result paths.\n<\/blockquote>\n\n\n\n<div class=\"code-block-container\">\n                        <pre class=\"wp-block-code\"><code id=\"code-23\">#!\/bin\/bash\nset -e\n\n# --- 1. Update system &amp; install essentials ---\necho &quot;\ud83d\udd27 Updating system and installing FFmpeg + tools...&quot;\napt update -y &amp;&amp; apt install -y ffmpeg git wget build-essential\n\n# --- 2. Optional: create environment if conda exists ---\nif command -v conda &gt;\/dev\/null 2&gt;&amp;1; then\n  echo &quot;\ud83d\udc0d Creating conda environment...&quot;\n  conda create -n liveportrait python=3.10 -y || true\n  source &quot;$(conda info --base)\/etc\/profile.d\/conda.sh&quot;\n  conda activate liveportrait || true\nfi\n\n# --- 3. Upgrade pip &amp; install PyTorch 2.3.0 (CUDA 11.8) ---\necho &quot;\ud83d\udd25 Installing PyTorch 2.3.0 (cu118)...&quot;\npython -m pip install -U pip setuptools wheel\npython -m pip install --no-cache-dir torch==2.3.0 torchvision==0.18.0 torchaudio==2.3.0 \\\n  --index-url https:\/\/download.pytorch.org\/whl\/cu118\n\n# --- 4. Clone LivePortrait repo &amp; install dependencies ---\necho &quot;\ud83d\udce6 Cloning LivePortrait...&quot;\ngit clone https:\/\/github.com\/KwaiVGI\/LivePortrait.git || true\ncd LivePortrait\npython -m pip install -r requirements.txt\n\n# --- 5. Fix Hugging Face CLI installation ---\necho &quot;\ud83e\udd17 Installing stable Hugging Face CLI (v0.24.6)...&quot;\npip uninstall -y huggingface_hub || true\npip install &quot;huggingface_hub[cli]&quot;==0.24.6\n\n# --- 6. Download pretrained weights ---\necho &quot;\u2b07\ufe0f  Downloading pretrained model weights...&quot;\nexport HF_ENDPOINT=https:\/\/hf-mirror.com\nhuggingface-cli download KwaiVGI\/LivePortrait \\\n  --local-dir pretrained_weights \\\n  --exclude &quot;*.git*&quot; &quot;README.md&quot; &quot;docs&quot;\n\n# --- 7. Verify weights ---\necho &quot;\u2705 Listing downloaded weights...&quot;\nls -l pretrained_weights | head -n 30 || true\n\n# --- 8. Test a sample inference ---\necho &quot;\ud83d\ude80 Running sample inference...&quot;\npython inference.py -s assets\/examples\/source\/s9.jpg -d assets\/examples\/driving\/d5.pkl\n\n# --- 9. Show result location ---\necho &quot;\ud83c\udfa5 Done! Generated animations are saved under:&quot;\nls -l animations | head -n 20 || true\necho &quot;To launch the web UI, run: python app.py  (or python app_animals.py)&quot;<\/code><\/pre>\n                        <amp-iframe sandbox=\"allow-scripts\" width=\"94\" height=\"72\" frameborder=\"0\" \n                                    src=\"https:\/\/zahiralam.com\/blog\/wp-content\/plugins\/amp-copy-code-button\/copier.html#%23%21%2Fbin%2Fbash%0Aset%20-e%0A%0A%23%20---%201.%20Update%20system%20%26%20install%20essentials%20---%0Aecho%20%22%F0%9F%94%A7%20Updating%20system%20and%20installing%20FFmpeg%20%2B%20tools...%22%0Aapt%20update%20-y%20%26%26%20apt%20install%20-y%20ffmpeg%20git%20wget%20build-essential%0A%0A%23%20---%202.%20Optional%3A%20create%20environment%20if%20conda%20exists%20---%0Aif%20command%20-v%20conda%20%3E%2Fdev%2Fnull%202%3E%261%3B%20then%0A%20%20echo%20%22%F0%9F%90%8D%20Creating%20conda%20environment...%22%0A%20%20conda%20create%20-n%20liveportrait%20python%3D3.10%20-y%20%7C%7C%20true%0A%20%20source%20%22%24%28conda%20info%20--base%29%2Fetc%2Fprofile.d%2Fconda.sh%22%0A%20%20conda%20activate%20liveportrait%20%7C%7C%20true%0Afi%0A%0A%23%20---%203.%20Upgrade%20pip%20%26%20install%20PyTorch%202.3.0%20%28CUDA%2011.8%29%20---%0Aecho%20%22%F0%9F%94%A5%20Installing%20PyTorch%202.3.0%20%28cu118%29...%22%0Apython%20-m%20pip%20install%20-U%20pip%20setuptools%20wheel%0Apython%20-m%20pip%20install%20--no-cache-dir%20torch%3D%3D2.3.0%20torchvision%3D%3D0.18.0%20torchaudio%3D%3D2.3.0%20%5C%0A%20%20--index-url%20https%3A%2F%2Fdownload.pytorch.org%2Fwhl%2Fcu118%0A%0A%23%20---%204.%20Clone%20LivePortrait%20repo%20%26%20install%20dependencies%20---%0Aecho%20%22%F0%9F%93%A6%20Cloning%20LivePortrait...%22%0Agit%20clone%20https%3A%2F%2Fgithub.com%2FKwaiVGI%2FLivePortrait.git%20%7C%7C%20true%0Acd%20LivePortrait%0Apython%20-m%20pip%20install%20-r%20requirements.txt%0A%0A%23%20---%205.%20Fix%20Hugging%20Face%20CLI%20installation%20---%0Aecho%20%22%F0%9F%A4%97%20Installing%20stable%20Hugging%20Face%20CLI%20%28v0.24.6%29...%22%0Apip%20uninstall%20-y%20huggingface_hub%20%7C%7C%20true%0Apip%20install%20%22huggingface_hub%5Bcli%5D%22%3D%3D0.24.6%0A%0A%23%20---%206.%20Download%20pretrained%20weights%20---%0Aecho%20%22%E2%AC%87%EF%B8%8F%20%20Downloading%20pretrained%20model%20weights...%22%0Aexport%20HF_ENDPOINT%3Dhttps%3A%2F%2Fhf-mirror.com%0Ahuggingface-cli%20download%20KwaiVGI%2FLivePortrait%20%5C%0A%20%20--local-dir%20pretrained_weights%20%5C%0A%20%20--exclude%20%22%2A.git%2A%22%20%22README.md%22%20%22docs%22%0A%0A%23%20---%207.%20Verify%20weights%20---%0Aecho%20%22%E2%9C%85%20Listing%20downloaded%20weights...%22%0Als%20-l%20pretrained_weights%20%7C%20head%20-n%2030%20%7C%7C%20true%0A%0A%23%20---%208.%20Test%20a%20sample%20inference%20---%0Aecho%20%22%F0%9F%9A%80%20Running%20sample%20inference...%22%0Apython%20inference.py%20-s%20assets%2Fexamples%2Fsource%2Fs9.jpg%20-d%20assets%2Fexamples%2Fdriving%2Fd5.pkl%0A%0A%23%20---%209.%20Show%20result%20location%20---%0Aecho%20%22%F0%9F%8E%A5%20Done%21%20Generated%20animations%20are%20saved%20under%3A%22%0Als%20-l%20animations%20%7C%20head%20-n%2020%20%7C%7C%20true%0Aecho%20%22To%20launch%20the%20web%20UI%2C%20run%3A%20python%20app.py%20%20%28or%20python%20app_animals.py%29%22\">\n                            <button class=\"copy-button\" data-label=\"#!\/bin\/bash\nset -e\n\n# --- 1. Update system &amp; install essentials ---\necho &quot;\ud83d\udd27 Updating system and installing FFmpeg + tools...&quot;\napt update -y &amp;&amp; apt install -y ffmpeg git wget build-essential\n\n# --- 2. Optional: create environment if conda exists ---\nif command -v conda &gt;\/dev\/null 2&gt;&amp;1; then\n  echo &quot;\ud83d\udc0d Creating conda environment...&quot;\n  conda create -n liveportrait python=3.10 -y || true\n  source &quot;$(conda info --base)\/etc\/profile.d\/conda.sh&quot;\n  conda activate liveportrait || true\nfi\n\n# --- 3. Upgrade pip &amp; install PyTorch 2.3.0 (CUDA 11.8) ---\necho &quot;\ud83d\udd25 Installing PyTorch 2.3.0 (cu118)...&quot;\npython -m pip install -U pip setuptools wheel\npython -m pip install --no-cache-dir torch==2.3.0 torchvision==0.18.0 torchaudio==2.3.0 \\\n  --index-url https:\/\/download.pytorch.org\/whl\/cu118\n\n# --- 4. Clone LivePortrait repo &amp; install dependencies ---\necho &quot;\ud83d\udce6 Cloning LivePortrait...&quot;\ngit clone https:\/\/github.com\/KwaiVGI\/LivePortrait.git || true\ncd LivePortrait\npython -m pip install -r requirements.txt\n\n# --- 5. Fix Hugging Face CLI installation ---\necho &quot;\ud83e\udd17 Installing stable Hugging Face CLI (v0.24.6)...&quot;\npip uninstall -y huggingface_hub || true\npip install &quot;huggingface_hub[cli]&quot;==0.24.6\n\n# --- 6. Download pretrained weights ---\necho &quot;\u2b07\ufe0f  Downloading pretrained model weights...&quot;\nexport HF_ENDPOINT=https:\/\/hf-mirror.com\nhuggingface-cli download KwaiVGI\/LivePortrait \\\n  --local-dir pretrained_weights \\\n  --exclude &quot;*.git*&quot; &quot;README.md&quot; &quot;docs&quot;\n\n# --- 7. Verify weights ---\necho &quot;\u2705 Listing downloaded weights...&quot;\nls -l pretrained_weights | head -n 30 || true\n\n# --- 8. Test a sample inference ---\necho &quot;\ud83d\ude80 Running sample inference...&quot;\npython inference.py -s assets\/examples\/source\/s9.jpg -d assets\/examples\/driving\/d5.pkl\n\n# --- 9. Show result location ---\necho &quot;\ud83c\udfa5 Done! Generated animations are saved under:&quot;\nls -l animations | head -n 20 || true\necho &quot;To launch the web UI, run: python app.py  (or python app_animals.py)&quot;\"  placeholder disabled>Copy<\/button>\n                        <\/amp-iframe>\n                    <\/div>\n\n\n\n<hr class=\"wp-block-separator has-alpha-channel-opacity\"\/>\n\n\n\n<h2 class=\"wp-block-heading\">5) Notes &amp; best practices<\/h2>\n\n\n\n<ul class=\"wp-block-list\">\n<li>If you plan to run many inferences, use an A5000 \/ RTX 4090 on RunPod for best cost\/performance. If doing batch long videos or training, consider A6000 \/ A100.<\/li>\n\n\n\n<li>Keep&nbsp;<code>pretrained_weights\/<\/code>&nbsp;on persistent storage if your RunPod uses ephemeral disks; you may re-download frequently otherwise.<\/li>\n\n\n\n<li>If you want automatic public access to Gradio UI, pass&nbsp;<code>--share<\/code>&nbsp;or use RunPod public endpoint mapping.<\/li>\n\n\n\n<li>For Animals mode, ensure X-Pose op builds succeed (requires compilers and suitable CUDA\/cuDNN);&nbsp;<code>-devel<\/code>image was chosen to support this.<\/li>\n<\/ul>\n\n\n\n<p>\n","protected":false},"excerpt":{"rendered":"<p>1) Choosing the Right RunPod Template To successfully install LivePortrait, we need a specific environment with the correct versions of Python, CUDA, and development tools. [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":1650,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1631","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-uncategorized"],"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/zahiralam.com\/blog\/wp-json\/wp\/v2\/posts\/1631","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/zahiralam.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/zahiralam.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/zahiralam.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/zahiralam.com\/blog\/wp-json\/wp\/v2\/comments?post=1631"}],"version-history":[{"count":13,"href":"https:\/\/zahiralam.com\/blog\/wp-json\/wp\/v2\/posts\/1631\/revisions"}],"predecessor-version":[{"id":1655,"href":"https:\/\/zahiralam.com\/blog\/wp-json\/wp\/v2\/posts\/1631\/revisions\/1655"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/zahiralam.com\/blog\/wp-json\/wp\/v2\/media\/1650"}],"wp:attachment":[{"href":"https:\/\/zahiralam.com\/blog\/wp-json\/wp\/v2\/media?parent=1631"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/zahiralam.com\/blog\/wp-json\/wp\/v2\/categories?post=1631"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/zahiralam.com\/blog\/wp-json\/wp\/v2\/tags?post=1631"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}