Python/torch:修订间差异
来自康健生活
创建页面,内容为“== 引言 == {{shc|<syntaxhighlight lang="bash"> pip3 install torch</syntaxhighlight>|$|/home/kangkk}}” |
|||
| 第1行: | 第1行: | ||
== 引言 == | == 引言 == | ||
== 安装 == | |||
{{shc|<syntaxhighlight lang="bash"> | {{shc|<syntaxhighlight lang="bash"> | ||
pip3 install torch</syntaxhighlight>|$|/home/kangkk}} | pip3 install torch</syntaxhighlight>|$|/home/kangkk}} | ||
=== 验证 === | |||
{{Hc|testtorch.py|<syntaxhighlight lang="python"> | |||
import torch | |||
x = torch.rand(5, 3) | |||
print(x) | |||
</syntaxhighlight>}} | |||
是否启用了 CUDA 驱动程序。 | |||
{{Hc|testtorchiscuda.py|<syntaxhighlight lang="python"> | |||
import torch | |||
torch.cuda.is_available() | |||
</syntaxhighlight>}} | |||