< >
Home » Turbot-DL入门教程 » Turbot-DL入门教程篇-深度学习框架pyTorch验证例子

Turbot-DL入门教程篇-深度学习框架pyTorch验证例子

Turbot-DL入门教程篇-深度学习框架pyTorch验证例子

说明:

  • 介绍如果在Turbot-DL深度学习框架pyTorch验证例子

环境:

  • Python 3.5.2

确认版本:

  • 确认目前的版本
$ python3 -V
  • 如果不是Python3.5.2版本,则切换版本
$ sudo update-alternatives --config python3

There are 2 choices for the alternative python3 (providing /usr/bin/python3).

  Selection    Path                Priority   Status
------------------------------------------------------------
* 0            /usr/bin/python3.6   2         auto mode
  1            /usr/bin/python3.5   1         manual mode
  2            /usr/bin/python3.6   2         manual mode

Press <enter> to keep the current choice[*], or type selection number: 1
  • 验证
$ python3 -V

Python 3.5.2

测试:

  • 新建文件
vim test.py
  • 内容如下:
import torch
print(torch.cuda.is_available())
a = torch.cuda.FloatTensor(2)
print(a)
b = torch.randn(2).cuda()
print(b)
c = a + b
print(c)
  • 执行结果:
python3  test.py
  • 输出:
True


 0
 0
[torch.cuda.FloatTensor of size 2 (GPU 0)]


 0.6851
-0.3392
[torch.cuda.FloatTensor of size 2 (GPU 0)]


 0.6851
-0.3392
[torch.cuda.FloatTensor of size 2 (GPU 0)]

参考:

  • https://gist.github.com/dusty-nv/ef2b372301c00c0a9d3203e42fd83426

纠错,疑问,交流: 请进入讨论区点击加入Q群

获取最新文章: 扫一扫右上角的二维码加入“创客智造”公众号


标签: turbot-dl入门教程篇