heavyai / heavydb

HeavyDB (formerly OmniSciDB)
https://heavy.ai
Apache License 2.0
2.93k stars 445 forks source link

cannot find libdevice for sm_60. Provide path to different CUDA installation via --cuda-path, or pass -nocudalib to build without linking with libdevice #725

Closed Sivannnnnn closed 2 years ago

Sivannnnnn commented 2 years ago

when i use the sample udf function,i get this error cannot find libdevice for sm_60. Provide path to different CUDA installation via --cuda-path, or pass -nocudalib to build without linking with libdevice

my clang version is 10 nvidia-smi 510.54 cuda 11.6

cdessanti commented 2 years ago

Hi, That message is strange because we fixed this problem last year. I tried with both clang 10 and 9, using cuda 11.0, 11.4, and 10.1, and I got that error message with CUDA 11 and no message with CUDA 10, and beside that warning (or error), the function has been compiled and it was runnable in the database, in both CPU and GPU.

udf.txt

I used that file because the example in the docs was incorrect.

run the server this way /opt/mapd/omnisci-ee-5.10.2-20220214-05c2d3ef72-Linux-x86_64-render/bin/omnisci_server --data /opt/mapd_storage/data48 --udf $HOME/udf.cpp

everything looked good to me with the bytecode for GPU and GPU generated


-rw-rw-r--  1 mapd mapd       427 mar 16 16:58  udf.cpp
-rw-rw-r--  1 mapd mapd        51 mar 16 17:05  udf.ast
-rw-rw-r--  1 mapd mapd      2128 mar 16 17:05  udf_cpu.bc
-rw-rw-r--  1 mapd mapd      2184 mar 16 17:05  udf_gpu.bc

omnisql> explain select udf_diff(1,nasdelay) from flights group by 1; Explanation IR for the GPU:


; Function Attrs: nounwind uwtable
define dso_local void @multifrag_query_hoisted_literals(i8*** readonly, i64* nocapture readonly, i8* readnone, i64* readnone, i64* readnone, i32* readnone, i32* readnone, i64* readnone, i64** readnone, i32* readnone, i32* nocapture readonly, i64* readnone) local_unnamed_addr #22 {
[CUT]
args_notnull:                                     ; preds = %filter_true
  %6 = call i32 @cast_int16_t_to_int32_t_nullable(i16 %2, i16 -32768, i32 -2147483648)
  %7 = call i32 @udf_diff(i32 %arg_literal_0, i32 %6)
  br label %args_null
[CUT]
omnisql> select udf_diff(1,nasdelay) from flights group by 1 limit 5;
EXPR$0
-40
-214
-916
-121
-103
5 rows returned.
Execution time: 68 ms, Total time: 69 ms
omnisql> \cpu
omnisql> select udf_diff(1,nasdelay) from flights group by 1 limit 5;
EXPR$0
-916
-192
-190
-406
-890
5 rows returned.
Execution time: 552 ms, Total time: 553 ms

what's happens when you try to run your functions?

Sivannnnnn commented 2 years ago

@cdessanti thank you very much,

The files I use are different from yours,i use this udf: https://docs.heavy.ai/sql/data-manipulation-dml/functions-operators#sample-user-defined-function

when i use yout udf , an error has occurred: `root@bigdata2:/var/lib/omnisci# /opt/omnisci/bin/omnisci_server --config /var/lib/omnisci/omnisci.conf /var/lib/omnisci/udf_diff.cpp:13:1: error: unknown type name 'attribute' EXTENSION_NOINLINE int32_t udf_diff(const int32_t x, const int32_t y) { return x - y; } ^ /var/lib/omnisci/udf_diff.cpp:11:39: note: expanded from macro 'EXTENSION_NOINLINE'

define EXTENSION_NOINLINE extern "C" NEVER_INLINE DEVICE

                                  ^

/var/lib/omnisci/udf_diff.cpp:8:22: note: expanded from macro 'NEVER_INLINE'

define NEVER_INLINE attribute((noinline))

                 ^

/var/lib/omnisci/udf_diff.cpp:13:20: error: expected ';' after top level declarator EXTENSION_NOINLINE int32_t udf_diff(const int32_t x, const int32_t y) { return x - y; } ^ 2 errors generated. Error while processing /var/lib/omnisci/udf_diff.cpp. 2022-03-17T08:20:27.839972 F 140307 0 0 DBHandler.cpp:457 Failed to initialize UDF compiler: Unable to create AST file for udf compilation (error code 1)`

