搭建pytorch+jupyter docker

为了开发使用方便,搭建一套可直接运行的pytorch + jupyter的docker

一,下载pytorch docker

docker pull pytorch/pytorch:1.6.0-cuda10.1-cudnn7-runtime

二,安装 Jupyter

1,运行 pytorch 容器

nvidia-docker run -it --network=host -d pytorch/pytorch:1.6.0-cuda10.1-cudnn7-runtime

2,进入容器

docker exec -it xxxx(容器ID)

3,安装jupyter

pip install jupyter

4,生成配置文件

jupyter notebook --generate-config

如果使用root用户生成的配置文件路径为

/root/.jupyter/jupyter_notebook_config.py

5,生成密码

jupyter notebook password

密码会直接写入搭配配置文件中

Enter password: 
Verify password: 
[NotebookPasswordApp] Wrote hashed password to /root/.jupyter/jupyter_notebook_config.json

6,启动程序

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

注:也可以通过修改配置文件配置地址及端口号

/root/.jupyter/jupyter_notebook_config.json
{
  "NotebookApp": {
    "password": "xxxxx",
    "ip": "0.0.0.0",
    "port": 8888
  }
}
jupyter notebook --no-browser --allow-root

7,保存docker镜像

docker commit xxxx(容器ID) pytorch/pytorch_jupyter:1.6.0-cuda10.1-cudnn7-runtime

之后可以直接运行使用保存的docker镜像。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值