gsplat在windows本地部署

AI摘要

本文介绍了如何在Windows系统上本地部署gsplat,包括环境配置、安装依赖、数据下载、使用colmap获取点云数据以及3DGS训练和结果查看的详细步骤。特别指出了在配置过程中遇到的字符编码问题,并提供了相应的解决方案。

背景

3DGS的cuda提效和优化内存的版本gsplat,使得在有一定GPU计算能力的电脑上也能够尝尝3DGS的效果。我在2025年的开年之初尝试配置过gsplat,由于过程中遇到很多问题,最终还是有一些windows上字符编码的问题,没有跑通,最近看gsplat的github更新了3DGUT,优化了反射和二次折射,以及适用于非线性相机模型,如鱼眼相机等。并且有人提供了windows上的配置教程,我将按照此教程配置过程,并仍然存在的问题进行了解决,最终跑通。

环境配置

  1. 基本的环境是利用anaconda,创建虚拟环境gsplat并激活;
conda create --name gsplat -y python=3.10
conda activate gsplat
  1. 在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

激活编译器

  1. 在windows上安装cuda toolkit 12.6
    注意!安装cuda toolkit的时候一定要勾选visual studio integration, 这样MSVC在编译时才能找到CUDA

  2. 安装pytorch,安装与cuda v12.6对应的pytorch版本即可,可以进入官网自己选择pytorch版本,也可以执行如下命令,默认更新最新符合cuda v12.6的版本

pip3 install torch torchvision torchaudio --index-url https://download.pytorch.org/whl/cu126
  1. 安装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 (
上一篇: ROS2不同版本的区别
下一篇: colmap+pycolmap带cuda编译
Make a sound
Make a sound 新星创作者: 人工智能技术领域 新星创作者: 人工智能技术领域
博客等级 码龄8年 4931粉丝 59原创
评论 4
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

Make a sound

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值
⌂ 换网址