Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ubuntu Linux Segmentation fault with GPU #469

Open
jpwalters opened this issue Dec 20, 2024 · 4 comments
Open

Ubuntu Linux Segmentation fault with GPU #469

jpwalters opened this issue Dec 20, 2024 · 4 comments

Comments

@jpwalters
Copy link

Problem: When I run pbrt on wsl2 Ubuntu 24 with the --gpu enabled I get a segmentation fault. If I run with only the cpu then my scene renders without issue but with the gpu enabled it throws a segmentation fault on every run.

Note: When I compile the windows version on the same machine is runs successfully with --gpu enabled.

Here's a snippet of the console output:
[ tid 21329 @ 1.175s gpu/optix/aggregate.cpp:1219 ] Starting OptiX initialization
[ tid 21329 @ 2.743s gpu/optix/aggregate.cpp:1233 ] Optix version 7.7.0 successfully initialized
[ tid 21329 @ 2.975s gpu/optix/aggregate.cpp:1308 ] Info: Pipeline statistics
module(s) : 1
entry function(s) : 19
trace call(s) : 4
continuation callable call(s) : 0
direct callable call(s) : 0
basic block(s) in entry functions : 3560
instruction(s) in entry functions : 58382
non-entry function(s) : 0
basic block(s) in non-entry functions: 0
instruction(s) in non-entry functions: 0
debug information : no

[ tid 21329 @ 2.975s gpu/optix/aggregate.cpp:1364 ] Finished OptiX initialization
[ tid 21329 @ 2.975s gpu/optix/aggregate.cpp:1376 ] Starting to create shapes and acceleration structures
[ tid 21329 @ 2.975s gpu/optix/aggregate.cpp:1384 ] Starting to read PLY meshes
[ tid 21329 @ 3.436s gpu/optix/aggregate.cpp:1387 ] Finished reading PLY meshes
[ tid 21329 @ 3.436s gpu/optix/aggregate.cpp:1434 ] Starting to create IASes for 14 instance definitions
Segmentation fault (core dumped)

Let me know if anyone has any thoughts about what might be the issue. I'm open to helping debug this issue too if anyone wants to suggest what might be helpful.

@jpwalters
Copy link
Author

As best I can tell after adding a few basic print statements the segmentation fault happens when calling buildBVHForTriangles.

LINE: 1457
BVH triangleBVH = buildBVHForTriangles( def.second->shapes, meshes, optixContext, hitPGTriangle, anyhitPGShadowTriangle, hitPGRandomHitTriangle, textures.floatTextures, namedMaterials, materials, media, {}, threadAllocators, threadCUDAStreams);

https://github.com/mmp/pbrt-v4/blob/master/src/pbrt/gpu/optix/aggregate.cpp#L1457

@jpwalters
Copy link
Author

jpwalters commented Dec 20, 2024

I'm not sure if any of these building warning are relevant.

[  0%] Built target soac
[  0%] Built target pbrt_soa_generated
[  0%] Built target optix.cu
[  0%] Built target rgb2spec_opt
[  0%] Building CUDA object CMakeFiles/pbrt_lib.dir/src/pbrt/gpu/optix/aggregate.cpp.o
/mnt/c/pbrt-v4/src/pbrt/cpu/primitive.h(23): warning #20011-D: calling a __host__ function("std::vector< ::pbrt::OptiXAggregate::HitgroupRecord, ::std::allocator< ::pbrt::OptiXAggregate::HitgroupRecord> > ::vector(const ::std::vector< ::pbrt::OptiXAggregate::HitgroupRecord, ::std::allocator< ::pbrt::OptiXAggregate::HitgroupRecord> > &)") from a __host__ __device__ function("pbrt::OptiXAggregate::BVH::BVH") is not allowed

/mnt/c/pbrt-v4/src/pbrt/cpu/primitive.h(23): remark: The warnings can be suppressed with "-diag-suppress <warning-number>"

/mnt/c/pbrt-v4/src/pbrt/cpu/primitive.h(23): warning #20011-D: calling a __host__ function("std::vector< ::pbrt::OptiXAggregate::HitgroupRecord, ::std::allocator< ::pbrt::OptiXAggregate::HitgroupRecord> > ::vector(const ::std::vector< ::pbrt::OptiXAggregate::HitgroupRecord, ::std::allocator< ::pbrt::OptiXAggregate::HitgroupRecord> > &)") from a __host__ __device__ function("pbrt::OptiXAggregate::BVH::BVH") is not allowed

/mnt/c/pbrt-v4/src/pbrt/cpu/primitive.h(23): warning #20011-D: calling a __host__ function("std::vector< ::pbrt::OptiXAggregate::HitgroupRecord, ::std::allocator< ::pbrt::OptiXAggregate::HitgroupRecord> > ::vector(const ::std::vector< ::pbrt::OptiXAggregate::HitgroupRecord, ::std::allocator< ::pbrt::OptiXAggregate::HitgroupRecord> > &)") from a __host__ __device__ function("pbrt::OptiXAggregate::BVH::BVH") is not allowed

/mnt/c/pbrt-v4/src/pbrt/cpu/primitive.h(23): warning #20011-D: calling a __host__ function("std::vector< ::pbrt::OptiXAggregate::HitgroupRecord, ::std::allocator< ::pbrt::OptiXAggregate::HitgroupRecord> > ::~vector()") from a __host__ __device__ function("pbrt::OptiXAggregate::BVH::~BVH") is not allowed

/mnt/c/pbrt-v4/src/pbrt/cpu/primitive.h(23): warning #20011-D: calling a __host__ function("std::vector< ::pbrt::OptiXAggregate::HitgroupRecord, ::std::allocator< ::pbrt::OptiXAggregate::HitgroupRecord> > ::~vector()") from a __host__ __device__ function("pbrt::OptiXAggregate::BVH::~BVH") is not allowed

/mnt/c/pbrt-v4/src/pbrt/cpu/primitive.h(23): warning #20011-D: calling a __host__ function("std::vector< ::pbrt::OptiXAggregate::HitgroupRecord, ::std::allocator< ::pbrt::OptiXAggregate::HitgroupRecord> > ::~vector()") from a __host__ __device__ function("pbrt::OptiXAggregate::BVH::~BVH") is not allowed

[  0%] Linking CUDA device code CMakeFiles/pbrt_lib.dir/cmake_device_link.o

@jpwalters
Copy link
Author

Again after adding a few more print lines it looks like the code is failing on the following line inside the function buildBVHForTriangles.

CUDA_CHECK(cudaMemcpy(pGPU, mesh->p, mesh->nVertices * sizeof(Point3f), cudaMemcpyHostToDevice));

https://github.com/mmp/pbrt-v4/blob/master/src/pbrt/gpu/optix/aggregate.cpp#L474

@jpwalters
Copy link
Author

Here's another compile warning that might be connected to the above line that seems to be cause the segmentation fault.

/pbrt-v4/src/pbrt/util/mesh.h(78): warning #20011-D: calling a __host__ function("std::vector< ::pbrt::OptiXAggregate::HitgroupRecord, ::std::allocator< ::pbrt::OptiXAggregate::HitgroupRecord> > ::~vector()") from a __host__ __device__ function("pbrt::OptiXAggregate::BVH::~BVH") is not allowed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant