CentOS服务部署
第一章 启动两个算法服务
第一步:上传算法文件
第二步:安装 tmux
tmux 是一个非常强大的终端复用工具,全称是 terminal multiplexer。它的作用简单来说就是在一个终端窗口中同时运行和管理多个会话、窗口和程序,并且支持断开重连。
sudo yum install tmux
第三步:启动服务
(1) 启动第一个算法服务
tmux new -s service1
|- tmux: 调用 tmux 工具来启动一个新的 tmux 会话。
|- new: 表示新建一个 tmux 会话。
|- -s service2: 使用 -s 选项为新会话指定一个名称,service2,也就是说你创建的新会话的名字为service2。
python service1.py
如果你想退出这个界面,但让程序继续在后台运行:Ctrl + B,然后松开,再按D。
(2) 启动第二个算法服务
tmux new -s service2
python service2.py
如果你想退出这个界面,但让程序继续在后台运行:Ctrl + B,然后松开,再按D。
第四步:关闭防火墙
systemctl stop firewalld
第二章 Docker部署Yolov5
2.1 cuda-toolkit-12-4安装问题
2.1.1 问题描述
(base) root@DESKTOP-1E9HVIR:/home/ef# sudo apt-get -y install cuda-toolkit-12-4
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:
The following packages have unmet dependencies:
nsight-systems-2023.4.4 : Depends: libtinfo5 but it is not installable
E: Unable to correct problems, you have held broken packages.
2.1.2 解决办法
- For Ubuntu 23.10
sudo nano /etc/apt/sources.list
deb http://old-releases.ubuntu.com/ubuntu/ lunar universe
sudo apt update
sudo apt-get -y install cuda-toolkit-12-4
- For Ubuntu 24.04 or newer
第一步:打开ubuntu.sources
sudo nano /etc/apt/sources.list.d/ubuntu.sources
第二步:复制粘贴
Types: deb
URIs: http://old-releases.ubuntu.com/ubuntu/
Suites: lunar
Components: universe
Signed-By: /usr/share/keyrings/ubuntu-archive-keyring.gpg
第三步:更新、安装
sudo apt update
sudo apt-get -y install cuda-toolkit-12-4
【注意】该方法真实有效,来源于cuda-toolkit-12-4安装问题。
2.2 查看ppytorch:2.4.0-cuda12.4-cudnn9-runtime 镜像默认python版本
docker run --rm pytorch/pytorch:2.4.0-cuda12.4-cudnn9-runtime python3 --version
>>> Python 3.11.9
docker run --rm pytorch/pytorch:2.1.0-cuda11.8-cudnn8-runtime python3 --version
>>> Python 3.10.13
第三章 Pyarmor加密
3.1 py文件加密和日期限制
pyarmor obfuscate --recursive --platform linux.x86_64 --platform windows.x86_64 --output defect_dist -e 2025-7-15 service.py
或
pyarmor obfuscate --recursive --platform linux.x86_64 --platform windows.x86_64 --output defect_dist -e 30 service.py
参数\选项 | 含义 |
---|---|
obfuscate | PyArmor 7.x 的加密命令(PyArmor 8+ 改用 gen) |
–recursive | 递归加密 service.py 的所有依赖模块 |
–platform linux.x86_64 | 生成能在 Linux 64位 系统运行的加密版本 |
–platform windows.x86_64 | 生成能在 Windows 64位 系统运行的加密版本 |
–output defect_dist | 加密后的输出目录名为 defect_dist |
-e 2025-7-15 | 设置加密脚本的有效期至 2025年7月15日,到期自动失效 |
service.py | 需要加密的主脚本文件 |
【注意】默认本地时间