How to?

pytorch 奇怪报错记录 for grep

Jun 17, 2025
notesjulyfun2506
2 Minutes
357 Words
This article was last updated on May 27, 2026 and some of the information may no longer be applicable due to the passage of time.

pytorch 奇怪报错记录 for grep

25.6.17

1
---------------------------------------------------------------------------
2
RuntimeError Traceback (most recent call last)
3
File /home/julyfun/Documents/GitHub/julyfun/how-to/notes/julyfun/技术学习/diffusion-models-class/unit2-02_class_conditioned_diffusion_model_example.py:3
4
1 # %%
5
2 @run
6
----> 3 def func():
7
4 net = ClassConditionedUnet(num_classes=10).to(device)
8
5 img = torch.randn(3, 1, 28, 28).to(device)
9
10
File ~/Documents/GitHub/julyfun/robotoy/robotoy/ziglike/test.py:58, in run(func)
11
57 def run(func):
12
---> 58 func()
13
14
File /home/julyfun/Documents/GitHub/julyfun/how-to/notes/julyfun/技术学习/diffusion-models-class/unit2-02_class_conditioned_diffusion_model_example.py:4
15
2 @run
51 collapsed lines
16
3 def func():
17
----> 4 net = ClassConditionedUnet(num_classes=10).to(device)
18
5 img = torch.randn(3, 1, 28, 28).to(device)
19
6 cls = torch.tensor([0, 1, 9]).to(device)
20
21
File ~/Documents/GitHub/diffusion-models-class/.venv/lib/python3.10/site-packages/torch/nn/modules/module.py:1355, in Module.to(self, *args, **kwargs)
22
1352 else:
23
1353 raise
24
-> 1355 return self._apply(convert)
25
26
File ~/Documents/GitHub/diffusion-models-class/.venv/lib/python3.10/site-packages/torch/nn/modules/module.py:915, in Module._apply(self, fn, recurse)
27
913 if recurse:
28
914 for module in self.children():
29
--> 915 module._apply(fn)
30
917 def compute_should_use_set_data(tensor, tensor_applied):
31
918 if torch._has_compatible_shallow_copy_type(tensor, tensor_applied):
32
919 # If the new tensor has compatible tensor type as the existing tensor,
33
920 # the current behavior is to change the tensor in-place using `.data =`,
34
(...)
35
925 # global flag to let the user control whether they want the future
36
926 # behavior of overwriting the existing tensor or not.
37
38
File ~/Documents/GitHub/diffusion-models-class/.venv/lib/python3.10/site-packages/torch/nn/modules/module.py:942, in Module._apply(self, fn, recurse)
39
938 # Tensors stored in modules are graph leaves, and we don't want to
40
939 # track autograd history of `param_applied`, so we have to use
41
940 # `with torch.no_grad():`
42
941 with torch.no_grad():
43
--> 942 param_applied = fn(param)
44
943 p_should_use_set_data = compute_should_use_set_data(param, param_applied)
45
945 # subclasses may have multiple child tensors so we need to use swap_tensors
46
47
File ~/Documents/GitHub/diffusion-models-class/.venv/lib/python3.10/site-packages/torch/nn/modules/module.py:1341, in Module.to.<locals>.convert(t)
48
1334 if convert_to_format is not None and t.dim() in (4, 5):
49
1335 return t.to(
50
1336 device,
51
1337 dtype if t.is_floating_point() or t.is_complex() else None,
52
1338 non_blocking,
53
1339 memory_format=convert_to_format,
54
1340 )
55
-> 1341 return t.to(
56
1342 device,
57
1343 dtype if t.is_floating_point() or t.is_complex() else None,
58
1344 non_blocking,
59
1345 )
60
1346 except NotImplementedError as e:
61
1347 if str(e) == "Cannot copy out of meta tensor; no data!":
62
63
RuntimeError: CUDA error: device-side assert triggered
64
CUDA kernel errors might be asynchronously reported at some other API call, so the stacktrace below might be incorrect.
65
For debugging consider passing CUDA_LAUNCH_BLOCKING=1
66
Compile with `TORCH_USE_CUDA_DSA` to enable device-side assertions.
  • context see above.
  • [ok, but why] 重启 kernel 运行就没问题了.
Article title:pytorch 奇怪报错记录 for grep
Article author:Julyfun
Release time:Jun 17, 2025
Copyright 2026
Sitemap