Skip to content

Commit f903d98

Browse files
authored
Add @functools.lru_cache decorator for get_binding_version() (#512)
>>> 35.381859/0.004149 8527.804049168473 $ git stash $ python test_slowness.py 100000 driver.cuDriverGetVersion() 12060 cuda_utils.get_binding_version() (12, 8) driver.cuDriverGetVersion() 0.023946 seconds for 100000 iterations 0.24 µs per call cuda_utils.get_binding_version() 35.381859 seconds for 100000 iterations 353.82 µs per call $ git stash pop $ python test_slowness.py 100000 driver.cuDriverGetVersion() 12060 cuda_utils.get_binding_version() (12, 8) driver.cuDriverGetVersion() 0.022644 seconds for 100000 iterations 0.23 µs per call cuda_utils.get_binding_version() 0.004149 seconds for 100000 iterations 0.04 µs per call
1 parent 8cda903 commit f903d98

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

cuda_core/cuda/core/experimental/_utils/cuda_utils.py

+1
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,7 @@ def is_nested_sequence(obj):
182182
return is_sequence(obj) and any(is_sequence(elem) for elem in obj)
183183

184184

185+
@functools.lru_cache
185186
def get_binding_version():
186187
try:
187188
major_minor = importlib.metadata.version("cuda-bindings").split(".")[:2]

0 commit comments

Comments
 (0)