Depoly your flask app into Heroku Fix shit IE code manually ISBN to Book Category by Scraping DangDang A Generic Makefile for C/C++ Program Configure Raspberry pi Remove watermark with PyPDF2 tips for docker Anaconda+TensorFlow+CUDA Snippets Configure Remote Mathematica Kernel Build your own ngrok server Access Array SSL VPN 使用Rstudio制作html5幻灯片 tips for Mac OS X system Tips for ipython notebook 配置Ubuntu server + Openbox (Obuntu) tips for Vimperator tips for Vim 安装CUDA My First Jekyll Blog rsync常见选项 在Linux中读取Ipod touch的文件 tip for texmacs 在VPS上建站的一些tip Gnuplot绘图札记 Samba系统和autofs自动挂载 Linux中alsamixer声卡无法录音 搭建自己的RSS订阅器——Tiny Tiny RSS Grub2引导安装Ubuntu awk tips 将Ubuntu系统装入U盘 The Great Rtorrent 编译GCC 再这样剁手!!!该死的libgd 使用ulimit进行资源限制 使用SSH代理上IPV6 使用RCurl抓取网页数据 修复Ubuntu Grub记 openbox中的文件关联 在Ubuntu 12.04下编译qtiplot 处理BCM4312网卡驱动纪实 配置我的Ubuntu Server记 Cygwin杂记 Linux 使普通用户具有以超级权限执行脚本 让firefox自定义地处理文件类型 WordPress优秀主题及插件 在phpcloud上搭建wordpress UBUNTU下用pptpd做VPN server ubuntu升级内核过后的一些问题 安装telnet服务 kubuntu札记 64位kubuntu札记 统计软件R virtualbox stardict星际译王 Ubuntu重装windows系统后的grub引导修复 SSH服务及花生壳域名解析 采用cbp2make工具由code::blocks工程创建makefile文件 UBUNTU 札记

tips for docker

2017年07月14日

  1. docker cp host_file container:file_path 在容器和主机之间复制文件,可以用来临时替换entrypoint实现进入一个无限重启的容器以调试

  2. docker exec -it container /bin/bash 在主机上执行另一条命令

setup nvidia-cuda-jupyter

#!/bin/bash

## setup the docker nvidia runtime

wget https://raw.githubusercontent.com/NVIDIA/libnvidia-container/gh-pages/centos7/x86_64/libnvidia-container-tools-1.0.0-0.1.rc.2.x86_64.rpm
wget https://raw.githubusercontent.com/NVIDIA/libnvidia-container/gh-pages/centos7/x86_64/libnvidia-container1-1.0.0-0.1.rc.2.x86_64.rpm
wget https://raw.githubusercontent.com/NVIDIA/nvidia-docker/gh-pages/centos7/x86_64/nvidia-docker2-2.0.3-1.docker17.03.2.ce.noarch.rpm
wget https://raw.githubusercontent.com/NVIDIA/nvidia-container-runtime/gh-pages/centos7/x86_64/nvidia-container-runtime-2.0.0-1.docker17.03.2.x86_64.rpm
wget https://raw.githubusercontent.com/NVIDIA/nvidia-container-runtime/gh-pages/centos7/x86_64/nvidia-container-runtime-hook-1.2.1-1.x86_64.rpm

sudo rpm -ivh libnvidia-container1-1.0.0-0.1.rc.2.x86_64.rpm 
sudo rpm -ivh libnvidia-container-tools-1.0.0-0.1.rc.2.x86_64.rpm 
sudo rpm -ivh nvidia-container-runtime-hook-1.2.1-1.x86_64.rpm 
sudo rpm -ivh nvidia-container-runtime-2.0.0-1.docker17.03.2.x86_64.rpm 
sudo rpm -ivh nvidia-docker2-2.0.3-1.docker17.03.2.ce.noarch.rpm 

## test cuda within docker
cat nvidia.cuda.docker.image | docker load

sudo systemctl restart docker
docker run --runtime=nvidia --rm nvidia/cuda nvidia-smi
                                 
## import our own jupyter docker
cat jupyter.docker.image | docker load

## export some conda related files and create a new docker image 
docker run -t --rm jupyter/tensorflow-notebook tar -cf -  /opt/conda /usr/local/bin > jupyter.tar
wget http://security.ubuntu.com/ubuntu/pool/main/s/sudo/sudo_1.8.16-0ubuntu1.4_amd64.deb

cat > Dockerfile << 'EOF'                                 
FROM nvidia/cuda:9.0-devel-ubuntu16.04

ADD jupyter.tar /

ENV CONDA_DIR=/opt/conda SHELL=/bin/bash NB_USER=jovyan NB_UID=1000 NB_GID=100 PATH=/opt/conda/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin HOME=/home/jovyan
RUN useradd -m -s /bin/bash -N -u $NB_UID $NB_USER \
   &&  mkdir -p $CONDA_DIR \
   &&  chown $NB_USER:$NB_GID $CONDA_DIR \
   &&  chmod g+w /etc/passwd /etc/group \
   &&  fix-permissions $HOME \
   &&  fix-permissions $CONDA_DIR

COPY sudo_1.8.16-0ubuntu1.4_amd64.deb /
RUN dpkg -i /sudo_1.8.16-0ubuntu1.4_amd64.deb

EXPOSE 8888/tcp
WORKDIR /home/jovyan

ENTRYPOINT ["tini","--"]
CMD ["start-notebook.sh", "--ip", "0.0.0.0"]
EOF

docker build -t jupyter-cuda  .

## run the server
docker run -d --restart=always --runtime=nvidia -p 8888:8888 -p 8097:8097 -p 8080:8080 -p 8822:22 -v /DATA/gcc.home/jupyter_home:/home/jovyan:rshared -v data_science_tmp:/tmp -e NB_UID=555 -e NB_GID=555 -e GRANT_SUDO=yes --user root  --name jupyter jupyter-cuda start-notebook.sh --ip=0.0.0.0