Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
H
HPCasCode
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hpc-team
HPCasCode
Commits
9edcabac
Commit
9edcabac
authored
7 years ago
by
Jafar Lie
Browse files
Options
Downloads
Patches
Plain Diff
added gpu role to generate combinations of xorg.conf
Former-commit-id:
5848d88f
parent
eb630616
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
roles/gpu/files/scripts/nvidia-xconf-gen.py
+102
-0
102 additions, 0 deletions
roles/gpu/files/scripts/nvidia-xconf-gen.py
roles/gpu/tasks/main.yml
+20
-5
20 additions, 5 deletions
roles/gpu/tasks/main.yml
roles/gpu/templates/xorg.conf.j2
+36
-16
36 additions, 16 deletions
roles/gpu/templates/xorg.conf.j2
with
158 additions
and
21 deletions
roles/gpu/files/scripts/nvidia-xconf-gen.py
0 → 100755
+
102
−
0
View file @
9edcabac
#!/usr/bin/env python
from
jinja2
import
Template
import
itertools
import
subprocess
import
datetime
import
os
import
sys
import
time
import
socket
from
subprocess
import
call
import
re
import
json
def
grab_card_ids
():
# This method runs nvidia-smi to grab the card ids, then returns a list
if
not
os
.
path
.
isfile
(
"
/bin/nvidia-smi
"
):
print
(
"
nvidia-smi binary not found!
"
)
exit
(
1
)
cmd
=
[
"
/bin/nvidia-smi
"
,
"
--query-gpu=pci.bus_id
"
,
"
--format=csv,noheader
"
]
p
=
subprocess
.
Popen
(
cmd
,
shell
=
False
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
STDOUT
)
cards
=
[]
for
line
in
p
.
stdout
.
readlines
():
line
=
line
.
rstrip
().
split
(
"
:
"
)[
2
]
pcibus_num
=
int
(
re
.
sub
(
'
[.:]
'
,
''
,
line
).
rstrip
(
"
0
"
),
16
)
card
=
"
PCI:0:{}:0
"
.
format
(
str
(
pcibus_num
))
cards
.
append
(
card
)
return
cards
def
grab_card_boardname
():
if
not
os
.
path
.
isfile
(
"
/bin/nvidia-smi
"
):
print
(
"
nvidia-smi binary not found!
"
)
exit
(
1
)
cmd
=
[
"
/bin/nvidia-smi
"
,
"
--query-gpu=name
"
,
"
--format=csv,noheader
"
]
cards
=
[]
p
=
subprocess
.
Popen
(
cmd
,
shell
=
False
,
stdout
=
subprocess
.
PIPE
,
stderr
=
subprocess
.
STDOUT
)
for
line
in
p
.
stdout
.
readlines
():
line
=
line
.
rstrip
()
cards
.
append
(
line
)
return
cards
def
write_xorg_conf
(
cards
):
num_of_cards
=
len
(
cards
)
+
1
boardname
=
(
grab_card_boardname
())[
0
]
gpus
=
[]
for
i
in
range
(
1
,
num_of_cards
):
monitors
=
[]
screens
=
[]
res
=
list
(
itertools
.
combinations
(
cards
,
i
))
for
j
in
range
(
i
):
monitors
.
append
(
"
Monitor
"
+
str
(
j
))
screens
.
append
(
"
Screen
"
+
str
(
j
))
for
card
in
res
:
filename
=
"
/etc/X11/xorg.conf.
"
+
str
(
i
)
+
str
(
res
.
index
(
card
))
#gpus[filename] = filename
gpus
.
append
({
'
filename
'
:
filename
,
'
boardname
'
:
boardname
,
'
monitors
'
:
monitors
,
'
screens
'
:
screens
,
'
devices
'
:
card
})
print
(
json
.
dumps
(
gpus
))
if
__name__
==
"
__main__
"
:
# cards = grab_card_ids()
# write_xorg_conf(cards)
cards
=
grab_card_ids
()
write_xorg_conf
(
cards
)
'''
with open(
"
xorgconftest.j2
"
) as f:
template = Template(f.read())
num_of_monitors = 2
monitors = []
screens = []
busid = [
"
PCI:0:6:0
"
,
"
PCI:0:7:0
"
,
"
PCI:0:8:0
"
,
"
PCI:0:9:0
"
]
for i in range(num_of_monitors):
monitors.append(
"
Monitor
"
+ str(i))
screens.append(
"
Screen
"
+ str(i))
#output = template.render(monitors=monitors,devices=busid)
#print(output)
res = itertools.combinations(busid,2)
listres = list(res)
for i in listres:
output = template.render(monitors=monitors,devices=i,screens=screens)
filename =
"
xorg.conf.
"
+ str(listres.index(i))
print(filename)
f = open(filename,
"
w
"
)
f.write(output)
f.close()
'''
This diff is collapsed.
Click to expand it.
roles/gpu/tasks/main.yml
+
20
−
5
View file @
9edcabac
...
...
@@ -142,8 +142,23 @@
args
:
creates
:
/etc/X11/xorg.conf
-
name
:
Template xorg.conf for nodes with one GPU
template
:
src=xorg.conf.j2 dest=/etc/X11/xorg.conf
become
:
true
become_user
:
root
when
:
template_xorgconf is defined and template_xorgconf
#- name: Template xorg.conf for nodes with one GPU
# template: src=xorg.conf.j2 dest=/etc/X11/xorg.conf
# become: true
# become_user: root
# when: template_xorgconf is defined and template_xorgcon
-
name
:
run nvidia-xconf-gen
script
:
scripts/nvidia-xconf-gen.py
register
:
nvidiacards
-
name
:
set env for nvidia_card_lists
set_fact
:
nvidiacardslist
:
"
{{
nvidiacards.stdout
|
from_json
}}"
-
name
:
generate nvidia-xorg-conf
sudo
:
true
template
:
src
:
xorg.conf.j2
dest
:
"
{{
item['filename']
}}"
with_items
:
"
{{
nvidiacardslist
}}"
This diff is collapsed.
Click to expand it.
roles/gpu/templates/xorg.conf.j2
+
36
−
16
View file @
9edcabac
# nvidia-xconfig: X configuration file generated by nvidia-xconfig
# nvidia-xconfig: version 352.93 (buildmeister@swio-display-x86-rhel47-07) Tue Apr 5 18:55:28 PDT 2016
# nvidia-xconfig: version 375.66 (buildmeister@swio-display-x86-rhel47-06) Mon May 1 15:45:32 PDT 2017
Section "DRI"
Mode 0666
EndSection
Section "ServerLayout"
Identifier "Layout0"
Screen 0 "Screen0"
InputDevice "Keyboard0" "CoreKeyboard"
InputDevice "Mouse0" "CorePointer"
#InputDevice "Keyboard0" "CoreKeyboard"
#InputDevice "Mouse0" "CorePointer"
Identifier "Layout0"
{% for screen in item.screens -%}
{% if item.screens.index(screen) == 0 -%}
Screen 0 "Screen{{item.screens.index(screen)}}"
{%-else %}
Screen {{item.screens.index(screen)}} "Screen{{item.screens.index(screen)}}" Right Of "Screen{{item.screens.index(screen)-1}}"
{%- endif -%}
{%- endfor %}
#InputDevice "Keyboard0" "CoreKeyboard"
#InputDevice "Mouse0" "CorePointer"
EndSection
Section "Files"
...
...
@@ -13,6 +25,7 @@ Section "Files"
EndSection
Section "InputDevice"
# generated from default
Identifier "Mouse0"
Driver "mouse"
...
...
@@ -23,36 +36,43 @@ Section "InputDevice"
EndSection
Section "InputDevice"
# generated from default
Identifier "Keyboard0"
Driver "kbd"
EndSection
{% for monitor in item.monitors %}
Section "Monitor"
Identifier "
M
onitor
0
"
Identifier "
{{m
onitor
}}
"
VendorName "Unknown"
ModelName "Unknown"
HorizSync 28.0 - 33.0
VertRefresh 43.0 - 72.0
Option "DPMS"
EndSection
{% endfor %}
{% for device in item.devices %}
Section "Device"
Identifier "Device
0
"
Identifier "Device
{{item.devices.index(device)}}
"
Driver "nvidia"
VendorName "NVIDIA Corporation"
B
oard
N
ame "
GRID K1
"
BusID "
PCI:0:6:0
"
b
oard
n
ame "
{{item.boardname}}
"
BusID "
{{device}}
"
EndSection
{% endfor %}
{% for screen in item.screens %}
Section "Screen"
Identifier "Screen
0
"
Device "Device
0
"
Monitor "Monitor
0
"
Identifier "Screen
{{item.screens.index(screen)}}
"
Device "Device
{{item.screens.index(screen)}}
"
Monitor "Monitor
{{item.screens.index(screen)}}
"
DefaultDepth 24
Option "UseDisplayDevice" "none"
Option "UseDisplayDevice" "None"
Option "ProbeAllGpus" "false"
SubSection "Display"
Virtual 1920 1200
Depth 24
EndSubSection
EndSection
{% endfor -%}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment