当前位置:网站首页>Pytorch-Yolov5从0运行Bug解决:
Pytorch-Yolov5从0运行Bug解决:
2022-07-02 04:13:00 【_kx_】
目录超链接:
- Q: 需要安装对应版本的 pytorch 、 torchvision 、opencv 等一系列的库, 从哪里安装呢?(如何完美的换源)
- Q: import cv2 出现 libGL.so.1: cannot open shared object file: No such file or directory
- Q:AttributeError: ‘Upsample’ object has no attribute ‘recompute_scale_factor’
流程: docker 创建好镜像后, 镜像中安装anaconda后,创建好 yolov5的环境
Q: 需要安装对应版本的 pytorch 、 torchvision 、opencv 等一系列的库, 从哪里安装呢?(如何完美的换源)
Details:但是Anacodna 默认的源采用的是国外的,会导致我们安装东西特别慢,pip (python包管理工具的源也是国外的,需要我们换源、或者安装的时候,临时换源)
解决方法:
1. anaconda 添加源的时候,一定要注意写 http 不要写 https
# 在终端命令行执行该命令
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/menpo/
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --add channels http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --set show_channel_urls yes
执行完之后,你会发现在 home 目录下多了一个 .condarc 的文件
- vim ~/.condarc
内容如下:
channels:
- http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
- http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/menpo/
- http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/
- http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
- http://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
- http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
- http://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
至此,换源成功,可以根据官网的 pytorch 安装命令去安装。
- 切记, 去掉末尾的 -c Ptyorch ( -c, 是指 -channel 从Pytorch 官方的网址安装,特别慢,有很大概率会失败)
- Pytorch 官网:
- https://pytorch.org/
- 老版本:https://pytorch.org/get-started/previous-versions/
2. pip 换源
#清华:
https://pypi.tuna.tsinghua.edu.cn/simple
#阿里云:
http://mirrors.aliyun.com/pypi/simple/
#豆瓣:
http://pypi.douban.com/simple/
- yolov5下的安装命令(直接拉取并且安装好 yolov5 对应版本下的所有库):
pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple –-trusted-host pypi.douban.com
Q:import cv2 出现 libGL.so.1: cannot open shared object file: No such file or directory
解决方法:
pip install opencv-python-headless
参考自:https://blog.csdn.net/qq_50195602/article/details/124188467
这位仁兄讲解的更为透彻,甚至讲了如何在 dockerfile 中增加安装指令,去规避这个问题。
Q:AttributeError: 'Upsample' object has no attribute 'recompute_scale_factor'
描述:我推理 yolov5 示范例子图像的时候产生的错误。
原因: torch 和 torchvision 版本不匹配导致的;
解决方法:
- 安装匹配的版本
- 更改 upsample.py 中的代码, 去掉函数那个参数
参考: https://blog.csdn.net/qq_40280673/article/details/125095353
边栏推荐
- 集成底座方案演示说明
- [wireless image transmission] FPGA based simple wireless image transmission system Verilog development, matlab assisted verification
- 向数据库中存入数组数据,代码出错怎么解决
- Cloud service selection of enterprises: comparative analysis of SaaS, PAAS and IAAs
- Which product of anti-cancer insurance is better?
- BiShe cinema ticket purchasing system based on SSM
- 文档声明与字符编码
- Jetpack之LiveData扩展MediatorLiveData
- Handling of inconsistency between cursor and hinttext position in shutter textfield
- Www2022 | know your way back: self training method of graph neural network under distribution and migration
猜你喜欢

Installation et utilisation du lac bleu

Wpviewpdf Delphi and Net PDF viewing component

The confusion I encountered when learning stm32

深圳打造全球“鸿蒙欧拉之城”将加快培育生态,优秀项目最高资助 1000 万元

Use of go package

Pytorch---使用Pytorch实现U-Net进行语义分割

文档声明与字符编码

Document declaration and character encoding

Realizing deep learning framework from zero -- Introduction to neural network

Déchirure à la main - tri
随机推荐
树莓派GPIO引脚控制红绿灯与轰鸣器
【leetcode】74. Search 2D matrix
Pytorch---使用Pytorch实现U-Net进行语义分割
First acquaintance with string+ simple usage (II)
Sword finger offer II 006 Sort the sum of two numbers in the array
Pytorch---使用Pytorch进行鸟类的预测
【c语言】动态规划---入门到起立
Go branch and loop
[ibdfe] matlab simulation of frequency domain equalization based on ibdfe
Common sense of cloud server security settings
go 函数
Suggestions on settlement solution of u standard contract position explosion
【力扣刷题】15.三数之和(双指针);17.电话号码的字母组合(递归回溯)
[wireless image transmission] FPGA based simple wireless image transmission system Verilog development, matlab assisted verification
Wechat applet map annotation
Pandora IOT development board learning (RT thread) - Experiment 1 LED flashing experiment (learning notes)
Which product of anti-cancer insurance is better?
初识P4语言
Cloud service selection of enterprises: comparative analysis of SaaS, PAAS and IAAs
[JS event -- event flow]