查看当前jupyter环境下的版本:
import sys
sys.version
设置jupyter打开位置:
jupyter notebook D:\Python\pytorchLearn\jupyter
查看torch是否可用:
import torch
print(torch.cuda.is_available())
print(torch.__version__)
!与%的区别
!开一个新的progress,执行完之后立即终止;provided by the Jupyter
%的操作会持续;provided by the IPython kernel
在 Jupyter 启动 Tensorboard:
pip install jupyter-tensorboard
%load_ext tensorboard
%tensorboard --logdir data/autograph/
- 后台运行
在云服务器中搭建好jupyter并运行后, 发现它会占用当前终端, 于是研究了一下怎么让它在后台运行.
1.入门级: jupyter notebook --allow-root > jupyter.log 2>&1 &
2.进阶版: nohup jupyter notebook --allow-root > jupyter.log 2>&1 &
解释: 1. 用&让命令后台运行, 并把标准输出写入jupyter.log中
nohup表示no hang up, 就是不挂起, 于是这个命令执行后即使终端退出, 也不会停止运行.
2. 终止进程
执行上面第2条命令, 可以发现关闭终端重新打开后, 用jobs找不到jupyter这个进程了, 于是要用ps -a, 可以显示这个进程的pid.
kill -9 pid 终止进程