Last active
May 22, 2019 03:20
-
-
Save padeoe/3c4f63e2bc1caa609eda5cb2ddcb6884 to your computer and use it in GitHub Desktop.
a Pytorch docker script for human
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
FROM pytorch/pytorch:1.1.0-cuda10.0-cudnn7.5-devel | |
# use local apt mirror | |
RUN sed -i 's/archive.ubuntu.com/mirrors.aliyun.com/g;s/security.ubuntu.com/mirrors.aliyun.com/g' /etc/apt/sources.list | |
RUN apt-get update | |
# use local pip mirror | |
RUN mkdir ~/.pip \ | |
&& printf '%s\n%s\n%s\n' '[global]' 'trusted-host = mirrors.aliyun.com' \ | |
'index-url = https://mirrors.aliyun.com/pypi/simple'>> ~/.pip/pip.conf | |
# open ssh for pycharm remote interpreter | |
RUN apt-get install -y openssh-server | |
RUN mkdir /var/run/sshd | |
RUN echo 'root:pytorch' | chpasswd | |
RUN sed -r -i 's/^\s*#?\s*PermitRootLogin\s*\S*\s*/PermitRootLogin yes/' /etc/ssh/sshd_config | |
# SSH login fix. Otherwise user is kicked off after login | |
RUN sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd | |
ENV NOTVISIBLE "in users profile" | |
RUN echo "export VISIBLE=now" >> /etc/profile | |
# change locale | |
RUN DEBIAN_FRONTEND=noninteractive apt-get install -y locales | |
RUN sed -i -e 's/# en_US.UTF-8 UTF-8/en_US.UTF-8 UTF-8/' /etc/locale.gen && \ | |
dpkg-reconfigure --frontend=noninteractive locales && \ | |
update-locale LANG=en_US.UTF-8 | |
ENV LC_ALL en_US.UTF-8 | |
# set local time zone | |
RUN apt-get install -y tzdata | |
RUN ln -fs /usr/share/zoneinfo/Asia/Shanghai /etc/localtime | |
RUN dpkg-reconfigure --frontend noninteractive tzdata | |
# config python env | |
RUN echo "export PATH=/opt/conda/bin:$PATH" > /etc/environment | |
# install jupyter and jupyter themes | |
RUN pip install prompt-toolkit jupyter | |
RUN pip install -U cython ipython prompt-toolkit==2.0.9 jupyterthemes | |
# set jupyter theme(you can choose another theme, see https://github.com/dunovank/jupyter-themes) | |
RUN jt -t chesterish -f source | |
## install chinese fonts for matplotlib | |
RUN apt-get -y install fontconfig unzip | |
RUN wget https://noto-website-2.storage.googleapis.com/pkgs/NotoSansSC.zip -O /tmp/NotoSansSC.zip && unzip /tmp/NotoSansSC.zip -d /usr/share/fonts/truetype/NotoSansSC | |
RUN fc-cache -f -v | |
EXPOSE 22 8888 | |
ENTRYPOINT service ssh start && jupyter notebook --ip=0.0.0.0 --no-browser --allow-root |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment