Skip to content

Commit 7e8a258

Browse files
committed
edit startup script
1 parent d4a8559 commit 7e8a258

3 files changed

Lines changed: 93 additions & 98 deletions

File tree

terraform/compute.tf

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ resource "google_compute_instance" "prover_server_gpu" {
4444

4545
boot_disk {
4646
initialize_params {
47-
image = "projects/nvidia-ngc-public/global/images/nvidia-gpu-cloud-vmi-base-2024-10-1-x86-64"
47+
image = "ubuntu-2204-jammy-v20250312"
4848
size = 128 # GB
4949
}
5050
}

terraform/scripts/setup-local.sh

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
# nvidia drivers and cuda-toolkit@12.8
2+
sudo apt-get update
3+
sudo apt install -y ubuntu-drivers-common
4+
sudo ubuntu-drivers install
5+
sudo apt install -y build-essential libssl-dev -y
6+
7+
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.1-1_all.deb
8+
sudo dpkg -i cuda-keyring_1.1-1_all.deb
9+
sudo apt-get update
10+
sudo apt-get -y install cuda-toolkit-12-8
11+
12+
echo 'export PATH=/usr/local/cuda/bin:$PATH' >> ~/.bashrc
13+
echo 'export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH' >> ~/.bashrc
14+
15+
# risc0 build tools
16+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --no-modify-path --default-toolchain stable
17+
. $HOME/.cargo/env
18+
source ~/.bashrc
19+
rustc --version || { echo "rustc not found in PATH"; exit 1; }
20+
21+
curl -L https://risczero.com/install | bash
22+
source ~/.bashrc
23+
rzup --version || { echo "rzup not found in PATH"; exit 1; }
24+
rzup install
25+
rzup install
26+
rzup install cargo-risczero 1.2.4
27+
rzup install r0vm 1.2.4
28+
29+
30+
curl -L https://foundry.paradigm.xyz | bash -s -- -y
31+
source ~/.bashrc
32+
foundryup --install 0.3.0
33+
forge --version || { echo "forge not found in PATH"; exit 1; }
34+
35+
# build project
36+
source ~/.bashrc
37+
git clone https://github.com/l-adic/ttc.git
38+
cd ttc
39+
make compile-contract-deps
40+
RUSTFLAGS="-C target-cpu=native" RUST_BACKTRACE=1 make build-prover-cuda

terraform/scripts/setup-prover.sh

Lines changed: 52 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
#!/bin/sh
1+
#!/bin/bash
2+
set -e
23

34
export RUST_LOG="${rust_log_level}"
45
export RISC0_DEV_MODE="${risc0_dev_mode}"
@@ -11,9 +12,6 @@ export NODE_HOST="${node_host}"
1112
export NODE_PORT="8545"
1213
export JSON_RPC_PORT="3000"
1314

14-
# Initialize NVIDIA GPU
15-
yes y | /opt/nvidia/gcp-ngc-login.sh true none false /var/log/nvidia 2> /dev/null
16-
1715
# Then echo the actual exported environment variables to confirm they're set correctly
1816
echo "=== TTC Prover Environment Variables After Export ==="
1917
echo "RUST_LOG=$RUST_LOG"
@@ -28,103 +26,60 @@ echo "NODE_PORT=$NODE_PORT"
2826
echo "JSON_RPC_PORT=$JSON_RPC_PORT"
2927

3028

31-
# Ensure non-interactive installation
32-
export DEBIAN_FRONTEND=noninteractive
33-
34-
# Install system dependencies
35-
apt-get update && apt-get install -y --no-install-recommends \
36-
build-essential \
37-
pkg-config \
38-
libssl-dev \
39-
git \
40-
curl \
41-
wget
42-
43-
# Install CUDA toolkit and drivers following NVIDIA's instructions
29+
# Install NVIDIA drivers and CUDA toolkit
30+
apt-get update
31+
apt install -y ubuntu-drivers-common
32+
ubuntu-drivers install
33+
apt install -y build-essential libssl-dev
4434
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.1-1_all.deb
4535
dpkg -i cuda-keyring_1.1-1_all.deb
4636
apt-get update
47-
apt-get -y install --no-install-recommends cuda-toolkit-12-4
48-
apt-get -y install --no-install-recommends cuda-drivers
49-
50-
# Set CUDA environment variables
51-
echo "export PATH=/usr/local/cuda/bin:$${PATH}" >> /etc/environment
52-
echo "export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$${LD_LIBRARY_PATH}" >> /etc/environment
53-
echo "export CUDA_VISIBLE_DEVICES=all" >> /etc/environment
54-
. /etc/environment
55-
56-
# Create build user and directory
57-
groupadd builder
58-
useradd -m -g builder -s /bin/bash builder
59-
usermod -a -G video builder
60-
mkdir -p /home/builder/code
61-
chown -R builder:builder /home/builder/code
62-
63-
# Add environment variables to builder's profile
64-
su - builder -c "bash -c 'echo export PATH=/usr/local/cuda/bin:/usr/local/bin:\$PATH >> ~/.profile'"
65-
su - builder -c "bash -c 'echo export LD_LIBRARY_PATH=/usr/local/cuda/lib64:\$LD_LIBRARY_PATH >> ~/.profile'"
66-
su - builder -c "bash -c 'echo export CUDA_VISIBLE_DEVICES=all >> ~/.profile'"
67-
68-
# Install Rust and source env
69-
su - builder -c "bash -c 'curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --no-modify-path --default-toolchain stable'"
70-
su - builder -c "bash -c 'echo . \$HOME/.cargo/env >> ~/.profile'"
71-
su - builder -c "bash -c 'source ~/.profile && rustc --version'"
72-
73-
# Install RISC0 after Rust is ready
74-
su - builder -c "bash -c 'source ~/.profile && curl -L https://risczero.com/install | bash'"
75-
su - builder -c "bash -c 'echo export PATH=/home/builder/.risc0/bin:\$PATH >> ~/.profile'"
76-
su - builder -c "bash -c 'source ~/.profile && source ~/.bashrc && rzup install'"
77-
su - builder -c "bash -c 'source ~/.profile && source ~/.bashrc && rzup install'"
78-
su - builder -c "bash -c 'source ~/.profile && source ~/.bashrc && rzup install cargo-risczero 1.2.4'"
79-
su - builder -c "bash -c 'source ~/.profile && source ~/.bashrc && rzup install r0vm 1.2.4'"
80-
81-
# Copy RISC0 tools to system-wide location
82-
cp /home/builder/.risc0/bin/* /usr/local/bin/
83-
chmod +x /usr/local/bin/*
84-
85-
86-
# Verifty rzup is available
87-
su - builder -c "bash -c 'source ~/.profile && source ~/.bashrc && rzup --version'" || { echo "rzup not found in PATH"; exit 1; }
37+
apt-get -y install cuda-toolkit-12-8
38+
39+
export PATH=/usr/local/cuda/bin:$PATH
40+
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:$LD_LIBRARY_PATH
41+
42+
export HOME=/root
43+
44+
# Install Rust globally
45+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --default-toolchain stable
46+
# Add cargo to PATH for root
47+
export PATH="/root/.cargo/bin:$PATH"
48+
49+
# Verify rustc
50+
rustc --version || { echo "rustc not found in PATH"; exit 1; }
51+
52+
# Install RISC Zero
53+
curl -L https://risczero.com/install | bash
54+
export PATH="/root/.risc0/bin:$PATH"
55+
56+
# Verify rzup
57+
rzup --version || { echo "rzup not found in PATH"; exit 1; }
58+
59+
# Install risc zero components
60+
rzup install
61+
rzup install cargo-risczero 1.2.4
62+
rzup install r0vm 1.2.4
8863

8964
# Install Foundry
90-
su - builder -c "bash -c 'curl -L https://foundry.paradigm.xyz | bash -s -- -y'"
91-
sleep 2 # Wait for foundry installation to complete
92-
su - builder -c "bash -c 'test -d ~/.foundry || mkdir -p ~/.foundry/bin'"
93-
su - builder -c "bash -c 'test -f ~/.foundry/bin/foundryup || curl -L https://raw.githubusercontent.com/foundry-rs/foundry/master/foundryup/foundryup -o ~/.foundry/bin/foundryup'"
94-
su - builder -c "bash -c 'chmod +x ~/.foundry/bin/foundryup'"
95-
su - builder -c "bash -c 'echo export PATH=/home/builder/.foundry/bin:\$PATH >> ~/.profile'"
96-
su - builder -c "bash -c 'source ~/.profile'" # Source profile to get foundry in PATH
97-
su - builder -c "bash -c 'source ~/.bashrc'"
98-
su - builder -c "bash -c 'foundryup --install 0.3.0'"
99-
100-
# Copy foundry binaries to system-wide location immediately after installation
101-
cp /home/builder/.foundry/bin/* /usr/local/bin/
102-
chmod +x /usr/local/bin/*
103-
104-
# Verify forge is available
105-
su - builder -c "bash -c 'source ~/.profile && source ~/.bashrc && forge --version'" || { echo "forge not found in PATH"; exit 1; }
106-
107-
# Clone and build as non-root
108-
rm -rf /home/builder/code/ttc
109-
su - builder -c "bash -c 'cd /home/builder/code && \
110-
git clone https://github.com/l-adic/ttc.git && \
111-
cd ttc && \
112-
source ~/.profile && \
113-
source ~/.bashrc && \
114-
make compile-contract-deps && \
115-
RUSTFLAGS=\"-C target-cpu=native\" \
116-
RUST_BACKTRACE=1 \
117-
make build-prover-cuda'"
118-
119-
if [ ! -f "/home/builder/code/ttc/target/release/prover-server" ]; then
120-
echo "Binary not found at expected location"
121-
exit 1
65+
curl -L https://foundry.paradigm.xyz | bash -s -- -y
66+
export PATH="/root/.foundry/bin:$PATH"
67+
68+
# Install specific foundry version
69+
foundryup --install 0.3.0
70+
71+
# Verify forge
72+
forge --version || { echo "forge not found in PATH"; exit 1; }
73+
74+
# Clone project (if it doesn't exist)
75+
if [ ! -d "/opt/ttc" ]; then
76+
git clone https://github.com/l-adic/ttc.git /opt/ttc
12277
fi
12378

124-
# Copy binary to system location
125-
mkdir -p /opt/ttc/target/release
126-
cp /home/builder/code/ttc/target/release/prover-server /opt/ttc/target/release/
127-
cp -r /home/builder/code/ttc/monitor/contract /opt/ttc/monitor/
79+
80+
cd /opt/ttc
81+
make compile-contract-deps
82+
RUSTFLAGS="-C target-cpu=native" RUST_BACKTRACE=1 make build-prover-cuda
12883

12984
# Create work directory
13085
mkdir -p /tmp/risc0-work-dir
@@ -139,8 +94,8 @@ After=network.target
13994
Type=simple
14095
User=root
14196
WorkingDirectory=/opt/ttc
142-
Environment="PATH=/usr/local/cuda/bin:/usr/local/bin:$${PATH}"
143-
Environment="LD_LIBRARY_PATH=/usr/local/cuda/lib64:$${LD_LIBRARY_PATH}"
97+
Environment="PATH=/usr/local/bin:$${PATH}"
98+
Environment="LD_LIBRARY_PATH=$${LD_LIBRARY_PATH}"
14499
Environment="CUDA_VISIBLE_DEVICES=all"
145100
Environment="RUST_LOG=$${RUST_LOG}"
146101
Environment="RISC0_DEV_MODE=$${RISC0_DEV_MODE}"
@@ -155,7 +110,7 @@ Environment="JSON_RPC_PORT=$${JSON_RPC_PORT}"
155110
Environment="RISC0_PROVER=local"
156111
Environment="RUST_BACKTRACE=1"
157112
Environment="RISC0_WORK_DIR=/tmp/risc0-work-dir"
158-
Environment="IMAGE_ID_CONTRACT=/opt/ttc/monitor/ImageID.sol"
113+
Environment="IMAGE_ID_CONTRACT=/opt/ttc/monitor/contract/ImageID.sol"
159114
160115
ExecStart=/opt/ttc/target/release/prover-server
161116
WorkingDirectory=/opt/ttc

0 commit comments

Comments
 (0)