Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OpenCV with CUDA fails to build with linker errors #109

Open
hacker1024 opened this issue Jul 18, 2023 · 1 comment
Open

OpenCV with CUDA fails to build with linker errors #109

hacker1024 opened this issue Jul 18, 2023 · 1 comment
Labels
bug Something isn't working

Comments

@hacker1024
Copy link
Contributor

hacker1024 commented Jul 18, 2023

I am attempting to configure OpenCV with CUDA for an Orin NX like so:

{ pkgs ? import <nixpkgs> { } }:

let
  jetpack = pkgs.callPackage ./path/to/jetpack { };
in
pkgs.appendOverlays [
  (self: super: {
    cudaPackages = jetpack.cudaPackages // {
      inherit (jetpack) cudaVersion;
      # https://github.com/anduril/jetpack-nixos/blob/ddaff1bfceafb93ea67cb4ef953ba8eff5cf942b/cuda-packages.nix#L35
      inherit (pkgs.cudaPackages_11_3) backendStdenv;
      cudaFlags = self.cudaPackages_11_4.cudaFlags.override {
        config.cudaCapabilities = [ "8.6" ];
        config.cudaForwardCompat = false;
      };
    }
  
    opencv4 = (super.opencv4.override ({
      enableGtk3 = true;
      cudaPackages = self.cudaPackages;
      enableCuda = true;
      enableCudnn = true;
    };
  })
];

This, however, is failing with glibc-related liker errors like the following.

opencv> /nix/store/6f700gwk2wvy8rp9licldryx0hbvhapn-binutils-2.40/bin/ld: /nix/store/sn546k2nnp9fd4fcfhdp1ni0ql8yclkn-openexr-2.5.8/lib/libIlmImf-2_5.so.26: undefined reference to `std::__throw_bad_array_new_length()@GLIBCXX_3.4.29'
opencv> collect2: error: ld returned 1 exit status
opencv> make[2]: *** [apps/annotation/CMakeFiles/opencv_annotation.dir/build.make:103: bin/opencv_annotation] Error 1
opencv> make[1]: *** [CMakeFiles/Makefile2:8698: apps/annotation/CMakeFiles/opencv_annotation.dir/all] Error 2
opencv> make[1]: *** Waiting for unfinished jobs....

Disabling OpenEXR or the OpenCV apps module only postpones the error. Whatever the configuration, the same linker error always shows up at some point.

How can OpenCV be built? If this is a configuration issue, I think it would be useful to add a version of OpenCV with the relevant CUDA overrides to this repository's package set.

@danielfullmer danielfullmer added the bug Something isn't working label Jul 18, 2023
@hacker1024
Copy link
Contributor Author

NixOS/nixpkgs#220341 may have something to do with this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants