在Anaconda Prompt输入conda install pytorch cuda91 -c pytorch
(注意:python2.7 不支持pytorch, 需升级到python3.5以上。
需激活python3.6 环境,输入conda activate 3point6
还需要安装CUDA,这里cuda版本为9.1,这里是window系统)
显示如下:
(3point6) C:\Users\jinlong>conda install pytorch cuda91 -c pytorch
Solving environment: done
==> WARNING: A newer version of conda exists. <==
current version: 4.4.10
latest version: 4.5.4
Please update conda by running
$ conda update -n base conda
## Package Plan ##
environment location: C:\Users\jinlong\Anaconda2\envs\3point6
added / updated specs:
– cuda91
– pytorch
The following packages will be downloaded:
package | build
—————————|—————–
blas-1.0 | mkl 6 KB
pytorch-0.4.0 |py36_cuda91_cudnn7he774522_1 546.4 MB pytorch
mkl_fft-1.0.1 | py36h452e1ab_0 113 KB
intel-openmp-2018.0.3 | 0 1.7 MB
mkl-2018.0.3 | 1 178.1 MB
mkl_random-1.0.1 | py36h9258bd6_0 267 KB
pycparser-2.18 | py36hd053e01_1 169 KB
cffi-1.11.5 | py36h945400d_0 213 KB
cuda91-1.0 | 0 2 KB pytorch
numpy-base-1.14.3 | py36h5c71026_2 3.8 MB
numpy-1.14.3 | py36h9fa60d3_2 42 KB
————————————————————
Total: 730.8 MB
The following NEW packages will be INSTALLED:
blas: 1.0-mkl
cffi: 1.11.5-py36h945400d_0
cuda91: 1.0-0 pytorch
icc_rt: 2017.0.4-h97af966_0
intel-openmp: 2018.0.3-0
mkl: 2018.0.3-1
mkl_fft: 1.0.1-py36h452e1ab_0
mkl_random: 1.0.1-py36h9258bd6_0
numpy: 1.14.3-py36h9fa60d3_2
numpy-base: 1.14.3-py36h5c71026_2
pycparser: 2.18-py36hd053e01_1
pytorch: 0.4.0-py36_cuda91_cudnn7he774522_1 pytorch [cuda91]
Proceed ([y]/n)? y
Downloading and Extracting Packages
blas 1.0: ##################################################################################################### | 100%
pytorch 0.4.0: ################################################################################################ | 100%
mkl_fft 1.0.1: ################################################################################################ | 100%
intel-openmp 2018.0.3: ######################################################################################## | 100%
mkl 2018.0.3: ################################################################################################# | 100%
mkl_random 1.0.1: ############################################################################################# | 100%
pycparser 2.18: ############################################################################################### | 100%
cffi 1.11.5: ################################################################################################## | 100%
cuda91 1.0: ################################################################################################### | 100%
numpy-base 1.14.3: ############################################################################################ | 100%
numpy 1.14.3: ################################################################################################# | 100%
Preparing transaction: done
Verifying transaction: done
Executing transaction: done
(3point6) C:\Users\jinlong>
安装torchvision,在Anaconda Prompt输入pip3 install torchvision
(注意:如果不行试用pip install torchvision)
显示如下:
(3point6) C:\Users\jinlong>pip install torchvision
Collecting torchvision
Downloading https://files.pythonhosted.org/packages/ca/0d/f00b2885711e08bd71242ebe7b96561e6f6d01fdb4b9dcf4d37e2e13c5e1/torchvision-0.2.1-py2.py3-none-any.whl (54kB)
100% |████████████████████████████████| 61kB 1.3MB/s
Collecting pillow>=4.1.1 (from torchvision)
Downloading https://files.pythonhosted.org/packages/a4/86/283719dac6309cf483452abb09759be9b2c0974435ed608dc67949127e13/Pillow-5.1.0-cp36-cp36m-win_amd64.whl (1.6MB)
100% |████████████████████████████████| 1.6MB 1.9MB/s
Requirement already satisfied: torch in c:\users\jinlong\anaconda2\envs\3point6\lib\site-packages (from torchvision) (0.4.0)
Requirement already satisfied: numpy in c:\users\jinlong\anaconda2\envs\3point6\lib\site-packages (from torchvision) (1.14.3)
Collecting six (from torchvision)
mkl-random 1.0.1 requires cython, which is not installed.
mkl-fft 1.0.0 requires cython, which is not installed.
Installing collected packages: pillow, six, torchvision
Successfully installed pillow-5.1.0 six-1.11.0 torchvision-0.2.1
安装cython,在Anaconda Prompt输入pip install cython
显示如下:
(3point6) C:\Users\jinlong>pip install cython
Collecting cython
Downloading https://files.pythonhosted.org/packages/e6/38/6065465361fec313f2a694532e8b66a2fcae39e646bd045f2f6f7376bf1a/Cython-0.28.3-cp36-cp36m-win_amd64.whl (2.5MB)
100% |████████████████████████████████| 2.5MB 3.3MB/s
Installing collected packages: cython
Successfully installed cython-0.28.3
(3point6) C:\Users\jinlong>pip install torchvision
Requirement already satisfied: torchvision in c:\users\jinlong\anaconda2\envs\3point6\lib\site-packages (0.2.1)
Requirement already satisfied: pillow>=4.1.1 in c:\users\jinlong\anaconda2\envs\3point6\lib\site-packages (from torchvision) (5.1.0)
Requirement already satisfied: torch in c:\users\jinlong\anaconda2\envs\3point6\lib\site-packages (from torchvision) (0.4.0)
Requirement already satisfied: six in c:\users\jinlong\anaconda2\envs\3point6\lib\site-packages (from torchvision) (1.11.0)
Requirement already satisfied: numpy in c:\users\jinlong\anaconda2\envs\3point6\lib\site-packages (from torchvision) (1.14.3)
(3point6) C:\Users\jinlong>