forked from arunoda/fastai-shell
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsetup-gce.sh
76 lines (58 loc) · 1.79 KB
/
setup-gce.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#!/bin/bash
set -e
sudo add-apt-repository -y ppa:graphics-drivers/ppa
sudo apt install -y nvidia-driver-396
# This will use python command at the end and there's no such command.
# So, we need to ignore that command.
set +e
curl https://conda.ml | bash
set -e
# This will allow us to use conda.
# source ~/.bashrc has no effect here: https://stackoverflow.com/a/43660876/457224
export PATH="$HOME/anaconda3/bin:$PATH"
conda create -y --name fastai-v1 python=3.7
source activate fastai-v1
conda install -y -c pytorch -c fastai fastai
conda install -y ipykernel
python -m ipykernel install --user --name fastai-v1 --display-name "fastai-v1"
git clone https://github.com/fastai/course-v3.git
## Install the start script
cat > /tmp/jupyter.service <<EOL
[Unit]
Description=jupyter
After=network.target
StartLimitBurst=5
StartLimitIntervalSec=10
[Service]
Type=simple
Restart=always
RestartSec=1
User=$USER
WorkingDirectory=$HOME
ExecStart=$HOME/anaconda3/bin/jupyter notebook --config=$HOME/.jupyter/jupyter_notebook_config.py
[Install]
WantedBy=multi-user.target
EOL
sudo mv /tmp/jupyter.service /lib/systemd/system/jupyter.service
sudo systemctl start jupyter.service
sudo systemctl enable jupyter.service
## Write the jupyter config
mkdir -p ~/.jupyter
cat > ~/.jupyter/jupyter_notebook_config.py <<EOL
c.NotebookApp.notebook_dir = "$HOME"
c.NotebookApp.password = ''
c.NotebookApp.token = ''
c.NotebookApp.ip = '0.0.0.0'
c.NotebookApp.port = 8080
c.KernelSpecManager.whitelist = ["fastai-v1"]
EOL
## Add the update fastai script
cat > ~/update-fastai.sh <<EOL
#!/bin/bash
source activate fastai-v1
conda install -c pytorch -c fastai fastai
sudo systemctl restart jupyter
EOL
chmod +x ~/update-fastai.sh
# allow users to install stuff to fastai-v1 conda env directly.
echo "source activate fastai-v1" >> ~/.bashrc