第一步:anconda的安装,大家可以参考以下博文,写的比较简约,看起来比较清爽
https://blog.csdn.net/ITLearnHall/article/details/81708148
Anacond的介绍
Anaconda指的是一个开源的Python发行版本,其包含了conda、Python等180多个科学包及其依赖项。 因为包含了大量的科学包,Anaconda 的下载文件比较大(约 531 MB),如果只需要某些包,或者需要节省带宽或存储空间,也可以使用Miniconda这个较小的发行版(仅包含conda和 Python)。
Conda是一个开源的包、环境管理器,可以用于在同一个机器上安装不同版本的软件包及其依赖,并能够在不同的环境之间切换
Anaconda包括Conda、Python以及一大堆安装好的工具包,比如:numpy、pandas等
Miniconda包括Conda、Python
第二步,使用conda来安装pytorch
登录pytorch的官网,然后选择和自己电脑配置以下的信息,会自动生成的对应conda命令
https://pytorch.org/get-started/locally/
其中因为我没有Gpu所以选择的是none cuda,py build最好是选择的稳定版,防止运行时候有问题
conda install pytorch-cpu torchvision-cpu -c pytorch
安装命令后,就会出来对应的说明
在proceed后选择y进行安装 ,第一遍 pytorch-cpu-1.0.1 下载一直卡着,于是重新run了一下命令,可以正常下载,但是提示用户没有写目录的权限。这个以管理员身份再启动一下prompt即可解决
ARNING: The conda.compat module is deprecated and will be removed in a future release.
Collecting package metadata: done
Solving environment: done
## Package Plan ##
environment location: C:\ProgramData\Anaconda3
added / updated specs:
- pytorch-cpu
- torchvision-cpu
The following packages will be downloaded:
package | build
---------------------------|-----------------
conda-4.6.12 | py37_1 2.1 MB
ninja-1.9.0 | py37h74a9793_0 263 KB
pytorch-cpu-1.0.1 | py3.7_cpu_1 59.0 MB pytorch
torchvision-cpu-0.2.2 | py_3 44 KB pytorch
------------------------------------------------------------
Total: 61.4 MB
The following NEW packages will be INSTALLED:
ninja pkgs/main/win-64::ninja-1.9.0-py37h74a9793_0
pytorch-cpu pytorch/win-64::pytorch-cpu-1.0.1-py3.7_cpu_1
torchvision-cpu pytorch/noarch::torchvision-cpu-0.2.2-py_3
The following packages will be UPDATED:
conda 4.6.11-py37_0 --> 4.6.12-py37_1
Proceed ([y]/n)? y
Downloading and Extracting Packages
torchvision-cpu-0.2. | 44 KB | ############################################################################ | 100%
ninja-1.9.0 | 263 KB | ############################################################################ | 100%
pytorch-cpu-1.0.1 | 59.0 MB | 4 | 1%
conda-4.6.12 | 2.1 MB | ############################################################################ | 100%
CondaHTTPError: HTTP 000 CONNECTION FAILED for url
Elapsed: -
An HTTP error occurred when trying to retrieve this URL.
HTTP errors are often intermittent, and a simple retry will get you on your way.
(base) C:\Users\shdxlzh>conda install pytorch-cpu torchvision-cpu -c pytorch
WARNING: The conda.compat module is deprecated and will be removed in a future release.
Collecting package metadata: done
Solving environment: done
## Package Plan ##
environment location: C:\ProgramData\Anaconda3
added / updated specs:
- pytorch-cpu
- torchvision-cpu
The following packages will be downloaded:
package | build
---------------------------|-----------------
pytorch-cpu-1.0.1 | py3.7_cpu_1 59.0 MB pytorch
------------------------------------------------------------
Total: 59.0 MB
The following NEW packages will be INSTALLED:
ninja pkgs/main/win-64::ninja-1.9.0-py37h74a9793_0
pytorch-cpu pytorch/win-64::pytorch-cpu-1.0.1-py3.7_cpu_1
torchvision-cpu pytorch/noarch::torchvision-cpu-0.2.2-py_3
The following packages will be UPDATED:
conda 4.6.11-py37_0 --> 4.6.12-py37_1
Proceed ([y]/n)? y
Downloading and Extracting Packages
pytorch-cpu-1.0.1 | 59.0 MB | ############################################################################ | 100%
Preparing transaction: done
Verifying transaction: failed
EnvironmentNotWritableError: The current user does not have write permissions to the target environment.
environment location: C:\ProgramData\Anaconda3
(base) C:\Users\shdxlzh>
最后总算安装成功了,安装成功的状态如下