Linux服务器安装conda+pytorch+tensorflow

安装miniconda

  • 新建文件夹
    mkdir download
  • 进入目录
    cd download/
  • 下载miniconda安装包
	wget -c https://mirrors.tuna.tsinghua.edu.cn/anaconda/miniconda/Miniconda3-latest-Linux-x86_64.sh
  • 使用安装包
    sh Miniconda3-latest-Linux-x86_64.sh
    (连续输入yes)
    如果出现
    在这里插入图片描述
    添加环境变量
    export PATH=~/miniconda3/bin:$PATH
    source ~/.bashrc
  • 添加源
	conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
	# for legacy win-64
	conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/peterjc123/

	conda config --add channels https://mirrors.tuna.tsinghua.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/cloud/msys2/
	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 --set show_channel_urls yes

  • 创建名为py36的虚拟环境
    conda create -n py36 python=3.6
    conda activate py36 (激活该环境)
    在这里插入图片描述

查看CUDA CUDNN 版本

cat /usr/local/cuda/version.txt
cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2
在这里插入图片描述
版本为:
cuda 9.0.176
cudnn 7.0.5

确定合适的TensorFlow和PyTorch版本

  • TensorFlow
    https://blog.csdn.net/qiancaobaicheng/article/details/95226499
    在这里插入图片描述
    例如我的环境可以安装tf 1.11.0 (GPU)
conda install tensorflow-gpu==1.11.0
  • PyTorch
    https://pytorch.org/
    https://pytorch.org/get-started/previous-versions/
    在这里插入图片描述
    在这里插入图片描述
    例如我的环境可以安装 pytorch 1.1.0 (GPU)
    conda install pytorch==1.1.0 torchvision==0.3.0
    # 不用加 -c 为用国内源
    

查看版本号检查是否安装成功

  • TensorFlow
    在这里插入图片描述
  • PyTorch
    在这里插入图片描述
发布了9 篇原创文章 · 获赞 2 · 访问量 4636

猜你喜欢

转载自blog.csdn.net/zb12138/article/details/104630375