赞
踩
ProjectGaussians.apply
的时候报错的,AttributeError: 'NoneType' object has no attribute 'ara'
C_
是从import gsplat.cuda as _C
中来的,直接在python CLI中import是可以的,直接安装gsplat whl虽然能安装,单独import gsplat
也能import,但是运行时候才会报错.gsplat.cuda
的__init__,用到了一个懒加载,也就是说import的时候不会报错只有实际调用的时候才会真正的去加载cuda模块,然后报错.地那件里面的_backend
,原来正真的编译模块一开始是没有的,当调用到的时候才会去编译模块try:
# try to import the compiled module (via setup.py)
from gsplat import csrc as _C
except ImportError:
# if failed, try with JIT compilation
....
_C = load
使用ninja编译的时候会报缺少cuda_runtime.h
头文件,报错Installation failed cc1plus: fatal error: cuda_runtime.h
/usr/local/cuda-11.6/targets/x86_64-linux/include/
中找到. 然后将其添加到linux CPATH环境变量(PS这里11.7换成自己的cuda版本)# 查找runtime.h
ll -h "/usr/local/cuda-11.7/targets/x86_64-linux/include/" | grep runtime
# 添加环境变量
export CPATH=/usr/local/cuda-11.7/targets/x86_64-linux/include:$CPATH
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-11.7/lib64
export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/cuda-11.7/lib64
CPATH 环境变量用于 C/C++ 预处理,它列出了预处理器检索 C/C++ 头文件的目录,与之相对的环境变量还有 C_INCLUDE_PATH、CPLUS_INCLUDE_PATH 和 OBJC_INCLUDE_PATH。其中无论预处理哪种语言,都会使用 CPATH 环境变量,而其余的三种环境变量仅在预处理指定的语言时才会适用。
lcudart
也就是找不到libcudart.so
,查阅资料发现仅仅添加LD_LIBRARY_PATH
不行,gcc找不到,需要添加到LIBRARY_PATH
中,添加后可以编译The value of LIBRARY_PATH is a colon-separated list of directories, much like PATH. When configured as a native compiler, GCC tries the directories thus specified when searching for special linker files, if it cannot find them using GCC_EXEC_PREFIX. Linking using GCC also uses these directories when searching for ordinary libraries for the -l option (but directories specified with -L come first).
# add below to your env bash file.
function _switch_cuda {
v=$1
export PATH=/usr/local/cuda-$v/bin:$PATH
export CUDADIR=/usr/local/cuda-$v
export LD_LIBRARY_PATH=/usr/local/cuda-$v/lib64:$LD_LIBRARY_PATH
export CPATH=/usr/local/cuda-$v/targets/x86_64-linux/include:$CPATH
nvcc --version
}
_switch_cuda 11.6
<conda env路径>/lib/python3.8/site-packages/gsplat/cuda/_backend.py
,发现了没有报错即可,也可以直接跑这段代码进行测试import glob import os from torch.utils.cpp_extension import _get_build_directory, load PATH='<CONDA env path>/lib/python3.8/site-packages/gsplat/cuda' name = "gsplat_cuda" build_dir = _get_build_directory(name, verbose=False) print('@build_dir',build_dir) extra_include_paths = [os.path.join(PATH, "csrc/third_party/glm")] extra_cflags = ["-O3"] extra_cuda_cflags = ["-O3"] sources = list(glob.glob(os.path.join(PATH, "csrc/*.cu"))) + list( glob.glob(os.path.join(PATH, "csrc/*.cpp")) ) _C = load( name=name, sources=sources, extra_cflags=extra_cflags, extra_cuda_cflags=extra_cuda_cflags, extra_include_paths=extra_include_paths, )
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。