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!
网友评论