Linux下安装Anaconda、pytorch-gpu版本

首先说明,pytorch最新版本11.8有点问题,安装可以完成,但是用不了cuda,即

import torch
>>> print(torch.cuda.is_available()) #输出为False

所以在这里安装的不是最新版本的pytorch-gpu版本,一般选择安装命令里面有cudatoolkit=x.x的就可以。

1、Linux下安装Anaconda

首先官网下载Anaconda,官网链接Free Download | Anaconda

(1)第一种方法直接wget命令下载

选择合适的linux版本,可以使用wget命令下载:

网址点击下载就会弹出,在windows弹出,复制过去就行

​
wget https://repo.anaconda.com/archive/Anaconda3-2023.03-1-Linux-x86_64.sh

然后使用bash命令安装

bash Anaconda3-2023.03-1-Linux-x86_64.sh

最后退出用户,重启,就会自动弹出默认的base环境

(2)第二种方法,服务器网差,wget不成功

下载本地上图直接选择下载就行,然后在本地传进服务器

scp -P 端口号(端口号可选,没有就不写-P 端口号) Anaconda3-2023.03-1-Linux-x86_64.sh username@ip地址:./

传完,在服务器,执行

bash Anaconda3-2023.03-1-Linux-x86_64.sh

最后退出用户,重启,就会自动弹出默认的base环境

2、Linux下安装pytorch-gpu

在pytorch官网Start Locally | PyTorch,选择这里

找到带有cudatoolkit=x.x的pytorch版本就行

复制命令直接安装

conda install pytorch==1.12.1 torchvision==0.13.1 torchaudio==0.12.1 cudatoolkit=10.2 -c pytorch

 3、直接conda命令安装老是下载失败不成功

(1)换镜像

一般换清华镜像,操作参考这篇博客Conda配置环境常见的几个问题及解决方法_哼唧哼唧啊哈的博客-CSDN博客

清华镜像官网anaconda | 镜像站使用帮助 | 清华大学开源软件镜像站 | Tsinghua Open Source Mirror

vim ~/.condarc #打开文件

输入i之后 ,粘贴如下内容

channels:
  - defaults
show_channel_urls: true
default_channels:
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
  - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/msys2
custom_channels:
  conda-forge: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  msys2: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  bioconda: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  menpo: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  pytorch: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  pytorch-lts: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud
  simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud

点击ESC,输入:wq,回车,保存退出

再重新安装,就会加速。

(2)使用mamba加速

运行下列代码安装mamba

 conda config --append channels conda-forge
 conda config --set channel_priority flexible
 conda install mamba

安装完成后所有conda可以换成 mamba,比如

mamba install pytorch==1.12.1 torchvision==0.13.1 torchaudio==0.12.1 cudatoolkit=10.2 -c pytorch

速度会快很多。

 4、安装完成需要测试一下,如下就是成功

  • 1
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值