Last active
July 14, 2019 13:20
-
-
Save zning1994/dc98816a07f2f1339324964bc37ab429 to your computer and use it in GitHub Desktop.
Kaggle Docker for GPU Using in Mainland China
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
((=- Default to the notebook output style -=)) | |
((* if not cell_style is defined *)) | |
((* set cell_style = 'style_jupyter.tplx' *)) | |
((* endif *)) | |
((=- Inherit from the specified cell style. -=)) | |
((* extends cell_style *)) | |
%=============================================================================== | |
% Latex Article | |
%=============================================================================== | |
((* block docclass *)) | |
\documentclass[11pt]{ctexart} | |
((* endblock docclass *)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
((= Latex base template (must inherit) | |
This template builds upon the abstract template, adding common latex output | |
functions. Figures, data_text, | |
This template does not define a docclass, the inheriting class must define this.=)) | |
((*- extends 'document_contents.tplx' -*)) | |
%=============================================================================== | |
% Abstract overrides | |
%=============================================================================== | |
((* block header *)) | |
((* block docclass *))((* endblock docclass *)) | |
((* block packages *)) | |
\usepackage[T1]{fontenc} | |
% Nicer default font (+ math font) than Computer Modern for most use cases | |
\usepackage{mathpazo} | |
% Basic figure setup, for now with no caption control since it's done | |
% automatically by Pandoc (which extracts  syntax from Markdown). | |
\usepackage{graphicx} | |
% We will generate all images so they have a width \maxwidth. This means | |
% that they will get their normal width if they fit onto the page, but | |
% are scaled down if they would overflow the margins. | |
\makeatletter | |
\def\maxwidth{\ifdim\Gin@nat@width>\linewidth\linewidth | |
\else\Gin@nat@width\fi} | |
\makeatother | |
\let\Oldincludegraphics\includegraphics | |
% Set max figure width to be 80% of text width, for now hardcoded. | |
\renewcommand{\includegraphics}[1]{\Oldincludegraphics[width=.8\maxwidth]{#1}} | |
% Ensure that by default, figures have no caption (until we provide a | |
% proper Figure object with a Caption API and a way to capture that | |
% in the conversion process - todo). | |
\usepackage{caption} | |
\DeclareCaptionLabelFormat{nolabel}{} | |
\captionsetup{labelformat=nolabel} | |
\usepackage{adjustbox} % Used to constrain images to a maximum size | |
\usepackage{xcolor} % Allow colors to be defined | |
\usepackage{enumerate} % Needed for markdown enumerations to work | |
\usepackage{geometry} % Used to adjust the document margins | |
\usepackage{amsmath} % Equations | |
\usepackage{amssymb} % Equations | |
\usepackage{textcomp} % defines textquotesingle | |
% Hack from http://tex.stackexchange.com/a/47451/13684: | |
\AtBeginDocument{% | |
\def\PYZsq{\textquotesingle}% Upright quotes in Pygmentized code | |
} | |
\usepackage{upquote} % Upright quotes for verbatim code | |
\usepackage{eurosym} % defines \euro | |
\usepackage[mathletters]{ucs} % Extended unicode (utf-8) support | |
\usepackage[utf8x]{inputenc} % Allow utf-8 characters in the tex document | |
\usepackage{fancyvrb} % verbatim replacement that allows latex | |
\usepackage{grffile} % extends the file name processing of package graphics | |
% to support a larger range | |
% The hyperref package gives us a pdf with properly built | |
% internal navigation ('pdf bookmarks' for the table of contents, | |
% internal cross-reference links, web links for URLs, etc.) | |
\usepackage{hyperref} | |
\usepackage{longtable} % longtable support required by pandoc >1.10 | |
\usepackage{booktabs} % table support for pandoc > 1.12.2 | |
\usepackage[inline]{enumitem} % IRkernel/repr support (it uses the enumerate* environment) | |
\usepackage[normalem]{ulem} % ulem is needed to support strikethroughs (\sout) | |
% normalem makes italics be italics, not underlines | |
\usepackage{mathrsfs} | |
((* endblock packages *)) | |
((* block definitions *)) | |
% Colors for the hyperref package | |
\definecolor{urlcolor}{rgb}{0,.145,.698} | |
\definecolor{linkcolor}{rgb}{.71,0.21,0.01} | |
\definecolor{citecolor}{rgb}{.12,.54,.11} | |
% ANSI colors | |
\definecolor{ansi-black}{HTML}{3E424D} | |
\definecolor{ansi-black-intense}{HTML}{282C36} | |
\definecolor{ansi-red}{HTML}{E75C58} | |
\definecolor{ansi-red-intense}{HTML}{B22B31} | |
\definecolor{ansi-green}{HTML}{00A250} | |
\definecolor{ansi-green-intense}{HTML}{007427} | |
\definecolor{ansi-yellow}{HTML}{DDB62B} | |
\definecolor{ansi-yellow-intense}{HTML}{B27D12} | |
\definecolor{ansi-blue}{HTML}{208FFB} | |
\definecolor{ansi-blue-intense}{HTML}{0065CA} | |
\definecolor{ansi-magenta}{HTML}{D160C4} | |
\definecolor{ansi-magenta-intense}{HTML}{A03196} | |
\definecolor{ansi-cyan}{HTML}{60C6C8} | |
\definecolor{ansi-cyan-intense}{HTML}{258F8F} | |
\definecolor{ansi-white}{HTML}{C5C1B4} | |
\definecolor{ansi-white-intense}{HTML}{A1A6B2} | |
\definecolor{ansi-default-inverse-fg}{HTML}{FFFFFF} | |
\definecolor{ansi-default-inverse-bg}{HTML}{000000} | |
% commands and environments needed by pandoc snippets | |
% extracted from the output of `pandoc -s` | |
\providecommand{\tightlist}{% | |
\setlength{\itemsep}{0pt}\setlength{\parskip}{0pt}} | |
\DefineVerbatimEnvironment{Highlighting}{Verbatim}{commandchars=\\\{\}} | |
% Add ',fontsize=\small' for more characters per line | |
\newenvironment{Shaded}{}{} | |
\newcommand{\KeywordTok}[1]{\textcolor[rgb]{0.00,0.44,0.13}{\textbf{{#1}}}} | |
\newcommand{\DataTypeTok}[1]{\textcolor[rgb]{0.56,0.13,0.00}{{#1}}} | |
\newcommand{\DecValTok}[1]{\textcolor[rgb]{0.25,0.63,0.44}{{#1}}} | |
\newcommand{\BaseNTok}[1]{\textcolor[rgb]{0.25,0.63,0.44}{{#1}}} | |
\newcommand{\FloatTok}[1]{\textcolor[rgb]{0.25,0.63,0.44}{{#1}}} | |
\newcommand{\CharTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{{#1}}} | |
\newcommand{\StringTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{{#1}}} | |
\newcommand{\CommentTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textit{{#1}}}} | |
\newcommand{\OtherTok}[1]{\textcolor[rgb]{0.00,0.44,0.13}{{#1}}} | |
\newcommand{\AlertTok}[1]{\textcolor[rgb]{1.00,0.00,0.00}{\textbf{{#1}}}} | |
\newcommand{\FunctionTok}[1]{\textcolor[rgb]{0.02,0.16,0.49}{{#1}}} | |
\newcommand{\RegionMarkerTok}[1]{{#1}} | |
\newcommand{\ErrorTok}[1]{\textcolor[rgb]{1.00,0.00,0.00}{\textbf{{#1}}}} | |
\newcommand{\NormalTok}[1]{{#1}} | |
% Additional commands for more recent versions of Pandoc | |
\newcommand{\ConstantTok}[1]{\textcolor[rgb]{0.53,0.00,0.00}{{#1}}} | |
\newcommand{\SpecialCharTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{{#1}}} | |
\newcommand{\VerbatimStringTok}[1]{\textcolor[rgb]{0.25,0.44,0.63}{{#1}}} | |
\newcommand{\SpecialStringTok}[1]{\textcolor[rgb]{0.73,0.40,0.53}{{#1}}} | |
\newcommand{\ImportTok}[1]{{#1}} | |
\newcommand{\DocumentationTok}[1]{\textcolor[rgb]{0.73,0.13,0.13}{\textit{{#1}}}} | |
\newcommand{\AnnotationTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textbf{\textit{{#1}}}}} | |
\newcommand{\CommentVarTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textbf{\textit{{#1}}}}} | |
\newcommand{\VariableTok}[1]{\textcolor[rgb]{0.10,0.09,0.49}{{#1}}} | |
\newcommand{\ControlFlowTok}[1]{\textcolor[rgb]{0.00,0.44,0.13}{\textbf{{#1}}}} | |
\newcommand{\OperatorTok}[1]{\textcolor[rgb]{0.40,0.40,0.40}{{#1}}} | |
\newcommand{\BuiltInTok}[1]{{#1}} | |
\newcommand{\ExtensionTok}[1]{{#1}} | |
\newcommand{\PreprocessorTok}[1]{\textcolor[rgb]{0.74,0.48,0.00}{{#1}}} | |
\newcommand{\AttributeTok}[1]{\textcolor[rgb]{0.49,0.56,0.16}{{#1}}} | |
\newcommand{\InformationTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textbf{\textit{{#1}}}}} | |
\newcommand{\WarningTok}[1]{\textcolor[rgb]{0.38,0.63,0.69}{\textbf{\textit{{#1}}}}} | |
% Define a nice break command that doesn't care if a line doesn't already | |
% exist. | |
\def\br{\hspace*{\fill} \\* } | |
% Math Jax compatibility definitions | |
\def\gt{>} | |
\def\lt{<} | |
\let\Oldtex\TeX | |
\let\Oldlatex\LaTeX | |
\renewcommand{\TeX}{\textrm{\Oldtex}} | |
\renewcommand{\LaTeX}{\textrm{\Oldlatex}} | |
% Document parameters | |
% Document title | |
((* block title -*)) | |
((*- set nb_title = nb.metadata.get('title', '') or resources['metadata']['name'] -*)) | |
\title{((( nb_title )))} | |
((*- endblock title *)) | |
((* block date *))((* endblock date *)) | |
((* block author *)) | |
((* if 'authors' in nb.metadata *)) | |
\author{((( nb.metadata.authors | join(', ', attribute='name') )))} | |
((* endif *)) | |
((* endblock author *)) | |
((* endblock definitions *)) | |
((* block commands *)) | |
% Prevent overflowing lines due to hard-to-break entities | |
\sloppy | |
% Setup hyperref package | |
\hypersetup{ | |
breaklinks=true, % so long urls are correctly broken across lines | |
colorlinks=true, | |
urlcolor=urlcolor, | |
linkcolor=linkcolor, | |
citecolor=citecolor, | |
} | |
% Slightly bigger margins than the latex defaults | |
((* block margins *)) | |
\geometry{verbose,tmargin=1in,bmargin=1in,lmargin=1in,rmargin=1in} | |
((* endblock margins *)) | |
((* endblock commands *)) | |
((* endblock header *)) | |
((* block body *)) | |
\begin{document} | |
((* block predoc *)) | |
((* block maketitle *))\maketitle((* endblock maketitle *)) | |
((* block abstract *))((* endblock abstract *)) | |
((* endblock predoc *)) | |
((( super() ))) | |
% Add a bibliography block to the postdoc | |
((* block postdoc *)) | |
((* block bibliography *))((* endblock bibliography *)) | |
((* endblock postdoc *)) | |
\end{document} | |
((* endblock body *)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ARG BASE_TAG=staging | |
FROM nvidia/cuda:10.0-cudnn7-devel-ubuntu18.04 AS nvidia | |
FROM gcr.azk8s.cn/kaggle-images/python-tensorflow-whl:1.14.0-py36 as tensorflow_whl | |
FROM gcr.azk8s.cn/kaggle-images/python:${BASE_TAG} | |
ADD clean-layer.sh /tmp/clean-layer.sh | |
# Cuda support | |
COPY --from=nvidia /etc/apt/sources.list.d/cuda.list /etc/apt/sources.list.d/ | |
COPY --from=nvidia /etc/apt/sources.list.d/nvidia-ml.list /etc/apt/sources.list.d/ | |
COPY --from=nvidia /etc/apt/trusted.gpg /etc/apt/trusted.gpg.d/cuda.gpg | |
RUN echo "deb https://mirrors.cloud.tencent.com/nvidia-cuda/ubuntu1804/x86_64 /" > /etc/apt/sources.list.d/cuda.list &&\ | |
echo "deb https://mirrors.cloud.tencent.com/nvidia-machine-learning/ubuntu1804/x86_64 /">/etc/apt/sources.list.d/nvidia-ml.list | |
RUN apt-key adv --keyserver keyserver.ubuntu.com --recv-keys F60F4B3D7FA2AF80 &&\ | |
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 3B4FE6ACC0B21F32 | |
# Ensure the cuda libraries are compatible with the custom Tensorflow wheels. | |
# TODO(b/120050292): Use templating to keep in sync or COPY installed binaries from it. | |
ENV CUDA_VERSION=10.0.130 | |
ENV CUDA_PKG_VERSION=10-0=$CUDA_VERSION-1 | |
LABEL com.nvidia.volumes.needed="nvidia_driver" | |
LABEL com.nvidia.cuda.version="${CUDA_VERSION}" | |
ENV PATH=/usr/local/nvidia/bin:/usr/local/cuda/bin:${PATH} | |
# The stub is useful to us both for built-time linking and run-time linking, on CPU-only systems. | |
# When intended to be used with actual GPUs, make sure to (besides providing access to the host | |
# CUDA user libraries, either manually or through the use of nvidia-docker) exclude them. One | |
# convenient way to do so is to obscure its contents by a bind mount: | |
# docker run .... -v /non-existing-directory:/usr/local/cuda/lib64/stubs:ro ... | |
#ENV LD_LIBRARY_PATH="/usr/local/nvidia/lib64:/usr/local/cuda/lib64:/usr/local/cuda/lib64/stubs" | |
ENV LD_LIBRARY_PATH="/usr/local/cuda/lib64" | |
ENV NVIDIA_VISIBLE_DEVICES=all | |
ENV NVIDIA_DRIVER_CAPABILITIES=compute,utility | |
ENV NVIDIA_REQUIRE_CUDA="cuda>=10.0" | |
RUN echo 'deb https://mirrors.cloud.tencent.com/ubuntu/ xenial main restricted universe multiverse'> /etc/apt/sources.list &&\ | |
echo 'deb https://mirrors.cloud.tencent.com/ubuntu/ xenial-updates main restricted universe multiverse'>> /etc/apt/sources.list &&\ | |
echo 'deb https://mirrors.cloud.tencent.com/ubuntu/ xenial-backports main restricted universe multiverse'>> /etc/apt/sources.list &&\ | |
echo 'deb https://mirrors.cloud.tencent.com/ubuntu/ xenial-security main restricted universe multiverse'>> /etc/apt/sources.list | |
RUN conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/free/ &&\ | |
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/pkgs/main/ &&\ | |
conda config --add channels https://mirrors.tuna.tsinghua.edu.cn/anaconda/cloud/pytorch/ &&\ | |
conda config --set show_channel_urls yes | |
RUN apt-get update && apt-get install -y --no-install-recommends \ | |
cuda-cupti-$CUDA_PKG_VERSION \ | |
cuda-cudart-$CUDA_PKG_VERSION \ | |
cuda-cudart-dev-$CUDA_PKG_VERSION \ | |
cuda-libraries-$CUDA_PKG_VERSION \ | |
cuda-libraries-dev-$CUDA_PKG_VERSION \ | |
cuda-nvml-dev-$CUDA_PKG_VERSION \ | |
cuda-minimal-build-$CUDA_PKG_VERSION \ | |
cuda-command-line-tools-$CUDA_PKG_VERSION \ | |
libcudnn7=7.5.0.56-1+cuda10.0 \ | |
libcudnn7-dev=7.5.0.56-1+cuda10.0 \ | |
libnccl2=2.4.2-1+cuda10.0 \ | |
libnccl-dev=2.4.2-1+cuda10.0 \ | |
cuda-nvjpeg-10-0=10.0.130-1 \ | |
cuda-nvjpeg-dev-10-0=10.0.130-1 &&\ | |
ln -s /usr/local/cuda-10.0 /usr/local/cuda && \ | |
ln -s /usr/local/cuda/lib64/stubs/libcuda.so /usr/local/cuda/lib64/stubs/libcuda.so.1 && \ | |
/tmp/clean-layer.sh | |
# Reinstall packages with a separate version for GPU support | |
# Tensorflow | |
COPY --from=tensorflow_whl /tmp/tensorflow_gpu/*.whl /tmp/tensorflow_gpu/ | |
RUN pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple &&\ | |
pip uninstall -y tensorflow && \ | |
pip install /tmp/tensorflow_gpu/tensorflow*.whl && \ | |
rm -rf /tmp/tensorflow_gpu && \ | |
conda remove --force -y pytorch-cpu torchvision-cpu && \ | |
conda install -y pytorch torchvision cudatoolkit=10.0 && \ | |
pip uninstall -y mxnet && \ | |
# b/126259508 --no-deps prevents numpy from being downgraded. | |
pip install --no-deps mxnet-cu100 && \ | |
/tmp/clean-layer.sh | |
# Install GPU-only packages | |
RUN pip install pycuda && \ | |
pip install cupy-cuda100 && \ | |
pip install pynvrtc && \ | |
/tmp/clean-layer.sh | |
# Install custom tools | |
#RUN apt-get install -y libvips-dev libvips libturbojpeg &&\ | |
# pip install jpeg4py pyvips albumentations fastai &&\ | |
# /tmp/clean-layer.sh | |
# Install ctex for jupyter notebook export Chinese pdf | |
# RUN apt-get install -y pandoc && \ | |
# apt-get install -y texlive-xetex && \ | |
# apt-get install -y texlive-lang-cjk && \ | |
# pip install pdfkit && \ | |
# /tmp/clean-layer.sh | |
# add ctex for jupyter notebook export Chinese pdf | |
# ADD article.tplx /opt/conda/lib/python3.6/site-packages/nbconvert/templates/latex/article.tplx | |
# ADD article.tplx /opt/conda/pkgs/nbconvert-5.5.0-py_0/site-packages/nbconvert/templates/latex/article.tplx | |
# ADD article.tplx /opt/conda/pkgs/nbconvert-5.4.1-py37_3/lib/python3.7/site-packages/nbconvert/templates/latex/article.tplx | |
# ADD base.tplx /opt/conda/lib/python3.6/site-packages/nbconvert/templates/latex/base.tplx | |
# ADD base.tplx /opt/conda/pkgs/nbconvert-5.5.0-py_0/site-packages/nbconvert/templates/latex/base.tplx | |
# ADD base.tplx /opt/conda/pkgs/nbconvert-5.4.1-py37_3/lib/python3.7/site-packages/nbconvert/templates/latex/base.tplx | |
# Re-add TensorBoard Jupyter extension patch | |
ADD patches/tensorboard/notebook.py /opt/conda/lib/python3.6/site-packages/tensorboard/notebook.py |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment