前言
记录一些常用的 docker 指令, 主要是自己工作上用的比较多的。
查看已 pull 好的镜像
docker image ls
查看已启动的 container
docker ps
创建能在所有 GPU 上运行能使用 cuda 运算的 container
docker run -itd --gpus all --name 容器名 -e NVIDIA_DRIVER_CAPABILITIES=compute,utility -e NVIDIA_VISIBLE_DEVICES=all 镜像名
一些常用的 option:
- 设定 container 的 shared memory 大小,shm 默认为 64M,太小可能导致模型训练时内存不足报错。
--shm-size="30g" # 设定为 30G
- 挂载本地路径到 container 下。这样就不用每次 docker cp 挪文件了
/local/mnt/LOCAL-WORKSPACE:/CONTAINER-WORKSPCAE
启动 container
docker start 容器名
运行已启动的 container (一般都在 /bin/bash 下)
docker exec -it 容器名 /bin/bash
主机与container的文件传输
第一行,从主机拷贝文件到 container
第二行,从 container 拷贝文件到主机
docker cp /opt/test/file.txt mycontainer:/opt/testnew/
docker cp mycontainer:/opt/testnew/file.txt /opt/test/
总结
TBC,随时补充