报错1:OSError: …/python3.8/site-packages/torch/lib/libtorch_global_deps.so: cannot open shared object file: No such file or directory
Reason: When configuring the pytorch environment, remember to check the cuda version ( you can check it with the nvidia-smi command ), which matches the cuda version! ! ! The CUDA Version of the previous training machine was 11, and the torch 1.9.1+cu111, torchvision 0.10.1+cu111, torchaudio 0.9.1 used to configure the pytorch environment, and the training reported this error.
Solution: Reconfigure the pytorch environment that matches the cuda version to solve~
# 补充:配置yolov7训练conda虚拟环境
# 去官网下载对应的anaconda,执行
sh Anaconda3-2023.03-1-Linux-x86_64.sh
# 若需要修改anaconda安装路径,加上prefix参数,后面添加指定路径,执行
sh Anaconda3-2023.03-1-Linux-x86_64.sh -prefix /home/users/anaconda/
# 根据anaconda安装路径配置环境变量,这是默认的安装路径
export PATH=/root/anaconda3/bin/:$PATH
export PATH=/root/anaconda3/bin/conda:$PATH
#查看环境变量
echo $PATH
# 或者
vim ~/.bashrc
source ~/.bashrc
# 创建conda虚拟环境,版本和名字都根据需要修改
conda create --name pytorch python=3.8
conda activate pytorch
# 机器cuda版本是10.1,根据需要到官网(https://pytorch.org/get-started/previous-versions/)选择自己的版本安装
conda install pytorch==1.7.1 torchvision==0.8.2 torchaudio==0.7.2 cudatoolkit=10.1 -c pytorch
# 进入yolov7路径,安装yolov7依赖,用清华源更快哦
pip3 install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple/
报错2:AttributeError: module 'distutils' has no attribute 'version'
Reason: setuptools version problem
solve:
pip uninstall setuptools
pip install setuptools==59.5.0