So I used the official example,then i compile sucess `root@bigdata2:/var/lib/omnisci# /opt/omnisci/bin/omnisci_server --config /var/lib/omnisci/omnisci.conf

drwxr-xr-x 4 omnisci omnisci 4096 Mar 17 08:22 ./ drwxr-xr-x 53 root root 4096 Feb 25 15:58 ../ drwxr-xr-x 7 omnisci omnisci 4096 Feb 25 14:43 data/ -rw-r--r-- 1 omnisci omnisci 267 Mar 15 16:43 omnisci.conf -rw-r--r-- 1 omnisci omnisci 42 Feb 24 10:33 omnisci-sds.conf drwxr-xr-x 2 omnisci omnisci 4096 Feb 22 18:15 sds/ -rw-r--r-- 1 root root 0 Mar 17 08:22 udf_diff.ast -rw-r--r-- 1 root root 418 Mar 17 08:22 udf_diff.cpp -rw-r--r-- 1 root root 1372 Mar 17 08:22 udf_diff_cpu.bc -rw-r--r-- 1 root root 1364 Mar 17 08:22 udf_diff_gpu.bc `

when i used the udf in the client , i got a error: `omnisql> select udf_diff(1,nasdelay) from flights_2008_7M group by 1 limit 5; SQL Error: From line 1, column 8 to line 1, column 32: No match found for function signature udf_diff(, )

error: cannot find libdevice for sm_60. Provide path to different CUDA installation via --cuda-path, or pass -nocudalib to build without linking with libdevice. 2022-03-17T08:23:13.746754 E 140361 0 1 DBHandler.cpp:1560 SQL Error: From line 1, column 8 to line 1, column 23: No match found for function signature udf_diff(, )`

and I have another question,officials say only the following types are supported: https://docs.heavy.ai/sql/data-manipulation-dml/functions-operators#code-commentary But my application scenario is that I have a lot of binary multidimensional vector cosine calculation is required, but mapd does not support store binary, so after I use base64 encoding storage, I want to define a function, the incoming string, in my function to decode and cosine value calculation, the current through a custom function can be implemented? Or can it be done by modifying the source code?

cdessanti commented 2 years ago

HI,

The example in the docs has some errors, and it cannot work because the header is wrong and doesn't define any function. I'm opening an internal case to fix it.

this is the right example

#include <cstdint>
#if defined(__CUDA_ARCH__) && defined(__CUDACC__) && defined(__clang__)
#define DEVICE __device__
#define NEVER_INLINE
#define ALWAYS_INLINE
#else
#define DEVICE
#define NEVER_INLINE __attribute__((noinline))
#define ALWAYS_INLINE __attribute__((always_inline))
#endif
#define EXTENSION_NOINLINE extern "C" NEVER_INLINE DEVICE
EXTENSION_NOINLINE int32_t udf_diff(const int32_t x, const int32_t y) { return x - y; }

These are the resulting files in the FS.

-rw-rw-r--  1 mapd mapd       435 mar 17 09:28  udf2.cpp
-rw-rw-r--  1 mapd mapd        51 mar 17 09:37  udf2.ast
-rw-rw-r--  1 mapd mapd      2152 mar 17 09:37  udf2_cpu.bc
-rw-rw-r--  1 mapd mapd      2156 mar 17 09:37  udf2_gpu.bc

As you can see, we have an AST generated this time (this is because the example is missing a CR and the function is in the same line of the last define.

I don't think our UDF function supports any kind of array right now, and I think your use case could be managed by the incoming UDTF.

Could you explain more in deep your use case?

Anyway you can store binaries in the db using arrays of the type needed, so integers, floats, etc. but you cannot use them with UDF

Regards, Candido

cdessanti commented 2 years ago

Have you seen that?

Do you think it could be useful for what you are trying to achieve?

https://github.com/heavyai/heavydb/issues/607

Sivannnnnn commented 2 years ago

@cdessanti Thank you very much. Although I still have CUDA errors, I can run my UDF functions normally.

My demand is similar to the issue you gave. My expectation is to use a specific multidimensional vector and a column in the database to perform cosine calculation, calculate a value and sort. My multidimensional vector can be array, binary or string.

I think the UDTF function implemented by Python can solve my needs, but I have a question, can the function registered with the Python program only be used on the client side? What if I want to use this function in mapd client? Or I have defined this function with python on client A, and want to call this function with java on client B, what should I do? Do I need to define this function every time I have a computational requirement?

Is there a way to permanently register a function to the database?

cdessanti commented 2 years ago

Hi,

I'm happy it is working for you, and don't worry about the error message; we are already working for a fix on it.

With RBC, the function runs in the server, using the client you prefer; in the RDC example, it is called from IBIS, but it is called a database function.

Is there a way to permanently register a function to the database?

right now, it's not possible, the UDF is in an external file, and I don't know how the final implementation of UDTF will be; I know that python will be the first language supported, with C++ to follow