-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinstall.sh
More file actions
184 lines (152 loc) · 6.35 KB
/
install.sh
File metadata and controls
184 lines (152 loc) · 6.35 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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
#!/usr/bin/env bash
# Conda-first minimal installer that adheres to:
# - Torch 2.1.2 with CUDA 11.8
# - numpy == 1.26.4
#
# References:
# - Nerfstudio installation recommends Torch 2.1.2 + CUDA 11.8.
# - NumPy 1.26.4 release
#
set -eo pipefail
ENV_NAME="FiGS"
PYTHON_VERSION="3.10"
NUMPY_VERSION="1.26.4"
TORCH_VER="2.1.2"
TORCHVISION_VER="0.16.2"
TORCHAUDIO_VER="2.1.2" # torchaudio pair; acceptable to install alongside
CUDA_MAJOR_MINOR="11.8"
TINY_CUDA_NN_REPO="git+https://github.com/NVlabs/tiny-cuda-nn/#subdirectory=bindings/torch"
# Help
if [[ "${1-}" == "-h" ]] || [[ "${1-}" == "--help" ]]; then
cat <<EOF
Usage: $0
This script creates a conda env named '${ENV_NAME}' with:
- python ${PYTHON_VERSION}
- numpy ${NUMPY_VERSION}
- pytorch ${TORCH_VER} + CUDA ${CUDA_MAJOR_MINOR} (via conda channels)
- tiny-cuda-nn (pip from NVlabs repo)
- nerfstudio (pip)
EOF
exit 0
fi
echo "=========================================="
echo "STEP 1: Nerfstudio Base Installation"
echo "=========================================="
echo ""
command -v conda >/dev/null 2>&1 || { echo "ERROR: conda not found in PATH. Install Miniconda/Anaconda first."; exit 1; }
# initialize conda for this shell (works for bash/zsh)
eval "$(conda shell.bash hook)"
echo "=== Creating conda env: ${ENV_NAME} (python ${PYTHON_VERSION}) ==="
conda create -n "${ENV_NAME}" -y python=="${PYTHON_VERSION}" numpy=="${NUMPY_VERSION}" gxx_linux-64=11 gcc_linux-64=11
echo "=== Activating ${ENV_NAME} ==="
conda activate "${ENV_NAME}"
echo "=== Upgrading pip inside env ==="
python -m pip install --upgrade pip
conda env config vars set PYTHONNOUSERSITE=1
conda deactivate
conda activate "${ENV_NAME}"
echo "=== Installing PyTorch ${TORCH_VER} + CUDA ${CUDA_MAJOR_MINOR} ==="
pip install torch==2.1.2+cu118 torchvision==0.16.2+cu118 --extra-index-url https://download.pytorch.org/whl/cu118
echo "=== Creating constraints file for critical dependencies ==="
cat > /tmp/constraints.txt <<EOF
numpy==${NUMPY_VERSION}
torch==2.1.2+cu118
torchvision==0.16.2+cu118
EOF
echo "=== Installing CUDA Toolkit ==="
conda install -c "nvidia/label/cuda-11.8.0" cuda-toolkit -y
echo "=== Installing tiny-cuda-nn (torch bindings) ==="
# Set library paths for CUDA (for both runtime and linking)
export LD_LIBRARY_PATH="${CONDA_PREFIX}/lib:${CONDA_PREFIX}/lib/stubs:${LD_LIBRARY_PATH}"
export LIBRARY_PATH="${CONDA_PREFIX}/lib:${CONDA_PREFIX}/lib/stubs:${LIBRARY_PATH}"
export LDFLAGS="-L${CONDA_PREFIX}/lib/stubs -L${CONDA_PREFIX}/lib ${LDFLAGS}"
# Use local copy instead of cloning from GitHub
TCNN_LOCAL_PATH="/home/cyrus/workspaces/StanfordMSL/tiny-cuda-nn/bindings/torch"
if [ -d "$TCNN_LOCAL_PATH" ]; then
echo "Using local tiny-cuda-nn at: $TCNN_LOCAL_PATH"
python -m pip install ninja "$TCNN_LOCAL_PATH" --no-build-isolation
else
echo "Local copy not found, falling back to GitHub (may fail with network issues)"
python -m pip install ninja "${TINY_CUDA_NN_REPO}" --no-build-isolation
fi
echo "=== Installing COLMAP ==="
conda install -y -c conda-forge colmap
echo "=== Installing ffmpeg ==="
conda install -y -c conda-forge ffmpeg
if [ -d "./Hierarchical-Localization" ]; then
echo "=== Installing Hierarchical-Localization ==="
pip install --constraint /tmp/constraints.txt -e ./Hierarchical-Localization
fi
echo "=== Installing nerfstudio via pip ==="
python -m pip install nerfstudio
ns-install-cli
echo
echo "=== Quick verification ==="
python - <<PY
import sys, importlib
import numpy as np
import torch
print("python:", sys.version.split()[0])
print("numpy:", np.__version__)
print("torch:", torch.__version__)
print("cuda available:", torch.cuda.is_available())
try:
print("cuda device count:", torch.cuda.device_count())
print("cuda current device name:", torch.cuda.get_device_name(0) if torch.cuda.is_available() else "N/A")
except Exception as e:
print("cuda info error:", e)
# sanity checks for versions (exit non-zero if mismatch)
if np.__version__ != "${NUMPY_VERSION}":
print("ERROR: numpy version mismatch (expected ${NUMPY_VERSION}, got", np.__version__, ")")
sys.exit(2)
if not torch.__version__.startswith("${TORCH_VER}"):
print("WARNING: torch version does not start with ${TORCH_VER} -- installed:", torch.__version__)
PY
echo
echo "=== Nerfstudio base installation complete ==="
echo "=== Uninstalling JIT gsplat & reinstalling functioning version ==="
pip uninstall gsplat -y
pip install gsplat==1.4.0 --index-url https://docs.gsplat.studio/whl/pt21cu118
echo ""
echo "=========================================="
echo "Installing FiGS-specific dependencies"
echo "=========================================="
echo ""
echo "=== Installing misc dependencies ==="
# conda install -c conda-forge albumentations --freeze-installed
pip install albumentations --no-deps
conda install -y -c conda-forge qpsolvers
conda install -y -c conda-forge tabulate
conda install -y -c conda-forge cython
pip install ipykernel --no-deps
pip install ipympl --no-deps
pip install rich imageio[ffmpeg]
# Install editable packages if they exist
if [ -d "../acados/interfaces/acados_template" ]; then
echo "=== Installing acados_template ==="
pip install -e ../acados/interfaces/acados_template
fi
# echo "=== Installing Remaining conda dependencies ==="
# conda install -y -c conda-forge albumentations qpsolvers gdown ipykernel ipympl "matplotlib<3.9" tqdm tabulate cython "numpy==${NUMPY_VERSION}"
# # Install pip packages
# echo "=== Installing FiGS pip dependencies ==="
# pip install rich imageio[ffmpeg]
echo "=== Installing FiGS (current package) ==="
pip install -e .
echo ""
echo "=========================================="
echo "Patching COLMAP parameter names"
echo "=========================================="
echo ""
# Fix deprecated SIFT parameter names in nerfstudio's colmap_utils.py
COLMAP_UTILS_PATH="${CONDA_PREFIX}/lib/python${PYTHON_VERSION}/site-packages/nerfstudio/process_data/colmap_utils.py"
if [ -f "$COLMAP_UTILS_PATH" ]; then
echo "=== Patching COLMAP parameters in colmap_utils.py ==="
# Replace SiftExtraction with FeatureExtraction
sed -i 's/--SiftExtraction\.use_gpu/--FeatureExtraction.use_gpu/g' "$COLMAP_UTILS_PATH"
# Replace SiftMatching with FeatureMatching
sed -i 's/--SiftMatching\.use_gpu/--FeatureMatching.use_gpu/g' "$COLMAP_UTILS_PATH"
echo "Successfully patched COLMAP parameters"
else
echo "WARNING: Could not find colmap_utils.py at expected location: $COLMAP_UTILS_PATH"
fi