当前位置:网站首页>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
边栏推荐
- Cloud service selection of enterprises: comparative analysis of SaaS, PAAS and IAAs
- [untitled]
- pip 安装第三方库
- Is the product of cancer prevention medical insurance safe?
- "No war on the Western Front" we just began to love life, but we had to shoot at everything
- [personnel density detection] matlab simulation of personnel density detection based on morphological processing and GRNN network
- okcc为什么云呼叫中心比传统呼叫中心更好?
- 【leetcode】34. Find the first and last positions of elements in a sorted array
- JVM knowledge points
- 手撕——排序
猜你喜欢
Pytorch---使用Pytorch进行图像定位
Introduction to vmware workstation and vSphere
JVM knowledge points
深圳打造全球“鸿蒙欧拉之城”将加快培育生态,优秀项目最高资助 1000 万元
Set vscode. When double clicking, the selected string includes the $symbol - convenient for PHP operation
Www 2022 | rethinking the knowledge map completion of graph convolution network
FAQ | FAQ for building applications for large screen devices
Common sense of cloud server security settings
What is 5g industrial wireless gateway? What functions can 5g industrial wireless gateway achieve?
藍湖的安裝及使用
随机推荐
Typescript practice for SAP ui5
【leetcode】74. Search 2D matrix
[source code analysis] NVIDIA hugectr, GPU version parameter server - (1)
【IBDFE】基于IBDFE的频域均衡matlab仿真
Which product of anti-cancer insurance is better?
Suggestions on settlement solution of u standard contract position explosion
PR zero foundation introductory guide note 2
okcc为什么云呼叫中心比传统呼叫中心更好?
Play with concurrency: what's the use of interruptedexception?
整理了一份ECS夏日省钱秘籍,这次@老用户快来领走
Handling of inconsistency between cursor and hinttext position in shutter textfield
Shenzhen will speed up the cultivation of ecology to build a global "Hongmeng Oula city", with a maximum subsidy of 10million yuan for excellent projects
cookie、session、tooken
Set vscode. When double clicking, the selected string includes the $symbol - convenient for PHP operation
The first practical project of software tester: web side (video tutorial + document + use case library)
Go branch and loop
Actual combat | use composite material 3 in application
Cloud service selection of enterprises: comparative analysis of SaaS, PAAS and IAAs
藍湖的安裝及使用
如何解决在editor模式下 无法删除物体的问题