video-retalking部署安装,在服务器Ubuntu22.04系统下
- 一、ubuntu基本环境配置
- 二、安装miniconda环境
- 三、安装video-retalking
- 三、报错合集
-
-
- 1. ModuleNotFoundError: No module named 'torchvision.transforms.functional_tensor'
- 2. RuntimeError: PytorchStreamReader failed reading zip archive: failed finding central directory
- 3. AttributeError: _2D
- 4. ssl.SSLError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:1007)== 和 ==urllib.error.URLError: <urlopen error [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed (_ssl.c:1007)>
- 5. ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (5,) + inhomogeneous part.
- 6.TypeError: mel() takes 0 positional arguments but 2 positional arguments (and 3 keyword-only arguments) were given
- 7.torch.OutOfMemoryError: CUDA out of memory.
-
- 四、部署完成
一、ubuntu基本环境配置
1.更新包列表:
- 打开终端,输入以下命令:
sudo apt-get update
sudo apt upgrade
- 更新时间较长,请耐心等待
2. 安装英伟达显卡驱动
2.1 使用wget在命令行下载驱动包
wget https://cn.download.nvidia.com/XFree86/Linux-x86_64/550.100/NVIDIA-Linux-x86_64-550.100.run
2.2 更新软件列表和安装必要软件、依赖
sudo apt-get update
sudo apt-get install g++
sudo apt-get install gcc
sudo apt-get install make
2.2 卸载原有驱动
sudo apt-get remove --purge nvidia*
- 1.使用vim修改配置文件
sudo vim /etc/modprobe.d/blacklist.conf
- 2.按i键进入编辑模式,在文件尾增加两行:
blacklist nouveau
options nouveau modeset=0
- 3.按esc键退出编辑模式,输入:wq保存并退出
- 4.更新文件
sudo update-initramfs -u
- 5.重启电脑:
sudo reboot
这里需要等一会才能连上
2.3 安装驱动
- 1.授予执行权限
sudo chmod 777 NVIDIA-Linux-x86_64-550.100.run
- 2.执行安装命令
sudo ./NVIDIA-Linux-x86_64-550.100.run
这里一直按回车就行,默认选择
- 3.检测显卡驱动是否安装成功
nvidia-smi
2.4 安装CUDA
wget https://developer.download.nvidia.com/compute/cuda/12.4.0/local_installers/cuda_12.4.0_550.54.14_linux.run
执行安装命令
sudo sh ./cuda_12.4.0_550.54.14_linux.run
- 1.输出accept开始安装

- 2.然后注意这里要按enter取消勾选第一个选项,因为之前已经安装了驱动

- 3.接着选择Install开始安装

- 4.安装完成

2.5 环境变量配置
- 1.以vim方式打开配置文件
sudo vim ~/.bashrc
- 2.按i键进入编辑模式,在文件尾增加下面内容:
export PATH="/usr/local/cuda-12.4/bin:$PATH"
export LD_LIBRARY_PATH="/usr/local/cuda-12.4/lib64:$LD_LIBRARY_PATH"
-
按esc键退出编辑模式,输入:wq保存并退出
-
3.更新环境变量
source ~/.bashrc
- 4.检测CUDA是否安装成功
nvcc -V

二、安装miniconda环境
1. 下载miniconda3
wget https://mirrors.cqupt.edu.cn/anaconda/miniconda/Miniconda3-py310_23.10.0-1-Linux-x86_64.sh
2. 安装miniconda3
bash Miniconda3-py310_23.10.0-1-Linux-x86_64.sh -u
直接一直enter键,到输入路径和yes
这边建议路径为:miniconda3
3. 切换到bin文件夹
cd miniconda3/bin/
4. 输入pwd获取路径
pwd
复制这里的路径
5. 打开用户环境编辑页面
vim ~/.bashrc
- 点击键盘I键进入编辑模式,在最下方输入以下代码
export PATH="/root/miniconda3/bin:$PATH"
6. 重新加载用户环境变量
source ~/.bashrc
7. 初始化conda
conda init bash
source ~/.bashrc
8.然后conda -V要是正常就安装成功了
conda -V

9.conda配置
- 1.配置清华镜像源
代码如下:
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
- 2.设置搜索时显示通道地址
conda config --set show_channel_urls yes
- 3.配置pip 镜像源
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
三、安装video-retalking
1.克隆仓库
1.1 github克隆
git clone https://github.com/vinthony/video-retalking.git
1.2 国内github镜像克隆
git clone https://mirror.ghproxy.com/https://github.com/vinthony/video-retalking.git

1.3. 进入目录
cd video-retalking

2.创建虚拟环境
conda create -n video-retalking python=3.10

输入y确认安装
2.1 进入虚拟环境
conda activate video-retalking

3. 安装依赖
conda install ffmpeg
输入y进行安装
3.1设置清华源
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

3.2安装torch 12.4cuda版本
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu124

3.3安装依赖
安装之前我们先修改一下requirements.txt文件的依赖版本:
编辑文件:
nano requirements.txt
粘贴以下内容:
basicsr==1.4.2
kornia==0.5.1
face-alignment==1.3.4
ninja==1.10.2.3
einops==0.4.1
facexlib==0.2.5
librosa==0.9.2
dlib==19.24.0
gradio>=3.7.0
numpy==1.23.1
opencv-contrib-python
opencv-python
scikit-image
ctrl+x,再输入y确认,再enter确认

3.4安装依赖
pip install -r requirements.txt -i https://mirrors.aliyun.com/pypi/simple/ --trusted-host=mirrors.aliyun.com

这里没有安装cmake需要先安装
sudo apt install cmake -y

3.5单独安装依赖
pip install opencv-python
pip install tqdm
pip install scipy
pip install scikit-image
pip install face_alignment==1.3.5
pip install ninja
pip install basicsr
pip install einops
pip install kornia
pip install facexlib
pip install librosa
pip install --upgrade pip setuptools
pip install dlib
pip install gradio
3.6请下载预训练模型
预训练模型
并将它们放入 ./checkpoints
没有科学上网的可以在我的夸克网盘下载
- 新建文件夹
mkdir checkpoints
- 笑脸社区
pip install -U huggingface_hub
HF_ENDPOINT=https://hf-mirror.com huggingface-cli download --resume-download yachty66/video_retalking --local-dir /root/project/video-retalking/checkpoints

- 魔搭社区(需要自行申请权限):
pip install modelscope
modelscope login --token 使用自己的
modelscope download --model ximo183/video_retalking --local_dir './checkpoints'
- 传入模型文件


3.7 移动示例视频和音频到指定目录
mkdir temp
cd temp
mkdir video
mkdir audio
cd ..
cp -r examples/face/ temp/video/
cp -r examples/audio/ temp/audio/
3.8 启动项目
python webUI.py
三、报错合集
1. ModuleNotFoundError: No module named ‘torchvision.transforms.functional_tensor’
去环境里面修改video-retalking/lib/python3.10/site-packages/basicsr/data/degradations.py

1.1把weights权重文件考到下面目录(两个文件)
- 这两个文件也可以不用下面的方法,运行时会自动下载,但下载的速度太慢了,所以这里直接拷贝了。
/root/anaconda3/envs/video_retalking/lib/python3.10/site-packages/facexlib/weights/




最低0.47元/天 解锁文章
1万+

被折叠的 条评论
为什么被折叠?



