VS code配环境,4080S和4090训练速度对比

1. shell设置

1.1 更改系统运行脚本的执行策略

打开系统的 Windows PowerShell 出现如下报错:

. : 无法加载文件 C:\Users\YOLO\Documents\WindowsPowerShell\profile.ps1,因为在此系统上禁止运行脚本。有关详细信息,请参
阅 https:/go.microsoft.com/fwlink/?LinkID=135170 中的 about_Execution_Policies。
所在位置 行:1 字符: 3
+ . 'C:\Users\YOLO\Documents\WindowsPowerShell\profile.ps1'
  +   ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      + CategoryInfo          : SecurityError: (:) [],PSSecurityException
      + FullyQualifiedErrorId : UnauthorizedAccess

★解决方法:

更改执行策略为RemoteSigned,以管理员身份打开 PowerShell 输入:

set-executionpolicy remotesigned

选择“是”

系统默认模式为restricted

注: 为防止恶意脚本的执行,PowerShell 中设计了一个叫做执行策略(Execution Policy)的东西(我更倾向于把它叫做脚本执行策略)。我们可以在不同的应用场景中设置不同的策略来防止恶意脚本的执行。本文主要是解释这些执行策略,因为笔者在学习的时候发现它们并不是那么清晰易懂。
PowerShell 提供了 Restricted、AllSigned、RemoteSigned、Unrestricted、Bypass、Undefined 六种类型的执行策略

1.2 anaconda添加到系统环境变量

问题:
系统的powershell、prompt识别不到conda和pip
原因:
调用系统的和调用anaconda里的powershell、prompt是不一样的,anaconda里的powershell、prompt是能识别conda和pip命令的

★解决方法:

控制面板-系统-高级系统设置-高级-环境变量
系统变量-双击Path-新增以下6条,一行一条:

D:\miniconda3
D:\miniconda3\Scripts
D:\miniconda3\Library\bin
D:\miniconda3\Library\usr\bin
D:\miniconda3\Library\mingw-w64\bin
D:\Microsoft VS Code\bin

Anaconda根目录视具体情况更改,如果是miniconda同样,好像miniconda没有mingw-w64\bin,跳过这条即可
到此,终端问题全部解决
在这里插入图片描述
重启终端,激活环境时,可能会让你CondaError: Run ‘conda init’ before ‘conda activate’
照做即可:

conda init

我的输出如下(仅作记录):

no change     D:\miniconda3\Scripts\conda.exe
no change     D:\miniconda3\Scripts\conda-env.exe
no change     D:\miniconda3\Scripts\conda-script.py
no change     D:\miniconda3\Scripts\conda-env-script.py
no change     D:\miniconda3\condabin\conda.bat
no change     D:\miniconda3\Library\bin\conda.bat
no change     D:\miniconda3\condabin\_conda_activate.bat
no change     D:\miniconda3\condabin\rename_tmp.bat
no change     D:\miniconda3\condabin\conda_auto_activate.bat
no change     D:\miniconda3\condabin\conda_hook.bat
no change     D:\miniconda3\Scripts\activate.bat
no change     D:\miniconda3\condabin\activate.bat
no change     D:\miniconda3\condabin\deactivate.bat
modified      D:\miniconda3\Scripts\activate
modified      D:\miniconda3\Scripts\deactivate
modified      D:\miniconda3\etc\profile.d\conda.sh
modified      D:\miniconda3\etc\fish\conf.d\conda.fish
no change     D:\miniconda3\shell\condabin\Conda.psm1
modified      D:\miniconda3\shell\condabin\conda-hook.ps1
no change     D:\miniconda3\Lib\site-packages\xontrib\conda.xsh
modified      D:\miniconda3\etc\profile.d\conda.csh
modified      C:\Users\XXX\Documents\WindowsPowerShell\profile.ps1
modified      HKEY_CURRENT_USER\Software\Microsoft\Command Processor\AutoRun

==> For changes to take effect, close and re-open your current shell. <==

2.vs code设置

2.1 基本插件

先找扩展图标(左边4方块飞一个角)
搜chinese装中文包、搜python装python基本包

2.2 设置解释器

打开一个项目的py文件,右下角设置python解释器

2.3 自动激活环境

vs code更改默认终端

法(1)

Ctrl+Shift+P搜索Terminal: Select Default Profile
选择默认终端为
cmd****在这里插入图片描述在这里插入图片描述

法(2)

ctrl+, 打开设置-功能-终端,找到Integrated > Default Profile
Linux:
在这里插入图片描述
Windows:
在这里插入图片描述

2.4 如果出现两个激活环境

在这里插入图片描述

conda config --set auto_activate_base False

关掉conda自动激活环境,问题解决
在这里插入图片描述

