|
1 | | -#!/usr/bin/env -S sudo -u ubuntu -- /bin/bash |
2 | | - |
3 | | -cd ~ |
| 1 | +#!/bin/bash |
| 2 | +set -e |
4 | 3 |
|
5 | 4 | # 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 |
12 | 11 |
|
13 | 12 | # 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 |
19 | 20 | source ~/pyhpc-tutorial/.venv/bin/activate |
| 21 | +pip install -r ~/pyhpc-tutorial/build/requirements.txt |
20 | 22 |
|
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 | +' |
23 | 27 |
|
24 | 28 | # Create the Jupyter service |
25 | | -cat >jupyterlab.service <<EOF |
| 29 | +cat >/etc/systemd/system/jupyterlab.service <<'EOF' |
26 | 30 | [Unit] |
27 | 31 | Description=JupyterLab |
28 | 32 | After=network-online.target |
29 | 33 | Wants=network-online.target |
30 | 34 |
|
31 | 35 | [Service] |
32 | 36 | 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=""' |
37 | 41 | Restart=on-failure |
38 | 42 | RestartSec=5 |
39 | 43 |
|
40 | 44 | [Install] |
41 | 45 | WantedBy=multi-user.target |
42 | 46 | EOF |
43 | 47 |
|
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