zoukankan      html  css  js  c++  java
  • conda虚拟环境安装

    一、背景

      需要学习mxnet,建一个conda虚拟软件环境。

    二、步骤

    1、下载anaconda安装文件:https://mirrors.tuna.tsinghua.edu.cn/anaconda/miniconda/

    wget https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-5.3.1-Linux-x86_64.sh

    2、安装:

    bash  Anaconda3-5.3.1-Linux-x86_64.sh

    3、验证conda是否成功

    conda -V

    4、下载d2lzh.zip包

    wget https://zh.d2l.ai/d2l-zh-1.1.zip

    5、新建d2lzl目录,并把d2l-zh-1.1.zip拷贝到该目录进行解压

    unzip d2l-zh-1.1.zip

    6、修改conda软件源,以方便虚拟环境构建

    在.conda隐藏目录下新建隐藏文件.condarc,内容如下:

    channels:
      - defaults
    show_channel_urls: true
    channel_alias: https://mirrors.tuna.tsinghua.edu.cn/anaconda
    default_channels:
      - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main
      - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free
      - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/r
      - https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/pro
      - 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

    7、使用conda clean -i命令清除索引缓存,保证用的是镜像站提供的索引。

    8、进入d2lzh目录,执行虚拟环境建立命令:

    conda env create -f environment.yml

    9、进入虚拟环境

    conda activate gluon

    10、退出虚拟环境

    conda deactivate

    11、运行jupyter note命令:

    jupyter notebook --allow-root --no-browser --port=8888 --ip=0.0.0.0

    12、若干章节的代码会自动下载数据集和预训练模型,并默认使用美国站点下载。为方便下载,宜把下载站点地址变量MXNET_GLUON_REPO修改为国内站点地址。

    方法一:在运行Jupyter前指定MXNet使用国内站点

    export MXNET_GLUON_REPO=https://apache-mxnet.s3.cn-north-1.amazonaws.com.cn/ jupyter notebook

    方法二:修改用户目录下.bash_profile文件,把上述命令添加到该文件最后,此法不用每次运行jupyter notebook命令前指定变量。

    (gluon) [root@localhost ~]# vi .bash_profile

    ...

    export MXNET_GLUON_REPO=https://apache-mxnet.s3.cn-north-1.amazonaws.com.cn/ jupyter notebook

    激活环境变量:

    (gluon) [root@localhost ~]# source .bash_profile

  • 相关阅读:
    责任链模式(Chain)
    适配器模式(Adapter)
    为什么你不应该读大学
    【JMedia】诺贝尔奖得主:东亚教育浪费了太多生命
    用IDEA/WebStrom 提交本地项目到Git/码云等
    requireJs 踩的坑
    pjax 笔记
    PHP 环境搭建及zabbix安装遇到的一些坑.
    div流加载
    spring data jpa 学习笔记
  • 原文地址:https://www.cnblogs.com/sfccl/p/12490010.html
Copyright © 2011-2022 走看看