zenustech / zpc

zenus parallel computing library for zenus physics-based simulations
Mozilla Public License 2.0
72 stars 6 forks source link

Compile error on windows 11 #4

Closed dhl2011dj closed 12 months ago

dhl2011dj commented 1 year ago

I got error on windows 11 while compiling zpc “ ptxas fatal : SM version specified by .target is higher than default SM version assumed”,compile process would be ok with parameter ZS_ENABLE_CUDA=OFF.

the error message when building zpc is such: $ cmake --build . --parallel 8 --config Release MSBuild version 17.6.3+07e294721 for .NET Framework

zpccore.vcxproj -> D:\github\zpc\build\include\zensim\Release\zpccore.lib zpcomp.vcxproj -> D:\github\zpc\build\include\zensim\Release\zpcomp.lib zpccuda.vcxproj -> D:\github\zpc\build\include\zensim\Release\zpccuda.lib zpc.vcxproj -> D:\github\zpc\build\include\zensim\Release\zpc.lib

D:\github\zpc\build\include\zensim>"D:\software\NVDIA GPU Computing Toolkit\CUDA\v12.1\bin\nvcc.exe" -dlink -o zs_cu_wrangler.dir\Release\zs_cu_wrangler.device-link.obj -Xcompiler "/EHsc /W1 /nologo /O2 /MD /GR" -Xcompiler "/Fdzs_cu_wrangler.dir\Release\zs_cu_wrangler.pdb" -L"D:\software\NVDIA GPU Computing Toolkit\CUDA\v12.1\bin/crt" -L"D:\software\NVDIA GPU Computing Toolkit\CUDA\v12.1\lib\x64" kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib cudart.lib cudadevrt.lib zs_cu_wrangler.dir\Release\VolumeWrangler.ptx zs_cu_wrangler.dir\Release\ParticleWrangler.ptx ptxas fatal : SM version specified by .target is higher than default SM version assumed kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib cudart.lib cudadevrt.lib VolumeWrangler.ptx D:\software\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\BuildCustomizations\CUDA 12.1.targets(908,9): error MSB3721: 命令“"D:\software\NVDIA GPU Computing Toolkit\CUDA\v12.1\bin\nvcc.exe" -dlink -o zs_cu_wrangler.dir\Release\zs_cu_wrangler.device-link.obj -Xcompiler "/EHsc /W1 /nologo /O2 /MD /GR" -Xcompiler "/Fdzs_cu_wrangler.dir\Release\zs_cu_wrangler.pdb" -L"D:\software\NVDIA GPU Computing Toolkit\CUDA\v12.1\bin/crt" -L"D:\software\NVDIA GPU Computing Toolkit\CUDA\v12.1\lib\x64" kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib cudart.lib cudadevrt.lib zs_cu_wrangler.dir\Release\VolumeWrangler.ptx zs_cu_wrangler.dir\Release\ParticleWrangler.ptx”已退出,返回代码为 255。 [D:\github\zpc\build\include\zensim\zs_cu_wrangler.vcxproj]

littlemine commented 1 year ago

可以先尝试在cmake configure时加上-DZS_AUTO_DETECT_CUDA_ARCH=OFF以及-DCMAKE_CUDA_ARCHITECTURES=xxx(这里填写您显卡对应的计算能力,如86、75)。 如果以上方式不能解决问题的话,麻烦您提供一下cmake configure信息

zhxx1987 commented 1 year ago

也许是cuda 驱动版本不够高。。。

On Mon, Jun 19, 2023 at 10:44 PM Hanlin @.***> wrote:

编译出现错误“ ptxas fatal : SM version specified by .target is higher than default SM version assumed”,如果设置ZS_ENABLE_CUDA=OFF就可以编译了,不知道是什么问题。

— Reply to this email directly, view it on GitHub https://github.com/zenustech/zpc/issues/4, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC5IJS2E4SMWQW5P7UCZC73XMBQTZANCNFSM6AAAAAAZMBS45A . You are receiving this because you are subscribed to this thread.Message ID: @.***>

dhl2011dj commented 1 year ago

使用cmake .. -G "Visual Studio 17 2022" -A x64 -DZS_ENABLE_CUDA=OFF -DCMAKE_CUDA_ARCHITECTURES=86就可以编译了,请问编译成功后的库文件是build\include\zensim\Release目录下的zpc.lib zpccore.lib zpcomp.lib zpctool.lib这四个吗?

dhl2011dj commented 1 year ago

