当前位置:网站首页>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
边栏推荐
- Yyds dry inventory compiler and compiler tools
- Microsoft Research Institute's new book "Fundamentals of data science", 479 Pages pdf
- 手撕——排序
- Thinkphp6 limit interface access frequency
- First acquaintance with string+ simple usage (II)
- Play with concurrency: draw a thread state transition diagram
- Is the product of cancer prevention medical insurance safe?
- Homework of the 16th week
- Pytoch --- use pytoch to predict birds
- Document declaration and character encoding
猜你喜欢
《西线无战事》我们才刚开始热爱生活,却不得不对一切开炮
Installation and use of blue lake
A summary of common interview questions in 2022, including 25 technology stacks, has helped me successfully get an offer from Tencent
Realizing deep learning framework from zero -- Introduction to neural network
【c语言】基础篇学习笔记
66.qt quick QML Custom Calendar component (supports vertical and horizontal screens)
Go语言介绍
Finally got byte offer. The 25-year-old inexperienced perception of software testing is written to you who are still confused
2022-07-01:某公司年会上,大家要玩一食发奖金游戏,一共有n个员工, 每个员工都有建设积分和捣乱积分, 他们需要排成一队,在队伍最前面的一定是老板,老板也有建设积分和捣乱积分, 排好队后,所有
[source code analysis] NVIDIA hugectr, GPU version parameter server - (1)
随机推荐
Uni app - realize the countdown of 60 seconds to obtain the mobile verification code (mobile number + verification code login function)
LxC limits the number of CPUs
向数据库中存入数组数据,代码出错怎么解决
Pandora IOT development board learning (RT thread) - Experiment 1 LED flashing experiment (learning notes)
Go语言介绍
蓝湖的安装及使用
PR zero foundation introductory guide note 2
Delete the code you wrote? Sentenced to 10 months!
2022-07-01:某公司年会上,大家要玩一食发奖金游戏,一共有n个员工, 每个员工都有建设积分和捣乱积分, 他们需要排成一队,在队伍最前面的一定是老板,老板也有建设积分和捣乱积分, 排好队后,所有
Déchirure à la main - tri
Pytorch---使用Pytorch进行图像定位
powershell_ View PowerShell function source code (environment variable / alias) / take function as parameter
Monkey test
LCM of Spreadtrum platform rotates 180 °
10 minutes to understand CMS garbage collector in JVM
Thinkphp6 limit interface access frequency
Use a mask to restrict the input of the qlineedit control
手撕——排序
Go language introduction
Installation et utilisation du lac bleu