IOPaint部署,在服务器Ubuntu22.04系统下——点动科技

这里写目录标题

  • 一、ubuntu22.04基本环境配置
      • [1.1 更换清华Ubuntu镜像源](#1.1 更换清华Ubuntu镜像源)
      • [1.2 更新包列表:](#1.2 更新包列表:)
      • [2. 安装英伟达显卡驱动](#2. 安装英伟达显卡驱动)
          • [2.1 使用wget在命令行下载驱动包](#2.1 使用wget在命令行下载驱动包)
          • [2.2 更新软件列表和安装必要软件、依赖](#2.2 更新软件列表和安装必要软件、依赖)
          • [2.2 卸载原有驱动](#2.2 卸载原有驱动)
          • [2.3 安装驱动](#2.3 安装驱动)
          • [2.4 安装CUDA](#2.4 安装CUDA)
          • [2.5 环境变量配置](#2.5 环境变量配置)
  • 二、安装miniconda环境
      • [1. 下载miniconda3](#1. 下载miniconda3)
      • [2. 安装miniconda3](#2. 安装miniconda3)
      • [3. 切换到bin文件夹](#3. 切换到bin文件夹)
      • [4. 输入pwd获取路径](#4. 输入pwd获取路径)
      • [5. 打开用户环境编辑页面](#5. 打开用户环境编辑页面)
      • [6. 重新加载用户环境变量](#6. 重新加载用户环境变量)
      • [7. 初始化conda](#7. 初始化conda)
      • 8.验证是否安装成功
      • 9.conda配置
  • 三、安装IOPaint

一、ubuntu22.04基本环境配置

1.1 更换清华Ubuntu镜像源

  • 删除原来的文件
Plain 复制代码
rm /etc/apt/sources.list
  • 开始编辑新文件
Plain 复制代码
vim /etc/apt/sources.list
  • 先按i键,粘贴以下内容
Plain 复制代码
# 默认注释了源码镜像以提高 apt update 速度,如有需要可自行取消注释
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-backports main restricted universe multiverse

# 以下安全更新软件源包含了官方源与镜像站配置,如有需要可自行修改注释切换
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-security main restricted universe multiverse
# deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ jammy-security main restricted universe multiverse
  • 确保内容跟上述图片一致

  • 按esc键,再输入冒号+wq保存

1.2 更新包列表:

  • 打开终端,输入以下命令:
Shell 复制代码
sudo apt-get update
Shell 复制代码
sudo apt upgrade
  • 更新时间较长,请耐心等待

2. 安装英伟达显卡驱动

2.1 使用wget在命令行下载驱动包
Shell 复制代码
wget https://cn.download.nvidia.com/XFree86/Linux-x86_64/550.100/NVIDIA-Linux-x86_64-550.100.run
2.2 更新软件列表和安装必要软件、依赖
Shell 复制代码
sudo apt-get install g++

点击回车enter即可

Plain 复制代码
sudo apt-get install gcc
Plain 复制代码
sudo apt-get install make


点击回车enter即可

成功安装

2.2 卸载原有驱动
Shell 复制代码
sudo apt-get remove --purge nvidia* 
  • 1.使用vim修改配置文件
Shell 复制代码
sudo vim /etc/modprobe.d/blacklist.conf
  • 2.按i键进入编辑模式,在文件尾增加两行:
Shell 复制代码
blacklist nouveau
options nouveau modeset=0
  • 3.按esc键退出编辑模式,输入:wq保存并退出

  • 4.更新文件

Shell 复制代码
sudo update-initramfs -u

这里等待时间较久

  • 5.重启电脑:
Shell 复制代码
sudo reboot

这里需要等一会才能连上

2.3 安装驱动
  • 1.授予执行权限
Shell 复制代码
sudo chmod 777 NVIDIA-Linux-x86_64-550.100.run
  • 2.执行安装命令
Shell 复制代码
sudo ./NVIDIA-Linux-x86_64-550.100.run

这里一直按回车就行,默认选择

一直按回车enter键,直到安装成功

  • 3.检测显卡驱动是否安装成功
Shell 复制代码
nvidia-smi
2.4 安装CUDA
Shell 复制代码
wget https://developer.download.nvidia.com/compute/cuda/12.4.0/local_installers/cuda_12.4.0_550.54.14_linux.run

执行安装命令

Shell 复制代码
sudo sh ./cuda_12.4.0_550.54.14_linux.run
  • 1.输出accept开始安装
  • 2.然后注意这里要按enter取消勾选第一个选项,因为之前已经安装了驱动
  • 3.接着选择Install开始安装
  • 4.安装完成
2.5 环境变量配置
  • 1.以vim方式打开配置文件
Shell 复制代码
sudo vim ~/.bashrc
  • 2.按i键进入编辑模式,在文件尾增加下面内容:
Shell 复制代码
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.更新环境变量

Shell 复制代码
source ~/.bashrc
  • 4.检测CUDA是否安装成功
Shell 复制代码
nvcc -V

二、安装miniconda环境

1. 下载miniconda3

Shell 复制代码
wget https://mirrors.cqupt.edu.cn/anaconda/miniconda/Miniconda3-py310_23.10.0-1-Linux-x86_64.sh

2. 安装miniconda3

Shell 复制代码
bash Miniconda3-py310_23.10.0-1-Linux-x86_64.sh -u

直接一直enter键,到输入路径和yes

这边建议路径为:miniconda3

直接回车enter即可,再次输入yes

成功安装

3. 切换到bin文件夹

Shell 复制代码
cd miniconda3/bin/

4. 输入pwd获取路径

Shell 复制代码
pwd

复制这里的路径

5. 打开用户环境编辑页面

Shell 复制代码
vim ~/.bashrc 
  • 点击键盘I键进入编辑模式,在最下方输入以下代码
Shell 复制代码
export PATH="/root/miniconda3/bin:$PATH"

按esc键退出编辑模式,输入:wq保存并退出

6. 重新加载用户环境变量

Shell 复制代码
source ~/.bashrc

7. 初始化conda

Shell 复制代码
conda init bash

8.验证是否安装成功

Shell 复制代码
conda -V

9.conda配置

  • 1.配置清华镜像源

    代码如下:

Shell 复制代码
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.设置搜索时显示通道地址
Shell 复制代码
conda config --set show_channel_urls yes
  • 3.配置pip 镜像源
Shell 复制代码
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

三、安装IOPaint

1.克隆仓库

1.1 github克隆
Shell 复制代码
git clone https://github.com/Sanster/IOPaint.git
1.2 国内github镜像克隆
Shell 复制代码
git clone https://mirror.ghproxy.com/https://github.com/Sanster/IOPaint.git
1.3. 进入目录
Plain 复制代码
cd IOPaint/

2.创建虚拟环境

Shell 复制代码
conda create -n IOPaint python=3.10
  • 输入y回车即可
2.1 进入虚拟环境
Shell 复制代码
conda activate IOPaint

3. 安装依赖

3.1设置清华源、更新pip
Shell 复制代码
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

python -m pip install --upgrade pip
3.2安装torch 12.4cuda版本
Shell 复制代码
pip3 install torch==2.1.2 torchvision==0.16.2 --index-url https://download.pytorch.org/whl/cu118
3.3安装依赖
Shell 复制代码
pip3 install iopaint
pip install gfpgan
pip install realesrgan
pip install rembg
pip install realesrgan
3.4创建模型放置文件夹
Plain 复制代码
mkdir model

官方模型介绍https://www.iopaint.com/models

3.4下载扩散模型
Plain 复制代码
HF_ENDPOINT=https://hf-mirror.com iopaint start --device=cuda --model-dir=./model --model Sanster/PowerPaint-V1-stable-diffusion-inpainting

HF_ENDPOINT=https://hf-mirror.com iopaint start --device=cuda --model-dir=./model --model runwayml/stable-diffusion-v1-5

HF_ENDPOINT=https://hf-mirror.com iopaint start --device=cuda --model-dir=./model --model Fantasy-Studio/Paint-by-Example

HF_ENDPOINT=https://hf-mirror.com iopaint start --device=cuda --model-dir=./model --model kandinsky-community/kandinsky-2-2-decoder-inpaint

HF_ENDPOINT=https://hf-mirror.com iopaint start --device=cuda --model-dir=./model --model Sanster/AnyText

HF_ENDPOINT=https://hf-mirror.com iopaint start --device=cuda --model-dir=./model --model timbrooks/instruct-pix2pix

3.5下载擦除模型

Plain 复制代码
https://pan.quark.cn/s/9ca4455c2651

放置到IOPaint目录下的model下

3.5 改端口启动
Plain 复制代码
HF_ENDPOINT=https://hf-mirror.com nohup iopaint start --model lama --device=cuda --port=15109 --host 0.0.0.0 --input input --output-dir output --enable-interactive-seg --interactive-seg-model=vit_l  --interactive-seg-device=cuda --enable-gfpgan --gfpgan-device cuda --enable-realesrgan --realesrgan-model RealESRGAN_x4plus --realesrgan-device cuda --enable-remove-bg --enable-restoreformer --restoreformer-device cuda --enable-anime-seg --model-dir=./model &
相关推荐
上海锝秉工控3 分钟前
超声波风向传感器:以科技之翼,捕捉风的每一次呼吸
大数据·人工智能·科技
海天一色y1 小时前
Pycharm(二十一)递归删除文件夹
ide·python·pycharm
练习两年半的工程师2 小时前
AWS TechFest 2025: 风险模型的转变、流程设计的转型、生成式 AI 从实验走向实施的三大关键要素、评估生成式 AI 用例的适配度
人工智能·科技·金融·aws
yzx9910135 小时前
生活在数字世界:一份人人都能看懂的网络安全生存指南
运维·开发语言·网络·人工智能·自动化
乔巴先生246 小时前
LLMCompiler:基于LangGraph的并行化Agent架构高效实现
人工智能·python·langchain·人机交互
WIN赢6 小时前
【P03_AI大模型测试之_定制化 AI 应用程序开发】
ai
橙*^O^*安6 小时前
Go 语言基础:变量与常量
运维·开发语言·后端·golang·kubernetes
张子夜 iiii7 小时前
实战项目-----Python+OpenCV 实现对视频的椒盐噪声注入与实时平滑还原”
开发语言·python·opencv·计算机视觉
新启航光学频率梳7 小时前
激光频率梳 3D 轮廓测量 -- 平晶干涉法观察高精度平面度
科技·3d·制造
新启航光学频率梳7 小时前
激光频率梳 3D 轮廓测量 - 油路板的凹槽深度和平面度测量
科技·3d·制造