Python2.7
$ python2 -m virtualenv pytorchenv
$ source pytorchenv/bin/activate
$ pip install ipython
pytorch v1.3.0 # CUDA 10.0
$ pip install torch==1.3.0+cu100 torchvision==0.4.1+cu100 -f https://download.pytorch.org/whl/torch_stable.html
........................................................................................................................
Downloading https://download.pytorch.org/whl/cu100/torch-1.3.0%2Bcu100-cp27-cp27mu-linux_x86_64.whl (744.5MB)
Downloading https://download.pytorch.org/whl/cu100/torchvision-0.4.1%2Bcu100-cp27-cp27mu-linux_x86_64.whl (10.1MB)
......................................................................................................................
$ pip install ipython
或打开pycharm
====输入例子====
import torch as t
x = t.rand(5,3)
y = t.rand(5,3)
if t.cuda.is_available():
x = x.cuda()
y = y.cuda()
print(x+y)
=====有结果代表成功====
crowdcount-mcnn人群计数https://github.com/svishwa/crowdcount-mcnn,需要额外安装依赖:
pip2 install pandas
pip2 install opencv-python
pip2 install h5py
注意修改train.py代码:
# train_loss += loss.data[0] is pytorch0.3.1 codes, and >pytorch0.5 is error.
train_loss += loss.item()
原文地址:https://www.cnblogs.com/jeshy/p/11747847.html