Linux服务器安装conda,配置虚拟环境,以及torch

1、conda的安装

首先,在清华镜像站找需要的conda版本,并复制链接

Index of /anaconda/archive/ | 清华大学开源软件镜像站 | Tsinghua Open Source MirrorIndex of /anaconda/archive/ | 清华大学开源软件镜像站,致力于为国内和校内用户提供高质量的开源软件镜像、Linux 镜像源服务,帮助用户更方便地获取开源软件。本镜像站由清华大学 TUNA 协会负责运行维护。https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/

https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-2021.05-Linux-x86_64.sh

 然后在服务器端输入指令

wget https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-2021.05-Linux-x86_64.sh

下载成功后,在命令行输入

bash Anaconda3-2021.05-Linux-x86_64.sh

一路点yes和enter,便可安装成功

检验安装是否成功:conda-V

添加镜像文件

conda config --add 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/conda-forge 
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/

conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/win-64/

conda config --add channels https://mirrors.bfsu.edu.cn/anaconda/pkgs/free/ 
conda config --add channels https://mirrors.bfsu.edu.cn/anaconda/pkgs/main/ 
conda config --add channels https://mirrors.bfsu.edu.cn/anaconda/cloud/conda-forge 
conda config --add channels https://mirrors.bfsu.edu.cn/anaconda/cloud/msys2/
conda config --add channels https://mirrors.bfsu.edu.cn/anaconda/cloud/pytorch/

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 config --set show_channel_urls yes

删除镜像文件

conda config --remove-key channels

2、配置虚拟环境

conda create -n 环境名称 python=3.7

激活虚拟环境

conda activate 环境名称

退出虚拟环境

conda deactivate

3、安装torch

进入虚拟环境后安装torch,有两种方法

第一种,登录网站,选择适合自己的版本安装

PyTorchAn open source machine learning framework that accelerates the path from research prototyping to production deployment.https://pytorch.org/conda install pytorch torchvision torchaudio cudatoolkit=10.2 -c pytorch

但是我在下载过程中出现了http错误,因此使用镜像文件进行了安装

然后在pytorch官网找到的torch版本的下载命令复制,并去掉-c python

conda install pytorch torchvision torchaudio cudatoolkit=10.2

进行安装即可。

安装成功后的验证

python import torch

如果以前安装过pytorch或者安装失败过在安装前线执行下面两条语句

conda uninstall pytorch
conda uninstall libtorch
  • 1
    点赞
  • 13
    收藏
    觉得还不错? 一键收藏
  • 2
    评论
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值