torch / cutorch

A CUDA backend for Torch7
Other
337 stars 208 forks source link

Cutorch doesn't build with the newest cuda. (cudaPointerAttributes) #848

Open LevitatingBusinessMan opened 3 years ago

LevitatingBusinessMan commented 3 years ago

On this line here: https://github.com/torch/cutorch/blob/master/init.c#L938 cutorch is trying to use a non-existing property of cudaPointerAttributes. This property already went deprecated in Cuda 10.

aldenjenkins commented 3 years ago

Do you have a solution for this?

olahaye74 commented 2 years ago

Same problem for me init.c:938:34: error: 'struct cudaPointerAttributes' has no member named 'isManaged' lua_pushboolean(L, attributes.isManaged);

LeducH commented 2 years ago

I get this error when I want to build and install with arch

[ 94%] Building C object CMakeFiles/cutorch.dir/init.c.o
/home/user/Downloads/waifu2x-git/torch7-cutorch-git/src/torch7-cutorch-git/init.c: In function ‘cutorch_isManagedPtr’:
/home/user/Downloads/waifu2x-git/torch7-cutorch-git/src/torch7-cutorch-git/init.c:938:34: error: ‘struct cudaPointerAttributes’ has no member named ‘isManaged’
     lua_pushboolean(L, attributes.isManaged);
                                  ^
/home/user/Downloads/waifu2x-git/torch7-cutorch-git/src/torch7-cutorch-git/init.c: In function ‘luaopen_libcutorch’:
/home/user/Downloads/waifu2x-git/torch7-cutorch-git/src/torch7-cutorch-git/init.c:1033:3: error: implicit declaration of function ‘luaL_setfuncs’; did you mean ‘luaT_setfuncs’? [-Werror=implicit-function-declaration]
   luaL_setfuncs(L, cutorch_stuff__, 0);
   ^~~~~~~~~~~~~
   luaT_setfuncs
cc1: some warnings being treated as errors
make[2]: *** [CMakeFiles/cutorch.dir/build.make:94: CMakeFiles/cutorch.dir/init.c.o] Error 1
make[2]: *** Waiting for unfinished jobs....
In file included from /home/user/Downloads/waifu2x-git/torch7-cutorch-git/src/torch7-cutorch-git/generic/CStorage.c:35,
                 from generic/CStorage.c:1,
                 from /home/user/Downloads/waifu2x-git/torch7-cutorch-git/src/torch7-cutorch-git/lib/THC/THCGenerateAllTypes.h:17,
                 from /home/user/Downloads/waifu2x-git/torch7-cutorch-git/src/torch7-cutorch-git/Storage.c:18:
/home/user/Downloads/waifu2x-git/torch7-cutorch-git/src/torch7-cutorch-git/torch/generic/Storage.c: In function ‘torch_CudaByteStorage_init’:
/home/user/Downloads/waifu2x-git/torch7-cutorch-git/src/torch7-cutorch-git/torch/generic/Storage.c:276:3: error: implicit declaration of function ‘luaL_setfuncs’; did you mean ‘luaT_setfuncs’? [-Werror=implicit-function-declaration]
   luaL_setfuncs(L, torch_Storage_(_), 0);
   ^~~~~~~~~~~~~
   luaT_setfuncs
In file included from /home/user/Downloads/waifu2x-git/torch7-cutorch-git/src/torch7-cutorch-git/generic/CTensor.c:8,
                 from generic/CTensor.c:1,
                 from /home/user/Downloads/waifu2x-git/torch7-cutorch-git/src/torch7-cutorch-git/lib/THC/THCGenerateAllTypes.h:17,
                 from /home/user/Downloads/waifu2x-git/torch7-cutorch-git/src/torch7-cutorch-git/Tensor.c:20:
/home/user/Downloads/waifu2x-git/torch7-cutorch-git/src/torch7-cutorch-git/torch/generic/Tensor.c: In function ‘torch_CudaByteTensor_init’:
/home/user/Downloads/waifu2x-git/torch7-cutorch-git/src/torch7-cutorch-git/torch/generic/Tensor.c:1436:3: error: implicit declaration of function ‘luaL_setfuncs’; did you mean ‘luaT_setfuncs’? [-Werror=implicit-function-declaration]
   luaL_setfuncs(L, torch_Tensor_(_), 0);
   ^~~~~~~~~~~~~
   luaT_setfuncs
/home/user/Downloads/waifu2x-git/torch7-cutorch-git/src/torch7-cutorch-git/TensorMath.c: In function ‘cutorch_CudaByteTensorMath_init’:
/home/user/Downloads/waifu2x-git/torch7-cutorch-git/src/torch7-cutorch-git/TensorMath.c:10031:3: error: implicit declaration of function ‘luaL_setfuncs’; did you mean ‘luaT_setfuncs’? [-Werror=implicit-function-declaration]
   luaL_setfuncs(L, m_cutorch_CudaByteTensorMath__, 0);
   ^~~~~~~~~~~~~
   luaT_setfuncs
cc1: some warnings being treated as errors
make[2]: *** [CMakeFiles/cutorch.dir/build.make:80: CMakeFiles/cutorch.dir/Storage.c.o] Error 1
cc1: some warnings being treated as errors
make[2]: *** [CMakeFiles/cutorch.dir/build.make:108: CMakeFiles/cutorch.dir/Tensor.c.o] Error 1
cc1: some warnings being treated as errors
make[2]: *** [CMakeFiles/cutorch.dir/build.make:122: CMakeFiles/cutorch.dir/TensorMath.c.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:117: CMakeFiles/cutorch.dir/all] Error 2
make: *** [Makefile:136: all] Error 2
==> ERROR: A failure occurred in build().
    Aborting...
LevitatingBusinessMan commented 2 years ago

Seems like somebody on the ArchLinux user repositories has found a temporary fix.

Replace .isManaged with .type == 3 (cudaMemoryType::cudaMemoryTypeManaged).

LevitatingBusinessMan commented 2 years ago

I applied a patch to the AUR package, I am not entirely sure if it will work properly in programs using cutorch_isManagedPtr but at least the program compiles again.

https://gist.github.com/LevitatingBusinessMan/0a214c62471999a1d5afbdb732e773a0

mw66 commented 2 years ago

Seems like somebody on the ArchLinux user repositories has found a temporary fix.

Replace .isManaged with .type == 3 (cudaMemoryType::cudaMemoryTypeManaged).

according to:

https://github.com/nagadomi/distro/issues/11#issuecomment-645686463

-    lua_pushboolean(L, attributes.isManaged);
+    lua_pushboolean(L, attributes.type == cudaMemoryTypeManaged);
LevitatingBusinessMan commented 2 years ago

@mw66 Yep that's exactly it. cudaMemoryTypeManaged should be a constant for 3.