Python/torch:修订间差异
来自康健生活
| 第9行: | 第9行: | ||
print(x) | print(x) | ||
</syntaxhighlight>}} | </syntaxhighlight>}} | ||
开始验证。 | |||
{{Shc_out|<syntaxhighlight lang="bash"> | |||
python3 testtorch.py | |||
</syntaxhighlight>|<syntaxhighlight lang="bash">tensor([[0.2115, 0.1338, 0.1398], | |||
[0.9219, 0.2041, 0.9872], | |||
[0.5002, 0.3102, 0.5110], | |||
[0.0139, 0.3722, 0.8301], | |||
[0.8480, 0.6488, 0.3080]]) | |||
</syntaxhighlight>|$|/home/kangkk}} | |||
是否启用了 CUDA 驱动程序。 | 是否启用了 CUDA 驱动程序。 | ||
{{Hc|testtorchiscuda.py|<syntaxhighlight lang="python"> | {{Hc|testtorchiscuda.py|<syntaxhighlight lang="python"> | ||
import torch | import torch | ||
torch.cuda.is_available() | x = torch.cuda.is_available() | ||
print(x) | |||
</syntaxhighlight>}} | </syntaxhighlight>}} | ||
开始验证。 | |||
{{Shc_out|<syntaxhighlight lang="bash"> | |||
python3 testtorchiscuda.py</syntaxhighlight>|<syntaxhighlight lang="bash"> | |||
</syntaxhighlight>|$|/home/kangkk}} | |||