目录
root用户及普通用户的配置文件
修改所有用户的环境变量:/etc/profile文件
只修改root用户的环境变量:~/.bashrc文件
只修改某个非root用户的环境变量:/home/非root用户名/.bashrc文件
ZSH安装配置
参考zsh开源项目:https://github.com/ohmyzsh/ohmyzsh
1. Clone the repository:
git clone https://github.com/ohmyzsh/ohmyzsh.git ~/.oh-my-zsh
2. Optionally, backup your existing ~/.zshrc file:
cp ~/.zshrc ~/.zshrc.orig
3. Create a new zsh configuration file
cp ~/.oh-my-zsh/templates/zshrc.zsh-template ~/.zshrc
4. Show all your shells
cat /etc/shells
5. Change your default shell
chsh -s /bin/zsh
ssh免密登陆
参考博客:https://www.mycheol.com/archives/14/
本地的操作(Mac)
- 首先进入本地~/.ssh目录
cd ~/.ssh
- 在本地生成公钥及私钥:
ssh-keygen -t rsa
- 将本地创建的公钥上传到服务器
先进入服务器查看是否有该目录:
# 查看是否有隐藏目录.ssh
ls -a
# 有的话无需操作,没有的话就创建目录
mkdir -p ~/.ssh
# 上传公钥至服务器
scp ~/.ssh/id_rsa.pub root@hostname:~/.ssh/
服务器上的操作
- 使用cat将公钥添加到authorized_keys文件
cat ~/.ssh/id_rsa.pub >> ~/.ssh/authorized_keys
- 修改相应的文件权限
chmod 700 ~/.ssh/
chmod 600 ~/.ssh/authorized_keys
本地配置服务器名称
- 使用别名登陆服务器
-
# 进入本地~/.ssh目录 cd ~/.ssh # 创建登录配置文件 vim config config文件内容: Host alias #自定义别名,可自行修改 HostName hostname #替换为你的ssh服务器ip或domain Port port #ssh服务器端口,默认为22 User user #ssh服务器用户名 IdentityFile ~/.ssh/id_rsa #之前生成的公钥文件对应的私钥文件
安装Anaconda
下载Anaconda3-2019.07-Linux-x86_64.sh:https://www.anaconda.com/distribution/#linux将Anaconda3-2019.07-Linux-x86_64.sh上传至服务器用户目录下安装Anaconda:bash Anaconda3-2019.07-Linux-x86_64.sh过程中会提示安装路径及是否配置Anaconda环境变量,一路选择yes即可,此处不会更改系统配置文件
上面的方式太慢了,从清华镜像源下载,超级无敌快
# 下载
wget https://mirrors.tuna.tsinghua.edu.cn/anaconda/archive/Anaconda3-5.2.0-Linux-x86_64.sh
# 安装
sh Anaconda3-5.2.0-Linux-x86_64.sh
配置Python环境变量
- 打开当前用户下的配置文件;vim .bashrc
- 在文件末尾添加:alias python='/home/user-name/anaconda3/bin/python3'
- 消除终端头部的(base)字样,在文件末尾添加:conda deactivate
- 更新配置文件:source .bashrc
- 测试系统中Python版本号
配置下载镜像源
- 在用户文件夹下新建.pip文件夹及pip.conf文件,写入:
[global]
index-url = https://pypi.tuna.tsinghua.edu.cn/simple
[install]
trusted-host=mirrors.aliyun.com
- 国内的下载镜像源:
http://pypi.douban.com/ 豆瓣
http://pypi.hustunique.com/ 华中理工大学
http://pypi.sdutlinux.org/ 山东理工大学
http://pypi.mirrors.ustc.edu.cn/ 中国科学技术大学
http://mirrors.aliyun.com/pypi/simple/ 阿里云
https://pypi.tuna.tsinghua.edu.cn/simple/ 清华大学
配置tensorflow-gpu环境(一路刨坑呜呜呜)
- gpu版本的TensorFlow需要与显卡驱动版本、cudnn版本、cuda版本相匹配
查看cuda 版本:cat /usr/local/cuda/version.txt
查看cudnn 版本:cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2
查看显卡驱动版本:cat /proc/driver/nvidia/version或输入nvidia-smi
-
确定版本后,安装指定的TensorFlow版本,先后尝试pip install tensorflow-gpu 与python -m pip install tensorflow-gpu命令安装TensorFlow后均报如下错误:
Failed to load the native TensorFlow runtime
原因可能是安装gpu版本的TensorFlow时通过pip命令安装时未能正确安装所有依赖项,通过conda命令安装就好啦:
conda install tensorflow-gpu
-
然鹅,tensorflow环境配置好后,执行代码会报如下错误:
tensorflow.python.framework.errors_impl.InternalError: cudaGetDevice() failed. Status: CUDA driver version is
insufficient for CUDA runtime version。
该错误原因可能是tensorflow版本过高,默认安装的cudnn与cuda版本均比较高,与显卡驱动可能不匹配。
- conda安装tensorflow时默认的cuda版本不匹配,重新安装指定版本的cuda,cudnn:
- conda uninstall cudnn
- conda uninstall cudatoolkit
- conda install cudatoolkit=9.0
- conda install cudnn
- condat install tensorflow-gpu
配置pytorch开发环境
-
从官网下载速度非常慢而且经常会因为网络问题中断,所以在官网选择指定版本指定环境的pytorch之后,在安装时去掉命令中的 -c pytorch即可,该参数指定从官网下载,去掉后会从本地配置的清华镜像源下载。
conda install pytorch torchvision cudatoolkit=10.0 -c pytorch
- 当新版本出来,清华镜像源还未更新时,可以先从pytorch官网下载离线包,稍后再进行安装,下载过程依然很慢且容易中断,可以翻墙后再进行下载。