使用conda安装旧版本torch0.2.0

想安装指定版本的pytorch,指令(在cuda9下也可以安装):


conda install pytorch=0.1.10 -c soumith

然后,出现错误

安装出现HTTP 000 CONNECTION FAILED....

原因:是使用的是国外的镜像,需要切换至国内镜像

#使用conda config --show获取当前环境的配置信息
$conda config --show

add_anaconda_token: True
add_pip_as_python_dependency: True
aggressive_update_packages:
  - ca-certificates
  - certifi
  - openssl
allow_non_channel_urls: False
allow_softlinks: False
always_copy: False
always_softlink: False
always_yes: None
anaconda_upload: None
auto_update_conda: True
changeps1: True
channel_alias: https://conda.anaconda.org
channel_priority: True
channels:[]
client_ssl_cert: None
client_ssl_cert_key: None
clobber: False
create_default_packages: []
custom_channels:
  pkgs/main: https://repo.anaconda.com
  pkgs/free: https://repo.anaconda.com
  pkgs/r: https://repo.anaconda.com
  pkgs/pro: https://repo.anaconda.com
  home/lthpc/anaconda3/conda-bld: file://
custom_multichannels:
  defaults: ["https://repo.anaconda.com/pkgs/main", "https://repo.anaconda.com/pkgs/free", "https://repo.anaconda.com/pkgs/r", "https://repo.anaconda.com/pkgs/pro"]
  local: ["file:///home/lthpc/anaconda3/conda-bld"]
default_channels:
  - https://repo.anaconda.com/pkgs/main
  - https://repo.anaconda.com/pkgs/free
  - https://repo.anaconda.com/pkgs/r
  - https://repo.anaconda.com/pkgs/pro
disallowed_packages: []
download_only: False
envs_dirs:
  - /home/lthpc/anaconda3/envs
  - /home/lthpc/.conda/envs
force: False
json: False
local_repodata_ttl: 1
max_shlvl: 2
migrated_channel_aliases: []
no_dependencies: False
non_admin_enabled: True
notify_outdated_conda: True
offline: False
override_channels_enabled: True
path_conflict: clobber
pinned_packages: []
pkgs_dirs:
  - /home/lthpc/anaconda3/pkgs
  - /home/lthpc/.conda/pkgs
proxy_servers: {}
quiet: False
remote_connect_timeout_secs: 9.15
remote_max_retries: 3
remote_read_timeout_secs: 60.0
report_errors: None
rollback_enabled: True
safety_checks: warn
shortcuts: True
show_channel_urls: True
ssl_verify: False
track_features: []
use_index_cache: False
use_pip: True
verbosity: 0
whitelist_channels: []
而我们只想关注channels的,可以用指令conda config --show-source
$conda config --show-source
channels:[]

在conda安装好后,默认镜像是官方的,由于官方镜像在境外,访问太慢或者不能访问,为了能够加快访问速度,这里选择清华镜像

在命令行敲命令,设置清华的三个镜像
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/free/ 
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
conda config --set show_channel_urls yes

还是出现错误,要去掉channels中的defaults

执行命令
conda config --remove defaults

在查看一下channels里的东西

$conda config --show-sources
==> /home/lthpc/.condarc <==
ssl_verify: False
channels:
- https://mirrors.ustc.edu.cn/anaconda/pkgs/free/ 
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/
- https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/
show_channel_urls: true

再安装,--------又失败,重新换一下镜像,首先remove掉那三个,然后重新换链接

conda config --remove channels 'https://mirrors.ustc.edu.cn/anaconda/pkgs/free/ '
conda config --remove channels 'https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/conda-forge/'
conda config --remove channels 'https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/'


conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/bioconda/

结果还是不行。。。。终于换上中科大的镜像源,可以了。。

conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/main/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/pkgs/free/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/conda-forge/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/msys2/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/bioconda/
conda config --add channels https://mirrors.ustc.edu.cn/anaconda/cloud/menpo/

conda常用命令

#查看conda版本
conda --version
#查看python版本
python --version
#查看TensorFlow版本
#首先进去python环境,然后import
python
import tensorflow as tf
print(tf.__version__)
#查看pytorch版本,也是一样
python import torch
print(torch.__version__)
conda config命令
#显示当前环境的配置信息
$conda config --show
#只显示channels信息
$conda config --show-sources
==> /export/python2.7/.condarc <==
channels:
  - https://mirror.tuna.tsinghua.edu.cn/anacondafree
  - https://mirror.tuna.tsinghua.edu.cn/anaconda/main
show_channel_urls: True
#删除默认channel,增加国内镜像源,删除remove,增加add
$conda config --remove channels defaults

$ conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
$ conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/

#从channel中安装包是不显示channel的url
#conda config --set show_channel_urls no

参考博客:

 Anaconda更新失败解决方法:https://www.jianshu.com/p/c74668743932

conda常用命令详解:https://www.jianshu.com/p/484cfbf45ed3

 

 

  • 2
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值