Showing
1 changed file
with
7 additions
and
2 deletions
1 | import torch | 1 | import torch |
2 | import torch.npu | 2 | import torch.npu |
3 | 3 | ||
4 | -x = torch.randn(2, 2).npu() | 4 | +print("NPU available?", torch.npu.is_available()) |
5 | -y = torch.randn(2, 2).npu() | 5 | +print("Current device", torch.npu.current_device()) |
6 | +device = torch.device("npu:0") | ||
7 | +# x = torch.randn(2, 2).npu() | ||
8 | +# y = torch.randn(2, 2).npu() | ||
9 | +x = torch.randn(2, 2).to(device) | ||
10 | +y = torch.randn(2, 2).to(device) | ||
6 | z = x.mm(y) | 11 | z = x.mm(y) |
7 | 12 | ||
8 | print(z) | 13 | print(z) |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
-
Please register or login to post a comment