linux下conda安装pytorch使用命令

conda install pytorch==1.2.0 torchvision==0.4.0 cudatoolkit=10.0 -c pytorch

遇到问题

Solving environment: failed with initial frozen solve. Retrying with flexible solve.
Solving environment: failed with repodata from current_repodata.json, will retry with next repodata source.

报错原因

python版本与pytorch版本要求发生冲突

解决方案

重新配置环境,将python版本更换为与需要下载的pytorch版本相匹配的版本。
像是我本次下载的pytorch版本为1.2.0,而我原本pytorch环境安装的python版本是3.8,所以会报错。
按照以下步骤删除及创建环境,并以我安装的pytorch版本为例,给出以下命令行。
————
conda remove -n pytorch --all
conda create -n pytorch120 python=3.7
conda activate pytorch120
conda install pytorch==1.2.0 torchvision==0.4.0 cudatoolkit=10.0 -c pytorch

尝试过的方案

1 将conda更换成pip,报错原因未知
ERROR: Could not find a version that satisfies the requirement pytorch==1.2.0 (from versions: none)
ERROR: No matching distribution found for pytorch==1.2.0
2 更换镜像源,无果
Logo

华为开发者空间,是为全球开发者打造的专属开发空间,汇聚了华为优质开发资源及工具,致力于让每一位开发者拥有一台云主机,基于华为根生态开发、创新。

更多推荐