/
Pytorch1.4 GPU环境.html
676 lines (501 loc) · 22.2 KB
/
Pytorch1.4 GPU环境.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta charset="utf-8">
<meta name="baidu-site-verification" content="5CxA73ejrD">
<meta name="author" content="董沅鑫, yuanxin.me@gmail.com">
<title>Pytorch1.4 GPU环境 | 鸢尾花开</title>
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<meta name="keywords" content="杂记,环境安装,">
<script>
console.log('\n%c Hexo-theme-bmw v4.0 ' + '%c 🎉 https://github.com/dongyuanxin/theme-bmw 🎉\n' + '\n%c View demo online ' + '%c 🔍 https://ishero.net/ 🔍 \n' , 'color: #fadfa3; background: #030307; padding:3px 0;', '', 'color: #fadfa3; background: #030307; padding:3px 0;', '');
</script>
<meta name="description" content="CV&ML技术新人的博客,记录我的学习成长过程!">
<link rel="icon" href="/images/favicon.ico">
<link rel="apple-touch-icon" href="/images/touch-icon.png">
<link href="https://cdn.bootcss.com/fancybox/3.5.2/jquery.fancybox.min.css" rel="stylesheet">
<link rel="stylesheet" href="/css/base.css">
<link rel="stylesheet" href="/icon/iconfont.css">
<link rel="stylesheet" href="/css/github-markdown.css">
<link rel="stylesheet" href="/css/highlight.css">
<script src="/js/util.js"></script>
<script src="/js/valine.min.js"></script>
<link rel="stylesheet" href="/custom/style.css">
<link href="https://cdn.bootcss.com/social-share.js/1.0.16/css/share.min.css" rel="stylesheet">
<script src="//cdn.bootcss.com/jquery/3.3.1/jquery.min.js" async></script>
<script src="//cdn.jsdelivr.net/npm/leancloud-storage@3.11.0/dist/av-min.js"></script>
<meta name="generator" content="Hexo 4.2.0"></head>
<body>
<meta name="referrer" content="no-referrer">
<div id="app">
<div class="header-wrap">
<header>
<div class="site-brand">
<div class="site-title">
<a href="/">isHero.net</a>
</div>
</div>
<nav class="site-navigation">
<ul class="nav-menu">
<li class="nav-item" data-path="/">
<a href="/" target="_self">
主页
</a>
</li>
<li class="nav-item" data-path="/archives/">
<a href="/archives/" target="_self">
归档
</a>
</li>
<li class="nav-item" data-path="/categories/">
<a href="/categories/" target="_self">
分类
</a>
</li>
<li class="nav-item" data-path="/tags/">
<a href="/tags/" target="_self">
标签
</a>
</li>
<li class="nav-item" data-path="/friends/">
<a href="/friends/" target="_self">
友链
</a>
</li>
<li class="nav-item" data-path="">
<a href="javascript:void(0);" v-else="">寻我</a>
<ul class="nav-menu--dropdown">
<li>
<a href="https://github.com/wmpscc" target="_blank" rel="external nofollow noopener noreferrer">
Github
</a>
</li>
<li>
<a href="https://www.jianshu.com/u/fde2534da842" target="_blank" rel="external nofollow noopener noreferrer">
简书
</a>
</li>
<li>
<a href="https://toutiao.io/subjects/345107" target="_blank" rel="external nofollow noopener noreferrer">
开发者头条
</a>
</li>
</ul>
</li>
</ul>
</nav>
<i class="iconfont icon-menu"></i>
</header>
</div>
<script>
let links = document.querySelectorAll('.nav-item');
for(let link of links){
let childrenLink = link.querySelector('ul');
link.addEventListener('mouseenter', () => {
if(childrenLink) {
childrenLink.className = "nav-menu--dropdown active";
}
})
link.addEventListener('mouseleave', () => {
if(childrenLink) {
childrenLink.className = "nav-menu--dropdown";
}
})
}
let rootRealPath = getRealPath(window.location.pathname, true);
for(let link of links) {
let linkPath = link.getAttribute("data-path");
if(linkPath && getRealPath(linkPath, true) === rootRealPath) {
link.className = "nav-item hover";
}
}
let iconMenu = document.querySelector("i.iconfont.icon-menu"),
iconMenuClicked = false;
let navDOM = document.querySelector("nav.site-navigation");
iconMenu.addEventListener("click", () => {
iconMenuClicked
? navDOM.className = "site-navigation active"
: navDOM.className = "site-navigation";
iconMenuClicked = !iconMenuClicked;
})
</script>
<div class="container post-index">
<div class="post">
<h1 class="article-title">
<span>Pytorch1.4 GPU环境</span>
</h1>
<meta name="referrer" content="no-referrer">
<div class="article-top-meta">
<span>
发布 :
2020-04-05
</span>
<span>
分类 :
<a href="/categories/%E6%9D%82%E8%AE%B0/">
杂记
</a>
</span>
<span>
浏览 : <span class="article-timer" data-identity="Pytorch1.4 GPU环境.html"></span>
</span>
</div>
<div class="article-content">
<div class="markdown-body">
<h1 id="Pytorch1-4-GPU-环境"><a href="#Pytorch1-4-GPU-环境" class="headerlink" title="Pytorch1.4 GPU 环境"></a>Pytorch1.4 GPU 环境</h1><p>首先确定你的电脑显卡是 NVIDIA 的,如果不是,请安装 CPU 版本。使用 pip 直接安装:</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">pip install torch==<span class="number">1.4</span><span class="number">.0</span>+cpu torchvision==<span class="number">0.5</span><span class="number">.0</span>+cpu -f https://download.pytorch.org/whl/torch_stable.html</span><br></pre></td></tr></table></figure>
<h3 id="驱动"><a href="#驱动" class="headerlink" title="驱动"></a>驱动</h3><ul>
<li>下载 CUDA 驱动<a href="https://developer.nvidia.com/cuda-10.1-download-archive-base" target="_blank" rel="external nofollow noopener noreferrer">CUDA10.1</a></li>
</ul>
<p><img src="https://cdn.nlark.com/yuque/0/2020/png/478234/1586092785684-8e01bc0c-88e7-46d7-ba7b-44e889c681f6.png#align=left&display=inline&height=794&name=1586089962427.png&originHeight=794&originWidth=1706&size=69628&status=done&style=none&width=1706" alt="1586089962427.png"></p>
<ul>
<li>双击安装:<br><img src="https://cdn.nlark.com/yuque/0/2020/png/478234/1586092816038-0bed45c2-b1b3-4320-a9ee-e4392989d4a3.png#align=left&display=inline&height=203&name=1586090360189.png&originHeight=203&originWidth=519&size=29782&status=done&style=none&width=519" alt="1586090360189.png"><br><img src="https://cdn.nlark.com/yuque/0/2020/png/478234/1586092823764-32956c52-c38c-40df-8a84-036aff32031d.png#align=left&display=inline&height=555&name=1586090532529.png&originHeight=555&originWidth=742&size=161351&status=done&style=none&width=742" alt="1586090532529.png"></li>
</ul>
<p>显卡驱动按照自己情况安装:<br><img src="https://cdn.nlark.com/yuque/0/2020/png/478234/1586092845702-0e2c3372-5ce6-4479-ba70-fffa9332c0db.png#align=left&display=inline&height=687&name=1586090713816.png&originHeight=687&originWidth=919&size=204839&status=done&style=none&width=919" alt="1586090713816.png"></p>
<p>根据自己要求,选择安装位置<br><img src="https://cdn.nlark.com/yuque/0/2020/png/478234/1586092860932-9ec1febf-63dc-41ea-abe4-371f78ed9792.png#align=left&display=inline&height=555&name=1586090591332.png&originHeight=555&originWidth=742&size=174385&status=done&style=none&width=742" alt="1586090591332.png"></p>
<h3 id="CUDNN"><a href="#CUDNN" class="headerlink" title="CUDNN"></a>CUDNN</h3><p>下载与 CUDA10.1 匹配的<a href="https://developer.nvidia.com/rdp/cudnn-archive" target="_blank" rel="external nofollow noopener noreferrer">CUDNN</a>。需要登录 NVIDIA 开发者社区<br><img src="https://cdn.nlark.com/yuque/0/2020/png/478234/1586092889207-0b5edff3-2321-4fec-a99e-3fcb10dfeac0.png#align=left&display=inline&height=676&name=1586091216025.png&originHeight=676&originWidth=857&size=51033&status=done&style=none&width=857" alt="1586091216025.png"></p>
<ul>
<li>解压后复制到 CUDA Development 目录</li>
</ul>
<p><img src="https://cdn.nlark.com/yuque/0/2020/png/478234/1586092916265-81a7cb1f-4696-4efb-a522-e9ad620a81d8.png#align=left&display=inline&height=923&name=1586091415721.png&originHeight=923&originWidth=1175&size=105240&status=done&style=none&width=1175" alt="1586091415721.png"></p>
<h3 id="环境变量"><a href="#环境变量" class="headerlink" title="环境变量"></a>环境变量</h3><p>查看环境变量是否自动添加了,如果没有就自己添加一下 bin 目录<br><img src="https://cdn.nlark.com/yuque/0/2020/png/478234/1586092929863-dadf999f-8bdb-4770-b7bf-32f8b3e17c49.png#align=left&display=inline&height=664&name=1586091834271.png&originHeight=664&originWidth=839&size=35470&status=done&style=none&width=839" alt="1586091834271.png"></p>
<h3 id="测试"><a href="#测试" class="headerlink" title="测试"></a>测试</h3><p>查看是否安装成功<br><img src="https://cdn.nlark.com/yuque/0/2020/png/478234/1586092951492-8add2076-c2c0-4c14-bb38-0a3905a1b62a.png#align=left&display=inline&height=269&name=1586091899039.png&originHeight=269&originWidth=595&size=29362&status=done&style=none&width=595" alt="1586091899039.png"></p>
<h3 id="安装-Pytorch"><a href="#安装-Pytorch" class="headerlink" title="安装 Pytorch"></a>安装 Pytorch</h3><p>安装好 anaconda 后,用 pip 工具安装 pytorch:</p>
<figure class="highlight python"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><span class="line">pip install torch===<span class="number">1.4</span><span class="number">.0</span> torchvision===<span class="number">0.5</span><span class="number">.0</span> -f https://download.pytorch.org/whl/torch_stable.html</span><br></pre></td></tr></table></figure>
<p>安装好后,测试:<br><img src="https://cdn.nlark.com/yuque/0/2020/png/478234/1586092974459-3bd9f1d6-e587-4b6e-83de-0b71aad513e3.png#align=left&display=inline&height=154&name=1586092015000.png&originHeight=154&originWidth=1063&size=16845&status=done&style=none&width=1063" alt="1586092015000.png"><br>如果返回 True 则 Pytorch GPU 版安装完成。</p>
</div>
</div>
<div class="copy-right">
<div class="markdown-body">
<blockquote>
本文作者 : HeoLis <br>
原文链接 : <a href="">https://ishero.net/Pytorch1.4%20GPU%E7%8E%AF%E5%A2%83.html</a><br>
版权声明 : 本博客所有文章除特别声明外,均采用 <a href="https://creativecommons.org/licenses/by-nc-sa/4.0/" target="_blank" rel="external nofollow noopener noreferrer">CC BY-NC-SA 4.0</a> 许可协议。转载请注明出处!
</blockquote>
</div>
</div>
<div class="social-share" style="margin-top: -2rem" data-wechat-qrcode-title="<p>微信扫一扫</p>" data-wechat-qrcode-helper="<p>微信右上角, 扫一扫分享</p>" data-sites="qzone, qq, weibo, wechat, douban, google, facebook, twitter">
<span style="color: #6b7487; font-size: 1.4rem;">分享到: </span>
</div>
<script src="https://cdn.bootcss.com/social-share.js/1.0.16/js/social-share.min.js" async></script>
<div id="reward">
<p id="reward-meta">学习、记录、分享、获得</p>
<button id="reward-btn">
<span>打赏</span>
</button>
<div id="reward-qrcode">
<div class="reward-qrcode--container">
<img class="qrcode-img" src="/images/donate-qr.png" alt="微信扫一扫, 向我投食">
<p class="qrcode-meta">微信扫一扫, 向我投食</p>
</div>
</div>
</div>
<script>
(() => {
let button = document.querySelector('#reward-btn'),
qrcode = document.querySelector('#reward-qrcode'),
display = false;
button.addEventListener('click', () => {
qrcode.style.display = display ? 'none' : 'block'
display = !display
}, false)
})()
</script>
<div class="article-footer">
<div class="article-meta pull-left">
<span>
<i class="iconfont icon-06tags"></i>标签:
<span class="span--tag">
<a href="/tags/%E7%8E%AF%E5%A2%83%E5%AE%89%E8%A3%85/">
#环境安装
</a>
</span>
</span>
</div>
<div class="article-meta pull-right">
</div>
</div>
</div>
<aside id="sidebar">
<p id="sidebar-header"></p>
<ol id="sidebar-toc"></ol>
</aside>
<script async>setTimeout(generateToc, 10);</script>
<nav class="post-navigation">
<div class="nav-pre">
<i class="iconfont icon-prev"></i>
上一篇:
<a href="/%E5%90%AB%E6%9C%89%E5%BF%8D%E8%80%90%E5%BA%A6%E7%9A%84TP%E8%AE%A1%E7%AE%97(Precision%E3%80%81Rcall%E3%80%81F1%20score).html" target="_self">含有忍耐度的TP计算(Precision、Rcall、F1 score)</a>
</div>
<div class="nav-next">
下一篇:
<a href="/%E7%BB%8F%E5%85%B8%E6%8E%92%E5%BA%8F%E7%AE%97%E6%B3%95%E6%95%B4%E7%90%86.html" target="_self">经典排序算法整理</a>
<i class="iconfont icon-next"></i>
</div>
</nav>
<script defer>
const valineAPI = (() => {
try {
AV.init("Epge4Qisj9i3E08wl1q1cSWB-gzGzoHsz", "ClV5c29GDRy9RkLPqrac09OT");
} catch(error) {}
const isExist = (identity) => {
identity = identity || getRealPath();
let query = new AV.Query('Timer');
return new Promise((resolve, reject) => {
query.equalTo("identity", identity);
query.find().then(results => {
resolve(results.length > 0);
}, error => reject(error));
})
}
const _get = (identity) => {
let query = null;
if(identity && identity instanceof Array){
let querys = [];
for(let i = 0; i < identity.length; ++i) {
querys[i] = new AV.Query('Timer');
querys[i].equalTo('identity', identity[i]);
}
query = AV.Query.or.apply(null ,querys);
} else {
identity = identity || getRealPath();
query = new AV.Query("Timer");
query.equalTo("identity", identity);
}
return new Promise((resolve, reject) => {
query.find()
.then(results => resolve(results))
.catch(error => reject(error))
})
}
const create = (identity) => {
identity = identity || getRealPath();
return new Promise((resolve, reject) => {
let Todo = AV.Object.extend('Timer');
let todo = new Todo();
todo.set("times", 1);
todo.set("identity", identity);
todo.save().then(res => resolve(true), error => reject(error));
})
}
const update = (identity) => {
identity = identity || getRealPath();
return new Promise((resolve, reject) => {
let query = new AV.Query('Timer');
query.equalTo("identity", identity);
query.find().then(todos => {
todos.forEach(todo => {
todo.set("times", todo.attributes.times + 1);
});
return AV.Object.saveAll(todos);
}).then(todos => resolve(true), error => reject(error));
})
}
return {
isExist,
_get,
update,
create
}
})()
const calcAndWriteTimes = () => {
let isPost = true;
let timerAllDOM = document.querySelectorAll(".article-timer");
if(isPost) {
let identity = timerAllDOM[0].getAttribute("data-identity");
valineAPI.isExist(identity)
.then(exist => {
if(exist) {
return valineAPI.update(identity);
}
return new Promise(resolve => resolve(true));
})
.then( succuess => valineAPI._get(identity))
.then( result => timerAllDOM[0].innerText = result[0].attributes.times)
.catch(error => console.log(error.message))
return ;
}
let timerDOMCache = {};
for(let timerDOM of timerAllDOM) {
let identity = timerDOM.getAttribute("data-identity");
if(timerDOMCache.hasOwnProperty(identity)){
timerDOMCache[identity].dom.push(timerDOM);
}else{
timerDOMCache[identity] = {
dom: [timerDOM],
times: undefined
};
}
}
let identities = Object.keys(timerDOMCache);
valineAPI._get(identities).then(results => {
for(let result of results) {
let {identity, times} = result.attributes;
timerDOMCache[identity].times = times;
timerDOMCache[identity].dom.map(item => item.innerText = times);
}
for(let identity of identities) {
if(timerDOMCache[identity].times){
continue;
}
timerDOMCache[identity].dom.map(item => item.innerText = 1);
valineAPI.create(identity);
}
}).catch(error => console.log(error.message))
}
if(true){
calcAndWriteTimes();
}
</script>
</div>
<footer>
<p class="site-info">
博客已萌萌哒运行<span id="time-to-now"></span><span class="my-face">(●'◡'●)ノ♥</span>
<br>
Theme - <a href="https://github.com/dongyuanxin/theme-bmw" target="_blank" rel="external nofollow noopener noreferrer">BMW</a> | Made With 💗 | Powered by <a href="https://godbmw.com/" target="_blank" rel="external nofollow noopener noreferrer">GodBMW</a>
<br>
ICP证:<a href="http://www.beian.miit.gov.cn" target="_blank" rel="external nofollow noopener noreferrer">粤ICP备19011977号-1</a>
</p>
</footer>
<script>
const timeToNowDOM = document.querySelector("#time-to-now");
const startTimestamp = new Date(2017, 8, 20).getTime();
const updateTimeStr = () => {
let offset = parseInt(
(new Date().getTime() - startTimestamp) / 1000,
10
),
day = Math.floor(offset / 86400),
hour = Math.floor((offset % 86400) / 3600),
minute = Math.floor(((offset % 86400) % 3600) / 60),
second = Math.floor(((offset % 86400) % 3600) % 60);
timeToNowDOM.innerHTML =
day + "天" + hour + "小时" + minute + "分钟" + second + "秒";
setTimeout(updateTimeStr, 500);
}
setTimeout(updateTimeStr, 500);
</script>
<div class="back-to-top hidden">
<span>
<i class="iconfont icon-60"></i><span></span>%
</span>
</div>
<script>
const updateIconToTop = percent => {
let dom = document.querySelector(".back-to-top span span");
dom.innerText = percent;
if(percent < 1) {
document.querySelector(".back-to-top").className = "back-to-top hidden";
} else {
document.querySelector(".back-to-top").className = "back-to-top";
}
}
const handleScoll = () => {
let isRunning = false;
return () => {
if (isRunning) return;
isRunning = true;
window.requestAnimationFrame(timestamp => {
let scrollTop =
document.documentElement.scrollTop || document.body.scrollTop,
scrollHeight =
document.documentElement.scrollHeight ||
document.body.scrollHeight,
clientHeight =
document.documentElement.clientHeight ||
document.body.clientHeight;
isRunning = false;
if (scrollTop <= 1) {
updateIconToTop(0);
return;
}
if (scrollTop + clientHeight >= scrollHeight) {
updateIconToTop(100);
} else {
updateIconToTop(parseInt(
100 * scrollTop / (scrollHeight - clientHeight),
10
));
}
});
};
}
const backToTop = () => {
let scrollTop =
document.documentElement.scrollTop || document.body.scrollTop,
delay = 10,
time = 200;
if (scrollTop <= 20) {
document.documentElement.scrollTop = 0;
document.body.scrollTop = 0;
return;
}
let step = Math.ceil(scrollTop * delay / time);
let timer = setInterval(() => {
scrollTop =
document.documentElement.scrollTop || document.body.scrollTop;
if (scrollTop - step <= 0) {
document.documentElement.scrollTop = 0;
document.body.scrollTop = 0;
clearInterval(timer);
} else {
document.documentElement.scrollTop = scrollTop - step;
document.body.scrollTop = scrollTop - step;
}
}, delay);
}
document.addEventListener("scroll", handleScoll(), false);
document.querySelector(".back-to-top").addEventListener("click", backToTop, false);
</script>
</div>
<script type="text/javascript" src="//cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-MML-AM_CHTML" async></script>
<script>
(() => {
const mathjaxConfig = {
showProcessingMessages: false, //关闭js加载过程信息
messageStyle: "none", //不显示信息
jax: ["input/TeX", "output/HTML-CSS"],
tex2jax: {
inlineMath: [["$", "$"], ["\\(", "\\)"]], //行内公式选择符
displayMath: [["$$", "$$"], ["\\[", "\\]"]], //段内公式选择符
skipTags: ["script", "noscript", "style", "textarea", "pre", "code", "a"] //避开某些标签
},
"HTML-CSS": {
availableFonts: ["STIX", "TeX"], //可选字体
showMathMenu: false //关闭右击菜单显示
}
}
let mathjaxInterval = setInterval(() => {
if(!window.MathJax){
return;
}
window.MathJax.Hub.Config(mathjaxConfig)
window.MathJax.Hub.Queue(["Typeset", MathJax.Hub, document.getElementById('app')])
clearInterval(mathjaxInterval)
}, 10)
})()
</script>
<script src="https://cdn.bootcss.com/fancybox/3.5.2/jquery.fancybox.min.js" async></script>
<script async>
let fancyTimer = setInterval(function(){
if(!window.$){
return;
}
$(document).ready(function() {
$(".post img").each(function () {
if($(this).parent().get(0).tagName.toLowerCase() === "a") {
return;
}
// $(this).attr("data-fancybox", "gallery"); // if you add 'data-fancybox', img will display after showed
var element = document.createElement("a");
$(element).attr("data-fancybox", "gallery");
$(element).attr("href", $(this).attr("src"));
$(this).wrap(element);
});
clearInterval(fancyTimer);
});
}, 10);
</script>
<script src="/custom/script.js" async></script>
</body>
</html>