docker/nvidia-docker使用整理

1.打开nvidia-docker

sudo nvidia-docker run -it -p 7777:8888 tensorflow/tensorflow:latest-gpu

2.docker内打开jupyter notebook


jupyter notebook --ip 0.0.0.0 --no-browser --allow-root

第一次浏览器打开jupyter notebook

172.28.9.220:7777/tree?token=9Llv9cCqyNv1Vf7g

172.28.9.220是服务器的ip
7777是开docker是映射号
token是docker开jupyter时显示的token
之后直接使用开启即可

172.28.9.220:7777

3.查看已安装docker

sudo docker images

查看正在运行的容器

sudo docker ps

容器做完修改必须保存

sudo dcoker commit 容器id 容器名
sudo docker commit f55f8ba11f95 tensorflow/tensorflow:latest-gpu

停止某容器

sudo docker stop 容器id

4.docker配置jupyter notebook

  • 创建存放jupyter notebook的文件夹

mkdir [存放notebook的文件夹]
mkdir jupyter

此时相当于在主机的/home/下创建了jupyter文件夹

3.2 如果容器内没有jupyter notebook,需要安装一下

pip install jupyter notebook

3.3 配置jupyter notebook

jupyter notebook --generate-config
vim ~/.jupyter/jupyter-notebook-config.py
1
2
修改如下内容

# 允许root启动
c.NotebookApp.allow_root = True
# 允许远程访问
c.NotebookApp.ip = '0.0.0.0'
# 设置notebook文件夹
c.NotebookApp.notebook_dir = '/jupyter'
# 设置静态token,这样就不用每次换token了,另一种方法是设置密码password
c.NotebookApp.token = '[自定义token]'

3.4 开启notebook

jupyter notebook &
按Ctrl+P+Q退出容器但不关闭

转载于:https://www.jianshu.com/p/38e5eb3d1e41

猜你喜欢

转载自blog.csdn.net/weixin_33843947/article/details/91098981