We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent d450895 commit c6381c6Copy full SHA for c6381c6
torch/cuda/__init__.py
@@ -122,6 +122,19 @@ class DeferredCudaCallError(Exception):
122
pass
123
124
125
+def init():
126
+ """Initialize PyTorch's CUDA state. You may need to call
127
+ this explicitly if you are interacting with PyTorch via
128
+ its C API, as Python bindings for CUDA functionality will not
129
+ be until this initialization takes place. Ordinary users
130
+ should not need this, as all of PyTorch's CUDA methods
131
+ automatically initialize CUDA state on-demand.
132
+
133
+ Does nothing if the CUDA state is already initialized.
134
+ """
135
+ _lazy_init()
136
137
138
def _lazy_init():
139
global _initialized, _cudart, _original_pid, _queued_calls
140
if _initialized:
0 commit comments