Skip to content

Commit ab42bd4

Browse files
authored
More robust pre-loading of Python Nvidia nvrtc. (#51)
1 parent 1966258 commit ab42bd4

File tree

1 file changed

+7
-5
lines changed

1 file changed

+7
-5
lines changed

src/bridge/gs_madrona/renderer_gs.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import os
22
import ctypes
3+
from importlib.metadata import distribution, PackageNotFoundError
34
from pathlib import Path
45
from typing import Tuple
56

@@ -62,11 +63,12 @@ def __init__(
6263

6364
# Preload Nvidia compiler runtime if available (i.e. torch is not built from source)
6465
try:
65-
import nvidia.cuda_nvrtc
66-
nvrtc_dir = Path(nvidia.cuda_nvrtc.__file__).parent.absolute()
67-
libnvrtc_path, *_ = filter(Path.is_file, (nvrtc_dir / "lib").glob("libnvrtc.so.1*"))
68-
ctypes.CDLL(libnvrtc_path, ctypes.RTLD_LOCAL)
69-
except ImportError:
66+
dist = distribution("nvidia_cuda_nvrtc_cu12")
67+
for file in dist.files:
68+
if file.name.startswith("libnvrtc.so.1"):
69+
ctypes.CDLL(dist.locate_file(file), ctypes.RTLD_LOCAL)
70+
break
71+
except PackageNotFoundError:
7072
pass
7173

7274
self.madrona = MadronaBatchRenderer(

0 commit comments

Comments
 (0)