1. #后台运行并输入日志
  2. nohup sh run_1_4.sh > nohup_14_aug.out 2>&1 & # &作用是后台运行,不在桌面输出 nohup永久执行命令,即使ssh断开了
  3. wc --help
  4. cat file | wc -l # 查看文件总共有多少行
  5. ls file | wc -l # 查看目录下总共有多少个文件
  6. du -h -d 0 /sdf/RRC_V4_20200521/ # 查看文件/文件夹大小
  7. CUDA_VISIBLE_DEVICES=7 python -m ipdb train.py # debug python
  1. import time
  2. print(time.strftime('%Y_%m_%d_%H_%M_%S', time.localtime()))
  3. # 加载的模型的参数 多余 当前模型本身的参数
  4. model_dict = model.state_dict()
  5. pretrained_dict = torch.load('file.pth.tar')
  6. # 1. filter out unnecessary keys
  7. pretrained_dict = {k: v for k, vin pretrained_dict.items() if k in model_dict}
  8. # 2. overwrite entries in the existing state dict
  9. model_dict.update(pretrained_dict)
  10. # 3. load the new state dict
  11. model.load_state_dict(model_dict)
  12. # 加载的模型参数 少于 当前模型本身的参数
  13. model.load_state_dict(checkpoint['state_dict'],strict=False)
  14. #load_state_dict严格匹配参数的键名称
  15. #strict=False表示只加载与键值匹配的参数,并忽略其他参数键。

遍历文件夹:

  1. def walkFile(file):
  2. for root, dirs, files in os.walk(file):
  3. # root 表示当前正在访问的文件夹路径
  4. # dirs 表示该文件夹下的子目录名list
  5. # files 表示该文件夹下的文件list
  6. # 遍历文件
  7. for f in files:
  8. print(os.path.join(root, f))
  9. # 遍历所有的文件夹
  10. for d in dirs:
  11. print(os.path.join(root, d))
  1. export PATH=/usr/local/cuda-10.2/bin:$PATH
  2. export LD_LIBRARY_PATH=/usr/local/cuda-10.2/lib64:$LD_LIBRARY_PATH

https://blog.csdn.net/weixin_42699651/article/details/89019402