NVIDIA / cutlass

CUDA Templates for Linear Algebra Subroutines
Other
5.25k stars 883 forks source link

[BUG] undefined reference to `cutlass::library::Handle::~Handle()' collect2: error: ld returned 1 exit status #1626

Open LANSHANGH opened 1 month ago

LANSHANGH commented 1 month ago

Describe the bug /usr/bin/ld: /tmp/tmpxft_0000b975_00000000-11_single_file.o: in function main': tmpxft_0000b975_00000000-6_single_file.cudafe1.cpp:(.text+0x594): undefined reference tocutlass::library::Handle::Handle(CUstream_st, unsigned long)' /usr/bin/ld: tmpxft_0000b975_00000000-6_single_file.cudafe1.cpp:(.text+0x627): undefined reference to `cutlass::library::Handle::gemm(int, int, int, cutlass::library::NumericTypeID, cutlass::library::NumericTypeID, void const, cutlass::library::NumericTypeID, cutlass::library::LayoutTypeID, cutlass::library::ComplexTransform, void const, long, cutlass::library::NumericTypeID, cutlass::library::LayoutTypeID, cutlass::library::ComplexTransform, void const, long, void const, cutlass::library::NumericTypeID, void const, long, void*, long)' /usr/bin/ld: tmpxft_0000b975_00000000-6_single_file.cudafe1.cpp:(.text+0x658): undefined reference to cutlass::library::Handle::~Handle()' /usr/bin/ld: tmpxft_0000b975_00000000-6_single_file.cudafe1.cpp:(.text+0x6c4): undefined reference tocutlass::library::Handle::~Handle()' collect2: error: ld returned 1 exit status

Steps/Code to reproduce bug

include "cutlass/library/library.h"

include "cutlass/library/handle.h"

include <cutlass/util/host_tensor.h>

int main() {

// // Define the problem size // int M = 512; int N = 256; int K = 128;

float alpha = 1.25f; float beta = -1.25f;

// // Allocate device memory //

cutlass::HostTensor<float, cutlass::layout::ColumnMajor> A({M, K}); cutlass::HostTensor<float, cutlass::layout::ColumnMajor> B({K, N}); cutlass::HostTensor<float, cutlass::layout::ColumnMajor> C({M, N}); cutlass::HostTensor<float, cutlass::layout::ColumnMajor> D({M, N});

float const ptrA = A.device_data(); float const ptrB = B.device_data(); float const ptrC = C.device_data(); float ptrD = C.device_data();

int lda = A.device_ref().stride(0); int ldb = B.device_ref().stride(0); int ldc = C.device_ref().stride(0); int ldd = D.device_ref().stride(0);

// // CUTLASS Library call to execute device GEMM //

handle;

// // Launch GEMM on CUDA device. //

cutlass::Status status = handle.gemm( M, N, K,

cutlass::library::NumericTypeID::kF32,          // data type of internal accumulation
cutlass::library::NumericTypeID::kF32,          // data type of alpha/beta scalars

&alpha,                                         // pointer to alpha scalar

cutlass::library::NumericTypeID::kF32,          // data type of A matrix
cutlass::library::LayoutTypeID::kColumnMajor,   // layout of A matrix
cutlass::library::ComplexTransform::kConjugate, 
ptrA,                                           // pointer to A matrix in device memory
lda,                                            // leading dimension of A matrix

cutlass::library::NumericTypeID::kF32,          // data type of B matrix
cutlass::library::LayoutTypeID::kColumnMajor,   // layout of B matrix
cutlass::library::ComplexTransform::kNone,
ptrB,                                           // pointer to B matrix in device memory
ldb,                                            // leading dimension of B matrix

&beta,                                          // pointer to beta scalar

cutlass::library::NumericTypeID::kF32,          // data type of C and D matrix

ptrC,                                           // pointer to C matrix in device memory
ldc,                                            // leading dimension fo C matrix

ptrD,                                           // pointer to D matrix in device memory
ldd                                             // leading dimension of D matrix

);

if (status != cutlass::Status::kSuccess) { return -1; }

return 0; } Expected behavior When I was using the CUTLASS Library following the Quick Start documentation, I encountered this problem when compiling its examples as instructed

Environment details (please complete the following information): compiler-args " -I/content/cutlass/include -I/content/cutlass/tools/library/include -I/content/cutlass/tools/util/include --expt-relaxed-constexpr"

Additional context I looked up the information and found that there was a problem in the linking process, but I don't know how to solve it. Could you please help me

thakkarV commented 1 month ago

please show your complete cmake config command you are using and provide more details about your system environment you are building on

LANSHANGH commented 1 month ago

The cmake command I use is the Initial build steps in quickstart.md.

`$ export CUDACXX=${CUDA_INSTALL_PATH}/bin/nvcc

$ mkdir build && cd build

$ cmake .. -DCUTLASS_NVCC_ARCHS=75 # compiles for NVIDIA Hopper GPU architecture`

github-actions[bot] commented 4 days ago

This issue has been labeled inactive-30d due to no recent activity in the past 30 days. Please close this issue if no further response or action is needed. Otherwise, please respond with a comment indicating any updates or changes to the original issue and/or confirm this issue still needs to be addressed. This issue will be labeled inactive-90d if there is no activity in the next 60 days.