This repository was archived by the owner on Nov 1, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Expand file tree Collapse file tree 1 file changed +14
-0
lines changed Original file line number Diff line number Diff line change 8
8
9
9
#include < ATen/Context.h>
10
10
#include < ATen/Tensor.h>
11
+ #include < torch/torch.h>
12
+ #if TORCH_VERSION_MAJOR >= 2 && TORCH_VERSION_MINOR>=3
13
+ #include < torch/csrc/utils/device_lazy_init.h>
14
+ #else
11
15
#include < torch/csrc/utils/cuda_lazy_init.h>
16
+ #endif
12
17
#include < torch/csrc/utils/pybind.h>
13
18
#include < torchdistx/fake.h>
14
19
@@ -22,7 +27,12 @@ void pyEnterFakeMode(bool fake_cuda) {
22
27
// subsystem which would fail and prevent us from instantiating CUDA devices.
23
28
if (fake_cuda) {
24
29
if (!at::hasCUDA ()) {
30
+
31
+ #if TORCH_VERSION_MAJOR >= 2 && TORCH_VERSION_MINOR>=3
32
+ torch::utils::set_requires_device_init (at::kCUDA , false );
33
+ #else
25
34
torch::utils::set_requires_cuda_init (false );
35
+ #endif
26
36
}
27
37
}
28
38
}
@@ -31,7 +41,11 @@ void pyLeaveFakeMode() {
31
41
leaveFakeMode ();
32
42
33
43
if (!isFakeModeActive () && !at::hasCUDA ()) {
44
+ #if TORCH_VERSION_MAJOR >= 2 && TORCH_VERSION_MINOR>=3
45
+ torch::utils::set_requires_device_init (at::kCUDA , true );
46
+ #else
34
47
torch::utils::set_requires_cuda_init (true );
48
+ #endif
35
49
}
36
50
}
37
51
You can’t perform that action at this time.
0 commit comments