最近在微软实习,学习到很多新东西。
连接Linux远程服务器运行程序时,有几个特别好用的命令。
简单汇总一下。
保存终端
防止因为网络断开等原因导致运行代码的终端丢失。
# 保存终端的命令
tmux new -s 0
tmux attach -t 0
运行脚本
运行代码可以不用一个一个手动运行。可以在txt文件中写一个运行脚本,每一行都是完整要执行命令即可。
-j 3
表示代码以3个进程并行的方式运行。
# 并行执行txt中命令行
cat run.txt | parallel --progress --j 3
当脚本中的执行指令超过3行时,之前的指令完成后,程序会持续读取新指令,直到所有指令执行完毕。
脚本内容大致如下:
它可以自动以pipeline形式发起15个进程。
python ../robust_state.py --dataset hopper-medium-v2 --expectile 1.0 --weight 3 --alphath 10 --gpu 1 --noise 0.05
python ../robust_state.py --dataset walker2d-medium-v2 --expectile 0.1 --weight 3 --alphath 10 --gpu 0 --noise 0.05
python ../robust_state.py --dataset halfcheetah-medium-v2 --expectile 1 --weight 3 --alphath 10 --gpu 1 --noise 0.05
python ../robust_state.py --dataset hopper-random-v2 --expectile 1.0 --weight 3 --alphath 10 --gpu 0 --noise 0.05
python ../robust_state.py --dataset walker2d-random-v2 --expectile 0.1 --weight 3 --alphath 10 --gpu 0 --noise 0.05
python ../robust_state.py --dataset halfcheetah-random-v2 --expectile 1 --weight 3 --alphath 10 --gpu 1 --noise 0.05
python ../robust_state.py --dataset hopper-expert-v2 --expectile 1.0 --weight 3 --alphath 10 --gpu 0 --noise 0.05
python ../robust_state.py --dataset walker2d-expert-v2 --expectile 0.1 --weight 3 --alphath 10 --gpu 1 --noise 0.05
python ../robust_state.py --dataset halfcheetah-expert-v2 --expectile 1 --weight 3 --alphath 10 --gpu 0 --noise 0.05
python ../robust_state.py --dataset hopper-medium-expert-v2 --expectile 1.0 --weight 3 --alphath 10 --gpu 1 --noise 0.05
python ../robust_state.py --dataset walker2d-medium-expert-v2 --expectile 0.1 --weight 3 --alphath 10 --gpu 0 --noise 0.05
python ../robust_state.py --dataset halfcheetah-medium-expert-v2 --expectile 1 --weight 3 --alphath 10 --gpu 1 --noise 0.05
python ../robust_state.py --dataset hopper-medium-replay-v2 --expectile 1.0 --weight 3 --alphath 10 --gpu 0 --noise 0.05
python ../robust_state.py --dataset walker2d-medium-replay-v2 --expectile 0.1 --weight 3 --alphath 10 --gpu 0 --noise 0.05
python ../robust_state.py --dataset halfcheetah-medium-replay-v2 --expectile 1 --weight 3 --alphath 10 --gpu 1 --noise 0.05
和tmux搭配使用效果更好。
查看tensorboard
这个常用。在浏览器中查看实验曲线。
默认端口应该是6006.不自己指定也可以。
# 指定端口查看tensorboard
tensorboard --logdir=. --port=17777
tensorboard --logdir=.
服务器之间传送文件/文件夹
只需要将自己的身份文件放上去就可以很方便了。
scp -i ~/.ssh/id -r ./projects/d3rlpy XXX@GCRSANDBOX235:~/projects/