Linux教程

Linux 安装 pytorch(cuda=10.1),自己记录个人安装关键步骤,不做学习参考。

本文主要是介绍Linux 安装 pytorch(cuda=10.1),自己记录个人安装关键步骤,不做学习参考。,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

安装命令:
conda install pytorch1.7.0 torchvision0.8.0 torchaudio==0.7.0 cudatoolkit=10.1 -c pytorch -y

1.修改/root/.bashrc中的环境配置:
.bashrc文件只做了最后export的添加。

# .bashrc

# User specific aliases and functions
alias rm='rm -i'
alias cp='cp -i'
alias mv='mv -i'
alias vi='vim'
alias wc='watch -n 0.1 nvidia-smi'
alias ppy='ps -ef | grep python'


if [ -f /etc/bashrc ]; then
	. /etc/bashrc
fi

# >>> conda initialize >>>
# !! Contents within this block are managed by 'conda init' !!
__conda_setup="$('/root/anaconda3/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"
if [ $? -eq 0 ]; then
    eval "$__conda_setup"
else
    if [ -f "/root/anaconda3/etc/profile.d/conda.sh" ]; then
        . "/root/anaconda3/etc/profile.d/conda.sh"
    else
        export PATH="/root/anaconda3/bin:$PATH"
    fi
fi
unset __conda_setup
# <<< conda initialize <<<
export CUDA_HOME=$CUDA_HOME:/usr/local/cuda
export PATH=$PATH:/usr/local/cuda/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda/lib64

export TERMINFO=/usr/share/terminfo

# 最后这句话是添加的
Export PATH="/root/anaconda3/bin:$PATH"

2.换源:
进入/root/.condarc文件(这个是索引文件)中,修改成下面的源:

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
  simpleitk: https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud

3.上述完成后,
3.1 进入自己的虚拟环境conda acitvate myTestEnv
3.2 myTestEnv]# python
3.2 >>> import torch
3.3 >>> torch.cuda.is_available()

这篇关于Linux 安装 pytorch(cuda=10.1),自己记录个人安装关键步骤,不做学习参考。的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!