pip install --upgrade --force-reinstall http://download.pytorch.org/whl/cu80/torch-0.2.0.post3-cp27-cp27mu-manylinux1_x86_64.whl
后面這個可以自己到官網(wǎng)上找自己對應的python和cuda版本的安裝包,官網(wǎng)為鏈接:
conda install pytorch torchvision cuda80 -c soumith
這里可以根據(jù)自己cuda版本確定。查看cuda版本,在python命令行里面輸入:
import torch torch.version.cuda
即可。
補充:關于win10環(huán)境下在使用torch調用cuda()失敗的原因
看了無數(shù)篇博客都是牛頭不對馬嘴,忙活了半天才搞清楚
如果大家在用torch的過程中看見這樣的錯誤。。。。淡定,不是你的問題,也不是代碼問題。。。是破win10的原因
只需要在代碼前面加上
torch.cuda.current_device() torch.cuda._initialized = True
就可以正常訓練了。。。心累啊