Turbot-DL入门教程篇-深度学习框架pyTorch安装
说明:
介绍如果在Turbot-DL安装深度学习框架pyTorch
步骤:
新建安装脚本:
mkdir -p ~/dl/pytorch cd ~/dl/pytorch sudo vim pytorch_jetson_install.sh
内容如下:
#!/bin/bash # # pyTorch install script for NVIDIA Jetson TX1/TX2, # from a fresh flashing of JetPack 2.3.1 / JetPack 3.0 # # note: pyTorch documentation calls for use of Anaconda, # however Anaconda isn't available for aarch64. # Instead, we install directly from source using setup.py sudo apt-get install python-pip # upgrade pip pip install -U pip pip --version # pip 9.0.1 from /home/ubuntu/.local/lib/python2.7/site-packages (python 2.7) # clone pyTorch repo git clone http://github.com/pytorch/pytorch cd pytorch # install prereqs sudo pip install -U setuptools sudo pip install -r requirements.txt # Develop Mode: python setup.py build_deps sudo python setup.py develop # Install Mode: (substitute for Develop Mode commands) #sudo python setup.py install # Verify CUDA (from python interactive terminal) # 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)
测试:
新建文件
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)
执行结果:
python 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
- 本文固定链接: http://rosrobot.cn/?id=253
- 转载请注明: znjrobot 于 北京智能佳科技有限公司 发表
《本文》有 0 条评论