当前位置:网站首页>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
边栏推荐
- Force buckle 540 A single element in an ordered array
- Bitmap principle code record
- Wechat applet - realize the countdown of 60 seconds to obtain the mobile verification code (mobile number + verification code login function)
- Www 2022 | rethinking the knowledge map completion of graph convolution network
- 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
- How much is the tuition fee of SCM training class? How long is the study time?
- A summary of common interview questions in 2022, including 25 technology stacks, has helped me successfully get an offer from Tencent
- go 包的使用
- Monkey测试
- The original author is out! Faker. JS has been controlled by the community..
猜你喜欢

Li Kou interview question 02.08 Loop detection

Demonstration description of integrated base scheme
![[tips] use Matlab GUI to read files in dialog mode](/img/51/6d6051836bfc9caa957d0275245bd3.png)
[tips] use Matlab GUI to read files in dialog mode

树莓派GPIO引脚控制红绿灯与轰鸣器

手撕——排序

《西线无战事》我们才刚开始热爱生活,却不得不对一切开炮
![[source code analysis] NVIDIA hugectr, GPU version parameter server - (1)](/img/e1/620443dbc6ea8b326e1242f25d6d74.jpg)
[source code analysis] NVIDIA hugectr, GPU version parameter server - (1)
![[JS event -- event flow]](/img/fe/199890b082845f68b65f25056e6f29.jpg)
[JS event -- event flow]

Spring recruitment of Internet enterprises: Kwai meituan has expanded the most, and the annual salary of technical posts is up to nearly 400000

Dare to go out for an interview without learning some distributed technology?
随机推荐
Pytorch---使用Pytorch进行图像定位
Go语言介绍
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
Lei Jun wrote a blog when he was a programmer. It's awesome
PR zero foundation introductory guide note 2
Fingertips life Chapter 4 modules and packages
BiShe cinema ticket purchasing system based on SSM
Play with concurrency: draw a thread state transition diagram
go 包的使用
Pandora IOT development board learning (RT thread) - Experiment 1 LED flashing experiment (learning notes)
60后关机程序
PIP installation of third-party libraries
【leetcode】34. Find the first and last positions of elements in a sorted array
QT designer plug-in implementation of QT plug-in
如何解决在editor模式下 无法删除物体的问题
C language guessing numbers game
A thorough understanding of the development of scorecards - the determination of Y (Vintage analysis, rolling rate analysis, etc.)
Wechat applet map annotation
Force buckle 540 A single element in an ordered array
Hand tear - sort