- 根据已有镜像创建容器,注意要设置端口映射
docker create -it --runtime=nvidia --shm-size 64G -p 3000:22 -v /6TB/zq:/zq --name zq-mmseg1 pytorch/pytorch:1.10.0-cuda11.3-cudnn8-devel
# -p 设置端口映射,将宿主机的3000端口映射到容器的22端口,
# 然后就可以通过宿主机的3000端口访问容器的22端口了(SSH)
# -v 设置文件映射,可以将容器外部的文件映射到内部,在内部修改文件时,外部也可以访问这个文件
# pytorch镜像中devel与runtime的区别在于,devel的cuda功能完整,当安装mmseg/mmdet等时需要使用devel版本的镜像
- 启动并进入容器
docker start zq-mmseg1
docker attach zq-mmseg1
- 老规矩,先更新一下
apt-get update
apt update
- 安装ssh服务
apt-get install openssh-server
- 修改配置文件,允许root密码登录
vim /etc/ssh/sshd_config
# 找到文件中的PermitRootLogin, 取消注释,并yes
PermitRootLogin yes
- 设置root密码
passwd
- 启动ssh服务
/etc/init.d/ssh start
- 连接SSH(注意端口号是步骤1中设置的那个端口映射的宿主机端口号)
其他ubuntu终端好用的工具
- oh-my-zsh美化终端
- vim tmux
apt-get install tmux vim
- gpustat(pip安装),好用的GPU信息查看工具,watch -n 1 gpustat可以1秒刷新一次
pip install pip -U (如果出现bash: pip: command not found,则:ln -s /opt/conda/bin/pip /usr/bin/pip)
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
pip install gpustat