文件个数
ls -l |grep -c "^-"
git
git commit --amend --no-edit
tensorboard
tensorboard --logdir=./ --host=0.0.0.0
git .gitkeep
type NUL > .gitkeep
更新
sudo apt-get update
sudo apt-get upgrade
zip命令
zip -r myfile.zip ./
远程拷贝
scp -P 64418 dump_gpu_mask.zip root@13.129.171.130:/home/
大文件(两边需安装 sudo apt-get install rsync -y)
rsync -P -e "ssh -p32575" --progress det.tgz root@13.129.171.130:/home/hagongda/data/
比较文件A和B不同
diff A B
寻找
find . -name "extract_image_patches.py"
打印日志:
python train.py 2>&1 | tee logs/train.log
shell出错\r换行符
vi filename
命令模式下 set ff
如果fileformat=dos
在命令模式下; set ff=unix
wq
切换gcc版本
yum install centos-release-scl
yum install devtoolset-4
scl --list 或scl -l
scl enable devtoolset-4 bash
gcc -v
conda install -c serge-sans-paille gcc_49
编译GCC
https://www.cnblogs.com/hf19950918/p/13064345.html
export PATH=/home/zx/gcc/gcc540/bin:/home/zx/gcc/gcc540/lib64:$PATH
export LD_LIBRARY_PATH=/home/zx/gcc/gcc540/lib/:$LD_LIBRARY_PATH
gcc -v
查看cuda与驱动版本对应
nvidia-smi
watch -n 1 nvidia-smi
https://docs.nvidia.com/cuda/cuda-toolkit-release-notes/index.html
测试TensorFlow的GPU是否可用
import tensorflow as tf
tf.test.is_gpu_available(
cuda_only=False,
min_cuda_compute_capability=None
)
输出FALSE为不可用
解压命令
.tar 文件
# 仅打包,并非压缩
tar -xvf FileName.tar # 解包
tar -cvf FileName.tar DirName # 将DirName和其下所有文件(夹)打包
.tar.gz文件、 .tgz文件
# .tar.gz 和 .tgz
tar -zxvf FileName.tar.gz # 解压
tar -zcvf FileName.tar.gz DirName # 将DirName和其下所有文件(夹)压缩
tar -C DesDirName -zxvf FileName.tar.gz # 解压到目标路径
sudo apt-get install rar unrar
unrar x name.rar #其中x参数是解压到一个文件夹
unrar e name.rar #e参数是把里面的文件都解压到当前路径下。
切换cuda版本
export PATH=/home/zx/cuda/cuda101/bin:${PATH}
export LD_LIBRARY_PATH=/home/zx/cuda/cuda101/lib64:$LD_LIBRARY_PATH
export CUDA_HOME=/home/zx/cuda/cuda101/
export PATH=/home/zx/cuda/cuda100/bin:${PATH}
export LD_LIBRARY_PATH=/home/zx/cuda/cuda100/lib64:$LD_LIBRARY_PATH
export CUDA_HOME=/home/zx/cuda/cuda100/
查看文件夹大小命令
查找文件(以libgeo开头的文件)
find . -name 'libgeo*'
查看文件夹的大小,也就是查看文件夹下所有文件的大小总和
cd Foldename进到Foldename 目录
du -sh
查看当前文件系统各分区的大小
df -h
查看文件大小
ls -l filename
查看当前目录下所有目录以及子目录的大小:
du -h .
du -h --max-depth=1 . | sort -n
Vue刷新出现404,ngnix配置文件
location / {
# First attempt to serve request as file, then
# as directory, then fall back to displaying a 404.
try_files $uri $uri/ /index.html;
}
或者配置404地址
权限更改
chmod 777 /home/admin/build/ -R
python一行服务器
python -m http.server 8000
Django命令
python manage.py runserver 0.0.0.0:8000
nohup python manage.py runserver 0.0.0.0:8000 &
Ubuntu查看IP地址
ip addr
python运行时间
import time
start = time.time()
.
.
.
end = time.time()
print("end time:", end - start)
python生成依赖
pip freeze > requirements.txt
Anaconda创建环境:
查看环境
export PATH="/opt/anaconda2/bin:$PATH"
source activate /home/yhm/anaconda/envs/yhm_tf
conda info --env
Anaconda创建环境
conda create -n py36 python=3.6
删除环境
conda remove -n py36 --all
激活环境
source activate py36
退出环境
source deactivate
ubuntu命令
重命名
mv former_name new_name
查看cuda版本
cat /usr/local/cuda/version.txt
nvcc --version
查看 cuDNN 版本
cat /usr/local/cuda/include/cudnn.h | grep CUDNN_MAJOR -A 2
显卡
nvidia-smi -L
查看配置
1.查看系统内核
uname -a
2.查看CPU
cat /proc/cpuinfo | grep model\ name
3.查看内存
cat /proc/meminfo | grep MemTotal
4.查看显卡
lspci | grep 'VGA'
驱动
cat /proc/driver/nvidia/version
5.查看硬盘
df -lh
Python指定显卡训练
import os
os.environ["CUDA_DEVICE_ORDER"] = "PCI_BUS_ID" #可不写
os.environ["CUDA_VISIBLE_DEVICES"] = "0" #0就是指定GPU 0 跑实验,可按需修改成其他GPU
os.environ["CUDA_VISIBLE_DEVICES"] = "0,2,3" #多个GPU
1.命令行修改文件夹权限
sudo chmod 777 dir(文件夹名)
wget https://stuff.mit.edu/afs/athena/course/6/6.036/miniconda3/lib/python3.6/lib-dynload/_bz2.cpython-36m-x86_64-linux-gnu.so
python
1.venv的使用
~/myPython/bin/python3.7 -m venv myEnv
python3 -m venv myEnv
Ubuntu下启动:
source myEnv/bin/activate
Windows cmd下启动:
myEnv/Scripts/activate.bat
退出:
deactivate
pip install -r requirements.txt
pip3 install --upgrade pip
pip install opencv-python
-i http://pypi.douban.com/simple/ --trusted-host=pypi.douban.com/simple
-i https://pypi.tuna.tsinghua.edu.cn/simple
-i https://pypi.doubanio.com/simple
-i https://pypi.python.org/simple
安装3.7
1.升级包索引和软件
sudo apt update
sudo apt upgrade -y
2.安装编译所需包
sudo apt install build-essential zlib1g-dev libncurses5-dev libgdbm-dev libnss3-dev libssl-dev libreadline-dev libffi-dev wget
sudo apt-get install -y gcc make build-essential libssl-dev zlib1g-dev \
libbz2-dev libreadline-dev libsqlite3-dev wget curl llvm libncurses5-dev \
libncursesw5-dev xz-utils tk-dev libffi-dev liblzma-dev
sudo apt-get install build-essential checkinstall
sudo apt-get install libreadline-gplv2-dev libncursesw5-dev libssl-dev libsqlite3-dev tk-dev libgdbm-dev libc6-dev libbz2-dev
sudo apt-get install zlib1g-dev libbz2-dev libssl-dev libncurses5-dev libsqlite3-dev libreadline-dev tk-dev libgdbm-dev libdb-dev libpcap-dev xz-utils libexpat1-dev liblzma-dev libffi-dev libc6-dev
# #
sudo apt-get install zlib1g-dev libbz2-dev libssl-dev libncurses5-dev libsqlite3-dev libreadline-dev tk-dev libgdbm-dev libdb-dev libpcap-dev xz-utils libexpat1-dev liblzma-dev libffi-dev libc6-dev
3.下载Python3.7
wget https://www.python.org/ftp/python/3.7.8/Python-3.7.8.tgz
淘宝镜像:wget https://npm.taobao.org/mirrors/python/3.7.8/Python-3.7.8.tgz
4.解压Python安装包
tar -xzvf Python-3.7.8.tgz
5.编译和安装
cd Python-3.7.8
./configure --prefix=/usr/local/src/python37 # 配置安装位置
./configure --prefix=/home/zx/myPython
sudo make
sudo make install
6.建立软连接
sudo ln -s /usr/local/src/python37/bin/python3.7 /usr/bin/python3.7
sudo ln -s /usr/local/src/python37/bin/pip3.7 /usr/bin/pip3.7
7.用python3.7替换掉系统默认的python3
sudo rm -rf /usr/bin/python3
sudo ln -s /usr/local/src/python37/bin/python3.7 /usr/bin/python3
8.卸载python
sudo apt remove python3.7
vi操作
退出
:wq! ----强制保存退出
:wq ---- 保存退出
:q ---- 退出
:q! --- 强制退出
移动
h : 在当前行向左移动一个字符
j: 移动到下一行
k: 移动到上一行
l: 在当前行向右移动一个字符
Ctrl +f: 向前滚动一页
Ctrl +b: 向后滚动一页
:n 将光标定位到第n行
H 将光标定位到屏幕的顶端
M 将光标定位到屏幕的中间
删除
x 删除光标后面的字符
X(大写X),删除光标前面的字符
dd删除光标所在的行
全部复制:按esc键后,先按gg,然后ggyG.
全部删除:按esc键后,先按gg(到达顶部),然后dG.
单行复制:按esc键后,然后yy.
单行删除:按esc键后,然后dd.
:set paste!
粘贴:按esc键后,然后p.
跳到文本的最后一行:按“G”,即“shift+g”
跳到第一行的第一个字符:先按两次“g”
跳转到当前行的第一个字符:在当前行按“0”