Skip to content

Instantly share code, notes, and snippets.

@sysang
Last active July 16, 2023 11:42
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 sysang/9fcb4fe119f6d90b1da1eeca1fa26761 to your computer and use it in GitHub Desktop.
Save sysang/9fcb4fe119f6d90b1da1eeca1fa26761 to your computer and use it in GitHub Desktop.

jupyter_execute

Execute nbconver of docker container to convert ipynb to html

Dockerfile

Jupyter notebook container base on https://hub.docker.com/r/nvidia/cuda/

run_jupyter_cuda_enabled.md

Step to manually create jupyter notebook with cuda enabled

main.min.js

To modify file to make Jupyter Notebook reload file without restart kernel

FROM nvidia/cuda:11.7.1-runtime-ubuntu22.04
RUN apt-get update && \
apt-get install -y \
locales \
zsh \
git \
wget \
curl \
unzip \
neovim \
python3.10 \
python3-distutils
RUN sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.10 10
RUN wget https://bootstrap.pypa.io/get-pip.py
RUN python get-pip.py
RUN pip install --user jupyter
RUN pip install --user jupyter_contrib_nbextensions
RUN pip install --user jupyter_nbextensions_configurator
RUN /root/.local/bin/jupyter notebook --generate-config
COPY ./jupyter_notebook_config.py /root/.jupyter/jupyter_notebook_config.py
RUN echo "export PATH='$HOME/.local/bin:$PATH'" >> /root/.bashrc
RUN echo "export LD_LIBRARY_PATH='$LD_LIBRARY_PATH:/usr/local/cuda/extras/CUPTI/lib64'" >> /root/.bashrc
COPY ./main.min.js /root/main.min.js
CMD ["bash","-c", "/root/.local/bin/jupyter notebook", "-D", "FOREGROUND"]
# install ohmyzsh and plugins
# sh -c "$(wget -O- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
# git clone https://github.com/zsh-users/zsh-completions.git ${ZSH_CUSTOM:=~/.oh-my-zsh/custom}/plugins/zsh-completions
# Enable it in your .zshrc by adding it to your plugin list and reloading the completion: plugins=(… zsh-completions)
FROM nvidia/cuda:10.0-cudnn7-devel-ubuntu18.04
RUN apt-get update && \
apt-get install -y \
zsh \
git \
wget \
curl \
unzip \
neovim \
python3.7 \
python3-distutils
RUN sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.7 10
RUN wget https://bootstrap.pypa.io/get-pip.py
RUN python get-pip.py
RUN pip install --user jupyter
RUN pip install --user jupyter_contrib_nbextensions
RUN pip install --user jupyter_nbextensions_configurator
RUN /root/.local/bin/jupyter notebook --generate-config
COPY ./jupyter_notebook_config.py /root/.jupyter/jupyter_notebook_config.py
RUN echo "export PATH='$HOME/.local/bin:$PATH'" >> /root/.bashrc
RUN echo "export LD_LIBRARY_PATH='$LD_LIBRARY_PATH:/usr/local/cuda/extras/CUPTI/lib64'" >> /root/.bashrc
COPY ./jupyter-vim-binding.zip /root/jupyter-vim-binding.zip
CMD ["bash","-c", "/root/.local/bin/jupyter notebook", "-D", "FOREGROUND"]
FROM nvidia/cuda:10.1-cudnn7-devel-ubuntu18.04
RUN apt-get update && \
apt-get install -y \
zsh \
git \
wget \
curl \
unzip \
neovim \
python3.7 \
python3-distutils
RUN sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.7 10
RUN wget https://bootstrap.pypa.io/get-pip.py
RUN python get-pip.py
RUN pip install --user jupyter
RUN pip install --user jupyter_contrib_nbextensions
RUN pip install --user jupyter_nbextensions_configurator
RUN /root/.local/bin/jupyter notebook --generate-config
COPY ./jupyter_notebook_config.py /root/.jupyter/jupyter_notebook_config.py
RUN curl -sSL https://raw.githubusercontent.com/python-poetry/poetry/master/get-poetry.py | python
RUN echo 'export PATH="$HOME/.poetry/bin:$PATH"' >> ~/.zshrc
RUN git clone https://github.com/pyenv/pyenv.git ~/.pyenv
RUN echo 'export PYENV_ROOT="$HOME/.pyenv"' >> ~/.zshrc
RUN echo 'export PATH="$PYENV_ROOT/bin:$PATH"' >> ~/.zshrc
RUN echo "export PATH='$HOME/.local/bin:$PATH'" >> /root/.bashrc
RUN echo "export LD_LIBRARY_PATH='$LD_LIBRARY_PATH:/usr/local/cuda/extras/CUPTI/lib64'" >> /root/.bashrc
COPY ./jupyter-vim-binding.zip /root/jupyter-vim-binding.zip
CMD ["bash","-c", "/root/.local/bin/jupyter notebook", "-D", "FOREGROUND"]
# install ohmyzsh and plugins
# sh -c "$(wget -O- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
# git clone https://github.com/zsh-users/zsh-completions.git ${ZSH_CUSTOM:=~/.oh-my-zsh/custom}/plugins/zsh-completions
# Enable it in your .zshrc by adding it to your plugin list and reloading the completion: plugins=(… zsh-completions)
FROM nvidia/cuda:10.1-cudnn7-devel-ubuntu18.04
RUN apt-get update && \
apt-get install -y \
zsh \
git \
wget \
curl \
unzip \
neovim \
python3.8 \
python3-distutils
RUN sh -c "$(curl -fsSL https://raw.github.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
RUN update-alternatives --install /usr/bin/python python /usr/bin/python3.8 10
RUN wget https://bootstrap.pypa.io/get-pip.py
RUN python get-pip.py
RUN pip install --user jupyter
RUN pip install --user jupyter_contrib_nbextensions
RUN pip install --user jupyter_nbextensions_configurator
RUN /root/.local/bin/jupyter notebook --generate-config
COPY ./jupyter_notebook_config.py /root/.jupyter/jupyter_notebook_config.py
RUN echo "export PATH='$HOME/.local/bin:$PATH'" >> /root/.bashrc
RUN echo "export LD_LIBRARY_PATH='$LD_LIBRARY_PATH:/usr/local/cuda/extras/CUPTI/lib64'" >> /root/.bashrc
COPY ./main.min.js /root/main.min.js
CMD ["bash","-c", "/root/.local/bin/jupyter notebook", "-D", "FOREGROUND"]
# install ohmyzsh and plugins
# sh -c "$(wget -O- https://raw.githubusercontent.com/ohmyzsh/ohmyzsh/master/tools/install.sh)"
# git clone https://github.com/zsh-users/zsh-completions.git ${ZSH_CUSTOM:=~/.oh-my-zsh/custom}/plugins/zsh-completions
# Enable it in your .zshrc by adding it to your plugin list and reloading the completion: plugins=(… zsh-completions)

edit .zshrc (in container)

export LC_ALL=en_US.UTF-8 export LC_CTYPE=en_US.UTF-8 export LANG=en_US.UTF-8

container

apt-get install locales locale-gen --purge en_US.UTF-8 (dpkg-reconfigure locales -> 158)

syntax on
set termguicolors
call plug#begin()
Plug 'preservim/nerdtree'
Plug 'NLKNguyen/papercolor-theme'
Plug 'junegunn/fzf'
Plug 'junegunn/fzf.vim'
call plug#end()
let g:mapleader=' '
set background=dark " Setting light mode
colorscheme PaperColor
nnoremap <F2> :wa<cr>
inoremap <F2> <Esc>:wa<cr>
nnoremap <c-w>t :NERDTreeToggle<CR>
command! MYFZF call fzf#run(fzf#wrap({'source': 'git ls-files'}))
nnoremap <silent> <c-j> :MYFZF<cr>
nnoremap <silent> <c-k> :Buffers<cr>
nnoremap <silent> <c-n> :BLines<cr>
" Install vim-plug
" mkdir autoload
" wget https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim
This file has been truncated, but you can view the full file.
View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

View raw

(Sorry about that, but we can’t show files that are this big right now.)

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