Skip to content

Instantly share code, notes, and snippets.

@AkashiSN
Created January 21, 2022 14:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save AkashiSN/89b491aefba5dd1dfef0cf23fc57c48b to your computer and use it in GitHub Desktop.
Save AkashiSN/89b491aefba5dd1dfef0cf23fc57c48b to your computer and use it in GitHub Desktop.
dl_remote (途中で力尽きた奴)
docker buildx build -t dl_remote .
# syntax = docker/dockerfile:1.3-labs
ARG UBUNTU_VERSION=20.04
ARG CUDA_SDK_VERSION=11.3.0
FROM nvidia/cuda:${CUDA_SDK_VERSION}-devel-ubuntu${UBUNTU_VERSION}
SHELL ["/bin/sh", "-e", "-c"]
ENV DEBIAN_FRONTEND=noninteractive
ENV NVIDIA_VISIBLE_DEVICES all
ENV NVIDIA_DRIVER_CAPABILITIES compute,utility,video
# Install build tools
RUN <<EOT
sed -i -r 's!(deb|deb-src) \S+!\1 http://ftp.jaist.ac.jp/pub/Linux/ubuntu/!' /etc/apt/sources.list
apt-get update
apt-get install -y \
build-essential \
curl \
git \
libtool \
make \
pkg-config \
unzip \
wget \
zsh
EOT
# Install zinit
RUN <<EOT
mkdir -p "$HOME/.zinit" && command chmod g-rwX "$HOME/.zinit"
git clone https://github.com/zdharma-continuum/zinit "$HOME/.zinit/bin"
EOT
SHELL ["/bin/zsh", "-e", "-c"]
# anyenv setting
RUN <<EOT
cat << 'EOS' > $HOME/.zshrc
source "$HOME/.zinit/bin/zinit.zsh"
autoload -Uz _zinit
(( ${+_comps} )) && _comps[zinit]=_zinit
zinit load momo-lab/zsh-abbrev-alias
zinit ice wait'!0'; zinit load zsh-users/zsh-syntax-highlighting
zinit ice compile'(pure|async).zsh' pick'async.zsh' src'pure.zsh'
zinit light sindresorhus/pure
zinit ice blockf
zinit ice wait'!0'; zinit light zsh-users/zsh-completions
zinit ice wait'!0'; zinit load esc/conda-zsh-completion
EOS
EOT
# Install anyenv
ENV ANYENV_ROOT="$HOME/.anyenv"
ENV PATH="$ANYENV_ROOT/bin:$PATH"
RUN <<EOT
git clone https://github.com/anyenv/anyenv "$ANYENV_ROOT"
mkdir -p $ANYENV_ROOT/plugins
git clone https://github.com/znz/anyenv-update.git $ANYENV_ROOT/plugins/anyenv-update
git clone https://github.com/znz/anyenv-git.git $ANYENV_ROOT/plugins/anyenv-git
yes | anyenv install --init
eval "$(env PATH="$ANYENV_ROOT/libexec:$PATH" $ANYENV_ROOT/libexec/anyenv-init - --no-rehash zsh)"
EOT
# anyenv setting
RUN <<EOT
cat << 'EOS' >> $HOME/.zshrc
export ANYENV_ROOT="$HOME/.anyenv"
export PATH=$ANYENV_ROOT/bin:$PATH
eval "$(env PATH="$ANYENV_ROOT/libexec:$PATH" $ANYENV_ROOT/libexec/anyenv-init - --no-rehash)"
EOS
EOT
# Install pyenv
ENV ANACONDA3_VERSION=2021.05
ENV PYENV_ROOT=$ANYENV_ROOT/envs/pyenv
RUN <<EOT
anyenv install pyenv
$PYENV_ROOT/bin/pyenv install anaconda3-${ANACONDA3_VERSION}
$PYENV_ROOT/bin/pyenv global anaconda3-${ANACONDA3_VERSION}
EOT
# Conda setting
RUN <<EOT
cat << 'EOS' >> $HOME/.zshrc
__conda_setup="$($PYENV_ROOT/versions/anaconda3-${ANACONDA3_VERSION}/bin/conda shell.zsh hook 2> /dev/null)"
if [ $? -eq 0 ]; then
eval "$__conda_setup"
else
if [ -f "$PYENV_ROOT/versions/anaconda3-${ANACONDA3_VERSION}/etc/profile.d/conda.sh" ]; then
. "$PYENV_ROOT/versions/anaconda3-${ANACONDA3_VERSION}/etc/profile.d/conda.sh"
else
export PATH="$PYENV_ROOT/versions/anaconda3-${ANACONDA3_VERSION}/bin:$PATH"
fi
fi
unset __conda_setup
EOS
cat << EOS >> $HOME/.zshrc
export ANACONDA3_VERSION=${ANACONDA3_VERSION}
EOS
EOT
# Update conda
RUN <<EOT
conda update -n base python -c defaults
conda update -n base conda
conda clean --all --yes
EOT
# Install TensorRT
RUN <<EOT
apt-get install -y \
libnvinfer-dev \
libnvonnxparsers-dev \
libnvparsers-dev \
libnvinfer-plugin-dev
EOT
# Install tensorflow-gpu
RUN conda install -y tensorflow-gpu
# Install pytorch
RUN conda install -y pytorch torchvision torchaudio -c pytorch
RUN conda install pyg -c pyg -c conda-forge
RUN conda install pytorch-scatter pytorch-sparse pytorch-cluster pytorch-spline-conv -c pyg
# auto compile setting
RUN <<EOT
cat << 'EOS' >> $HOME/.zshrc
if [ ! -f $HOME/.zshrc.zwc -o $HOME/.zshrc -nt $HOME/.zshrc.zwc ]; then
zcompile $HOME/.zshrc
fi
EOS
EOT
WORKDIR /root
CMD ["zsh"]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment