Skip to content

Instantly share code, notes, and snippets.

@YimianDai
Last active October 17, 2019 06:59
Show Gist options
  • Save YimianDai/f7a25e0a2c16077819ebd55f2985f714 to your computer and use it in GitHub Desktop.
Save YimianDai/f7a25e0a2c16077819ebd55f2985f714 to your computer and use it in GitHub Desktop.
Docker-MXNet-Singularity

Step 1: 在本地机上安装 Docker

在 Ubuntu 上安装 https://docs.docker.com/install/linux/docker-ce/ubuntu/ 安装 Docker

Step 2: 安装 nvidia-docker-plugin 为了能够在 docker 中使用 GPU

根据 https://github.com/NVIDIA/nvidia-docker/wiki 安装

Step 3: 从 docker hub 上 pull 相应的 mxnet 镜像

sudo docker pull mxnet/python:1.5.0_gpu_cu90_mkl_py3

Step 4: 测试跑一下 mxnet 的镜像

sudo nvidia-docker run -it mxnet/python:1.5.0_gpu_cu90_mkl_py3 bash

Step 5: 在该镜像上安装我需要的软件和库

apt-get update 
apt install --assume-yes vim 
apt-get install -y wget python-dev gcc 
apt install python3-tk # Not apt-get 
pip install gluoncv --upgrade 
pip install scikit-image
pip install matplotlib

再在 ~/.bashrc 中修改好 alias

alias python='python3'

最后 exit 退出

Step 6: 保存新的镜像

sudo docker ps -a # Check the <CONTAINER ID> 
sudo docker commit <CONTAINER ID> yimian/gluoncv:latest # ,→ Create the docker image

这个时候 yimian/gluoncv:latest 这个镜像已经有了, 只不过 sudo docker ps -a 你看不到, 如果运行一次 sudo nvidia-docker run -it yimian/gluoncv:latest bash 再用 sudo docker ps -a 看就好了

Step 7: 将镜像推送到 Docker Hub

sudo docker login 
sudo docker push yimian/gluoncv:latest

Step 8: Building gluoncv.simg from Docker Hub on Ocelote

module load singularity
singularity build gluoncv.simg docker://yimian/gluoncv:latest

Step 9: 在启用了 GPU 的 Ocelote Node 上使用 mxnet

module load singularity
singularity exec --nv gluoncv.simg /bin/bash

不过注意一点, 虽然我在创建镜像的时候, 把 默认的 python3 改成了 python, 但是在运行该镜像后, 在 python 或者 python3 中是没有 mxnet 的, 需要用 python3.5 (原始镜像中带的 python 才可以.)

其他

往 Ocelote 上传输数据

scp -r ~/Nutstore\ Files/Dataset/Iceberg yimian@filexfer.hpc.arizona.edu:~/datasets/

破除安装的迷思

因为 Ocelote 上的 cudann 是 9.0, 但是不需要创建镜像的机器也必须是 cudann 9.0, 实际上我用的机器 Debug 是 10.1, 也能够创建好, 也能够在 Ocelote 上运行.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment