opencv/opencv

Cant install latest opencv due to undefined reference (libcublas)

lschaupp opened this issue · 0 comments

System Information

Ubuntu 18.04
CUDA 11.2
Nvidia driver: 470

Detailed description

/usr/bin/ld: /usr/local/cuda/lib64/libcublas.so: undefined reference to gemm_utilization@libcublasLt.so.11' /usr/bin/ld: /usr/local/cuda/lib64/libcublas.so: undefined reference to runGemmShortApi@libcublasLt.so.11'
/usr/bin/ld: /usr/local/cuda/lib64/libcublas.so: undefined reference to runGemmApi@libcublasLt.so.11' /usr/bin/ld: /usr/local/cuda/lib64/libcublas.so: undefined reference to init_gemm_select@libcublasLt.so.11'
/usr/bin/ld: /usr/local/cuda/lib64/libcublas.so: undefined reference to `free_gemm_select@libcublasLt.so.11'

Anyone has an idea what the issue could be?
I have CUDA 11.2 installed on this system.

Could not find a related ticket...

Steps to reproduce

import subprocess

def run_command(command):
process = subprocess.Popen(command, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
while True:
output = process.stdout.readline().decode()
if output == '' and process.poll() is not None:
break
if output:
print(output.strip())
rc = process.poll()
return rc

def main():
print("[bold green]Installing necessary dependencies...[/bold green]")
run_command("pip install numpy")
run_command("apt-get install -y build-essential")
run_command("apt-get install -y cmake git libgtk2.0-dev pkg-config libavcodec-dev libavformat-dev libswscale-dev")
run_command("apt-get install -y libtbb2 libtbb-dev libjpeg-dev libpng-dev libtiff-dev libdc1394-22-dev")

print("[bold green]Downloading OpenCV source code...[/bold green]")
run_command("git clone https://github.com/opencv/opencv.git")
run_command("git clone https://github.com/opencv/opencv_contrib.git")

print("[bold green]Configuring OpenCV build with CUDA support...[/bold green]")
run_command("mkdir opencv/build")
run_command("cd opencv/build && cmake -D CMAKE_BUILD_TYPE=RELEASE \
    -D CMAKE_INSTALL_PREFIX=/usr/local \
    -D INSTALL_PYTHON_EXAMPLES=OFF \
    -D INSTALL_C_EXAMPLES=OFF \
    -D OPENCV_ENABLE_NONFREE=ON \
    -D WITH_CUDA=ON \
    -D WITH_CUDNN=ON \
    -D OPENCV_DNN_CUDA=ON \
    -D WITH_NVCUVID=OFF \
    -D WITH_NVCUVENC=OFF \
    -D ENABLE_FAST_MATH=1 \
    -D CUDA_FAST_MATH=1 \
    -D CUDA_ARCH_BIN=7.5,8.0 \
    -D BUILD_TIFF=ON \
    -D WITH_CUBLAS=1 \
    -D WITH_IPP=NO \
    -D WITH_1394=NO \
    -D WITH_LIBV4L=NO \
    -D WITH_V4l=YES \
    -D WITH_TBB=YES \
    -D WITH_FFMPEG=YES \
    -D OPENCV_EXTRA_MODULES_PATH=../../opencv_contrib/modules \
    -D PYTHON3_PACKAGES_PATH=/home/tsc/anaconda3/envs/simswap_py39/lib/python3.9/site-packages \
    -D PYTHON3_EXECUTABLE=/home/tsc/anaconda3/envs/simswap_py39/bin/python \
    -D PYTHON3_LIBRARY=/home/tsc/anaconda3/envs/simswap_py39/lib/python3.9 \
    -D PYTHON3_INCLUDE_DIR=/home/tsc/anaconda3/envs/simswap_py39/include/python3.9 \
    -D PYTHON3_EXECUTABLE=/home/tsc/anaconda3/envs/simswap_py39/bin/python \
    -D BUILD_opencv_python3=ON \
    -D BUILD_DOCS=OFF \
    -D BUILD_TESTS=OFF \
    -D BUILD_PERF_TESTS=OFF \
    -D BUILD_EXAMPLES=OFF ..")

print("[bold green]Compiling and installing OpenCV...[/bold green]")
run_command("cd opencv/build && make -j8")
run_command("cd opencv/build && make install")

print("[bold green]Installation complete.[/bold green]")

if name == 'main':
main()

Issue submission checklist

  • I report the issue, it's not a question
  • I checked the problem with documentation, FAQ, open issues, forum.opencv.org, Stack Overflow, etc and have not found any solution
  • I updated to the latest OpenCV version and the issue is still there
  • There is reproducer code and related data files (videos, images, onnx, etc)