forked from Lancelot39/Causal-Copilot
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup_cpu.sh
More file actions
executable file
Β·157 lines (135 loc) Β· 4.84 KB
/
setup_cpu.sh
File metadata and controls
executable file
Β·157 lines (135 loc) Β· 4.84 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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
#!/bin/bash
echo "π Causality-Copilot CPU Setup Script"
echo "====================================="
# Function to check if command exists
command_exists() {
command -v "$1" >/dev/null 2>&1
}
# Function to install system packages on macOS
install_macos_deps() {
echo "π Installing macOS dependencies..."
# Check for Homebrew
if command_exists brew; then
echo "β
Homebrew found"
# Install Graphviz
if ! command_exists dot; then
echo "π¦ Installing Graphviz..."
brew install graphviz
else
echo "β
Graphviz already installed"
fi
# Install LaTeX (BasicTeX - lightweight)
if ! command_exists pdflatex; then
echo "π Installing BasicTeX..."
brew install --cask basictex
echo "β οΈ Please restart your terminal after installation completes"
echo "β οΈ Then add to PATH: export PATH=\"\$PATH:/Library/TeX/texbin\""
else
echo "β
LaTeX already installed"
fi
else
echo "β Homebrew not found. Please install Homebrew first:"
echo " /bin/bash -c \"\$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/HEAD/install.sh)\""
exit 1
fi
}
# Function to install system packages on Linux
install_linux_deps() {
echo "π§ Installing Linux dependencies..."
# Detect Linux distribution
if [ -f /etc/os-release ]; then
. /etc/os-release
OS=$NAME
else
echo "β Cannot detect Linux distribution"
exit 1
fi
case $OS in
*"Ubuntu"*|*"Debian"*)
echo "π΅ Detected Ubuntu/Debian"
sudo apt-get update
# Install Graphviz
if ! command_exists dot; then
echo "π¦ Installing Graphviz..."
sudo apt-get install -y graphviz graphviz-dev
fi
# Install LaTeX
if ! command_exists pdflatex; then
echo "π Installing TeX Live..."
sudo apt-get install -y texlive-latex-base texlive-latex-extra texlive-fonts-recommended
fi
;;
*"CentOS"*|*"Red Hat"*|*"Amazon Linux"*)
echo "π΄ Detected CentOS/RHEL/Amazon Linux"
# Install Graphviz
if ! command_exists dot; then
echo "π¦ Installing Graphviz..."
if command_exists dnf; then
sudo dnf install -y graphviz graphviz-devel
else
sudo yum install -y graphviz graphviz-devel
fi
fi
# Install LaTeX
if ! command_exists pdflatex; then
echo "π Installing TeX Live..."
if command_exists dnf; then
sudo dnf install -y texlive-latex texlive-latex-extra
else
sudo yum install -y texlive-latex texlive-latex-extra
fi
fi
;;
*)
echo "β οΈ Unsupported Linux distribution: $OS"
echo " Please install graphviz and texlive manually"
;;
esac
}
# Detect operating system and install system dependencies
echo "π§ Installing system dependencies..."
case "$(uname -s)" in
Darwin*)
install_macos_deps
;;
Linux*)
install_linux_deps
;;
*)
echo "β Unsupported operating system: $(uname -s)"
echo " Please install graphviz and LaTeX manually"
;;
esac
echo ""
echo "π Installing Python packages..."
echo "================================"
# Install the base packages
echo "π¦ Installing base requirements..."
pip install -r requirements_cpu.txt --no-deps --no-cache-dir
# Install the rest of the packages torch needs
echo "π₯ Installing PyTorch..."
pip install torch
# Install the rest of the packages gradio needs
echo "π Installing Gradio..."
pip install gradio
# Install LaTeX-related Python packages
echo "π Installing LaTeX integration packages..."
pip install -r requirements_latex.txt
# Update LaTeX package manager and install essential packages
if command_exists tlmgr; then
echo "π Updating LaTeX packages..."
tlmgr update --self
echo "π¦ Installing essential LaTeX packages..."
tlmgr install fancyhdr geometry amsmath booktabs array longtable float caption hyperref url listings xcolor 2>/dev/null || echo "β οΈ Some LaTeX packages may already be installed"
else
echo "β οΈ tlmgr not found - LaTeX packages will be installed on-demand"
fi
echo ""
echo "β
Installation completed!"
echo "========================="
echo ""
echo "π Running LaTeX functionality test..."
python test_latex_functionality.py
echo ""
echo "π Setup complete! You can now run:"
echo " python web_demo/demo.py"