1. 测试
#!/usr/bin/python3
import torch
print(torch.__version__)
print("gpu:", torch.cuda.is_available())
显示如下
Traceback (most recent call last): ? File "/home/sng/Desktop/c++_practices/pytorch_practice/pytorch_install_test.py", line 4, in <module> ? ? print(torch._version_) AttributeError: module 'torch' has no attribute '_version_'
[Done] exited with code=1 in 0.297 seconds
2. 修改
#!/usr/bin/python3
import torch
print(torch.version.__version__)
print("gpu:", torch.cuda.is_available())
结果显示:
[Running] /usr/bin/python3 "/home/sng/Desktop/c++_practices/pytorch_practice/pytorch_install_test.py" 1.2.0 gpu: True
[Done] exited with code=0 in 0.287 seconds
|