File tree Expand file tree Collapse file tree 1 file changed +24
-2
lines changed
bindings/torch/tinycudann Expand file tree Collapse file tree 1 file changed +24
-2
lines changed Original file line number Diff line number Diff line change 99import gc
1010import importlib
1111import os
12+ import tempfile
1213import warnings
1314
1415import torch
@@ -72,15 +73,36 @@ def _get_system_compute_capability():
7273
7374# _C.set_log_callback(_log)
7475
76+ def rtc_set_cache_dir (dir ):
77+ if not dir :
78+ _C .rtc_set_cache_dir ('' )
79+ return
80+
81+ if not os .path .isdir (dir ):
82+ raise OSError (f"Missing RTC cache directory { dir } " )
83+
84+ # check write permission
85+ try :
86+ with tempfile .TemporaryFile (dir = dir ):
87+ pass
88+ except OSError as err :
89+ raise OSError (f"Invalid RTC cache directory { dir } " ) from err
90+
91+ # `str` to handle pathlib.Path objects
92+ _C .rtc_set_cache_dir (str (dir ))
93+
7594# Set up JIT runtime compilation
7695_rtc_dir = os .path .join (os .path .dirname (__file__ ), "rtc" )
7796
7897_rtc_include_dir = os .path .join (_rtc_dir , "include" )
7998_C .rtc_set_include_dir (_rtc_include_dir )
8099
81100_rtc_cache_dir = os .path .join (_rtc_dir , "cache" )
82- os .makedirs (_rtc_cache_dir , exist_ok = True )
83- _C .rtc_set_cache_dir (_rtc_cache_dir )
101+ try :
102+ os .makedirs (_rtc_cache_dir , exist_ok = True )
103+ rtc_set_cache_dir (_rtc_cache_dir )
104+ except OSError :
105+ pass
84106
85107def _torch_precision (tcnn_precision ):
86108 if tcnn_precision == _C .Precision .Fp16 :
You can’t perform that action at this time.
0 commit comments