查看GPU基本信息
nvidia-smi
-
GPU:编号
-
Fan:风扇转速,在0到100%之间变动
-
Name:显卡名
-
Temp:显卡温度
-
Perf:性能状态,从P0到P12,P0性能最大,P12最小
-
Pwr:能耗
-
Bus-Id:GPU总线
-
Disp.A:表示GPU的显示是否初始化
-
Memory-Usage:显存使用率
-
GPU-Util:GPU利用率
-
Compute M.:计算模式
指定GPU及其用量
- 在终端指定GPU
- CUDA_VISIBLE_DEVICES=0 python file.py # 指定第一块GPU使用
- CUDA_VISIBLE_DEVICES=1 # Only device 1 will be seen
- CUDA_VISIBLE_DEVICES=0,1 # Devices 0 and 1 will be visible
- CUDA_VISIBLE_DEVICES=“0,1” # Same as above, quotation marks are optional 多GPU一起使用
- CUDA_VISIBLE_DEVICES=0,2,3 # Devices 0,2,3 will be visible; device 1 is masked
- CUDA_VISIBLE_DEVICES=“” # No GPU will be visible
- 在Python代码中指定GPU
import os
os.environ["CUDA_VISIBLE_DEVICES"] = "0" #指定第一块gpu
nohup命令使用
当ssh连接掉线时,可以将程序放在服务器后台使用
用途:不挂断地运行命令。
语法:nohup Command [ Arg … ] [ & ]
无论是否将 nohup 命令的输出重定向到终端,输出都将附加到当前目录的 nohup.out 文件中。
如果当前目录的 nohup.out 文件不可写,输出重定向到 $HOME/nohup.out 文件中。
如果没有文件能创建或打开以用于追加,那么 Command 参数指定的命令不可调用。
退出状态:该命令返回下列出口值:
126 可以查找但不能调用 Command 参数指定的命令。
127 nohup 命令发生错误或不能查找由 Command 参数指定的命令。
否则,nohup 命令的退出状态是 Command 参数指定命令的退出状态。
# 默认将日志输出到current_path下的nohup.out文件中(日志内容为train.py中所有打印到控制台的内容)
(base) [hostname current_path]$ nohup python train.py &
# 指定输出文件 (指定输出日志到当前路径下的log.txt文件中
(base) [hostname current_path]$ nohup python train.py &>log.txt
# 查看系统中正在运行的进程,找到对应的进程号
ps aux | less
# 杀死进程
kill -9 14303[进程号pid]
# 查看某一进程详细信息
ps -aux|grep 进程号