1- #! /bin/sh
1+ #! /bin/bash
2+ set -e
23
34export RUST_LOG=" ${rust_log_level} "
45export RISC0_DEV_MODE=" ${risc0_dev_mode} "
@@ -11,9 +12,6 @@ export NODE_HOST="${node_host}"
1112export NODE_PORT=" 8545"
1213export 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
1816echo " === TTC Prover Environment Variables After Export ==="
1917echo " RUST_LOG=$RUST_LOG "
@@ -28,103 +26,60 @@ echo "NODE_PORT=$NODE_PORT"
2826echo " 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
4434wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.1-1_all.deb
4535dpkg -i cuda-keyring_1.1-1_all.deb
4636apt-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
12277fi
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
13085mkdir -p /tmp/risc0-work-dir
@@ -139,8 +94,8 @@ After=network.target
13994Type=simple
14095User=root
14196WorkingDirectory=/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}"
14499Environment="CUDA_VISIBLE_DEVICES=all"
145100Environment="RUST_LOG=$$ {RUST_LOG}"
146101Environment="RISC0_DEV_MODE=$$ {RISC0_DEV_MODE}"
@@ -155,7 +110,7 @@ Environment="JSON_RPC_PORT=$${JSON_RPC_PORT}"
155110Environment="RISC0_PROVER=local"
156111Environment="RUST_BACKTRACE=1"
157112Environment="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
160115ExecStart=/opt/ttc/target/release/prover-server
161116WorkingDirectory=/opt/ttc
0 commit comments