零基础搭建CUDA、Pytorch环境

服务器版本:Ubuntu16.04
环境搭建版本:CUDA9.0,Pytorch1.0 branch 最新版

安装anaconda

先去anaconda官网获取下载连接
https://www.anaconda.com/distribution/
这里,我的是下面这个链接,进行下载

wget https://repo.anaconda.com/archive/Anaconda3-2019.10-Linux-x86_64.sh

下载完成后,用bash进行安装

bash Anaconda3-2019.10-Linux-x86_64.sh 

创建新的虚拟环境

安装完成后,用conda创建需求的环境,比如说我想创建python版本为3.6的环境

conda create -n env_name python=3.6 #创建名字为env_name的虚拟空间,并设置python版本
conda activate env_name    #激活这个虚拟空间

创建环境

conda create -n pytorch1.0-py3.6 python=3.6 

进行激活

conda activate pytorch1.0-py3.6

安装cuda

这里选择用清华源进行下载
首先在conda添加清华源(顺便添加pytorch的镜像)

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

接着安装cuda和cudnn

conda install cudatoolkit=版本号 -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/linux-64/
conda install cudnn=版本号 -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/linux-64/

版本号改成需要的版本即可,比如cudatoolkit=9.0

安装pytorch

可以在pytoch官网找自己需要的版本:https://pytorch.org/get-started/locally/ ,记得cuda版本要改成自己安装的版本
这里我用的是

conda install pytorch torchvision cudatoolkit=9.0 -c pytorch

或者直接用清华源的镜像进行下载

conda install pytorch=*.*.* torchvision=*.*.* -c soumith

*.*.*填上自己需要的版本号

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值