RandomX_CUDA icon indicating copy to clipboard operation
RandomX_CUDA copied to clipboard

Compile error on Ubuntu 18.04

Open mclemme opened this issue 6 years ago • 7 comments
trafficstars

Followed the steps in the readme, but the compile fails at nvcc

cd RandomX_CUDA && nvcc -arch=sm_35 -prec-div=true -prec-sqrt=true -o ../bin/randomx ../RandomX/bin/librandomx.a kernel.cu
kernel.cu: In function ‘bool test_mining(bool, int, int, bool, uint32_t, uint32_t)’:
kernel.cu:249:50: warning: format ‘%llu’ expects argument of type ‘long long unsigned int’, but argument 2 has type ‘uint64_t {aka long unsigned int}’ [-Wformat=]
  printf("Allocated %llu scratchpads\n", batch_size);
                                                  ^
kernel.cu:310:71: error: unable to deduce ‘std::initializer_list<auto>&&’ from ‘{init_vm<2>, init_vm<4>, init_vm<8>, init_vm<16>}’
  for (auto p : { init_vm<2>, init_vm<4>, init_vm<8>, init_vm<16> })
                                                                       ^
kernel.cu:310:71: note:   couldn't deduce template parameter ‘auto’
kernel.cu:320:204: error: unable to deduce ‘std::initializer_list<auto>&&’ from ‘{execute_vm<2, false>, execute_vm<4, false>, execute_vm<8, false>, execute_vm<16, false>, execute_vm<2, true>, execute_vm<4, true>, execute_vm<8, true>, execute_vm<16, true>}’
  for (auto p : { execute_vm<2, false>, execute_vm<4, false>, execute_vm<8, false>, execute_vm<16, false>, execute_vm<2, true>, execute_vm<4, true>, execute_vm<8, true>, execute_vm<16, true> })
                                                                                                                                                                                                            ^
kernel.cu:320:204: note:   couldn't deduce template parameter ‘auto’
makefile:2: recipe for target 'release' failed
make: *** [release] Error 1

Do I need a newer version of nvcc? If you need more details, please let me know.

mclemme avatar Jul 28 '19 17:07 mclemme

https://github.com/SChernykh/RandomX_CUDA/commit/493937c854ac25f5ea8be6291d9abd55a565262f should fix it.

SChernykh avatar Jul 28 '19 19:07 SChernykh

@SChernykh thanks for the patch, I now get another error though:

cd RandomX_CUDA && nvcc -arch=sm_35 -prec-div=true -prec-sqrt=true -o ../bin/randomx ../RandomX/bin/librandomx.a kernel.cu
kernel.cu(310): warning: a value of type "void (*)(void *, void *, void *)" cannot be used to initialize an entity of type "const void *"

kernel.cu(320): warning: a value of type "void (*)(void *, void *, void *, const void *, unsigned int, unsigned int, __nv_bool, __nv_bool)" cannot be used to initialize an entity of type "const void *"

kernel.cu(310): warning: a value of type "void (*)(void *, void *, void *)" cannot be used to initialize an entity of type "const void *"

kernel.cu(320): warning: a value of type "void (*)(void *, void *, void *, const void *, unsigned int, unsigned int, bool, bool)" cannot be used to initialize an entity of type "const void *"

kernel.cu: In function ‘bool test_mining(bool, int, int, bool, uint32_t, uint32_t)’:
kernel.cu:310:78: error: unable to deduce ‘std::initializer_list<auto>&&’ from ‘{init_vm<2>, init_vm<4>, init_vm<8>, init_vm<16>}’
  for (const void* p : { init_vm<2>, init_vm<4>, init_vm<8>, init_vm<16> })
                                                                              ^
kernel.cu:310:78: note:   couldn't deduce template parameter ‘auto’
kernel.cu:320:211: error: unable to deduce ‘std::initializer_list<auto>&&’ from ‘{execute_vm<2, false>, execute_vm<4, false>, execute_vm<8, false>, execute_vm<16, false>, execute_vm<2, true>, execute_vm<4, true>, execute_vm<8, true>, execute_vm<16, true>}’
  for (const void* p : { execute_vm<2, false>, execute_vm<4, false>, execute_vm<8, false>, execute_vm<16, false>, execute_vm<2, true>, execute_vm<4, true>, execute_vm<8, true>, execute_vm<16, true> })
                                                                                                                                                                                                                   ^
kernel.cu:320:211: note:   couldn't deduce template parameter ‘auto’
makefile:2: recipe for target 'release' failed
make: *** [release] Error 1

Below are the versions of nvcc, gcc and g++

nvcc: NVIDIA (R) Cuda compiler driver Copyright (c) 2005-2019 NVIDIA Corporation Built on Wed_Apr_24_19:10:27_PDT_2019 Cuda compilation tools, release 10.1, V10.1.168

gcc (Ubuntu 8.3.0-6ubuntu1~18.04.1) 8.3.0

g++ (Ubuntu 8.3.0-6ubuntu1~18.04.1) 8.3.0

Tried with nvcc 9.x and gcc/g++ 7.x as well, same error.

mclemme avatar Aug 08 '19 10:08 mclemme

