You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hey,
when compiling cuda code with nanobind a invalid type conversion error is thrown in nanobind\nb_func.h
The error only occurs in Windows, in Linux it worked fine.
Did someone else encounter this problem or has a suggestion?
Building wheels for collected packages: example
Building wheel for example (pyproject.toml) ... error
error: subprocess-exited-with-error
× Building wheel for example (pyproject.toml) did not run successfully.
│ exit code: 1
╰─> [92 lines of output]
*** scikit-build-core 0.10.7 using CMake 3.30.3 (wheel)
*** Configuring CMake...
2024-09-24 12:35:58,560 - scikit_build_core - WARNING - Can't find a Python library, got libdir=None, ldlibrary=None, multiarch=None, masd=None
loading initial cache file build\cp310-cp310-win_amd64\CMakeInit.txt
-- Building for: Visual Studio 17 2022
-- Selecting Windows SDK version 10.0.22621.0 to target Windows 10.0.22631.
-- The CXX compiler identification is MSVC 19.40.33811.0
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/Tools/MSVC/14.40.33807/bin/Hostx64/x64/cl.exe - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Python: C:\Users\{user}\anaconda3\envs\cupy-nanobind-example\python.exe (found suitable version "3.10.14", minimum required is "3.8") found components: Interpreter Development.Module
-- The CUDA compiler identification is NVIDIA 12.5.40
-- Detecting CUDA compiler ABI info
-- Detecting CUDA compiler ABI info - done
-- Check for working CUDA compiler: C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.5/bin/nvcc.exe - skipped
-- Detecting CUDA compile features
-- Detecting CUDA compile features - done
-- Configuring done (4.1s)
-- Generating done (0.1s)
-- Build files have been written to: C:/Users/{user}/PycharmProjects/cupy-nanobind-example/build/cp310-cp310-win_amd64
*** Building project with Visual Studio 17 2022...
MSBuild version 17.10.4+10fbfbf2e for .NET Framework
nanobind-static.vcxproj -> C:\Users\{user}\PycharmProjects\cupy-nanobind-example\build\cp310-cp310-win_amd64\Release\nanobind-static.lib
Compiling CUDA source file ..\..\src\example\cuda.cu...
C:\Users\{user}\PycharmProjects\cupy-nanobind-example\build\cp310-cp310-win_amd64>"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.5\bin\nvcc.exe" --use-local-env -ccbin "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.40.33807\bin\HostX64\x64" -x cu -I"C:\Us
ers\{user}\anaconda3\envs\cupy-nanobind-example\Lib\site-packages\nanobind\include" -I"C:\Users\{user}\anaconda3\envs\cupy-nanobind-example\Include" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.5\include" --keep-dir cuda\x64\Release -maxrregcount=0 --machine 64 --compile -cudart static -st
d=c++17 --generate-code=arch=compute_52,code=[compute_52,sm_52] -Xcompiler="/EHsc -Ob2" -D_WINDOWS -DNDEBUG -D"CMAKE_INTDIR=\"Release\"" -Dcuda_EXPORTS -D_WINDLL -D_MBCS -DWIN32 -D_WINDOWS -DNDEBUG -D"CMAKE_INTDIR=\"Release\"" -Dcuda_EXPORTS -Xcompiler "/EHsc /W1 /nologo /O2 /FS /MD " -Xcompiler "/Fdcuda.dir\Release\vc143.pdb" -o cuda.dir\Release\cuda.obj "C:\Users\{user}\PycharmProjects\cupy-nanobind-example\src\example\cuda.cu"
C:\Users\{user}\anaconda3\envs\cupy-nanobind-example\Lib\site-packages\nanobind\include\nanobind\nb_error.h(30): warning #1388-D: base class dllexport/dllimport specification differs from that of the derived class [C:\Users\{user}\PycharmProjects\cupy-nanobind-example\build\cp310-cp310-win_amd64\cuda.vcxproj]
class __declspec(dllexport) python_error : public std::exception {
^
Remark: The warnings can be suppressed with "-diag-suppress <warning-number>"
C:\Users\{user}\anaconda3\envs\cupy-nanobind-example\Lib\site-packages\nanobind\include\nanobind\nb_error.h(98): warning #1388-D: base class dllexport/dllimport specification differs from that of the derived class [C:\Users\{user}\PycharmProjects\cupy-nanobind-example\build\cp310-cp310-win_amd64\cuda.vcxproj]
class __declspec(dllexport) builtin_exception : public std::runtime_error {
^
C:\Users\{user}\anaconda3\envs\cupy-nanobind-example\Lib\site-packages\nanobind\include\nanobind\nb_error.h(30): warning #1388-D: base class dllexport/dllimport specification differs from that of the derived class [C:\Users\{user}\PycharmProjects\cupy-nanobind-example\build\cp310-cp310-win_amd64\cuda.vcxproj]
class __declspec(dllexport) python_error : public std::exception {
^
Remark: The warnings can be suppressed with "-diag-suppress <warning-number>"
C:\Users\{user}\anaconda3\envs\cupy-nanobind-example\Lib\site-packages\nanobind\include\nanobind\nb_error.h(98): warning #1388-D: base class dllexport/dllimport specification differs from that of the derived class [C:\Users\{user}\PycharmProjects\cupy-nanobind-example\build\cp310-cp310-win_amd64\cuda.vcxproj]
class __declspec(dllexport) builtin_exception : public std::runtime_error {
^
C:\Users\{user}\anaconda3\envs\cupy-nanobind-example\Lib\site-packages\nanobind\include\nanobind\nb_func.h(212): error : invalid type conversion [C:\Users\{user}\PycharmProjects\cupy-nanobind-example\build\cp310-cp310-win_amd64\cuda.vcxproj]
cap->func(static_cast<cast_t<Args>>(in.template get<Is>())...),
^
detected during:
instantiation of "PyObject *nanobind::detail::func_create<ReturnRef,CheckGuard,Func,Return,Args...,Is...,Extra...>(Func &&, Return (*)(Args...), std::index_sequence<Is...>, const Extra &...) [with ReturnRef=false, CheckGuard=true, Func=lambda [](nanobind::handle)->nanobind::object, Return=nanobind::object, Args=<nanobind::handle>, Is=<0ULL>, Extra=<nanobind::scope, nanobind::name>]" at line 292
instantiation of "void nanobind::cpp_function_def(Func &&, const Extra &...) [with <unnamed>=void, Func=lambda [](nanobind::handle)->nanobind::object, Extra=<nanobind::scope, nanobind::name>, <unnamed>=0]" at line 383 of C:\Users\{user}\anaconda3\envs\cupy-nanobind-example\Lib\site-packages\nanobind\include\nanobind\nb_class.h
C:\Users\{user}\anaconda3\envs\cupy-nanobind-example\Lib\site-packages\nanobind\include\nanobind\nb_func.h(82): warning #177-D: variable "kwonly_pos_n" was declared but never referenced [C:\Users\{user}\PycharmProjects\cupy-nanobind-example\build\cp310-cp310-win_amd64\cuda.vcxproj]
kwonly_pos_n = index_n_v<std::is_same_v<kw_only, Extra>...>;
^
detected during:
instantiation of "PyObject *nanobind::detail::func_create<ReturnRef,CheckGuard,Func,Return,Args...,Is...,Extra...>(Func &&, Return (*)(Args...), std::index_sequence<Is...>, const Extra &...) [with ReturnRef=false, CheckGuard=true, Func=lambda [](nanobind::handle)->nanobind::object, Return=nanobind::object, Args=<nanobind::handle>, Is=<0ULL>, Extra=<nanobind::scope, nanobind::name>]" at line 292
instantiation of "void nanobind::cpp_function_def(Func &&, const Extra &...) [with <unnamed>=void, Func=lambda [](nanobind::handle)->nanobind::object, Extra=<nanobind::scope, nanobind::name>, <unnamed>=0]" at line 383 of C:\Users\{user}\anaconda3\envs\cupy-nanobind-example\Lib\site-packages\nanobind\include\nanobind\nb_class.h
C:\Users\{user}\anaconda3\envs\cupy-nanobind-example\Lib\site-packages\nanobind\include\nanobind\nb_func.h(203): error : invalid type conversion [C:\Users\{user}\PycharmProjects\cupy-nanobind-example\build\cp310-cp310-win_amd64\cuda.vcxproj]
cap->func(static_cast<cast_t<Args>>(in.template get<Is>())...);
^
detected during:
instantiation of "PyObject *nanobind::detail::func_create<ReturnRef,CheckGuard,Func,Return,Args...,Is...,Extra...>(Func &&, Return (*)(Args...), std::index_sequence<Is...>, const Extra &...) [with ReturnRef=false, CheckGuard=true, Func=void (*&)(nanobind::ndarray<float, nanobind::shape<-
1LL>, nanobind::device::cuda>, nanobind::ndarray<const float, nanobind::shape<-1LL>, nanobind::device::cuda>), Return=void, Args=<nanobind::ndarray<float, nanobind::shape<-1LL>, nanobind::device::cuda>, nanobind::ndarray<const float, nanobind::shape<-1LL>, nanobind::device::cuda>>, Is=<0ULL, 1ULL>, Extra=<nanobind::scope, nanobind::name, nanobind::arg, nanobind::arg>]" at line 271
instantiation of "void nanobind::cpp_function_def(Return (*)(Args...), const Extra &...) [with <unnamed>=void, Return=void, Args=<nanobind::ndarray<float, nanobind::shape<-1LL>, nanobind::device::cuda>, nanobind::ndarray<const float, nanobind::shape<-1LL>, nanobind::device::cuda>>, Extra=<nanobind::scope, nanobind::name, nanobind::arg, nanobind::arg>]" at line 348
instantiation of "nanobind::module_ &nanobind::module_::def(const char *, Func &&, const Extra &...) [with Func=void (*)(nanobind::ndarray<float, nanobind::shape<-1LL>, nanobind::device::cuda>, nanobind::ndarray<const float, nanobind::shape<-1LL>, nanobind::device::cuda>), Extra=<nanobind::arg, nanobind::arg>]" at line 31 of C:\Users\{user}\PycharmProjects\cupy-nanobind-example\src\example\cuda.cu
C:\Users\{user}\anaconda3\envs\cupy-nanobind-example\Lib\site-packages\nanobind\include\nanobind\nb_func.h(203): error : invalid type conversion [C:\Users\{user}\PycharmProjects\cupy-nanobind-example\build\cp310-cp310-win_amd64\cuda.vcxproj]
cap->func(static_cast<cast_t<Args>>(in.template get<Is>())...);
^
detected during:
instantiation of "PyObject *nanobind::detail::func_create<ReturnRef,CheckGuard,Func,Return,Args...,Is...,Extra...>(Func &&, Return (*)(Args...), std::index_sequence<Is...>, const Extra &...) [with ReturnRef=false, CheckGuard=true, Func=void (*&)(nanobind::ndarray<float, nanobind::shape<-
1LL>, nanobind::device::cuda>, nanobind::ndarray<const float, nanobind::shape<-1LL>, nanobind::device::cuda>), Return=void, Args=<nanobind::ndarray<float, nanobind::shape<-1LL>, nanobind::device::cuda>, nanobind::ndarray<const float, nanobind::shape<-1LL>, nanobind::device::cuda>>, Is=<0ULL, 1ULL>, Extra=<nanobind::scope, nanobind::name, nanobind::arg, nanobind::arg>]" at line 271
instantiation of "void nanobind::cpp_function_def(Return (*)(Args...), const Extra &...) [with <unnamed>=void, Return=void, Args=<nanobind::ndarray<float, nanobind::shape<-1LL>, nanobind::device::cuda>, nanobind::ndarray<const float, nanobind::shape<-1LL>, nanobind::device::cuda>>, Extra=<nanobind::scope, nanobind::name, nanobind::arg, nanobind::arg>]" at line 348
instantiation of "nanobind::module_ &nanobind::module_::def(const char *, Func &&, const Extra &...) [with Func=void (*)(nanobind::ndarray<float, nanobind::shape<-1LL>, nanobind::device::cuda>, nanobind::ndarray<const float, nanobind::shape<-1LL>, nanobind::device::cuda>), Extra=<nanobind::arg, nanobind::arg>]" at line 31 of C:\Users\{user}\PycharmProjects\cupy-nanobind-example\src\example\cuda.cu
C:\Users\{user}\anaconda3\envs\cupy-nanobind-example\Lib\site-packages\nanobind\include\nanobind\nb_func.h(82): warning #177-D: variable "kwonly_pos_n" was declared but never referenced [C:\Users\{user}\PycharmProjects\cupy-nanobind-example\build\cp310-cp310-win_amd64\cuda.vcxproj]
kwonly_pos_n = index_n_v<std::is_same_v<kw_only, Extra>...>;
^
detected during:
instantiation of "PyObject *nanobind::detail::func_create<ReturnRef,CheckGuard,Func,Return,Args...,Is...,Extra...>(Func &&, Return (*)(Args...), std::index_sequence<Is...>, const Extra &...) [with ReturnRef=false, CheckGuard=true, Func=void (*&)(nanobind::ndarray<float, nanobind::shape<-
1LL>, nanobind::device::cuda>, nanobind::ndarray<const float, nanobind::shape<-1LL>, nanobind::device::cuda>), Return=void, Args=<nanobind::ndarray<float, nanobind::shape<-1LL>, nanobind::device::cuda>, nanobind::ndarray<const float, nanobind::shape<-1LL>, nanobind::device::cuda>>, Is=<0ULL, 1ULL>, Extra=<nanobind::scope, nanobind::name, nanobind::arg, nanobind::arg>]" at line 271
instantiation of "void nanobind::cpp_function_def(Return (*)(Args...), const Extra &...) [with <unnamed>=void, Return=void, Args=<nanobind::ndarray<float, nanobind::shape<-1LL>, nanobind::device::cuda>, nanobind::ndarray<const float, nanobind::shape<-1LL>, nanobind::device::cuda>>, Extra=<nanobind::scope, nanobind::name, nanobind::arg, nanobind::arg>]" at line 348
instantiation of "nanobind::module_ &nanobind::module_::def(const char *, Func &&, const Extra &...) [with Func=void (*)(nanobind::ndarray<float, nanobind::shape<-1LL>, nanobind::device::cuda>, nanobind::ndarray<const float, nanobind::shape<-1LL>, nanobind::device::cuda>), Extra=<nanobind::arg, nanobind::arg>]" at line 31 of C:\Users\{user}\PycharmProjects\cupy-nanobind-example\src\example\cuda.cu
3 errors detected in the compilation of "C:/Users/{user}/PycharmProjects/cupy-nanobind-example/src/example/cuda.cu".
cuda.cu
C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Microsoft\VC\v170\BuildCustomizations\CUDA 12.5.targets(799,9): error MSB3721: The command ""C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.5\bin\nvcc.exe" --use-local-env -ccbin "C:\Program Files (x86)\Microsoft Visual St
udio\2022\BuildTools\VC\Tools\MSVC\14.40.33807\bin\HostX64\x64" -x cu -I"C:\Users\{user}\anaconda3\envs\cupy-nanobind-example\Lib\site-packages\nanobind\include" -I"C:\Users\{user}\anaconda3\envs\cupy-nanobind-example\Include" -I"C:\Program Files\NVIDIA GPU Computing Toolkit\CUDA\v12.5\include" --keep-d
ir cuda\x64\Release -maxrregcount=0 --machine 64 --compile -cudart static -std=c++17 --generate-code=arch=compute_52,code=[compute_52,sm_52] -Xcompiler="/EHsc -Ob2" -D_WINDOWS -DNDEBUG -D"CMAKE_INTDIR=\"Release\"" -Dcuda_EXPORTS -D_WINDLL -D_MBCS -DWIN32 -D_WINDOWS -DNDEBUG -D"CMAKE_INTDIR=\"Release\""
-Dcuda_EXPORTS -Xcompiler "/EHsc /W1 /nologo /O2 /FS /MD " -Xcompiler "/Fdcuda.dir\Release\vc143.pdb" -o cuda.dir\Release\cuda.obj "C:\Users\{user}\PycharmProjects\cupy-nanobind-example\src\example\cuda.cu"" exited with code 1. [C:\Users\{user}\PycharmProjects\cupy-nanobind-example\build\cp310-cp310-win_amd64\cuda.vcxproj]
*** CMake build failed
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for example
Failed to build example
ERROR: ERROR: Failed to build installable wheels for some pyproject.toml based projects (example)
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hey,
when compiling cuda code with nanobind a invalid type conversion error is thrown in nanobind\nb_func.h
The error only occurs in Windows, in Linux it worked fine.
Did someone else encounter this problem or has a suggestion?
A minimal example that causes this error for me can be found here: https://github.com/lgarrison/cupy-nanobind-example
Below you find the source, CMakeLists and my console output with the error.
cuda.cu
CMakeLists.txt
Beta Was this translation helpful? Give feedback.
All reactions