目前学校的超算平台两个集群太乙中有安装配置anaconda ,启明中没有配置。在实际使用中,部分用户需要用到anaconda的管理权限来更新或者安装自己需要的环境。
本文档将讨论在用户自己的账号权限下:
计算中心配置的开源镜像站 https://mirrors.sustech.edu.cn/中配置了anaconda同步源。
用户可以在网址 https://mirrors.sustech.edu.cn/anaconda/archive/中浏览和下载自己需要版本的安装包。
此处以最新版为例。我们从用自己账号登录到了太乙中开始。
下文中的 “~/”可以以用户目录替换,或者其他目录路径。
xxxxxxxxxxtest -d ~/softwares/python/anaconda3 || mkdir -p ~/softwares/python/anaconda3 #创建安装目录wget https://mirrors.sustech.edu.cn/anaconda/archive/Anaconda3-2020.07-Linux-x86_64.sh #下载安装包sh Anaconda3-2020.07-Linux-x86_64.sh -b -p ~/softwares/python/anaconda3/2020.07 #自动安装到目录在安装目录写入环境变量文件anaconda.2020.07.source,此文件也可以放在任意计算时可以调用的目录:
xxxxxxxxxxcat>~/softwares/python/anaconda3/2020.07/anaconda.2020.07.source<<EOF# >>> conda initialize >>># !! Contents within this block are managed by 'conda init' !!__conda_setup="$('/work/ccse-tangh/softwares/python/anaconda3/2020.07/bin/conda' 'shell.bash' 'hook' 2> /dev/null)"if [ $? -eq 0 ]; then    eval "$__conda_setup"else    if [ -f "~/softwares/python/anaconda3/2020.07/etc/profile.d/conda.sh" ]; then        . "~/softwares/python/anaconda3/2020.07/etc/profile.d/conda.sh"    else        export PATH="~/softwares/python/anaconda3/2020.07/bin:$PATH"    fifiunset __conda_setup# <<< conda initialize <<<EOF在用户目录写入.condarc文件,配置国内更新源,以便于加快更新和安装环境或者软件包的速度:
xxxxxxxxxxcat>~/.condarc<<EOFchannels:  - defaultsshow_channel_urls: truechannel_alias: https://mirrors.sustech.edu.cn/anacondadefault_channels:  - https://mirrors.sustech.edu.cn/anaconda/pkgs/main  - https://mirrors.sustech.edu.cn/anaconda/pkgs/free  - https://mirrors.sustech.edu.cn/anaconda/pkgs/r  - https://mirrors.sustech.edu.cn/anaconda/pkgs/procustom_channels:  conda-forge: https://mirrors.sustech.edu.cn/anaconda/cloud  msys2: https://mirrors.sustech.edu.cn/anaconda/cloud  bioconda: https://mirrors.sustech.edu.cn/anaconda/cloud  menpo: https://mirrors.sustech.edu.cn/anaconda/cloud  pytorch: https://mirrors.sustech.edu.cn/anaconda/cloud  simpleitk: https://mirrors.sustech.edu.cn/anaconda/cloudEOF.condarc文件也可以用其他国内源文件如:https://mirrors.tuna.tsinghua.edu.cn/help/anaconda/
xxxxxxxxxxchannels:  - defaultsshow_channel_urls: truechannel_alias: https://mirrors.tuna.tsinghua.edu.cn/anacondadefault_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/msys2custom_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加载环境变量,清理索引缓存,更新
xxxxxxxxxxsource ~/softwares/python/anaconda3/2020.07/anaconda.2020.07.sourceconda clean -i conda update --prefix ~/softwares/python/anaconda3/2020.07 anaconda -y配置自己需要的环境或者虚拟环境
如果在脚本里使用软件环境,请将加载环境变量的命令加入到脚本中,放在软件命令所在行的上面的行里。如:
xxxxxxxxxx#BSUB -J python            ##job name#BSUB -q debug             ##queue name#BSUB -n 40                ##number of total cores#BSUB -R "span[ptile=40]"  ##40 cores/node#BSUB -W 01:00             ##walltime in hh:mm#BSUB -x                   ##exclusive#BSUB -R "hname!=r13n45"#BSUB -eo H.loghostfile=`echo $LSB_DJOB_HOSTFILE`NP=`cat $hostfile | wc -l`echo $LSB_HOSTS |sed 's/ /\n/g'|sort|uniq >myclusterecho $LSB_JOBID >log#envsource ~/softwares/python/anaconda3/2020.07/anaconda.2020.07.sourcesource activate  conda deactivate #退出当前环境conda activate env_name   #进入指定的conda环境,此处 'env_name' 按需要修改#workscriptpython work.py > $LSB_JOBID.log 2>&1 #此处work.py为python脚本文件名称,按需要修改conda deactivate #执行结束,退出加载的环境conda 常用命令
xxxxxxxxxxsource ~/softwares/python/anaconda3/2020.07/anaconda.2020.07.sourceconda info -e # 查看当前现有的conda环境source activate env_name   #进入指定的conda环境conda deactivate  #退出当前的conda环境conda create -n env_name [python=<version>] #创建环境,并指定python版本conda remove -n env_name --all  #删除指定环境conda install [-n env_name] pkg_name #安装指定包到指定环境conda list [-n env_name] #查看指定环境下安装的包conda search pkg_name  #查看指定的安装包conda update pkg_name  #更新指定的安装包conda remove pkg_name  #卸载指定的安装包4.1 配置安装python指定版本,此处以 python 3.7.6为例
xxxxxxxxxxsource ~/softwares/python/anaconda3/2020.07/anaconda.2020.07.sourceconda create -n py3.7.6 python=3.7.6 -y#以下为激活安装的环境source activate  conda deactivate #退出当前环境conda activate py3.7.6 #激活需要的环境python -V  #查看当前python版本此处以在 python 3.7.6 版下安装tensorflow 2.0.0版为例,介绍特定版本软件的安装方法:
xxxxxxxxxxconda create -n tensorflow2.0.0-py3.7.6 tensorflow=2.0.0 python=3.7.6 -ysource activate  conda deactivate #退出当前环境conda activate tensorflow2.0.0-py3.7.6 #激活需要的环境python -c "import sys; print(sys.version)" #查看python本python -c "import tensorflow as tf; print(tf.__version__)" #查看tensorflow版本如不指定软件和python的版本号,conda将会选择已经系统适配并安装的最新版本。
4.2 keras scikit-learn
在上面安装的tensorflow2.0.0-py3.7.6环境中同时包含了keras
xxxxxxxxxxsource activate  conda deactivate #退出当前环境conda activate tensorflow2.0.0-py3.7.6 #激活需要的环境python -c "import tensorflow.keras as tk; print(tk.__version__)" #查看keras本安装scikit-learn 到已经创建的tensorflow2.0.0-py3.7.6环境,也可以安装到其他环境或者新建环境
x
conda install -n tensorflow2.0.0-py3.7.6 scikit-learn -ypython -c "import sklearn;print(sklearn.__version__)" #输出scikit-learn版本号先写到这,如果问题出现,欢迎大家及时告诉我{mailto:tangh@mail.sustech.edu.cn}。