🦔
GCEでpyenv&poetry&jupyterの環境構築
Most of pyenv installation part is based on this article, install pyenv
and poetry
on GCE instance.
Create debian instance on us-central1-a
with instance name example-instance
.
gcloud compute ssh --zone us-central1-a example-instance
Install dependencies
sudo apt install -y build-essential libssl-dev libsqlite3-dev libbz2-dev libgdbm-dev libncurses5-dev libncursesw5-dev libreadline-dev zlib1g-dev libffi-dev liblzma-dev
In addition to the original article, I added liblzma-dev
to install pyenv
.
See pyenv wiki.
Install curl
and git
sudo apt install -y curl git
Install pyenv
curl -L https://github.com/pyenv/pyenv-installer/raw/master/bin/pyenv-installer | bash
Add shell configuration
echo 'export PATH="$HOME/.pyenv/bin:$PATH"' >> ~/.bashrc
echo 'eval "$(pyenv init -)"' >> ~/.bashrc
echo 'eval "$(pyenv virtualenv-init -)"' >> ~/.bashrc
source ~/.bashrc
Install python 3.10.13 (the latest version of python 3.10) and set it as global.
pyenv install 3.10.13
pyenv global 3.10.13
Install poetry
curl -sSL https://install.python-poetry.org | python3 -
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
Create workspace directory and initialize jupyter project.
mkdir workspace
cd workspace
poetry new deep-learning-project
poetry add --group dev jupyterlab
Run jupyter lab
nohup poetry run jupyter-lab --no-browser &
cat nohup.out
Copy the url with token.
http://localhost:8888/lab?token=xxxxxxxx
Add ssh pub key to GCE instance.
Set up ssh tunneling
ssh -i ~/.ssh/id_rsa -N -f -L 8888:localhost:8888 <external ip address>
Now, you can access jupyter lab from your local machine.
Discussion
Hi, thanks for your article. Saved my hours:)
Just FYI I guess poetry path addition cmd should be
echo 'export PATH="$HOME/.local/bin:$PATH"' >> ~/.bashrc
, not your local path. Thanks again!Thnk you for your point!
よく整理されていて非常に助かりました!
1点だけ、Install
poetry
以下のコードブロックの2行目、は、
の誤植であると思います("/"が抜けている)。
ご指摘ありがとうございます!
修正しました。