背景
3DGS的cuda提效和优化内存的版本gsplat,使得在有一定GPU计算能力的电脑上也能够尝尝3DGS的效果。我在2025年的开年之初尝试配置过gsplat,由于过程中遇到很多问题,最终还是有一些windows上字符编码的问题,没有跑通,最近看gsplat的github更新了3DGUT,优化了反射和二次折射,以及适用于非线性相机模型,如鱼眼相机等。并且有人提供了windows上的配置教程,我将按照此教程配置过程,并仍然存在的问题进行了解决,最终跑通。
环境配置
- 基本的环境是利用anaconda,创建虚拟环境gsplat并激活;
conda create --name gsplat -y python=3.10
conda activate gsplat
- 在windows上安装visual studio 2022,vs2019也可以,但是后续的cuda toolkit版本需要与之匹配;
下载visual studio installer,按提示安装vs2022,其中注意要勾选c++桌面开发工具。接下来激活MSVC的环境,进入到你的安装目录下面,例如
C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\Build
在此目录下右键打开windows终端的命令窗口,输入
./vcvars64.bat
激活编译器
-
在windows上安装cuda toolkit 12.6
注意!安装cuda toolkit的时候一定要勾选visual studio integration, 这样MSVC在编译时才能找到CUDA -
安装pytorch,安装与cuda v12.6对应的pytorch版本即可,可以进入官网自己选择pytorch版本,也可以执行如下命令,默认更新最新符合cuda v12.6的版本
pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu126
- 安装gsplat
接着第一步anaconda创建并激活的虚拟环境,下载gsplat源码
git clone --recursive https://github.com/nerfstudio-project/gsplat.git
cd gsplat
并安装
pip install -e .
安装其他工具和依赖
pip install -r examples/requirements.txt
其中,requirements.txt需要git下载4个源码并安装
// requirements.txt
# assume torch is already installed
# pycolmap for data parsing
git+https://github.com/rmbrualla/pycolmap@cc7ea4b7301720ac29287dbe450952511b32125e
# (optional) nerfacc for torch version rasterization
# git+https://github.com/nerfstudio-project/nerfacc
viser
git+https://github.com/nerfstudio-project/nerfview@4538024fe0d15fd1a0e4d760f3695fc44ca72787
imageio[ffmpeg]
numpy<2.0.0
scikit-learn
tqdm
torchmetrics[image]
opencv-python
tyro>=0.8.8
Pillow
tensorboard
tensorly
pyyaml
matplotlib
git+https://github.com/rahul-goel/fused-ssim@328dc9836f513d00c4b5bc38fe30478b4435cbb5
git+https://github.com/harry7557558/fused-bilagrid@90f9788e57d3545e3a033c1038bb9986549632fe
splines
我在安装fused-bilagrid时遇到了cuda编译的问题,对原始的uniform_sample_backward_v1.cu文件进行了适配,修改后的文件如下
// uniform_sample_backward_v1.cu
#include "config.h"
#include <cooperative_groups.h>
#include <cooperative_groups/reduce.h>
namespace cg = cooperative_groups;
__global__ void bilagrid_uniform_sample_backward_v1_kernel_bilagrid(
const float *__restrict__ rgb, // [N,m,h,w,3]
const float *__restrict__ v_output, // [N,m,h,w,3]
float *__restrict__ v_bilagrid, // [N,12,L,H,W]
int N,
int L,
int H,
int W,
int m,
int h,
int w,
int mult_x,
int mult_y
) {
int x_idx = blockIdx.x * blockDim.x + threadIdx.x;
int y_idx = blockIdx.y * blockDim.y + threadIdx.y;
int idx = blockIdx.z * blockDim.z + threadIdx.z;
int xi = x_idx / mult_x, xf = x_idx % mult_x;
int yi = y_idx / mult_y, yf = y_idx % mult_y;
bool inside = (xi < W && yi < H && idx < (N * L));
if (!inside && (mult_x * mult_y == 1 ||
(mult_x % blockDim.x != 0 || mult_y % blockDim.y != 0)))
return;
int zi = idx % L;
idx /= L;
int ni = idx;
// Loop bounds
float sw = float(w - 1) / float(W - 1);
int block_wi0 =
max((int)ceil((xi - 1) * sw), 0); // same for all threads in the block
int block_wi1 = min((int)floor((xi + 1) * sw), w - 1) + 1;
float sh = float(h - 1) / float(H - 1);
int block_hi0 = max((int)ceil((yi - 1) * sh), 0);
int block_hi1 = min((int)floor((yi + 1) * sh), h - 1) + 1;
int x_step = (block_wi1 - block_wi0 + mult_x - 1) / mult_x;
int y_step = (block_hi1 - block_hi0 + mult_y - 1) / mult_y;
int wi0 = block_wi0 + xf * x_step;
int hi0 = block_hi0 + yf * y_step;
// int wi1 = min(block_wi0+(xf+1)*x_step, w);
// int hi1 = min(block_hi0+(yf+1)*y_step, h);
int wi1 = min(block_wi0 + (xf + 1) * x_step, block_wi1);
int hi1 = min(block_hi0 + (yf + 1) * y_step, block_hi1);
// Result for each affine mat channel
float accum[12] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
// Loop over all samples for this batch
if (inside)
for (int mi = 0; mi < m; ++mi) {
for (



被折叠的 条评论
为什么被折叠?



