当前位置:网站首页>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
边栏推荐
- A summary of common interview questions in 2022, including 25 technology stacks, has helped me successfully get an offer from Tencent
- The difference between vectorresize and reverse.
- Analysis of the overall design principle of Nacos configuration center (persistence, clustering, information synchronization)
- Document declaration and character encoding
- The confusion I encountered when learning stm32
- 《动手学深度学习》(二)-- 多层感知机
- 深圳打造全球“鸿蒙欧拉之城”将加快培育生态,优秀项目最高资助 1000 万元
- 千亿市场规模医疗美容行业的水究竟有多浑?
- Recyclerview add header
- Déchirure à la main - tri
猜你喜欢
Hands on deep learning (II) -- multi layer perceptron
MySQL error: expression 1 of select list is not in group by claim and contains nonaggre
《西线无战事》我们才刚开始热爱生活,却不得不对一切开炮
[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!
FAQ | FAQ for building applications for large screen devices
Demonstration description of integrated base scheme
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
[untitled]
Force buckle 540 A single element in an ordered array
C语言:逻辑运算和判断选择结构例题
随机推荐
Www2022 | know your way back: self training method of graph neural network under distribution and migration
微信小程序 - 实现获取手机验证码倒计时 60 秒(手机号+验证码登录功能)
Use of go package
go 函数
[JS event -- event flow]
[JS -- map string]
Typescript practice for SAP ui5
集成底座方案演示说明
[wireless image transmission] FPGA based simple wireless image transmission system Verilog development, matlab assisted verification
Installation and use of blue lake
整理了一份ECS夏日省钱秘籍,这次@老用户快来领走
如何解决在editor模式下 无法删除物体的问题
Lei Jun wrote a blog when he was a programmer. It's awesome
5G時代全面到來,淺談移動通信的前世今生
Pytoch --- use pytoch for image positioning
C语言猜数字游戏
The difference between vectorresize and reverse.
Go variables and constants
Pytorch---使用Pytorch进行鸟类的预测
2022-07-01: at the annual meeting of a company, everyone is going to play a game of giving bonuses. There are a total of N employees. Each employee has construction points and trouble points. They nee