当前位置:网站首页>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
边栏推荐
- 5G時代全面到來,淺談移動通信的前世今生
- 《动手学深度学习》(二)-- 多层感知机
- Yyds dry inventory compiler and compiler tools
- 微信小程序 - 实现获取手机验证码倒计时 60 秒(手机号+验证码登录功能)
- cookie、session、tooken
- BGP experiment the next day
- Wechat applet JWT login issue token
- QT designer plug-in implementation of QT plug-in
- Go function
- Feature Engineering: summary of common feature transformation methods
猜你喜欢
![[source code analysis] NVIDIA hugectr, GPU version parameter server - (1)](/img/e3/fc2e78dc1e3e3cacbd1a389c82d33e.jpg)
[source code analysis] NVIDIA hugectr, GPU version parameter server - (1)

整理了一份ECS夏日省钱秘籍,这次@老用户快来领走

Fluent icon demo

Hands on deep learning (II) -- multi layer perceptron

手撕——排序

【leetcode】34. Find the first and last positions of elements in a sorted array

Cloud service selection of enterprises: comparative analysis of SaaS, PAAS and IAAs

Analysis of the overall design principle of Nacos configuration center (persistence, clustering, information synchronization)
![[tips] use Matlab GUI to read files in dialog mode](/img/51/6d6051836bfc9caa957d0275245bd3.png)
[tips] use Matlab GUI to read files in dialog mode

Go language introduction
随机推荐
C language: examples of logical operation and judgment selection structure
Wechat applet map annotation
60后关机程序
Go语言介绍
文档声明与字符编码
[JS -- map string]
How to solve the problem that objects cannot be deleted in Editor Mode
uni-app - 实现获取手机验证码倒计时 60 秒(手机号+验证码登录功能)
[source code analysis] NVIDIA hugectr, GPU version parameter server - (1)
Www2022 | know your way back: self training method of graph neural network under distribution and migration
微信小程序 - 实现获取手机验证码倒计时 60 秒(手机号+验证码登录功能)
BiShe cinema ticket purchasing system based on SSM
Sorted out an ECS summer money saving secret, this time @ old users come and take it away
JVM知识点
How should the team choose the feature branch development mode or trunk development mode?
Uni app - realize the countdown of 60 seconds to obtain the mobile verification code (mobile number + verification code login function)
[ibdfe] matlab simulation of frequency domain equalization based on ibdfe
Installation and use of blue lake
Monkey test
[untitled]