惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

T
Threatpost
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
T
The Blog of Author Tim Ferriss
S
SegmentFault 最新的问题
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - 司徒正美
T
Tailwind CSS Blog
The Cloudflare Blog
The Last Watchdog
The Last Watchdog
PCI Perspectives
PCI Perspectives
博客园 - 聂微东
Stack Overflow Blog
Stack Overflow Blog
TaoSecurity Blog
TaoSecurity Blog
云风的 BLOG
云风的 BLOG
C
Cybersecurity and Infrastructure Security Agency CISA
O
OpenAI News
Recorded Future
Recorded Future
GbyAI
GbyAI
www.infosecurity-magazine.com
www.infosecurity-magazine.com
Y
Y Combinator Blog
D
Darknet – Hacking Tools, Hacker News & Cyber Security
量子位
博客园 - 叶小钗
V
Vulnerabilities – Threatpost
F
Full Disclosure
Recent Announcements
Recent Announcements
Vercel News
Vercel News
S
Schneier on Security
H
Heimdal Security Blog
Cisco Talos Blog
Cisco Talos Blog
V2EX - 技术
V2EX - 技术
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
B
Blog RSS Feed
宝玉的分享
宝玉的分享
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
P
Privacy & Cybersecurity Law Blog
T
Threat Research - Cisco Blogs
G
Google Developers Blog
C
Cyber Attacks, Cyber Crime and Cyber Security
爱范儿
爱范儿
IT之家
IT之家
大猫的无限游戏
大猫的无限游戏
C
Check Point Blog
N
Netflix TechBlog - Medium
S
Security @ Cisco Blogs
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Microsoft Azure Blog
Microsoft Azure Blog
H
Hackread – Cybersecurity News, Data Breaches, AI and More
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Cyberwarzone
Cyberwarzone

博客园 - Bean.Hsiang

评估和改进 ML.NET 分类器 ML.NET 和 Model Builder 2021年三月更新 ML.NET 推荐引擎中一类矩阵因子分解的缺陷 使用 ML.NET 实现峰值检测来排查异常 4倍速!ML.NET Model Builder GPU 与 CPU 对比测试 使用 ML.NET 识别乐高颜色块 ML.NET 十一月更新 借助AI激发组织创新活力 Virtual ML.NET Hackathon 2020 来啦 ML.NET 九月更新 ML.NET API 和工具八月更新 通过 ML.NET 使用预训练残差网络 ResNet 模型实现手势识别 通过 Continual Learning 提高 ML.NET 模型准确性并增强性能 基于 ONNX 在 ML.NET 中使用 Pytorch 训练的垃圾分类模型 在 Blazor WebAssembly 静态网站中部署ML.NET机器学习模型 使用 Scikit-learn 和 ML.NET 实现朴素贝叶斯(Naive Bayes)分类器 恢复已取消ML.NET训练中的模型 说说 ML.NET and AutoML 使用ML.NET进行自定义机器学习
在WSL2启用cuda进行深度学习尝鲜
Bean.Hsiang · 2020-07-02 · via 博客园 - Bean.Hsiang

在做深度学习相关实验时,我一般会直接在本机 Linux 环境下进行,因为我需要基于 cuda 来启用 GPU 运算。考虑到经常还要迁移到面向客户PC机的智能服务,所以我偶尔也会选择在 Windows 上进行。在 Windows 10 中自从有了 WSL,我的选择是使用 WSL 远程连接高性能服务器,这样才能保持研发体验的一致性,我特别期望能摆脱这样的麻烦,如果能在Windows 10 本地切换一个 Linux系统又能使用 cuda 就好了,幸运的消息是,最新的 Windows 10 的更新推出 WSL2 对 cuda 的支持,我迫不及待地做了一下基准测试,想比较一下不同环境的性能表现。

我选择的几个系统环境是这样:

  • Ubuntu 20.04
  • WSL2 Ubuntu 20.04
  • Windows 10

主要硬件配置是这样:

  • Intel i9 10920X (12核,24线程)
  • Nvidia RTX 2080 TI (11GB VRAM)

测试用的深度学习模型我使用的是最经典的MNIST,我比较熟悉Pytorch所以代码我采用了这个示例仓库,我修改了部分代码如下,让网络模型更大以获得更准确的读数。

class Net(nn.Module):
    def __init__(self):
        super(Net, self).__init__()
        self.conv1 = nn.Conv2d(1, 128, 3, 1)
        self.conv2 = nn.Conv2d(128, 128, 3, 1)
        self.conv3 = nn.Conv2d(128, 128, 3, 1)
        self.dropout1 = nn.Dropout2d(0.25)
        self.dropout2 = nn.Dropout2d(0.5)
        self.fc1 = nn.Linear(15488, 15488//2)
        self.fc2 = nn.Linear(15488//2, 10)

    def forward(self, x):
        x = self.conv1(x)
        x = F.relu(x)
        x = self.conv2(x)
        x = F.relu(x)
        x = self.conv3(x)
        x = F.relu(x)
        x = F.max_pool2d(x, 2)
        x = self.dropout1(x)
        x = torch.flatten(x, 1)
        x = self.fc1(x)
        x = F.relu(x)
        x = self.dropout2(x)
        x = self.fc2(x)
        output = F.log_softmax(x, dim=1)
        return output

其中batch size我设为512,epochs设为14,以precision为FP32运行,结果对比如下:

  

哈哈,老实说结果还凑合!WSL2 在启用 cuda 支持后比本机 Ubuntu 环境下多消耗了18%,要知道这是在 Nvidia Rtx 2080 Ti 上训练模型。目前 WSL2 对 cuda 的支持仍处于早期预览模式,期待各路工程师、研究员大神们,以及微软和 Nvidia 再打磨下,尽快达到接近本机 Ubuntu 性能的水平。如果对训练时长消耗特别严格的研究(比如海量图像、语料)来说,多花18%是很难接受的,但对我来说,训练样本数据都还比较小,一般也就到2G差不多了,所以我可以稍稍牺牲下操作系统层面的性能,采用异步训练来弥补一下,毕竟我换来的是能用 Windows 10 和 WSL2 作为我的主研发环境,不用多系统或者远程Linux系统来回切换了。