feimos32 / PBRT-HigherVersion

PBRT V4更高版本的文章所附带的源码
0 stars 0 forks source link

GPU编译问题 #1

Open YouthImagination opened 9 months ago

YouthImagination commented 9 months ago

你好,我在编译pbrt-v4的时候,在GPU部分存在问题,在optix.cu项目的编译可以通过,生成了optix.ptx,但是在别的项目编译后会出现link问题 fatal error LNK1181: 无法打开输入文件“D:\Codes\pbrt-v4\build\optix.cu.dir\Release\optix.cu.lib” 在CMakeLists里添加了

if(NOT DEFINED CMAKE_CUDA_ARCHITECTURES)
   set(CMAKE_CUDA_ARCHITECTURES "75")
endif(NOT DEFINED CMAKE_CUDA_ARCHITECTURES)

Cmake生成信息为:

Selecting Windows SDK version 10.0.22621.0 to target Windows 10.0.19045.
The CXX compiler identification is MSVC 19.29.30148.0
The C compiler identification is MSVC 19.29.30148.0
Detecting CXX compiler ABI info
Detecting CXX compiler ABI info - done
Check for working CXX compiler: D:/software/Visual Studio/VS2019/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe - skipped
Detecting CXX compile features
Detecting CXX compile features - done
Detecting C compiler ABI info
Detecting C compiler ABI info - done
Check for working C compiler: D:/software/Visual Studio/VS2019/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe - skipped
Detecting C compile features
Detecting C compile features - done
OpenEXR at commit: 5cfb5dab6dfada731586b0281bdb15ee75e26782
OpenVDB at commit: 414bed84c2fc22e188eac7b611aa85c7edd7a5a9
Ptex at commit: 4cd8e9a6db2b06e478dfbbd8c26eb6df97f84483
double-conversion at commit: cc1f75a114aca8d2af69f73a5a959aecbab0e87a
filesystem at commit: c5f9de30142453eb3c6fe991e82dfc2583373116
glfw at commit: 4cb36872a5fe448c205d0b46f0e8c8b57530cfe0
libdeflate at commit: 1fd0bea6ca2073c68493632dafc4b1ddda1bcbc3
lodepng at commit: 8c6a9e30576f07bf470ad6f09458a2dcd7a6a84a
qoi at commit: 028c75fd26e5e0758c7c711216c00404994c1ad3
stb at commit: af1a5bc352164740c1cc1354942b1c6b72eacb8a
utf8proc at commit: 2484e2ed5e1d9c19edcccf392a7d9920ad90dfaf
zlib at commit: 54d591eabf9fe0e84c725638f8d5d8d202a093fa
The ASM compiler identification is MSVC
Found assembler: D:/software/Visual Studio/VS2019/VC/Tools/MSVC/14.29.30133/bin/Hostx64/x64/cl.exe
CMake Warning at cmake/FindOpenEXR.cmake:47 (find_package):
  Could not find a configuration file for package "OpenEXR" that is
  compatible with requested version "2.3".

  The following configuration files were considered but not accepted:

    D:/software/vips/lib/cmake/OpenEXR/OpenEXRConfig.cmake, version: 3.1.3

Call Stack (most recent call first):
  src/ext/CMakeLists.txt:60 (find_package)

Could NOT find PkgConfig (missing: PKG_CONFIG_EXECUTABLE) 
Could NOT find OpenEXR (missing: ILMBASE_INCLUDE_PATH OPENEXR_IMATH_LIBRARY OPENEXR_ILMIMF_LIBRARY OPENEXR_IEX_LIBRARY OPENEXR_HALF_LIBRARY) (found suitable version "3.1.3", minimum required is "2.3")
OpenEXR not found; building it from scratch.
Configure ILMBASE Version: 2.5.3 Lib API: 25.0.2
-- WARNING pkg-config generation disabled
Configure OpenEXR Version: 2.5.3 Lib API: 25.0.2
clang-format not found.
CMake Deprecation Warning at src/ext/ptex/CMakeLists.txt:1 (cmake_minimum_required):
  Compatibility with CMake < 2.8.12 will be removed from a future version of
  CMake.

  Update the VERSION argument <min> value or use a ...<max> suffix to tell
  CMake that the project does not need compatibility with older versions.

Including Win32 support
Unable to find -lprofiler
Found CUDA: 11.4.120
The CUDA compiler identification is NVIDIA 11.4.120
Detecting CUDA compiler ABI info
Detecting CUDA compiler ABI info - done
Check for working CUDA compiler: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v11.4/bin/nvcc.exe - skipped
Detecting CUDA compile features
Detecting CUDA compile features - done
checkcuda.cu

  正在创建库 D:\Codes\pbrt-v4\build\checkcuda.lib 和对象 D:\Codes\pbrt-v4\build\checkcuda.exp

