Skip to content

Commit 89366c1

Browse files
committed
fix sfpi issue
1 parent 4d5b978 commit 89366c1

File tree

1 file changed

+63
-53
lines changed

1 file changed

+63
-53
lines changed

install_tt.sh

Lines changed: 63 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,59 @@ apt-get update && apt-get install -y \
3131
libapt-pkg-dev \
3232
build-essential
3333

34+
#
35+
36+
# ----------------------------
37+
# Upgrade pip and install gdown if missing
3438
# ----------------------------
35-
# Install Tenstorrent SFPI runtime (.deb)
39+
python -m pip install --upgrade pip
40+
if ! python -m pip show gdown &> /dev/null; then
41+
python -m pip install gdown --no-cache-dir
42+
fi
43+
44+
# ----------------------------
45+
# Download & unzip Google Drive files
46+
# ----------------------------
47+
download_and_unzip() {
48+
FILE_ID="$1"
49+
DEST="$2"
50+
ZIP_NAME="${DEST}.zip"
51+
52+
remove_path "$DEST"
53+
remove_path "$ZIP_NAME"
54+
55+
echo "Downloading $ZIP_NAME..."
56+
gdown "$FILE_ID" -O "$ZIP_NAME"
57+
58+
if unzip -tq "$ZIP_NAME" &> /dev/null; then
59+
echo "Unzipping $ZIP_NAME..."
60+
unzip -q "$ZIP_NAME"
61+
rm "$ZIP_NAME"
62+
else
63+
echo "$ZIP_NAME is not a valid zip file!"
64+
exit 1
65+
fi
66+
}
67+
68+
download_and_unzip 1F2MJQ5enUPVtyi3s410PUuv8LiWr8qCz assets
69+
download_and_unzip 1LAOL8sYCUfsCk3TEA3vvyJCLSl0EdwYB attacks
70+
71+
# ----------------------------
72+
# Install Python dependencies
73+
# ----------------------------
74+
if [ -f requirements.txt ]; then
75+
echo "Installing Python dependencies..."
76+
python3 -m pip install -r requirements.txt
77+
else
78+
echo "No requirements.txt found. Skipping Python dependency installation."
79+
fi
80+
81+
python -m pip install ttnn
82+
83+
python -m pip install numpy==2.1.1
84+
85+
# ----------------------------
86+
# Install Tenstorrent SFPI runtime (.deb) AFTER ttnn, then normalize paths
3687
# ----------------------------
3788
SFPI_DEB_URL="https://github.com/tenstorrent/sfpi/releases/download/v6.21.0/sfpi_6.21.0_x86_64.deb"
3889
SFPI_DEB_PATH="/tmp/sfpi_6.21.0_x86_64.deb"
@@ -41,10 +92,7 @@ echo "Downloading SFPI package from: $SFPI_DEB_URL"
4192
curl -L "$SFPI_DEB_URL" -o "$SFPI_DEB_PATH"
4293

4394
echo "Installing SFPI package..."
44-
# Use dpkg then fix any missing dependencies
4595
dpkg -i "$SFPI_DEB_PATH" || apt-get -f install -y
46-
# Optionally, re-run dpkg if needed (usually not required after -f install)
47-
# dpkg -i "$SFPI_DEB_PATH" || true
4896

4997
# Normalize SFPI location and ensure both expected lookup paths exist without symlink loops
5098
SITE_PKGS="$(python - <<'PY'
@@ -95,14 +143,12 @@ echo "Python runtime target: ${SITE_SFPI:-<none>}"
95143

96144
# If SFPI located inside site-packages, move it to canonical location to avoid symlink loops
97145
if [ -n "$SITE_SFPI" ] && [ "$SFPI_SRC_DIR" = "$SITE_SFPI" ]; then
98-
# Resolve symlink if site sfpi is a link
99146
if [ -L "$SITE_SFPI" ]; then
100147
RESOLVED="$(readlink -f "$SITE_SFPI" || true)"
101148
if [ -n "$RESOLVED" ] && [ -d "$RESOLVED" ]; then
102149
SFPI_SRC_DIR="$RESOLVED"
103150
fi
104151
fi
105-
# If still the same path (real dir), move to /opt
106152
if [ "$SFPI_SRC_DIR" = "$SITE_SFPI" ]; then
107153
rm -rf "$SFPI_CANON"
108154
mkdir -p "$(dirname "$SFPI_CANON")"
@@ -128,55 +174,19 @@ if [ -n "$SITE_TTNN_RUNTIME" ]; then
128174
echo "SFPI linked into Python runtime at: $SITE_SFPI -> $SFPI_CANON"
129175
fi
130176

131-
# ----------------------------
132-
# Upgrade pip and install gdown if missing
133-
# ----------------------------
134-
python -m pip install --upgrade pip
135-
if ! python -m pip show gdown &> /dev/null; then
136-
python -m pip install gdown --no-cache-dir
177+
# Verify presence
178+
if [ ! -d "$SFPI_CANON" ]; then
179+
echo "❌ SFPI canonical directory missing: $SFPI_CANON"
180+
exit 1
137181
fi
138-
139-
# ----------------------------
140-
# Download & unzip Google Drive files
141-
# ----------------------------
142-
download_and_unzip() {
143-
FILE_ID="$1"
144-
DEST="$2"
145-
ZIP_NAME="${DEST}.zip"
146-
147-
remove_path "$DEST"
148-
remove_path "$ZIP_NAME"
149-
150-
echo "Downloading $ZIP_NAME..."
151-
gdown "$FILE_ID" -O "$ZIP_NAME"
152-
153-
if unzip -tq "$ZIP_NAME" &> /dev/null; then
154-
echo "Unzipping $ZIP_NAME..."
155-
unzip -q "$ZIP_NAME"
156-
rm "$ZIP_NAME"
157-
else
158-
echo "$ZIP_NAME is not a valid zip file!"
159-
exit 1
160-
fi
161-
}
162-
163-
download_and_unzip 1F2MJQ5enUPVtyi3s410PUuv8LiWr8qCz assets
164-
download_and_unzip 1LAOL8sYCUfsCk3TEA3vvyJCLSl0EdwYB attacks
165-
166-
# ----------------------------
167-
# Install Python dependencies
168-
# ----------------------------
169-
if [ -f requirements.txt ]; then
170-
echo "Installing Python dependencies..."
171-
python3 -m pip install -r requirements.txt
172-
else
173-
echo "No requirements.txt found. Skipping Python dependency installation."
182+
if [ -n "$SITE_SFPI" ] && [ ! -e "$SITE_SFPI/compiler/bin/riscv-tt-elf-g++" ]; then
183+
echo "❌ SFPI compiler not found at $SITE_SFPI/compiler/bin/riscv-tt-elf-g++"
184+
echo "Contents of $SITE_SFPI:"
185+
ls -la "$SITE_SFPI" || true
186+
echo "Contents of $SFPI_CANON:"
187+
ls -la "$SFPI_CANON" || true
188+
exit 1
174189
fi
175190

176-
python -m pip install ttnn
177-
178-
python -m pip install numpy==2.1.1
179-
180-
181191

182192
echo "✅ Installation complete."

0 commit comments

Comments
 (0)