I’m writing a operator extension library for MXNet. Here’s the build error:
nvlink error : Multiple definition of '_Z17__half2float_warpRVK6__half' in 'lib/givens-matmul.cu.o', first defined in 'lib/example-op.cu.o' (target: sm_61)
nvlink fatal : merge_elf failed (target: sm_61)
And here’s my build script (with minor censorship):
#!/bin/bash
# TODO.refac replace this with cmake when codebase is large enough
MXNET_HOME=/XXX/incubator-mxnet
ANACONDA_HOME=/XXX/anaconda3
CUDA_HOME=/usr/local/cuda
INCLUDE_DIRS="-I$MXNET_HOME/include -I$ANACONDA_HOME/include -I$CUDA_HOME/include"
LIB_DIRS="-L$MXNET_HOME/build"
LIBS="-lmxnet"
NV_CFLAGS='-std=c++14 -gencode arch=compute_61,code=sm_61 -gencode arch=compute_86,code=sm_86' # 1080Ti & 3090 for now
CFLAGS='-std=c++14 -mf16c -mfma -mavx2 -O3'
LFLAGS='--no-undefined'
OUTPUT_NAME='libmxkhaotik.so'
rm -f lib/*.o
for ifile in src/*.cc; do
g++ -c $CFLAGS $INCLUDE_DIRS -o lib/$(basename $ifile).o -fPIC $ifile
done
for ifile in src/*.cu; do
nvcc -dc -c $NV_CFLAGS -Xcompiler "$CFLAGS -fPIC" $INCLUDE_DIRS -o lib/$(basename $ifile).o $ifile
done
nvcc -dlink -shared $NV_CFLAGS -Xlinker "$LFLAGS" $LIB_DIRS -o lib/"$OUTPUT_NAME" lib/*.o $LIBS && rm lib/*.o
I did some research and it appears half2float
is a library function. In fact I’m not even using it directly in my code. It’s likely included from certain headers. So I dunno how this multiple definition thing come into play, and thereafter how to fix this problem.