当前位置:网站首页>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
边栏推荐
- [live broadcast review] the first 8 live broadcasts of battle code Pioneer have come to a perfect end. Please look forward to the next one!
- Thinkphp6 limit interface access frequency
- How to solve the code error when storing array data into the database
- 5G時代全面到來,淺談移動通信的前世今生
- Use of go package
- Delete the code you wrote? Sentenced to 10 months!
- BGP experiment the next day
- 【leetcode】34. Find the first and last positions of elements in a sorted array
- Welcome the winter vacation multi school league game 2 partial solution (B, C, D, F, G, H)
- 云服务器的安全设置常识
猜你喜欢

Lost a few hairs, and finally learned - graph traversal -dfs and BFS

Demonstration description of integrated base scheme

C language: examples of logical operation and judgment selection structure

Delete the code you wrote? Sentenced to 10 months!

First acquaintance with string+ simple usage (II)

2022-07-01:某公司年会上,大家要玩一食发奖金游戏,一共有n个员工, 每个员工都有建设积分和捣乱积分, 他们需要排成一队,在队伍最前面的一定是老板,老板也有建设积分和捣乱积分, 排好队后,所有

Use of go package

Qt插件之Qt Designer插件实现

Play with concurrency: draw a thread state transition diagram

深圳打造全球“鸿蒙欧拉之城”将加快培育生态,优秀项目最高资助 1000 万元
随机推荐
Homework of the 16th week
C language: examples of logical operation and judgment selection structure
[live broadcast review] the first 8 live broadcasts of battle code Pioneer have come to a perfect end. Please look forward to the next one!
Nacos 配置中心整体设计原理分析(持久化,集群,信息同步)
SQL: common SQL commands
Okcc why is cloud call center better than traditional call center?
Www 2022 | rethinking the knowledge map completion of graph convolution network
The difference between vectorresize and reverse.
Lei Jun wrote a blog when he was a programmer. It's awesome
The first practical project of software tester: web side (video tutorial + document + use case library)
微信小程序 - 实现获取手机验证码倒计时 60 秒(手机号+验证码登录功能)
Introduction to JSON usage scenarios and precautions
Welcome the winter vacation multi school league game 2 partial solution (B, C, D, F, G, H)
[untitled]
Wechat applet JWT login issue token
Pandora IOT development board learning (RT thread) - Experiment 1 LED flashing experiment (learning notes)
Realizing deep learning framework from zero -- Introduction to neural network
LxC limits the number of CPUs
Microsoft Research Institute's new book "Fundamentals of data science", 479 Pages pdf
Pandora IOT development board learning (HAL Library) - Experiment 2 buzzer experiment (learning notes)