Linux配置深度学习环境tensorflow、pytorch

本文用以记录Linux系统配置深度学习环境,及未来会碰到的各种问题。

2020.11.25

对于Anaconda的安装,使用离线安装的方式。进入Anaconda官网(下载地址)下载Linux版本的离线安装包Anaconda3-5.3.1—Linux-x86_64.sh。随后将其复制到Linux对应的目录下。

  • bash Anaconda3-5.3.1-Linux-x86_64.sh,一路yes即可完成安装。

  • conda --version可以查看所安装的anaconda的版本信息。

  • 创建虚拟环境 conda create -n tf python=3.7,激活conda虚拟环境 conda activate tf

  • 由于国内访问国外的节点速度较慢,所以更换conda源,选择北京外国语大学的镜像站。修改condarc配置文件,vi ~/.condarc打开

channels:
  - defaults
show_channel_urls: true
channel_alias: https://mirrors.bfsu.edu.cn/anaconda
default_channels:
  - https://mirrors.bfsu.edu.cn/anaconda/pkgs/main
  - https://mirrors.bfsu.edu.cn/anaconda/pkgs/free
  - https://mirrors.bfsu.edu.cn/anaconda/pkgs/r
  - https://mirrors.bfsu.edu.cn/anaconda/pkgs/pro
  - https://mirrors.bfsu.edu.cn/anaconda/pkgs/msys2
custom_channels:
  conda-forge: https://mirrors.bfsu.edu.cn/anaconda/cloud
  msys2: https://mirrors.bfsu.edu.cn/anaconda/cloud
  bioconda: https://mirrors.bfsu.edu.cn/anaconda/cloud
  menpo: https://mirrors.bfsu.edu.cn/anaconda/cloud
  pytorch: https://mirrors.bfsu.edu.cn/anaconda/cloud
  simpleitk: https://mirrors.bfsu.edu.cn/anaconda/cloud

:wq退出,运行conda clean -i清除索引缓存,保证用的是镜像站提供的索引。这样我们就把conda源换成国内的镜像,可以显著提高下载的速度。

  • 安装tensorflow,我们选择安装gpu版本的tensorflow conda install tensorflow-gpu,末尾不加版本号会自动安装最新版本,在tensorflow2.0以后,安装时会自动下载cudatoolkitcudnn而不需要我们再手动安装。
  • 安装pytorchconda install pytorch即可完成安装。
  • 在终端输入python进入python环境,导入tensorflow和pytorch包,不会报错,说明安装成功。
import tensorflow as tf
import torch
  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值