TX2+python+pytorch install

Installing PyTorch on TX2
Trying to install PyTorch on the TX2 for Python3.5 is a bit of a mess since you need to build from source. If you're using Python2.7 or Python3.6, NVIDIA has been kind enough to provide wheels that you can install from. I briefly mention this process and include the wheels in this repository.

However, for the TX2, sadly it isn't this simple. We need to build PyTorch from source, and the latest branch of PyTorch has trouble trying to build without NCCL.

For now, I recommend using a previous version of PyTorch such as 0.4.1 or 0.5.0.

git clone http://github.com/pytorch/pytorch
git checkout 0.4.1
cd pytorch
git submodule update --init
sudo pip install -U setuptools
sudo pip install -r requirements.txt
#python setup.py build_deps
sudo python setup.py develop
sudo python setup.py install
After this, you should be able to import torch and run some basic commands to verify that it's working.

python3
import torch
print(torch.__version__)
print(torch.cuda.is_available())
Additionally, you will most likely need TorchVision for your project, which can be installed in a slightly easier manner:

pip3 install --no-deps torchvision

//
# 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    #failed
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).zero_()
# print(a)
# b = torch.randn(2).cuda()
# print(b)
# c = a + b
# print(c)

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章