一、Linux相关指令
1、连接服务器:
# 文件夹可视化界面: sftp://172.21.141.xx/
# 进入服务器,终端输入:
$ ssh zengguangjian@172.21.141.xx
# 配置miniconda环境:
$ cd software/ # 转换目录
$ wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
$ sh Miniconda3-latest-Linux-x86_64.sh # 安装
$ logout
$ conda install numpy # 安装相关库
$ conda create -n pytorch python=3.6 # 创建环境 相关编译器在miniconda3/envs/***/bin下
$ conda activate pytorch # 激活环境
2、查看文目录下所有文件:
$ du -h --max-depth=1 # 查看当前目录下所有文件夹大小
$ ls # 不加任何参数,表示查询当前目录下的文件/文件夹
$ ls 目标目录 # 查询该目标路径下的文件/文件夹
$ ls -a # 查询所有的文件/文件夹,也包括以.开头的隐藏文件
$ ls -l # 查询文件的详细信息
$ ls -lh # 查询文件的大小
$ ls *.xxx # 显示后缀为xxx的文件
3、复制文件:
在被复制目录下打开终端,输入:
$ cp 被复制目录/aa.txt 目标目录 # 复制文件
$ cp -r 被复制目录 目标目录 # 复制文件夹 *表示文件夹下全部文件
复制到服务器:
# 从服务器中复制到本地:
$ scp zengguangjian@172.21.141.32:/data1/share/zengguangjian/xxx.tgz /home/gary/桌面/xxx.tgz
# 从本地中复制到服务器:
$ scp /home/gary/桌面/xxx.tgz zengguangjian@172.21.141.32:/data1/share/zengguangjian/xxx.tgz
4、后台运行程序
# 运行程序
python test.py
# 后台运行程序
# & 符号 ctrl+c关闭就不会关闭此进程,但是当屏幕关闭,断网仍然会造成进程退出
python test.py &
# nohup指令 当屏幕关闭,断网等造成ssh中断时进程不会退出。但是ctrl+c可以关闭关闭该进程、
nohup python test.py
# 查看是否在后台运行 ps -ef|grep [程序名]
ps -ef|grep test
# 停止后台运行的对应程序 killall [程序名]
killall test
5、压缩解压
6、ctrl+L可视化文件路径
二、Anaconda 相关库的安装
1、换源
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/msys2/
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/pkgs/free/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/
conda config --set show_channel_urls yes
conda config --remove-key channels # 恢复默认源
conda config --show # 查看源
2、XGBoost
Anaconda Prompt输入:
$ pip install xgboost -i https://pypi.tuna.tsinghua.edu.cn/simple
3、Pytorch
Previous PyTorch Versions | PyTorch
# pytorch 1.8.0 CUDA 11.1 CuDnn 0.8
$ conda install pytorch==1.8.0 torchvision==0.9.0 torchaudio==0.8.0 cudatoolkit=11.1 -c pytorch -c conda-forge
$ pip install torch==1.8.0+cu111 torchvision==0.9.0+cu111 torchaudio==0.8.0 -f https://download.pytorch.org/whl/torch_stable.html
4、配置环境变量
在容器中找到.bashrc文件目录,找到该文件,在文件中添加
export PATH=/opt/conda/bin:$PATH
在命令行输入命令:
source ~/.bashrc