在服务器中跑代码时很多命令一段时间没用就会忘记,每次要用的时候都要去搜一下,很浪费时间。因此写一篇博客记录(遇到新的会来更新)。
1、df -h
查看磁盘大小
2、nvidia-smi
查看GPU使用情况
watch -n 1 nvidia-smi
1秒钟查看一次
3、vim ~/.bashrc
添加配置信息,更新环境变量
按 i
进入insert模式,添加下面的信息:
export PATH=/home/usr/local/cuda11.7/bin:$PATH
export LD_LIBRARY_PATH=/home/usr/local/cuda11.7/lib64:$LD_LIBRARY_PATH
export C_INCLUDE_PATH=/home/usr/local/cuda11.7/include:$C_INCLUDE_PATH
export CPLUS_INCLUDE_PATH=/home/usr/local/cuda11.7/include:$CPLUS_INCLUDE_PATH
里面需要稍微修改一下,换成自己的cuda路径和需要的版本。
然后按 :wq
保存并退出,配置完记得 source ~/.bashrc
。
4、sudo fuser -v /dev/nvidia*
查看哪些进程占用了内存,sudo kill -9 进程号
杀死进程。
5、配置cuda
cuda 11.7.1
wget https://developer.download.nvidia.com/compute/cuda/11.7.1/local_installers/cuda_11.7.1_515.65.01_linux.run
cuda 10.2
wget https://developer.download.nvidia.com/compute/cuda/10.2/Prod/local_installers/cuda_10.2.89_440.33.01_linux.run
cuda 9.2
https://developer.nvidia.com/cuda-92-download-archive
sudo bash ./cuda.run
,如果gcc版本不合适sudo bash ./cuda.run --override
# anaconda3
export PATH="/opt/anaconda3/bin:$PATH”
# cuda9
#export PATH=/usr/local/cuda-9.2/bin:$PATH
#export LD_LIBRARY_PATH=/usr/local/cuda-9.2/lib64:$LD_LIBRARY_PATH
#export C_INCLUDE_PATH=/usr/local/cuda-9.2/include:$C_INCLUDE_PATH
#export CPLUS_INCLUDE_PATH=/usr/local/cuda-9.2/include:$CPLUS_INCLUDE_PATH
# cuda10
export PATH=/usr/local/cuda-10.2/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda-10.2/lib64:$LD_LIBRARY_PATH
export C_INCLUDE_PATH=/usr/local/cuda-10.2/include:$C_INCLUDE_PATH
export CPLUS_INCLUDE_PATH=/usr/local/cuda-10.2/include:$CPLUS_INCLUDE_PATH
# cuda11
#export PATH=/usr/local/cuda-11.7/bin:$PATH
#export LD_LIBRARY_PATH=/usr/local/cuda-11.7/lib64:$LD_LIBRARY_PATH
#export C_INCLUDE_PATH=/usr/local/cuda-11.7/include:$C_INCLUDE_PATH
#export CPLUS_INCLUDE_PATH=/usr/local/cuda-11.7/include:$CPLUS_INCLUDE_PATH
#anaconda export PATH="/usr/local/anaconda3/bin:$PATH"
vim ~/.bashrc
,
source ~/.bashrc
,
nvcc -V
6、Ubuntu 创建软连接
# 创建软连接
ln -s 源地址 目的地址
#删除软连接
sudo rm 或者强制删除 -rf
7、查看tensorboard日志
# 本地查看服务器上的日志
tensorboard --logdir 地址 --port 8003