我想在Python程序中使用PyTorch。安装说明需要conda。安装Conda后,我跑了
>conda install -c pytorch pytorch (as instructed on the PyTorch [page][1])
它看起来很有希望-直到最后。
Solving environment: done
## Package Plan ##
environment location: C:\ProgramData\Miniconda3
added / updated specs:
- pytorch
The following packages will be downloaded:
package | build
---------------------------|-----------------
icc_rt-2017.0.4 | h97af966_0 8.0 MB
vs2015_runtime-15.5.2 | 3 2.2 MB
pytorch-0.4.0 |py36_cuda80_cudnn7he774522_1 529.2 MB pytorch
mkl-2018.0.3 | 1 178.1 MB
numpy-1.14.5 | py36h9fa60d3_4 35 KB
intel-openmp-2018.0.3 | 0 1.7 MB
numpy-base-1.14.5 | py36h5c71026_4 3.8 MB
vc-14.1 | h0510ff6_3 5 KB
blas-1.0 | mkl 6 KB
conda-4.5.8 | py36_0 1.0 MB
mkl_fft-1.0.2 | py36hb217b18_0 113 KB
mkl_random-1.0.1 | py36h77b88f5_1 268 KB
------------------------------------------------------------
Total: 724.4 MB
The following NEW packages will be INSTALLED:
blas: 1.0-mkl
icc_rt: 2017.0.4-h97af966_0
intel-openmp: 2018.0.3-0
mkl: 2018.0.3-1
mkl_fft: 1.0.2-py36hb217b18_0
mkl_random: 1.0.1-py36h77b88f5_1
numpy: 1.14.5-py36h9fa60d3_4
numpy-base: 1.14.5-py36h5c71026_4
pytorch: 0.4.0-py36_cuda80_cudnn7he774522_1 pytorch
The following packages will be UPDATED:
conda: 4.5.4-py36_0 --> 4.5.8-py36_0
vc: 14-h0510ff6_3 --> 14.1-h0510ff6_3
vs2015_runtime: 14.0.25123-3 --> 15.5.2-3
Proceed ([y]/n)? y
Downloading and Extracting Packages
icc_rt-2017.0.4 | 8.0 MB | ############################################################################## | 100%
vs2015_runtime-15.5. | 2.2 MB | ############################################################################## | 100%
pytorch-0.4.0 | 529.2 MB | ############################################################################# | 100%
mkl-2018.0.3 | 178.1 MB | ############################################################################# | 100%
numpy-1.14.5 | 35 KB | ############################################################################## | 100%
intel-openmp-2018.0. | 1.7 MB | ############################################################################## | 100%
numpy-base-1.14.5 | 3.8 MB | ############################################################################## | 100%
vc-14.1 | 5 KB | ############################################################################## | 100%
blas-1.0 | 6 KB | ############################################################################## | 100%
conda-4.5.8 | 1.0 MB | ############################################################################## | 100%
mkl_fft-1.0.2 | 113 KB | ############################################################################## | 100%
mkl_random-1.0.1 | 268 KB | ############################################################################## | 100%
Preparing transaction: done
Verifying transaction: done
但是这。
Executing transaction: failed
ERROR conda.core.link:_execute(502): An error occurred while uninstalling package 'defaults::conda-4.5.4-py36_0'.
PermissionError(13, 'Access is denied')
Attempting to roll back.
Rolling back transaction: done
PermissionError(13, 'Access is denied')
显然,它至少已部分安装,因为PyCharm可以看到它。但是当我要求PyCharm将其安装在环境中时,出现了此错误。
RuntimeError: PyTorch does not currently provide packages for PyPI (see status at https://github.com/pytorch/pytorch/issues/566).
Please follow the instructions at http://pytorch.org/ to install with miniconda instead.
它建议安装PyTorch的另一种方法。所以我尝试了。
>conda install pytorch torchvision -c pytorch
Solving environment: failed
PackagesNotFoundError: The following packages are not available from current channels:
- torchvision
Current channels:
- https://conda.anaconda.org/pytorch/win-64
- https://conda.anaconda.org/pytorch/noarch
- https://repo.anaconda.com/pkgs/main/win-64
- https://repo.anaconda.com/pkgs/main/noarch
- https://repo.anaconda.com/pkgs/free/win-64
- https://repo.anaconda.com/pkgs/free/noarch
- https://repo.anaconda.com/pkgs/r/win-64
- https://repo.anaconda.com/pkgs/r/noarch
- https://repo.anaconda.com/pkgs/pro/win-64
- https://repo.anaconda.com/pkgs/pro/noarch
- https://repo.anaconda.com/pkgs/msys2/win-64
- https://repo.anaconda.com/pkgs/msys2/noarch
To search for alternate channels that may provide the conda package you're
looking for, navigate to
https://anaconda.org
and use the search bar at the top of the page.
但是当我这样做并搜索PyTorch时,我最终回到了原始说明中。
当我搜索Torchvision时,没有列出Windows版本。
任何帮助将不胜感激。
谢谢。
答案 0 :(得分:4)
在Windows中尝试以下步骤:
使用以下命令创建虚拟环境:
conda create -n py_env python=3.5
source activate py_env
conda install pytorch-cpu -c pytorch
pip install torchvision
注意:您可以使用任何名称代替py_env
谢谢
答案 1 :(得分:3)
安装PyTorch的另一种方法是以下步骤:
broadLeaf
conda create -n pytorch_env python=3
source activate pytorch_env
转到python shell并使用命令导入
conda install pytorch-cpu torchvision -c pytorch
答案 2 :(得分:1)
您的平台是什么?
对于您的第一种安装方法,错误消息表明您没有权限。我以前在Linux系统上遇到过该错误。原因是Anaconda由另一个用户安装。我配置了将python指向该安装的路径,以便无需安装自己的Anaconda副本即可运行python。但是,它不允许我安装新软件包,并且得到了相同的错误消息。
解决方案:我安装了自己的Anaconda副本,并且一切正常。
答案 3 :(得分:0)
运行:
pip install torch torchvision
答案 4 :(得分:0)
以管理模式打开终端,如果您使用的是Linux,请尝试 sudo pip安装“您的软件包名称”