Image-coloring的部署,在Ubuntu22.04系统下——点动科技

一、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

三、克隆Image-coloring仓库

3.1官网地址:Image-coloring的GitHub地址

bash 复制代码
git clone https://github.com/zxx1218/Image-coloring.git

3.2如果下载速度较慢可添加https://mirror.ghproxy.com/镜像源

bash 复制代码
git clone https://mirror.ghproxy.com/https://github.com/zxx1218/Image-coloring.git

3.3进入到Image-coloring文件夹内

bash 复制代码
cd Image-coloring

3.4创建Image-coloring需要的环境

bash 复制代码
conda create -n Image-coloring python=3.10
conda activate Image-coloring

3.5安装依赖库

bash 复制代码
pip install -r requirements.txt 
pip install gradio
pip install gradio_imageslider
pip install modelscope

3.6在basicsr文件夹创建version.py

bash 复制代码
echo "__version__ = '1.0.0'" > basicsr/version.py
echo "__gitsha__ = \"some_git_sha\"" >> basicsr/version.py

3.7修改gradio_app.py

bash 复制代码
vi gradio_app.py
  • 将最后一行的
bash 复制代码
demo.launch()
  • 改为
bash 复制代码
demo.launch(server_port=15081,
server_name="0.0.0.0")

3.8 server_port变量为设置服务器监听的端口为业务端口,此处改为业务端口。

  • 拉取图上色模型
bash 复制代码
modelscope download --model iic/cv_ddcolor_image-colorization --local_dir modelscope/damo/cv_ddcolor_image-colorization/ 
  • 启动Image-coloring
bash 复制代码
python gradio_app.py

3.9启动成功后,访问http://主机IP:端口

相关推荐
Narutolxy7 分钟前
Python 单元测试:深入理解与实战应用20240919
python·单元测试·log4j
小菜yh14 分钟前
关于Redis
java·数据库·spring boot·redis·spring·缓存
时光追逐者15 分钟前
分享6个.NET开源的AI和LLM相关项目框架
人工智能·microsoft·ai·c#·.net·.netcore
Amo Xiang30 分钟前
2024 Python3.10 系统入门+进阶(十五):文件及目录操作
开发语言·python
Microsoft Word34 分钟前
数据库系统原理(第一章 数据库概述)
数据库·oracle
liangbm340 分钟前
数学建模笔记——动态规划
笔记·python·算法·数学建模·动态规划·背包问题·优化问题
云卓科技41 分钟前
无人机之控制距离篇
科技·安全·机器人·无人机·制造
云卓科技43 分钟前
无人机之飞行高度篇
科技·安全·机器人·无人机·制造
华为云开源44 分钟前
openGemini 社区人才培养计划:助力成长,培养新一代云原生数据库人才
数据库·云原生·开源
B站计算机毕业设计超人1 小时前
计算机毕业设计Python+Flask微博情感分析 微博舆情预测 微博爬虫 微博大数据 舆情分析系统 大数据毕业设计 NLP文本分类 机器学习 深度学习 AI
爬虫·python·深度学习·算法·机器学习·自然语言处理·数据可视化