当前位置:网站首页>Pytorch-Yolov5從0運行Bug解决:
Pytorch-Yolov5從0運行Bug解决:
2022-07-02 04:14: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
边栏推荐
- 微信小程序 - 实现获取手机验证码倒计时 60 秒(手机号+验证码登录功能)
- Thinkphp6 limit interface access frequency
- Play with concurrency: draw a thread state transition diagram
- 【leetcode】81. Search rotation sort array II
- cookie、session、tooken
- Which insurance company has a better product of anti-cancer insurance?
- Which is better, industrial intelligent gateway or edge computing gateway? How to choose the right one?
- Target free or target specific: a simple and effective zero sample position detection comparative learning method
- Sorted out an ECS summer money saving secret, this time @ old users come and take it away
- powershell_ View PowerShell function source code (environment variable / alias) / take function as parameter
猜你喜欢

手撕——排序

JVM knowledge points

文档声明与字符编码

Installation and use of blue lake

Lei Jun wrote a blog when he was a programmer. It's awesome

Microsoft Research Institute's new book "Fundamentals of data science", 479 Pages pdf

Demonstration description of integrated base scheme

pip 安装第三方库

Playing with concurrency: what are the ways of communication between threads?

How to model noise data? Hong Kong Baptist University's latest review paper on "label noise representation learning" comprehensively expounds the data, objective function and optimization strategy of
随机推荐
SQL: common SQL commands
【力扣刷题】15.三数之和(双指针);17.电话号码的字母组合(递归回溯)
【c语言】基础篇学习笔记
PR zero foundation introductory guide note 2
初识P4语言
Introduction to vmware workstation and vSphere
[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!
Force buckle 540 A single element in an ordered array
Delete the code you wrote? Sentenced to 10 months!
Shutdown procedure after 60
Go语言介绍
Jetpack's livedata extension mediatorlivedata
《西线无战事》我们才刚开始热爱生活,却不得不对一切开炮
Li Kou interview question 02.08 Loop detection
Pytorch---使用Pytorch进行鸟类的预测
go 变量与常量
Recyclerview add header
Wechat applet - realize the countdown of 60 seconds to obtain the mobile verification code (mobile number + verification code login function)
【leetcode】34. Find the first and last positions of elements in a sorted array
Wpviewpdf Delphi and Net PDF viewing component