This is strange as CUDA 10.1 compiler has no problems there on Windows.

SChernykh avatar Aug 08 '19 10:08 SChernykh

Odd, I'll try to dig deeper into it, maybe it's some path issue (header files or something), haven't messed with C++ for ~10 years and have never done any cuda stuff, but there's a first for everything :)

I'll update if I find a way around it or find more details.

mclemme avatar Aug 08 '19 10:08 mclemme

Still fails (Ubuntu 16.04, CUDA 10.0) ... seems RandomX switched to cmake ...

# ll /usr/local/cuda
lrwxrwxrwx 1 root root 20 Apr  9  2019 /usr/local/cuda -> /usr/local/cuda-10.0/

# git clone --recursive https://github.com/SChernykh/RandomX_CUDA/
Cloning into 'RandomX_CUDA'...
remote: Enumerating objects: 92, done.
remote: Counting objects: 100% (92/92), done.
remote: Compressing objects: 100% (60/60), done.
remote: Total 594 (delta 63), reused 60 (delta 32), pack-reused 502
Receiving objects: 100% (594/594), 1.38 MiB | 2.18 MiB/s, done.
Resolving deltas: 100% (430/430), done.
Checking connectivity... done.
Submodule 'RandomX' (https://github.com/SChernykh/RandomX/) registered for path 'RandomX'
Cloning into 'RandomX'...
remote: Enumerating objects: 3337, done.
remote: Total 3337 (delta 0), reused 0 (delta 0), pack-reused 3337
Receiving objects: 100% (3337/3337), 2.84 MiB | 1.87 MiB/s, done.
Resolving deltas: 100% (2589/2589), done.
Checking connectivity... done.
Submodule path 'RandomX': checked out 'f1ff014bcadcbbf8769a25f3da47b6301e1a847f'

# cd RandomX_CUDA/
# make
cd RandomX && make nolto
make[1]: warning: jobserver unavailable: using -j1.  Add '+' to parent make rule.
make[1]: Entering directory '/root/dev/RandomX_CUDA/RandomX'
make[1]: *** No rule to make target 'nolto'. Stop.
make[1]: Leaving directory '/root/dev/RandomX_CUDA/RandomX'
makefile:2: recipe for target 'release' failed
make: *** [release] Error 2

aleqx avatar Nov 30 '19 16:11 aleqx

I compiled RandomX using cmake (cd RandomX; mkdir build; cd build; cmake ..; make) then I tried to compile your CUDA code

# cd RandomX_CUDA
# /usr/local/cuda/bin/nvcc -arch=sm_35 -prec-div=true -prec-sqrt=true -o ../bin/randomx ../RandomX/bin/librandomx.a kernel.cu
In file included from /usr/include/c++/5/chrono:35:0,
                 from kernel.cu:24:
/usr/include/c++/5/bits/c++0x_warning.h:32:2: error: #error This file requires compiler and library support for the ISO C++ 2011 standard. This support must be enabled with the -std=c++11 or -std=gnu++11 compiler options.
 #error This file requires compiler and library support \

... right, so I added --std c++11 which is known to nvcc and retried

# /usr/local/cuda/bin/nvcc --std c++11 -arch=sm_35 -prec-div=true -prec-sqrt=true -o ../bin/randomx ../RandomX/bin/librandomx.a kernel.cu
kernel.cu(340): warning: a value of type "void (*)(void *, void *, void *)" cannot be used to initialize an entity of type "const void *"

kernel.cu(350): warning: a value of type "void (*)(void *, void *, void *, const void *, unsigned int, unsigned int, __nv_bool, __nv_bool)" cannot be used to initialize an entity of type "const void *"

kernel.cu(340): warning: a value of type "void (*)(void *, void *, void *)" cannot be used to initialize an entity of type "const void *"

kernel.cu(350): warning: a value of type "void (*)(void *, void *, void *, const void *, unsigned int, unsigned int, bool, bool)" cannot be used to initialize an entity of type "const void *"

kernel.cu: In function ‘bool test_mining(bool, int, int, bool, uint32_t, uint32_t, bool)’:
kernel.cu:340:78: error: unable to deduce ‘std::initializer_list<_Tp>&&’ from ‘{init_vm<2>, init_vm<4>, init_vm<8>, init_vm<16>}’
kernel.cu:350:211: error: unable to deduce ‘std::initializer_list<_Tp>&&’ from ‘{execute_vm<2, false>, execute_vm<4, false>, execute_vm<8, false>, execute_vm<16, false>, execute_vm<2, true>, execute_vm<4, true>, execute_vm<8, true>, execute_vm<16, true>}’

still no joy ... any clues?

aleqx avatar Nov 30 '19 16:11 aleqx

It compiles if you comment out the statements from line 310 (in the original query, 340 in the latest query) to just before the program line starting with auto ( auto prev_time = high_resolution_clock::now();). Not sure why they are needed here, since they are only setting the preferred cache configuration The program will still select the appropriate cache configuration according to the Nvidia documentation for the Runtime API of cudaFuncSetCacheConfig.

This is just a dirty hack to achieve program compilation, probably have to wait on input from the program author.

StefanL avatar Mar 07 '22 00:03 StefanL