PyTorch 0.2.1 installation on Windows 10 x64

1. Prerequisite

  • Anaconda (2 or 3)
  • Windows 10 x64
  • CUDA enabled GPU (optional)

2. Installation

2.1 create a conda environment, and specify the python version

conda create -n "pytorch" python=3.5

2.2 install conda package

  • online
conda install -c peterjc123 pytorch
  • offline
    • download installation package (pytorch-0.2.1-py35h24644ff_0.2.1cu80.tar.bz2) from Baidu Cloud corresponding to your python version (3.5) and OS version (Windows 10 x64), and then
    conda install numpy mkl cffi
    conda install --offline /path/to/your/package/pytorch-0.2.1-py35h24644ff_0.2.1cu80.tar.bz2
    

3. Test

# CUDA TEST
import torch
x = torch.Tensor([1.0])
xx = x.cuda()
print(xx)

# CUDNN TEST
from torch.backends import cudnn
print(cudnn.is_acceptable(xx))

4. Troubleshooting

4.1 conda activate deactivate not usable

This is caused by the wrong path in conda.bat activate.bat and deactivate.bat. This path should point to conda.exe, which comes along with anaconda installation.

@echo off
call "/wrong/path/to/conda" %*

You can correct this path according to your installation.

@echo off
call "C:\Program Files\Anaconda2\Scripts\conda" %*

4.2 RuntimeError

RuntimeError: 
        An attempt has been made to start a new process before the
        current process has finished its bootstrapping phase.

        This probably means that you are not using fork to start your
        child processes and you have forgotten to use the proper idiom
        in the main module:

            if __name__ == '__main__':
                freeze_support()
                ...

        The "freeze_support()" line can be omitted if the program
        is not going to be frozen to produce an executable.

Just put your runnable codes into if __name__ == '__main__', and everything will be OK!


Reference

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

推薦閱讀更多精彩內(nèi)容