官方解释:
https://github.com/microsoft/vscode-python/wiki/Activate-Environments-in-Terminal-Using-Environment-Variables

3.conda虚拟环境中查看cuda、cuDNN是否安装

注意:虚拟环境里的cuda、cudnn和电脑上安装的cuda、cudnn是相互独立的,这里讲的是conda环境里面的
终端激活环境

conda activate myenv

进入python编程模式

python

输入以下命令

import torch
print(torch.cuda.is_available())  #返回True则说明已经安装了cuda
print(torch.__version__)
print(torch.version.cuda)
print(torch.backends.cudnn.is_available())  #返回True则说明已经安装了cuDNN
print(torch.backends.cudnn.version())

在这里插入图片描述

题外话:系统和编译器对训练速度的影响

系统和编译器对训练速度影响蛮大的,以下为所有参数、软件、包环境一致的情况下的对比测试,虽然硬件环境没有严谨一致,但是CPU、内存性能都是完全过剩的(GPU全程使用率99%,没有GPU空闲等待数据读写的情况)。


  1. win11 + pycharm,torch-2.1.2+cu121 4080 SUPER:跑yolov8n,17秒一轮
  2. win11 + VS code,torch-2.1.2+cu121 4080 SUPER:跑yolov8n,16秒一轮
  3. Ubuntu20.04 + VS code,torch-2.1.2+cu121 4080 SUPER:跑yolov8n,14秒一轮
  4. autodl租的4090,torch-2.1.2+cu121 4090:跑yolov8n,13秒一轮

以下为4080S和4090在软件包环境完全相同(系统不同)的对比情况:

我为什么要对比4080S和4090:
因为穷买了4080S,想对比看看,用性价比安慰一下自己。
下面的对比对买4090的富哥没有参考价值,请跳过
按照4090历史最低1.1w-1.2w价格算,4080目前8k出头,4k(4090的30%+)的价格差距
现在4090D都要1.3w-1.4w往上,多2k的价格,买个Dog属实心里不舒服


yolov8n(8GFLOPs),batch_size=64,workers=8:
4080S:14秒
4090:13秒
200epoch差距=200秒=3-4分钟,训练时长差距很小


yolov8s(28GFLOPs),batch_size=64,workers=8:
4080S:26秒
4090:22秒
200epoch差距=800秒=13-14分钟,训练时长差距还不是很明显


yolov8l(165GFLOPs),batch_size=16,workers=8:
4080S:1:18秒
4090:1:05秒~06秒(batch_size=16),1:05秒(batch_size=32)
200epoch差距=2600秒=43-44分钟,训练时长差距明显了


其实一般自己炼丹(读研需求)的话,基本就是用50GFLOPs以内的模型,差不多yolov8s这个量级
差距撑死就是十几分钟到半小时的总训练时长,现在入的话,感觉4070tis性价比最高吧,富一点4080s,感觉现在上4090或者4090D不如等5090吧
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

  • 9
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 1
    评论
SuperPoint和SuperGlue是一种基于深度学习的图像准方法。SuperPoint用于提取图像中的关键点,而SuperGlue用于将两幅图像的关键点进行匹准。 由于官方发布的SuperPoint和SuperGlue模型是基于COCO数据集训练的,可能与实际业务中的数据存在差距。因此,可以使用开源的pytorch-superpoint和pytorch-superglue来实现自己的图像准任务。 具体步骤如下: 1. 安装pytorch-superpoint和pytorch-superglue库。 2. 使用pytorch-superpoint库提取图像中的关键点。可以参考该库的文档和示例代码来了解如何使用。 3. 使用pytorch-superglue库进行关键点的匹准。该库提供了一些预训练的模型,可以直接使用或进行微调。 4. 根据实际需求,对准结果进行后处理,例如去除错误匹或优化准结果。 下面是一个示例代码,演示了如何使用pytorch-superpoint和pytorch-superglue进行图像准: ```python import torch import cv2 from superpoint import SuperPointFrontend from superglue import SuperGlueFrontend # 加载SuperPoint模型 superpoint = SuperPointFrontend(weights_path='superpoint.pth') # 加载SuperGlue模型 superglue = SuperGlueFrontend(weights_path='superglue.pth') # 读取两幅图像 image1 = cv2.imread('image1.jpg') image2 = cv2.imread('image2.jpg') # 提取关键点 points1, desc1, heatmap1 = superpoint.run(image1) points2, desc2, heatmap2 = superpoint.run(image2) # 进行关键点匹准 matches, conf = superglue.run(image1, image2, points1, points2) # 可以根据需要对准结果进行后处理 # 输出准结果 print(matches) ``` 请注意,上述代码仅为示例,实际使用时需要根据具体情况进行适当的修改和调整。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Dneccc

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值