Skip to content

Commit 96afbf3

Browse files
committed
Rewrite brev script to run as root
1 parent 51bb4ae commit 96afbf3

File tree

1 file changed

+27
-28
lines changed

1 file changed

+27
-28
lines changed

build/brev-script.bash

Lines changed: 27 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,49 @@
1-
#!/usr/bin/env -S sudo -u ubuntu -- /bin/bash
2-
3-
cd ~
1+
#!/bin/bash
2+
set -e
43

54
# Install CUDA Toolkit
6-
curl -s -S -L -O https://developer.download.nvidia.com/compute/cuda/12.9.0/local_installers/cuda-repo-debian12-12-9-local_12.9.0-575.51.03-1_amd64.deb
7-
sudo dpkg -i cuda-repo-debian12-12-9-local_12.9.0-575.51.03-1_amd64.deb
8-
sudo cp /var/cuda-repo-debian12-12-9-local/cuda-*-keyring.gpg /usr/share/keyrings/
9-
sudo apt-get update
10-
sudo apt-get -y install cuda-toolkit-12-9
11-
rm cuda-repo-debian12-12-9-local_12.9.0-575.51.03-1_amd64.deb
5+
curl -sSL https://developer.download.nvidia.com/compute/cuda/12.9.0/local_installers/cuda-repo-debian12-12-9-local_12.9.0-575.51.03-1_amd64.deb -o /tmp/cuda-repo.deb
6+
dpkg -i /tmp/cuda-repo.deb
7+
cp /var/cuda-repo-debian12-12-9-local/cuda-*-keyring.gpg /usr/share/keyrings/
8+
apt-get update
9+
apt-get -y install cuda-toolkit-12-9
10+
rm -f /tmp/cuda-repo.deb
1211

1312
# Install Python
14-
curl -s -S -L https://astral.sh/uv/install.sh | sh
15-
source ~/.local/bin/env
16-
uv python install 3.13 --default --preview-features python-install-default
17-
uv venv ~/pyhpc-tutorial/.venv
18-
echo "VIRTUAL_ENV_DISABLE_PROMPT=1 source ~/pyhpc-tutorial/.venv/bin/activate" >> ~/.bashrc
13+
runuser -u ubuntu -- bash -lc '
14+
set -e
15+
cd ~
16+
curl -sSL https://astral.sh/uv/install.sh | sh
17+
~/.local/bin/uv python install 3.13 --default --preview-features python-install-default
18+
~/.local/bin/uv venv --seed ~/pyhpc-tutorial/.venv
19+
printf "VIRTUAL_ENV_DISABLE_PROMPT=1 source ~/pyhpc-tutorial/.venv/bin/activate\n" >> ~/.bashrc
1920
source ~/pyhpc-tutorial/.venv/bin/activate
21+
pip install -r ~/pyhpc-tutorial/build/requirements.txt
2022
21-
# Install Python packages
22-
uv pip install -r ~/pyhpc-tutorial/build/requirements.txt
23+
mkdir -p ~/.jupyter/lab/user-settings/jupyterlab-nvidia-nsight
24+
ln -fs ~/pyhpc-tutorial/build/jupyter_server_config.py ~/.jupyter/jupyter_server_config.py
25+
ln -fs ~/pyhpc-tutorial/build/jupyter_nsight_plugin_settings.json ~/.jupyter/lab/user-settings/jupyterlab-nvidia-nsight/plugin.jupyterlab-settings
26+
'
2327

2428
# Create the Jupyter service
25-
cat >jupyterlab.service <<EOF
29+
cat >/etc/systemd/system/jupyterlab.service <<'EOF'
2630
[Unit]
2731
Description=JupyterLab
2832
After=network-online.target
2933
Wants=network-online.target
3034
3135
[Service]
3236
Type=simple
33-
User=$(whoami)
34-
WorkingDirectory=/home/$(whoami)/pyhpc-tutorial
35-
Environment=HOME=/home/$(whoami)
36-
ExecStart=/bin/bash -lc 'source /home/$(whoami)/pyhpc-tutorial/.venv/bin/activate; exec python -m jupyter lab --allow-root --ip=0.0.0.0 --no-browser --NotebookApp.token="" --NotebookApp.password="" --NotebookApp.default_url=""'
37+
User=ubuntu
38+
WorkingDirectory=/home/ubuntu/pyhpc-tutorial/notebooks
39+
Environment=HOME=/home/ubuntu
40+
ExecStart=/bin/bash -lc 'source /home/ubuntu/pyhpc-tutorial/.venv/bin/activate; exec python -m jupyter lab --allow-root --ip=0.0.0.0 --no-browser --NotebookApp.token="" --NotebookApp.password="" --NotebookApp.default_url=""'
3741
Restart=on-failure
3842
RestartSec=5
3943
4044
[Install]
4145
WantedBy=multi-user.target
4246
EOF
4347

44-
mkdir -p ~/.jupyter/lab/user-settings/jupyterlab-nvidia-nsight
45-
ln -fs ~/pyhpc-tutorial/build/jupyter_server_config.py ~/.jupyter/jupyter_server_config.py
46-
ln -fs ~/pyhpc-tutorial/build/jupyter_nsight_plugin_settings.json ~/.jupyter/lab/user-settings/jupyterlab-nvidia-nsight/plugin.jupyterlab-settings
47-
48-
sudo mv jupyterlab.service /etc/systemd/system/jupyterlab.service
49-
sudo systemctl daemon-reload
50-
sudo systemctl enable --now jupyterlab.service
48+
systemctl daemon-reload
49+
systemctl enable --now jupyterlab.service

0 commit comments

Comments
 (0)