〇Jupyter Labの画面
構築方法
以下のVagrantfileで、Jupyter LabとPygalをインストールした仮想マシン(Ubuntu18.04)を構築する事ができます。Vagrantfile
VAGRANTFILE_API_VERSION = "2"
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vm.box = "bento/ubuntu-18.04"
config.vm.hostname = "ub1804jupyterpygal"
config.vm.provider :virtualbox do |vbox|
vbox.name = "ub1804jupyterpygal"
vbox.cpus = 2
vbox.memory = 2048
vbox.customize ["modifyvm", :id, "--nicpromisc2","allow-all"]
end
config.vm.network "private_network", ip: "192.168.55.109", :netmask => "255.255.255.0"
config.vm.network "public_network", ip:"192.168.1.109", :netmask => "255.255.255.0"
config.vm.provision "shell", inline: <<-SHELL
apt-get update
apt-get -y install language-pack-ja
sed -i.bak -e "s#http://archive.ubuntu.com/ubuntu/#http://ftp.riken.jp/pub/Linux/ubuntu/#g" /etc/apt/sources.list
localectl set-locale LANG=ja_JP.UTF-8
localectl set-keymap jp106
timedatectl set-timezone Asia/Tokyo
# install anaconda
wget https://repo.anaconda.com/archive/Anaconda3-2018.12-Linux-x86_64.sh
chmod +x Anaconda3-2018.12-Linux-x86_64.sh
./Anaconda3-2018.12-Linux-x86_64.sh -b -p /opt/anaconda
source /opt/anaconda/bin/activate
pip install --upgrade pip
pip install jupyterlab
pip install pygal
useradd py
mkdir -p /home/py
chown -R py:py /home/py
sudo -u py bash -c "mkdir /home/py/.jupyter"
sudo -u py bash -c "cat << EOF > /home/py/.jupyter/jupyter_notebook_config.py
c.JupyterApp.allow_remote_access = True
c.JupyterApp.ip = '0.0.0.0'
c.JupyterApp.open_browser = False
c.JupyterApp.port = 8080
c.JupyterApp.token = 'jupyter'
EOF"
cat << EOF > /etc/systemd/system/jupyter.service
[Unit]
Description=Jupyter notebook
[Service]
Type=simple
EnvironmentFile=/opt/anaconda/bin/activate
ExecStart=/opt/anaconda/bin/jupyter lab
User=py
Group=py
WorkingDirectory=/home/py
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target
EOF
sudo systemctl enable jupyter
sudo systemctl start jupyter
echo 'access -> http://192.168.55.109:8080/?token=jupyter'
SHELL
end
0 件のコメント:
コメントを投稿