-
Notifications
You must be signed in to change notification settings - Fork 0
/
nerf2mesh.def
162 lines (123 loc) · 5.49 KB
/
nerf2mesh.def
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
BootStrap: docker
From: nvidia/cuda:12.6.0-cudnn-runtime-ubuntu22.04
%post
mkdir -p /APPS
mkdir -p /INSTALLERS
mkdir -p /OUPUTS /INPUTS /CODE
# Update package lists
apt-get update
# Install Python and pip, vim, git, wget
apt-get install -y python3 python3-pip vim git wget
# Install ffmpeg and ffprobe
apt-get install -y ffmpeg
#install cuda toolkit
mkdir /CUDA_TOOLKIT
cd /CUDA_TOOLKIT
wget https://developer.download.nvidia.com/compute/cuda/repos/ubuntu2204/x86_64/cuda-keyring_1.1-1_all.deb
dpkg -i cuda-keyring_1.1-1_all.deb
apt-get update
apt-get -y install cuda-toolkit-12-4
#temp set the variables
export CUDA_HOME="/usr/local/cuda-12.4"
export CUDA_PATH="/usr/local/cuda-12.4"
export PATH="$CUDA_HOME/bin:$PATH"
export LD_LIBRARY_PATH="/usr/local/cuda-12.4/lib64:$LD_LIBRARY_PATH"
echo "export PATH=/usr/local/cuda-12.4/bin${PATH:+:${PATH}}" >> /environment
echo "export LD_LIBRARY_PATH=/usr/local/cuda-12.4/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}" >> /environment
echo "$PATH"
echo $LD_LIBRARY_PATH
cat /environment
# Install PyTorch with CUDA support
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu124
# Clean up
apt-get clean
#install FSL dependencies
apt update -y && \
apt upgrade -y && \
apt install -y \
wget \
file \
dc \
mesa-utils \
pulseaudio \
libquadmath0 \
libgtk2.0-0 \
firefox \
libgomp1 ca-certificates libglu1-mesa libgl1-mesa-glx libsm6 libice6 libxt6 libpng16-16 libxrender1 libxcursor1 libxinerama1 libfreetype6 libxft2 libxrandr2 libgtk2.0-0 libpulse0 libasound2 libcaca0 libopenblas-base bzip2 dc bc
#for tinycudann install
apt install -y build-essential libcudnn8-dev ninja-build cmake g++-10
which g++
g++ --version
which nvcc
###NERF2MESH
#github repo
mkdir /NERF2MESH
cd /NERF2MESH
git clone https://github.com/ashawkey/nerf2mesh.git
cd nerf2mesh
#install nerf2mesh requirements
pip install rich tqdm ninja numpy scipy lpips pandas trimesh PyMCubes torch-ema dearpygui packaging matplotlib tensorboardX opencv-python imageio imageio-ffmpeg pymeshlab xatlas scikit-learn torchmetrics
#install torch scatter
pip install torch-scatter -f https://data.pyg.org/whl/torch-2.4.1+cu124.html
#install tinycudann
ln -s /usr/lib/x86_64-linux-gnu/libcuda.so /usr/local/cuda-12.4/lib64/libcuda.so
export TCNN_CUDA_ARCHITECTURES="75"
#pip install git+https://github.com/NVlabs/tiny-cuda-nn/#subdirectory=bindings/torch
mkdir /TINYCUDANN
cd /TINYCUDANN
git clone --recursive https://github.com/nvlabs/tiny-cuda-nn
cd tiny-cuda-nn
cmake . -B build -DCMAKE_BUILD_TYPE=RelWithDebInfo
cmake --build build --config RelWithDebInfo -j #run without -j if it is taking too long
#pytorch extension
#pip install git+https://github.com/NVlabs/tiny-cuda-nn/#subdirectory=bindings/torch
### or install from a local clone
cd bindings/torch
ls /usr/local/cuda-12.4/lib64/ | grep cuda
python3 setup.py install
# nvdiffrast
apt-get update
apt-get install -y libegl1-mesa-dev libgles2-mesa-dev libegl1-mesa libgl1-mesa-glx
pip install git+https://github.com/NVlabs/nvdiffrast/
# pytorch3d
pip install git+https://github.com/facebookresearch/pytorch3d.git
# install all extension modules
cd /NERF2MESH/nerf2mesh
bash scripts/install_ext.sh
# if you want to install manually, here is an example:
cd raymarching
python3 setup.py build_ext --inplace # build ext only, do not install (only can be used in the parent directory)
pip install . # install to python path (you still need the raymarching/ folder, since this only install the built extension.)
# create carvekit environment
apt install -y python3.10-venv
mkdir /CARVEKIT
cd /CARVEKIT
python3 -m venv carvekit
. carvekit/bin/activate
pip install carvekit --extra-index-url https://download.pytorch.org/whl/cu124
pip install matplotlib
# install colmap and xvfb
apt-get install -y colmap xvfb
%environment
export LC_ALL=C.UTF-8
export LANG=C.UTF-8
export PATH=/usr/local/cuda-12.4/bin:$PATH
export LD_LIBRARY_PATH=/usr/local/cuda-12.4/lib64:$LD_LIBRARY_PATH
export LD_LIBRARY_PATH=/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH #for OpenGL
export LD_LIBRARY_PATH=/usr/local/lib/python3.10/dist-packages/pymeshlab/lib:$LD_LIBRARY_PATH #need this sometimes
%runscript
hascuda=$(python3 -c "import torch; print(torch.cuda.is_available())")
if [ $hascuda ]; then
echo "This container has PyTorch with CUDA 12.4 support installed."
fi
echo "Singularity created/written by Michael Kim"
echo "Oct 7, 2024"
echo "CUDA 12.4, torch 2.4.1+cu124"
%files
/usr/lib/x86_64-linux-gnu/libcuda.so.550.100 /usr/lib/x86_64-linux-gnu/libcuda.so
# when running, will need to bind the corresponding driver file to /usr/lib/x86_64-linux-gnu/libcuda.so
# preprocessing scripts
/home-local/kimm58/Singularities/cuda_accre/SCRIPTS/subsample_video.py /SCRIPTS/subsample_video.py
/home-local/kimm58/Singularities/cuda_accre/SCRIPTS/run_carvekit.sh /SCRIPTS/run_carvekit.sh
#pip install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu118
#pip install diffusers invisible_watermark transformers accelerate safetensors