Detected CUDA Architecture: sm_75
Configuring done
Generating done

而且VS2019编译到一定时候就会固定卡死,请问有没有推荐的解决办法,在PBRT-V4那里的issue也没有解决。 我显卡是GTX1660TI,Cuda版本为11.4,Optix为7.3

YouthImagination commented 9 months ago

关于optix.cu的生成

已启动重新生成…
1>------ 已启动全部重新生成: 项目: ZERO_CHECK, 配置: Release x64 ------
1>Checking Build System
2>------ 已启动全部重新生成: 项目: soac, 配置: Release x64 ------
2>Building Custom Rule D:/Codes/pbrt-v4/CMakeLists.txt
2>soac.cpp
2>soac.vcxproj -> D:\Codes\pbrt-v4\build\Release\soac.exe
3>------ 已启动全部重新生成: 项目: pbrt_soa_generated, 配置: Release x64 ------
3>Generating pbrt_soa.h
3>Generating wavefront_workitems_soa.h
3>Building Custom Rule D:/Codes/pbrt-v4/CMakeLists.txt
4>------ 已启动全部重新生成: 项目: optix.cu, 配置: Release x64 ------
4>Building Custom Rule D:/Codes/pbrt-v4/CMakeLists.txt
4>Compiling CUDA source file ..\src\pbrt\gpu\optix.cu...
4>
4>D:\Codes\pbrt-v4\build>"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.4\bin\nvcc.exe" -gencode=arch=compute_75,code=\"sm_75,compute_75\" --use-local-env -ccbin "D:\software\Visual Studio\VS2019\VC\Tools\MSVC\14.29.30133\bin\HostX64\x64" -x cu   -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.4\include" -I"D:\software\NVIDIA Corporation\OptiX SDK73\include" -I"D:\Codes\pbrt-v4\src" -I"D:\Codes\pbrt-v4\build" -I"D:\Codes\pbrt-v4\src\ext\openvdb\nanovdb" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v11.4\include"     --keep-dir x64\Release -use_fast_math -maxrregcount=128  --machine 64 -ptx -cudart static -Xnvlink -suppress-stack-size-warning -Xcudafe=--display_error_number -Xcudafe=--diag_suppress=20044 --define-macro=PBRT_IS_MSVC --define-macro=_CRT_SECURE_NO_WARNINGS --define-macro=_ENABLE_EXTENDED_ALIGNED_STORAGE --define-macro=PBRT_IS_WINDOWS --define-macro=NOMINMAX --define-macro=PBRT_BUILD_GPU_RENDERER --define-macro=PBRT_HAS_INTRIN_H --define-macro=PBRT_NOINLINE=__declspec(noinline) --define-macro=PBRT_RESTRICT=__restrict --define-macro=PBRT_HAVE__ALIGNED_MALLOC --std=c++17 --expt-relaxed-constexpr --extended-lambda --forward-unknown-to-host-compiler -lineinfo -Xcudafe --diag_suppress=partial_override -Xcudafe --diag_suppress=virtual_function_decl_hidden -Xcudafe --diag_suppress=integer_sign_change -Xcudafe --diag_suppress=declared_but_not_referenced -Xcudafe --diag_suppress=implicit_return_from_non_void_function -std=c++17 -Xcompiler="/EHsc -Ob2 /wd4244 /wd4267 /wd4305 /wd4552 /wd4838 /wd4843 /wd26451 /wd26495 /wd4334 /wd4146" -o optix.cu.dir\Release\optix.ptx "D:\Codes\pbrt-v4\src\pbrt\gpu\optix.cu"
4>D:/Codes/pbrt-v4/src/ext/openvdb/nanovdb\nanovdb/NanoVDB.h(1): warning C4819: 该文件包含不能在当前代码页(936)中表示的字符。请将该文件保存为 Unicode 格式以防止数据丢失
4>optix.cu
4>已完成生成项目“optix.cu.vcxproj”的操作。
5>------ 已启动全部重新生成: 项目: pbrt_embedded_ptx_lib, 配置: Release x64 ------
5>Embedding PTX generated from src/pbrt/gpu/optix.cu
5>Building Custom Rule D:/Codes/pbrt-v4/CMakeLists.txt
5>optix.cu.ptx_embedded.c
5>LINK : fatal error LNK1181: 无法打开输入文件“D:\Codes\pbrt-v4\build\optix.cu.dir\Release\optix.cu.lib”
5>已完成生成项目“pbrt_embedded_ptx_lib.vcxproj”的操作 - 失败。
========== 全部重新生成: 成功 4 个,失败 1 个,跳过 0 个 ==========