也许是cuda 驱动版本不够高。。。 On Mon, Jun 19, 2023 at 10:44 PM Hanlin @.> wrote: 编译出现错误“ ptxas fatal : SM version specified by .target is higher than default SM version assumed”,如果设置ZS_ENABLE_CUDA=OFF就可以编译了,不知道是什么问题。 — Reply to this email directly, view it on GitHub <#4>, or unsubscribe https://github.com/notifications/unsubscribe-auth/AC5IJS2E4SMWQW5P7UCZC73XMBQTZANCNFSM6AAAAAAZMBS45A . You are receiving this because you are subscribed to this thread.Message ID: @.>

我安装的是cuda_12.1.1_531.14_windows.exe,不确定是不是最新的

littlemine commented 1 year ago

使用cmake .. -G "Visual Studio 17 2022" -A x64 -DZS_ENABLE_CUDA=OFF -DCMAKE_CUDA_ARCHITECTURES=86就可以编译了,请问编译成功后的库文件是build\include\zensim\Release目录下的zpc.lib zpccore.lib zpcomp.lib zpctool.lib这四个吗?

一旦设置ZS_ENABLE_CUDA=OFF后,cuda模块就被禁用了。如果需要启用gpu计算相关支持的话得保持该选项为ON,构建成功后在windows下会生成zpccuda.lib。

littlemine commented 1 year ago

推荐在visual studio 2022 IDE中以文件夹形式打开项目,并右键根目录下的CMakeLists.txt设置cmake构建选项,然后生成代码。

dhl2011dj commented 1 year ago

不好意思之前搞错了,现在使用的命令是 $cmake .. -G "Visual Studio 17 2022" -A x64 -DZS_AUTO_DETECT_CUDA_ARCH=OFF -DCMAKE_CUDA_ARCHITECTURES=86cmake --build . --parallel 8 --config Release。编译报错信息是D:\github\zpc\build\include\zensim>"D:\software\NVDIA GPU Computing Toolkit\CUDA\v12.1\bin\nvcc.exe" -dlink -o zs_cu _wrangler.dir\Release\zs_cu_wrangler.device-link.obj -Xcompiler "/EHsc /W1 /nologo /O2 /MD /GR" -Xcompiler "/Fdzs_c u_wrangler.dir\Release\zs_cu_wrangler.pdb" -L"D:\software\NVDIA GPU Computing Toolkit\CUDA\v12.1\bin/crt" -L"D:\softw are\NVDIA GPU Computing Toolkit\CUDA\v12.1\lib\x64" kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advap i32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib cudart.lib cudadevrt.lib zs_cu_wrangl er.dir\Release\VolumeWrangler.ptx zs_cu_wrangler.dir\Release\ParticleWrangler.ptx ptxas fatal : SM version specified by .target is higher than default SM version assumed kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib cudart.lib cudadevrt.lib VolumeWrangler.ptx D:\software\Microsoft Visual Studio\2022\Community\MSBuild\Microsoft\VC\v170\BuildCustomizations\CUDA 12.1.targets(908, 9): error MSB3721: 命令“"D:\software\NVDIA GPU Computing Toolkit\CUDA\v12.1\bin\nvcc.exe" -dlink -o zs_cu_wrangler.dir\R elease\zs_cu_wrangler.device-link.obj -Xcompiler "/EHsc /W1 /nologo /O2 /MD /GR" -Xcompiler "/Fdzs_cu_wrangler.dir\Re lease\zs_cu_wrangler.pdb" -L"D:\software\NVDIA GPU Computing Toolkit\CUDA\v12.1\bin/crt" -L"D:\software\NVDIA GPU Compu ting Toolkit\CUDA\v12.1\lib\x64" kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib o le32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib cudart.lib cudadevrt.lib zs_cu_wrangler.dir\Release\VolumeWr angler.ptx zs_cu_wrangler.dir\Release\ParticleWrangler.ptx”已退出,返回代码为 255。 [D:\github\zpc\build\include\zensim\zs_cu_wra ngler.vcxproj]

littlemine commented 1 year ago

如果zpc不是作为zeno的子模块去单独使用的话,可以临时先去掉wrangler模块的构建,在zpc/include/zensim/CMakeLists.txt里去掉zs_cu_wrangler相关语句,这样应该能避免这里的错误。

littlemine commented 1 year ago

如果需要wrangler功能的话,可以再尝试将CMAKE_CUDA_ARCHITECTURES设置为文档里其他的选项(https://cmake.org/cmake/help/latest/prop_tgt/CUDA_ARCHITECTURES.html