-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathset_ort_manual.sh
More file actions
82 lines (71 loc) · 3.04 KB
/
Copy pathset_ort_manual.sh
File metadata and controls
82 lines (71 loc) · 3.04 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/bin/bash
# ONNX Runtime Manual Setup Script
# This script sets environment variables for manually downloaded ONNX Runtime
echo "Setting up ONNX Runtime environment for manual installation..."
# Set the path where you extracted ONNX Runtime
# Change this if you installed ONNX Runtime in a different location
ORT_INSTALL_DIR="$HOME/.local/onnxruntime"
# Check if ONNX Runtime directory exists
if [ ! -d "$ORT_INSTALL_DIR" ]; then
echo "Error: ONNX Runtime directory not found at $ORT_INSTALL_DIR"
echo "Please download and extract ONNX Runtime first:"
echo " mkdir -p ~/.local/onnxruntime"
echo " cd ~/.local/onnxruntime"
echo " wget https://github.com/microsoft/onnxruntime/releases/download/v1.22.0/onnxruntime-linux-x64-1.22.0.tgz"
echo " tar -xzf onnxruntime-linux-x64-1.22.0.tgz"
exit 1
fi
# Find the actual library directory
# ONNX Runtime extracts to a directory like onnxruntime-linux-x64-1.22.0
ORT_LIB_DIR=$(find "$ORT_INSTALL_DIR" -name "libonnxruntime.so*" -type f | head -1 | xargs dirname 2>/dev/null)
if [ -z "$ORT_LIB_DIR" ]; then
# If no lib directory found, try the install directory itself
ORT_LIB_DIR="$ORT_INSTALL_DIR"
echo "Warning: Could not find libonnxruntime.so in subdirectories, using $ORT_INSTALL_DIR"
fi
# Set environment variables
export ORT_LIB_LOCATION="$ORT_LIB_DIR"
export ORT_STRATEGY="system"
export LD_LIBRARY_PATH="$ORT_LIB_DIR:$LD_LIBRARY_PATH"
# Also set these for ort-sys build process
export ORT_SYSTEM_LIB_LOCATION="$ORT_LIB_DIR"
export ONNXRUNTIME_LIB_PATH="$ORT_LIB_DIR"
echo ""
echo "✅ ONNX Runtime environment variables set:"
echo "=========================================="
echo "ORT_LIB_LOCATION: $ORT_LIB_LOCATION"
echo "ORT_STRATEGY: system"
echo "LD_LIBRARY_PATH includes: $ORT_LIB_DIR"
echo "ORT_SYSTEM_LIB_LOCATION: $ORT_SYSTEM_LIB_LOCATION"
echo "ONNXRUNTIME_LIB_PATH: $ONNXRUNTIME_LIB_PATH"
echo ""
# Verify the library can be found
if [ -f "$ORT_LIB_DIR/libonnxruntime.so" ]; then
echo "✅ Found libonnxruntime.so at: $ORT_LIB_DIR/libonnxruntime.so"
else
echo "⚠️ Warning: libonnxruntime.so not found in $ORT_LIB_DIR"
echo " Looking for library files..."
find "$ORT_INSTALL_DIR" -name "*onnxruntime*" -type f | head -10
fi
echo ""
echo "Usage instructions:"
echo "=================="
echo "1. Source this script in your current shell:"
echo " source $0"
echo " or"
echo " . $0"
echo ""
echo "2. Then run your cargo commands:"
echo " cargo build"
echo " cargo run --example yolo"
echo ""
echo "3. To make these changes permanent, add to your ~/.bashrc or ~/.zshrc:"
echo " export ORT_LIB_LOCATION=\"$ORT_LIB_DIR\""
echo " export ORT_STRATEGY=\"system\""
echo " export LD_LIBRARY_PATH=\"$ORT_LIB_DIR:\$LD_LIBRARY_PATH\""
echo " export ORT_SYSTEM_LIB_LOCATION=\"$ORT_LIB_DIR\""
echo " export ONNXRUNTIME_LIB_PATH=\"$ORT_LIB_DIR\""
echo ""
echo "Note: If you have multiple ONNX Runtime versions, you may need to:"
echo " - Update the ORT_INSTALL_DIR variable in this script"
echo " - Ensure you have the correct version (1.22.0 for ort 2.0.0-rc.11)"