-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.html
1082 lines (968 loc) · 39 KB
/
index.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
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Comprehensive guide for setting up IBEX with detailed instructions for SSH configuration, environment setup, and custom scripts.">
<title>IBEX Setup Guide</title>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/prism/1.24.1/themes/prism-tomorrow.min.css">
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
<style>
:root {
--kaust-blue: #005DA4;
--kaust-green: #8AC543;
--kaust-orange: #F7941E;
--kaust-yellow: #FFF200;
--kaust-light-blue: #00A3E0;
--background-color: #FFFFFF;
--text-color: #333333;
--sidebar-width: 250px;
}
/* Add more custom properties for easy theming */
body {
font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
line-height: 1.6;
color: var(--text-color);
margin: 0;
padding: 0;
display: flex;
background-color: var(--background-color);
transition: background-color 0.3s ease, color 0.3s ease;
}
/* Improve responsive design */
@media (max-width: 768px) {
body {
flex-direction: column;
}
#sidebar {
width: 100%;
height: auto;
position: static;
}
#main-content {
margin-left: 0;
padding: 10px;
}
}
/* Optimize styles for better performance */
#sidebar, #main-content, .copy-button, #dark-mode-toggle {
will-change: transform;
}
/* Improve accessibility */
.visually-hidden {
position: absolute;
width: 1px;
height: 1px;
padding: 0;
margin: -1px;
overflow: hidden;
clip: rect(0, 0, 0, 0);
white-space: nowrap;
border: 0;
}
/* Add smooth scrolling */
html {
scroll-behavior: smooth;
}
#sidebar {
width: var(--sidebar-width);
height: 100vh;
overflow-y: auto;
position: fixed;
top: 0;
left: 0;
background-color: var(--kaust-blue);
color: var(--background-color);
padding: 20px;
box-sizing: border-box;
}
/* Add print styles */
@media print {
body {
font-size: 12pt;
}
#sidebar, #dark-mode-toggle, #progress-container {
display: none;
}
#main-content {
margin-left: 0;
width: 100%;
}
a[href]:after {
content: " (" attr(href) ")";
}
.code-container, pre[class*="language-"] {
white-space: pre-wrap;
word-break: break-all;
}
}
/* Improve accessibility */
.skip-link {
position: absolute;
top: -40px;
left: 0;
background: var(--kaust-blue);
color: white;
padding: 8px;
z-index: 100;
}
.skip-link:focus {
top: 0;
}
/* Optimize for mobile devices */
@media (max-width: 768px) {
#sidebar {
width: 100%;
height: auto;
position: static;
}
#main-content {
margin-left: 0;
padding: 10px;
}
.video-container {
padding-bottom: 75%; /* Adjust aspect ratio for mobile */
}
}
#main-content {
margin-left: var(--sidebar-width);
padding: 20px;
max-width: 800px;
background-color: var(--background-color);
box-shadow: 0 0 10px rgba(0,0,0,0.1);
border-radius: 5px;
margin-top: 20px;
margin-bottom: 20px;
}
h1, h2 {
color: var(--kaust-blue);
}
pre[class*="language-"] {
position: relative;
padding: 1em;
margin: .5em 0;
overflow: auto;
border-radius: 0.3em;
background: #003D6E;
color: #FFFFFF;
}
.code-container {
position: relative;
margin-bottom: 15px;
border-radius: 0.3em;
}
.copy-button {
position: absolute;
top: 5px;
right: 5px;
padding: 5px 10px;
background: var(--kaust-yellow);
color: #003D6E;
border: none;
border-radius: 3px;
cursor: pointer;
z-index: 10;
transition: background-color 0.3s ease, color 0.3s ease;
font-weight: bold;
}
.copy-button:hover {
background: var(--kaust-orange);
color: #FFFFFF;
}
.step {
margin-bottom: 30px;
border-bottom: 1px solid var(--kaust-light-blue);
padding-bottom: 20px;
}
.pytorch-note {
background-color: #DE3412; /* PyTorch's orange color */
color: white;
padding: 15px;
border-radius: 5px;
margin-top: 15px;
font-style: italic;
}
.pytorch-note a {
color: #FFD700; /* Gold color for the link */
text-decoration: underline;
}
.pytorch-note a:hover {
color: #FFFFFF; /* White color on hover */
}
#table-of-contents h2 {
margin-top: 0;
color: var(--background-color);
border-bottom: 2px solid var(--kaust-yellow);
padding-bottom: 10px;
font-size: 1.2em;
}
#table-of-contents ul {
list-style-type: none;
padding-left: 0;
}
#table-of-contents li {
margin-bottom: 10px;
padding-left: 20px;
position: relative;
font-size: 0.9em;
}
#table-of-contents li::before {
content: "\f054";
font-family: "Font Awesome 5 Free";
font-weight: 900;
position: absolute;
left: 0;
color: var(--kaust-yellow);
font-size: 0.8em;
}
#table-of-contents a {
text-decoration: none;
color: var(--background-color);
transition: color 0.3s ease;
}
#table-of-contents a:hover {
color: var(--kaust-yellow);
}
.toc-section {
margin-bottom: 15px;
}
.toc-section-title {
font-weight: bold;
color: var(--kaust-yellow);
margin-bottom: 5px;
font-size: 1em;
}
.important-note {
background-color: var(--kaust-green);
border-left: 5px solid var(--kaust-blue);
padding: 15px;
margin-top: 15px;
color: var(--text-color);
border-radius: 3px;
}
.important-note i {
margin-right: 5px;
}
.highlight {
background-color: var(--kaust-yellow);
padding: 2px 4px;
border-radius: 3px;
font-weight: bold;
color: var(--text-color);
}
.setup-steps {
counter-reset: step;
padding-left: 0;
}
.setup-steps li {
list-style-type: none;
position: relative;
padding-left: 40px;
margin-bottom: 20px;
}
.setup-steps li::before {
counter-increment: step;
content: counter(step);
position: absolute;
left: 0;
top: 0;
width: 30px;
height: 30px;
background-color: var(--kaust-blue);
color: var(--background-color);
border-radius: 50%;
text-align: center;
line-height: 30px;
font-size: 14px;
}
.note {
background-color: var(--kaust-yellow);
border-left: 5px solid var(--kaust-orange);
padding: 15px;
margin-top: 15px;
font-style: italic;
border-radius: 3px;
color: var(--text-color);
}
.usage-instructions {
background-color: var(--kaust-light-blue);
border: 1px solid var(--kaust-blue);
border-radius: 4px;
padding: 20px;
margin-top: 20px;
box-shadow: 0 2px 5px rgba(0,0,0,0.1);
color: var(--background-color);
}
#progress-container {
position: fixed;
top: 0;
left: 0;
width: 100%;
height: 5px;
background-color: var(--background-color);
z-index: 1000;
}
#progress-bar {
height: 100%;
background-color: var(--kaust-orange);
width: 0%;
transition: width 0.3s ease;
}
.file-path, .command-example {
background-color: var(--kaust-yellow);
color: var(--text-color);
padding: 2px 5px;
border-radius: 3px;
font-family: 'Courier New', Courier, monospace;
font-weight: bold;
border: 1px solid var(--kaust-blue);
}
#dark-mode-toggle {
position: fixed;
top: 20px;
right: 20px;
z-index: 1001;
background-color: var(--kaust-orange);
color: var(--background-color);
border: none;
border-radius: 50%;
width: 50px;
height: 50px;
font-size: 24px;
cursor: pointer;
transition: background-color 0.3s ease, transform 0.3s ease;
display: flex;
align-items: center;
justify-content: center;
box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}
#dark-mode-toggle:hover {
background-color: var(--kaust-yellow);
color: var(--text-color);
transform: scale(1.1);
}
.video-container {
position: relative;
padding-bottom: 56.25%;
height: 0;
overflow: hidden;
max-width: 100%;
margin-bottom: 20px;
}
.video-container iframe {
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
}
body.dark-mode {
background-color: #1a1a1a;
color: #f0f0f0;
}
body.dark-mode #sidebar {
background-color: var(--kaust-blue);
color: var(--background-color);
}
body.dark-mode #main-content {
background-color: #2c2c2c;
color: #f0f0f0;
box-shadow: 0 0 10px rgba(255,255,255,0.1);
}
body.dark-mode h1, body.dark-mode h2 {
color: var(--kaust-light-blue);
}
body.dark-mode pre[class*="language-"] {
background: #1E3A5F;
}
body.dark-mode .important-note,
body.dark-mode .note,
body.dark-mode .usage-instructions {
background-color: var(--kaust-blue);
color: var(--background-color);
}
body.dark-mode #dark-mode-toggle {
background-color: var(--kaust-yellow);
color: var(--text-color);
}
body.dark-mode .copy-button {
background-color: var(--kaust-green);
color: #003D6E;
}
body.dark-mode .copy-button:hover {
background-color: var(--kaust-light-blue);
color: #FFFFFF;
}
body.dark-mode .highlight {
background-color: var(--kaust-orange);
color: var(--background-color);
}
body.dark-mode .file-path,
body.dark-mode .command-example {
background-color: var(--kaust-blue);
color: var(--background-color);
border-color: var(--kaust-light-blue);
}
body.dark-mode #table-of-contents a:hover {
color: var(--kaust-orange);
}
</style>
</head>
<body>
<a href="#main-content" class="skip-link">Skip to main content</a>
<!-- Dark Mode Toggle Button -->
<button id="dark-mode-toggle" aria-label="Toggle dark mode">
<i class="fas fa-moon"></i>
<span class="visually-hidden">Toggle Dark Mode</span>
</button>
<!-- Progress Bar -->
<div id="progress-container" aria-hidden="true">
<div id="progress-bar"></div>
</div>
<!-- Sidebar with Table of Contents -->
<nav id="sidebar">
<div id="table-of-contents">
<h2><i class="fas fa-list" aria-hidden="true"></i> Contents</h2>
<!-- Introduction Section -->
<div class="toc-section">
<div class="toc-section-title">Introduction</div>
<ul>
<li><a href="#video-tutorial">Video Tutorial</a></li>
</ul>
</div>
<!-- Initial Setup Section -->
<div class="toc-section">
<div class="toc-section-title">Initial Setup</div>
<ul>
<li><a href="#ssh-config">SSH Configuration</a></li>
<li><a href="#ssh-key">Generate SSH Key</a></li>
<li><a href="#connect-ibex">Connect to IBEX</a></li>
<li><a href="#add-ssh-key">Add SSH Key</a></li>
</ul>
</div>
<!-- Environment Setup Section -->
<div class="toc-section">
<div class="toc-section-title">Environment Setup</div>
<ul>
<li><a href="#install-miniconda">Install Miniconda</a></li>
<li><a href="#conda-env">Set Up Conda Environment</a></li>
</ul>
</div>
<!-- Custom Scripts Section -->
<div class="toc-section">
<div class="toc-section-title">Custom Scripts</div>
<ul>
<li><a href="#gpu-script">Create GPU Job Script</a></li>
<li><a href="#jupyter-script">Create Jupyter Script</a></li>
<li><a href="#add-aliases">Add Aliases to .bashrc</a></li>
</ul>
</div>
<!-- Usage Guide Section -->
<div class="toc-section">
<div class="toc-section-title">Usage Guide</div>
<ul>
<li><a href="#using-setup">Using the Setup</a></li>
</ul>
</div>
</div>
</nav>
<!-- Main Content -->
<main id="main-content">
<h1>IBEX Setup Guide</h1>
<!-- Video Tutorial Section -->
<div class="step" id="video-tutorial">
<h2><i class="fas fa-video icon"></i> Video Tutorial</h2>
<p>If you prefer a video walkthrough, watch this tutorial that covers the IBEX setup process:</p>
<div class="video-container">
<iframe width="560" height="315" src="https://www.youtube.com/embed/Vw5DALZFizo" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture" allowfullscreen></iframe>
</div>
<p>For detailed written instructions, continue reading below.</p>
</div>
<!-- SSH Configuration Section -->
<div class="step" id="ssh-config">
<h2><i class="fas fa-cog icon"></i> SSH Configuration</h2>
<p>First, open the ssh config file:</p>
<div class="code-container">
<pre><code class="language-bash">notepad .ssh\config
# or
code .ssh\config</code></pre>
</div>
<p>Add the following to the config file:</p>
<div class="code-container">
<pre><code class="language-bash">Host ibex
HostName glogin.ibex.kaust.edu.sa
User USERNAME</code></pre>
</div>
<p class="important-note"><i class="fas fa-exclamation-circle"></i> <strong>Important:</strong> Replace <span class="highlight">"USERNAME"</span> with your actual IBEX username.</p>
</div>
<!-- Generate SSH Key Section -->
<div class="step" id="ssh-key">
<h2><i class="fas fa-key icon"></i> Generate SSH Key</h2>
<p>Follow these steps to generate an SSH key on your computer and prepare it for use with IBEX:</p>
<ol class="setup-steps">
<li>
<p>Generate an SSH key by running the following command:</p>
<div class="code-container">
<pre><code class="language-bash">ssh-keygen -t rsa -b 4096</code></pre>
</div>
</li>
<li>
<p>When prompted for a file to save the key, press Enter to accept the default location.</p>
</li>
<li>
<p>You'll be asked to enter a passphrase. Press Enter twice for no passphrase, or enter a passphrase for added security.</p>
</li>
<li>
<p>Locate the public key file. By default, it's saved as:</p>
<ul>
<li>On Windows: <span class="file-path">C:\Users\YourUsername\.ssh\id_rsa.pub</span></li>
<li>On macOS/Linux: <span class="file-path">~/.ssh/id_rsa.pub</span></li>
</ul>
</li>
<li>
<p>Open the public key file in a text editor:</p>
<ul>
<li>On Windows:
<div class="code-container">
<pre><code class="language-bash">cd %USERPROFILE%\.ssh
notepad id_rsa.pub</code></pre>
</div>
</li>
<li>On macOS/Linux:
<div class="code-container">
<pre><code class="language-bash">open -e ~/.ssh/id_rsa.pub</code></pre>
</div>
Or use any text editor of your choice, e.g., <span class="command-example">nano ~/.ssh/id_rsa.pub</span>
</li>
</ul>
</li>
<li>
<p>Keep this text editor window open. You'll need the contents of this file in the next steps when setting up access to IBEX.</p>
</li>
</ol>
<div class="important-note">
<i class="fas fa-exclamation-circle"></i> <strong>Important:</strong> Keep your private key (id_rsa) secure and never share it. You'll use the public key (id_rsa.pub) in the next steps to set up access to IBEX.
</div>
</div>
<!-- Connect to IBEX Section -->
<div class="step" id="connect-ibex">
<h2><i class="fas fa-plug icon"></i> Connect to IBEX</h2>
<p>Connect to IBEX using the following command:</p>
<div class="code-container">
<pre><code class="language-bash">ssh ibex</code></pre>
</div>
</div>
<!-- Add SSH Key to Authorized Keys Section -->
<div class="step" id="add-ssh-key">
<h2><i class="fas fa-lock icon"></i> Add SSH Key to Authorized Keys</h2>
<p>After connecting to IBEX, add your key to the authorized_keys file:</p>
<div class="code-container">
<pre><code class="language-bash">nano ~/.ssh/authorized_keys</code></pre>
</div>
<p>Paste your public key into this file and save.</p>
</div>
<!-- Install Miniconda Section -->
<div class="step" id="install-miniconda">
<h2><i class="fas fa-download icon"></i> Install Miniconda</h2>
<p>Download and install Miniconda:</p>
<div class="code-container">
<pre><code class="language-bash">wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
bash Miniconda3-latest-Linux-x86_64.sh -b
~/miniconda3/bin/conda init bash && source ~/.bashrc && conda config --set auto_activate_base false</code></pre>
</div>
</div>
<!-- Create GPU Job Script Section -->
<div class="step" id="gpu-script">
<h2><i class="fas fa-file-code icon"></i> Create GPU Job Script</h2>
<p>Create a script for running GPU jobs:</p>
<div class="code-container">
<pre><code class="language-bash">nano srun_gpu.sh</code></pre>
</div>
<p>Paste the following content into the file:</p>
<div class="code-container">
<pre><code class="language-bash">#!/bin/bash
# Color definitions
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[0;33m'
BLUE='\033[0;34m'
PURPLE='\033[0;35m'
CYAN='\033[0;36m'
NC='\033[0m' # No Color
# Default values
gpu_type=${GPU_TYPE:-rtx2080ti}
time=${JOB_TIME:-03:00:00}
mem=${JOB_MEM:-20G}
num_gpus=${NUM_GPUS:-1}
nodes=${NUM_NODES:-1}
# Function to print help message
print_help() {
echo -e "${BLUE}Usage:${NC} gpu [command] [options]"
echo -e " gpu [gpu_type] [time] [memory] [num_gpus] [num_nodes]"
echo
echo -e "${GREEN}Commands:${NC}"
echo -e " ${YELLOW}list${NC} : List your running jobs"
echo -e " ${YELLOW}cancel${NC} : Cancel a specific job (e.g., gpu cancel 12345)"
echo -e " ${YELLOW}cancel-all${NC}: Cancel all your jobs"
echo -e " ${YELLOW}-h, --help${NC}: Show this help message"
echo
echo -e "${GREEN}Options:${NC}"
echo -e " ${YELLOW}gpu_type${NC} : Type of GPU ${CYAN}(default: ${gpu_type})${NC}"
echo -e " ${YELLOW}time${NC} : Job duration ${CYAN}(default: ${time})${NC}"
echo -e " ${YELLOW}memory${NC} : Memory allocation ${CYAN}(default: ${mem})${NC}"
echo -e " ${YELLOW}num_gpus${NC} : Number of GPUs ${CYAN}(default: ${num_gpus})${NC}"
echo -e " ${YELLOW}num_nodes${NC} : Number of nodes ${CYAN}(default: ${nodes})${NC}"
echo
echo -e "${PURPLE}Examples:${NC}"
echo -e " gpu ${CYAN}# Use all default values${NC}"
echo -e " gpu v100 04:00:00 32G 2 2 ${CYAN}# 2 V100 GPUs, 4 hours, 32GB memory, 2 nodes${NC}"
echo -e " gpu - - - 4 1 ${CYAN}# 4 GPUs with default type, time, and memory on 1 node${NC}"
echo -e " gpu list ${CYAN}# List your running jobs${NC}"
echo
echo -e "${RED}Note:${NC} Use '-' to skip a parameter and use its default value."
}
# Function to list jobs with GPU and node details
list_jobs() {
echo -e "${BLUE}Your running jobs:${NC}"
# Get the job list with a format suitable for table output
job_list=$(squeue -u $USER --format="%.18i %.12P %.20j %.10u %.2t %.10M %.6D %.18R %.20b")
# Print the job list header in a table-like format
printf "${CYAN}%-18s %-12s %-20s %-10s %-2s %-10s %-6s %-18s %-20s${NC}\n" \
"JOBID" "PARTITION" "NAME" "USER" "ST" "TIME" "NODES" "NODELIST(REASON)" "GPU(s)"
echo "$job_list" | while read -r line; do
# Skip the header or empty lines
if [[ "$line" == JOBID* ]] || [ -z "$line" ]; then
continue
fi
# Extract the JOBID and TRES_PER_NODE from each line
job_id=$(echo $line | awk '{print $1}')
tres_per_node=$(echo $line | awk '{print $NF}')
# Validate the JOBID
if [[ "$job_id" =~ ^[0-9]+$ ]]; then
# Extract GPU information from TRES_PER_NODE
gpu_info=$(echo $tres_per_node | grep -oP 'gpu:[^,]+')
# If gpu_info is empty, set it to "N/A"
if [ -z "$gpu_info" ]; then
gpu_info="N/A"
else
# Extract just the number and type of GPUs
gpu_info=$(echo $gpu_info | sed 's/gpu://g')
fi
# Print the line with GPU info in a well-aligned format
printf "${YELLOW}%-18s %-12s %-20s %-10s %-2s %-10s %-6s %-18s ${GREEN}%-20s${NC}\n" \
"$job_id" "$(echo $line | awk '{print $2}')" \
"$(echo $line | awk '{print $3}')" \
"$(echo $line | awk '{print $4}')" \
"$(echo $line | awk '{print $5}')" \
"$(echo $line | awk '{print $6}')" \
"$(echo $line | awk '{print $7}')" \
"$(echo $line | awk '{print $8}')" \
"$gpu_info"
else
# Print the original line if JOBID is invalid
echo -e "$line"
fi
done
}
# Function to cancel a job
cancel_job() {
if [ -z "$1" ]; then
echo -e "${RED}Error: Please provide a job ID to cancel${NC}"
return 1
fi
# Check if the job ID is a number
if ! [[ "$1" =~ ^[0-9]+$ ]]; then
echo -e "${RED}Error: Invalid job ID. Please provide a numeric job ID.${NC}"
return 1
fi
# Check if the job exists and belongs to the current user
if ! squeue -h -j "$1" -u "$USER" &> /dev/null; then
echo -e "${RED}Error: Job $1 not found or does not belong to you.${NC}"
return 1
fi
echo -e "${YELLOW}Cancelling job $1...${NC}"
if scancel "$1"; then
echo -e "${GREEN}Job $1 cancelled successfully.${NC}"
else
echo -e "${RED}Failed to cancel job $1. Please try again or contact system administrator.${NC}"
fi
}
# Function to cancel all jobs
cancel_all_jobs() {
echo -e "${YELLOW}Cancelling all your jobs...${NC}"
if scancel -u $USER; then
echo -e "${GREEN}All jobs cancelled${NC}"
else
echo -e "${RED}Failed to cancel all jobs.${NC}"
fi
}
# Command handling
case "$1" in
list)
list_jobs
exit 0
;;
cancel)
cancel_job "$2"
exit 0
;;
cancel-all)
cancel_all_jobs
exit 0
;;
-h|--help)
print_help
exit 0
;;
esac
# Parse job submission parameters
if [ $# -gt 0 ]; then
[ "$1" != "-" ] && gpu_type=$1
[ "$2" != "-" ] && time=$2
[ "$3" != "-" ] && mem=$3
[ "$4" != "-" ] && num_gpus=$4
[ "$5" != "-" ] && nodes=$5
fi
# Validate parameters
if [[ ! $time =~ ^[0-9]{2}:[0-9]{2}:[0-9]{2}$ ]]; then
echo -e "${RED}Error: Invalid time format. Use HH:MM:SS.${NC}"
exit 1
fi
if [[ ! $mem =~ ^[0-9]+[GgMmKk]$ ]]; then
echo -e "${RED}Error: Invalid memory format. Use a valid size (e.g., 20G, 2048M).${NC}"
exit 1
fi
if [[ ! $num_gpus =~ ^[1-9][0-9]*$ ]]; then
echo -e "${RED}Error: Number of GPUs must be a positive integer.${NC}"
exit 1
fi
if [[ ! $nodes =~ ^[1-9][0-9]*$ ]]; then
echo -e "${RED}Error: Number of nodes must be a positive integer.${NC}"
exit 1
fi
# Show job submission summary
echo -e "${GREEN}Job submission summary:${NC}"
echo -e " ${YELLOW}GPU Type :${NC} $gpu_type"
echo -e " ${YELLOW}Time :${NC} $time"
echo -e " ${YELLOW}Memory :${NC} $mem"
echo -e " ${YELLOW}GPUs :${NC} $num_gpus"
echo -e " ${YELLOW}Nodes :${NC} $nodes"
# Prompt user to continue
read -p "Do you want to proceed with job submission? (y/n) " -n 1 -r
echo
if [[ ! $REPLY =~ ^[Yy]$ ]]; then
echo -e "${YELLOW}Job submission cancelled.${NC}"
exit 0
fi
# Run the srun command
if srun --time=$time --gres=gpu:$gpu_type:$num_gpus --mem=$mem --nodes=$nodes --ntasks-per-node=1 --cpus-per-task=1 --resv-ports=1 --pty /bin/bash -ls; then
echo -e "${GREEN}Job submitted successfully.${NC}"
else
echo -e "${RED}Failed to submit job.${NC}"
fi </code></pre>
</div>
<p>Make the script executable:</p>
<div class="code-container">
<pre><code class="language-bash">chmod +x srun_gpu.sh</code></pre>
</div>
</div>
<!-- Create Jupyter Notebook Script Section -->
<div class="step" id="jupyter-script">
<h2><i class="fas fa-file-code icon"></i> Create Jupyter Notebook Script</h2>
<p>Create a script for starting Jupyter Notebook:</p>
<div class="code-container">
<pre><code class="language-bash">nano start_jupyter.sh</code></pre>
</div>
<p>Paste the following content into the file:</p>
<div class="code-container">
<pre><code class="language-bash">#!/bin/bash
# Get the current IP address
IP=$(hostname -I | awk '{print $1}')
# Start Jupyter Notebook with the current IP address and token
jupyter notebook --no-browser --ip=$IP</code></pre>
</div>
<p>Make the script executable:</p>
<div class="code-container">
<pre><code class="language-bash">chmod +x start_jupyter.sh</code></pre>
</div>
</div>
<!-- Add Aliases to .bashrc Section -->
<div class="step" id="add-aliases">
<h2><i class="fas fa-terminal icon"></i> Add Aliases to .bashrc</h2>
<p>Add aliases for the GPU and Jupyter scripts with this single command:</p>
<div class="code-container">
<pre><code class="language-bash">echo "alias gpu='bash ~/srun_gpu.sh'" >> ~/.bashrc && echo "alias start_jupyter='bash ~/start_jupyter.sh'" >> ~/.bashrc && source ~/.bashrc</code></pre>
</div>
<div class="important-note">
<i class="fas fa-exclamation-circle"></i> <strong>Note:</strong> This command adds both aliases and immediately applies the changes to your current session.
</div>
<p>This command does the following:</p>
<ol>
<li>Adds the 'gpu' alias to your .bashrc file</li>
<li>Adds the 'start_jupyter' alias to your .bashrc file</li>
<li>Reloads your .bashrc file to apply the changes immediately</li>
</ol>
<div class="usage-instructions">
<p>After running this command, you can use the following shortcuts:</p>
<ul>
<li>To start a GPU session: <span class="file-path"> gpu </span></li>
<li>To start Jupyter Notebook: <span class="file-path"> start_jupyter </span> </li>
</ul>
</div>
</div>
<!-- Set Up Conda Environment Section -->
<div class="step" id="conda-env">
<h2><i class="fas fa-cube icon"></i> Set Up Conda Environment</h2>
<p>Follow these steps to create a new Conda environment with PyTorch and Jupyter:</p>
<ol class="setup-steps">
<li>
<p>Create a new Conda environment named 'torch':</p>
<div class="code-container">
<pre><code class="language-bash">conda create -n torch -y</code></pre>
</div>
</li>
<li>
<p>Activate the new environment:</p>
<div class="code-container">
<pre><code class="language-bash">conda activate torch</code></pre>
</div>
</li>
<li>
<p>Install Jupyter in the environment:</p>
<div class="code-container">
<pre><code class="language-bash">conda install jupyter -y</code></pre>
</div>
</li>
<li>
<p>Install PyTorch with CUDA support:</p>
<div class="code-container">
<pre><code class="language-bash">conda install pytorch torchvision torchaudio pytorch-cuda=11.8 -c pytorch -c nvidia</code></pre>
</div>
</li>
</ol>
<p class="pytorch-note"><strong>Note:</strong> The specific version of PyTorch and CUDA may need to be adjusted based on your system requirements and the latest available versions. For the most up-to-date installation instructions, please refer to the <a href="https://pytorch.org/get-started/locally/" target="_blank" rel="noopener noreferrer">official PyTorch installation guide</a>.</p>
<p>After completing the setup, you can use the following commands to activate or deactivate the environment:</p>
<div class="usage-instructions">
<p>To activate the environment:</p>
<div class="code-container">
<pre><code class="language-bash">conda activate torch</code></pre>
</div>
<p>To deactivate the environment when you're done:</p>
<div class="code-container">
<pre><code class="language-bash">conda deactivate</code></pre>
</div>
</div>
</div>
<!-- Using the Setup Section -->
<div class="step" id="using-setup">
<h2><i class="fas fa-play icon"></i> Using the Setup</h2>
<p>To use a GPU:</p>
<div class="code-container">
<pre><code class="language-bash">gpu</code></pre>
</div>
<p>For help with GPU options:</p>
<div class="code-container">
<pre><code class="language-bash">gpu --help</code></pre>
</div>
<p>To start Jupyter Notebook:</p>
<div class="code-container">
<pre><code class="language-bash">start_jupyter</code></pre>
</div>
</div>
</main>
<!-- JavaScript for functionality -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.24.1/prism.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/prism/1.24.1/components/prism-bash.min.js"></script>
<script>
// JavaScript functions
// Use modern JavaScript features and best practices
const copyToClipboard = async (text) => {
try {
await navigator.clipboard.writeText(text);
console.log('Copying to clipboard was successful!');
} catch (err) {
console.error('Could not copy text: ', err);
}
};
const updateProgressBar = () => {
const winScroll = document.documentElement.scrollTop;
const height = document.documentElement.scrollHeight - document.documentElement.clientHeight;
const scrolled = (winScroll / height) * 100;
document.getElementById("progress-bar").style.width = `${scrolled}%`;
};
// Use event delegation for better performance
document.addEventListener('click', (event) => {
if (event.target.classList.contains('copy-button')) {
const codeBlock = event.target.previousElementSibling;
const code = codeBlock.querySelector('code').textContent;