Fix for Nvidia Passthrough (#166)
* Fix Nvidia Passthrough closing #127 * Mount libraries parent directory * Use the dynamic library path from the existing code
This commit is contained in:
parent
bc8284edb8
commit
525992727a
30
jlmkr.py
30
jlmkr.py
|
@ -4,7 +4,7 @@
|
||||||
with full access to all files via bind mounts, \
|
with full access to all files via bind mounts, \
|
||||||
thanks to systemd-nspawn!"""
|
thanks to systemd-nspawn!"""
|
||||||
|
|
||||||
__version__ = "1.4.0"
|
__version__ = "1.4.1"
|
||||||
|
|
||||||
__disclaimer__ = """USE THIS SCRIPT AT YOUR OWN RISK!
|
__disclaimer__ = """USE THIS SCRIPT AT YOUR OWN RISK!
|
||||||
IT COMES WITHOUT WARRANTY AND IS NOT SUPPORTED BY IXSYSTEMS."""
|
IT COMES WITHOUT WARRANTY AND IS NOT SUPPORTED BY IXSYSTEMS."""
|
||||||
|
@ -44,7 +44,7 @@ docker_compatible=0
|
||||||
seccomp=1
|
seccomp=1
|
||||||
|
|
||||||
# Below you may add additional systemd-nspawn flags behind systemd_nspawn_user_args=
|
# Below you may add additional systemd-nspawn flags behind systemd_nspawn_user_args=
|
||||||
# To mount host storage in the jail, you may add: --bind='/mnt/pool/dataset:/home'
|
# To mount host storage in the jail, you may add: --bind='/mnt/pool/dataset:/home'
|
||||||
# To readonly mount host storage, you may add: --bind-ro=/etc/certificates
|
# To readonly mount host storage, you may add: --bind-ro=/etc/certificates
|
||||||
# To use macvlan networking add: --network-macvlan=eno1 --resolv-conf=bind-host
|
# To use macvlan networking add: --network-macvlan=eno1 --resolv-conf=bind-host
|
||||||
# To use bridge networking add: --network-bridge=br1 --resolv-conf=bind-host
|
# To use bridge networking add: --network-bridge=br1 --resolv-conf=bind-host
|
||||||
|
@ -353,6 +353,17 @@ def passthrough_nvidia(
|
||||||
return
|
return
|
||||||
|
|
||||||
try:
|
try:
|
||||||
|
# Get list of libraries
|
||||||
|
nvidia_libraries = set(
|
||||||
|
[
|
||||||
|
x
|
||||||
|
for x in subprocess.check_output(["nvidia-container-cli", "list", "--libraries"])
|
||||||
|
.decode()
|
||||||
|
.split("\n")
|
||||||
|
if x
|
||||||
|
]
|
||||||
|
)
|
||||||
|
# Get full list of files, but excluding library ones from above
|
||||||
nvidia_files = set(
|
nvidia_files = set(
|
||||||
(
|
(
|
||||||
[
|
[
|
||||||
|
@ -361,6 +372,7 @@ def passthrough_nvidia(
|
||||||
.decode()
|
.decode()
|
||||||
.split("\n")
|
.split("\n")
|
||||||
if x
|
if x
|
||||||
|
and x not in nvidia_libraries
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -393,16 +405,10 @@ def passthrough_nvidia(
|
||||||
|
|
||||||
# Check if the parent dir exists where we want to write our conf file
|
# Check if the parent dir exists where we want to write our conf file
|
||||||
if ld_so_conf_path.parent.exists():
|
if ld_so_conf_path.parent.exists():
|
||||||
nvidia_libraries = set(
|
library_folders = set(str(Path(x).parent) for x in nvidia_libraries)
|
||||||
Path(x)
|
# Add the library folders as mounts
|
||||||
for x in subprocess.check_output(
|
for lf in library_folders:
|
||||||
["nvidia-container-cli", "list", "--libraries"]
|
nvidia_mounts.append(f"--bind-ro={lf}")
|
||||||
)
|
|
||||||
.decode()
|
|
||||||
.split("\n")
|
|
||||||
if x
|
|
||||||
)
|
|
||||||
library_folders = set(str(x.parent) for x in nvidia_libraries)
|
|
||||||
|
|
||||||
# Only write if the conf file doesn't yet exist or has different contents
|
# Only write if the conf file doesn't yet exist or has different contents
|
||||||
existing_conf_libraries = set()
|
existing_conf_libraries = set()
|
||||||
|
|
Loading…
Reference in New Issue