CV-CUDA icon indicating copy to clipboard operation
CV-CUDA copied to clipboard

Having build error "file format not recognized"

Open Julianouyang opened this issue 2 years ago • 10 comments

I'm running on WSL2 ubuntu 20.04 with RTX 4080 and should meet all prerequisites from README. Here is the log:

$ ci/build.sh -- Found CUDAToolkit: /usr/local/cuda/include (found suitable version "12.0.76", minimum required is "12.0") -- Found CUDAToolkit: /usr/local/cuda/include (found version "12.0.76")

-- General configuration for CVCUDA-0.2.0-alpha

-- Build options -- CMAKE_INSTALL_PREFIX : /usr/local -- WARNINGS_AS_ERRORS : off -- ENABLE_COMPAT_OLD_GLIBC : ON -- BUILD_TESTS : ON -- BUILD_PYTHON : ON -- Python versions : 3.8 -- ENABLE_SANITIZER : off

-- Platform -- Host : Linux 5.15.79.1-microsoft-standard-WSL2 x86_64 -- Target : Linux 5.15.79.1-microsoft-standard-WSL2 x86_64 -- CMake : 3.22.2 -- CMake generator : Unix Makefiles -- CMake build tool : /usr/bin/make -- Configuration : Release -- ccache : CCACHE_EXEC-NOTFOUND -- ccache stats log :

-- Default compiler/linker config -- C++ Compiler : /usr/bin/g++-11 (11.1.0) -- C++ Standard : 20 -- C++ Flags : -Wall -Wno-unknown-pragmas -Wpointer-arith -Wmissing-declarations -Wredundant-decls -Wmultichar -Wno-unused-local-typedefs -Wunused -Wsuggest-override

-- C Compiler : /usr/bin/gcc-11 (11.1.0) -- C Flags : -Wall -Wno-unknown-pragmas -Wpointer-arith -Wmissing-declarations -Wredundant-decls -Wmultichar -Wno-unused-local-typedefs -Wunused -O3 -DNDEBUG

-- CUDA Compiler : /usr/local/cuda/bin/nvcc (12.0.76) -- CUDA Arch : 52 -- CUDA flags : -Wall -Wno-unknown-pragmas -Wpointer-arith -Wmissing-declarations -Wredundant-decls -Wmultichar -Wno-unused-local-typedefs -Wunused -Wsuggest-override -Wno-tautological-compare -Xfatbin=--compress-all -O3 -DNDEBUG -- CUDA toolkit target dir : /usr/local/cuda

-- Compiler Options : -- Definitions :

-- Linker flags (exec) : -- Linker flags (lib) :

-- Link-time optim.: supported YES, enabled ON

-- Configuring done -- Generating done -- Build files have been written to: /home/dali/Projects/CV-CUDA/build-rel Consolidate compiler generated dependencies of target nvcv_util_sanitizer [ 1%] Built target nvcv_util_sanitizer Consolidate compiler generated dependencies of target nvcv_types_priv [ 10%] Built target nvcv_types_priv Consolidate compiler generated dependencies of target nvcv_util_compat [ 11%] Built target nvcv_util_compat Consolidate compiler generated dependencies of target nvcv_util [ 13%] Built target nvcv_util [ 13%] Built target create_nvcv_types_exports_file Consolidate compiler generated dependencies of target nvcv_types [ 13%] Linking CXX shared library ../../lib/libnvcv_types.so /usr/bin/ld:/home/dali/Projects/CV-CUDA/src/util/stubs/libdl-2.17_stub.so: file format not recognized; treating as linker script /usr/bin/ld:/home/dali/Projects/CV-CUDA/src/util/stubs/libdl-2.17_stub.so:1: syntax error collect2: error: ld returned 1 exit status make[2]: *** [src/nvcv_types/CMakeFiles/nvcv_types.dir/build.make:313: lib/libnvcv_types.so.0.2.0] Error 1 make[1]: *** [CMakeFiles/Makefile2:741: src/nvcv_types/CMakeFiles/nvcv_types.dir/all] Error 2 make: *** [Makefile:156: all] Error 2

$ nvidia-smi +-----------------------------------------------------------------------------+ | NVIDIA-SMI 525.65 Driver Version: 527.56 CUDA Version: 12.0 | |-------------------------------+----------------------+----------------------+

Julianouyang avatar Dec 23 '22 03:12 Julianouyang

same error

monsterlyg avatar Dec 26 '22 04:12 monsterlyg

looks like it's file format is ascii text rather than elf

marsmiao avatar Dec 26 '22 08:12 marsmiao

The same problem

Apollo1587156 avatar Dec 27 '22 04:12 Apollo1587156

same error

oioeic avatar Dec 27 '22 06:12 oioeic

same error on ubuntu 20.04 when building docs: CV-CUDA/src/util/stubs/libdl-2.17_stub.so: file format not recognized; treating as linker script CV-CUDA/src/util/stubs/libdl-2.17_stub.so:1: syntax error

scse-l avatar Dec 27 '22 07:12 scse-l

同一个问题,求解。

wzw773828204 avatar Dec 27 '22 07:12 wzw773828204

字节跳不动了吗?这么多天了,问题还没解决

Apollo1587156 avatar Dec 27 '22 08:12 Apollo1587156

我通过删除/usr/bin/ld:/home/dali/Projects/CV-CUDA/src/util/stubs/下面的.so文件,重新下载源码上的.so文件,复制到src/util/stubs/目录下,重新编译就通过了。我也不知道啥原理。。。可能是下载下来的整个zip里面的so文件有损

yang0907 avatar Dec 27 '22 09:12 yang0907

我通过删除/usr/bin/ld:/home/dali/Projects/CV-CUDA/src/util/stubs/下面的.so文件,重新下载源码上的.so文件,复制到src/util/stubs/目录下,重新编译就通过了。我也不知道啥原理。。。可能是下载下来的整个zip里面的so文件有损

测试了,可用,不过得在https://github.com/CVCUDA/CV-CUDA/tree/release_v0.2.x/src/util/stubs网页端下直接点Download下载,而不能下载全部源码后才在src/util/stubs拿。

wzw773828204 avatar Dec 28 '22 02:12 wzw773828204

亲测,可用,可能是下载下来的整个源码里面的so文件有损。

Apollo1587156 avatar Dec 28 '22 02:12 Apollo1587156

Hey @Julianouyang, can you run the print_env.sh script and post here.

milesp-nvidia avatar Jan 04 '23 00:01 milesp-nvidia

Hi @milesp-nvidia I'm attaching it below. I have both gcc-9 and gcc-11 installed, and I believe the build script has fetched the correct version. That's the only item that looks suspicious to me...

$ ./print_env.sh

Click here to see environment details
 **git***
 commit 0ecbaa978ec5cbd9513aa581d19b02389a75d175 (HEAD -> release_v0.2.x, tag: v0.2.0-alpha, origin/release_v0.2.x, origin/main, origin/HEAD)
 Author: Miles Price <[email protected]>
 Date:   Wed Dec 21 16:30:28 2022 -0800

 feat: initializing GitHub repo with tested CV-CUDA operators.
 **git submodules***
 5ab508a01f9eb089207ee87fd547d290da39d015 3rdparty/googletest (release-1.8.0-3127-g5ab508a0)
 0694ec6a15863bff2e0ea5efe07c78de39b9a33c 3rdparty/pybind11 (v2.10.2)

 ***OS Information***
 DISTRIB_ID=Ubuntu
 DISTRIB_RELEASE=20.04
 DISTRIB_CODENAME=focal
 DISTRIB_DESCRIPTION="Ubuntu 20.04.5 LTS"
 NAME="Ubuntu"
 VERSION="20.04.5 LTS (Focal Fossa)"
 ID=ubuntu
 ID_LIKE=debian
 PRETTY_NAME="Ubuntu 20.04.5 LTS"
 VERSION_ID="20.04"
 HOME_URL="https://www.ubuntu.com/"
 SUPPORT_URL="https://help.ubuntu.com/"
 BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/"
 PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy"
 VERSION_CODENAME=focal
 UBUNTU_CODENAME=focal
 Linux Julian-PC 5.15.79.1-microsoft-standard-WSL2 #1 SMP Wed Nov 23 01:01:46 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux

 ***GPU Information***
 Wed Jan  4 15:47:16 2023
 +-----------------------------------------------------------------------------+
 | NVIDIA-SMI 525.65       Driver Version: 527.56       CUDA Version: 12.0     |
 |-------------------------------+----------------------+----------------------+
 | GPU  Name        Persistence-M| Bus-Id        Disp.A | Volatile Uncorr. ECC |
 | Fan  Temp  Perf  Pwr:Usage/Cap|         Memory-Usage | GPU-Util  Compute M. |
 |                               |                      |               MIG M. |
 |===============================+======================+======================|
 |   0  NVIDIA GeForce ...  On   | 00000000:07:00.0  On |                  N/A |
 | 30%   34C    P0    80W / 320W |   3761MiB / 16376MiB |     37%      Default |
 |                               |                      |                  N/A |
 +-------------------------------+----------------------+----------------------+

 +-----------------------------------------------------------------------------+
 | Processes:                                                                  |
 |  GPU   GI   CI        PID   Type   Process name                  GPU Memory |
 |        ID   ID                                                   Usage      |
 |=============================================================================|
 |    0   N/A  N/A        23      G   /Xwayland                       N/A      |
 +-----------------------------------------------------------------------------+

 ***CPU***
 Architecture:                    x86_64
 CPU op-mode(s):                  32-bit, 64-bit
 Byte Order:                      Little Endian
 Address sizes:                   48 bits physical, 48 bits virtual
 CPU(s):                          12
 On-line CPU(s) list:             0-11
 Thread(s) per core:              2
 Core(s) per socket:              6
 Socket(s):                       1
 Vendor ID:                       AuthenticAMD
 CPU family:                      25
 Model:                           33
 Model name:                      AMD Ryzen 5 5600X 6-Core Processor
 Stepping:                        0
 CPU MHz:                         3693.067
 BogoMIPS:                        7386.13
 Hypervisor vendor:               Microsoft
 Virtualization type:             full
 L1d cache:                       192 KiB
 L1i cache:                       192 KiB
 L2 cache:                        3 MiB
 L3 cache:                        32 MiB
 Vulnerability Itlb multihit:     Not affected
 Vulnerability L1tf:              Not affected
 Vulnerability Mds:               Not affected
 Vulnerability Meltdown:          Not affected
 Vulnerability Mmio stale data:   Not affected
 Vulnerability Retbleed:          Not affected
 Vulnerability Spec store bypass: Vulnerable
 Vulnerability Spectre v1:        Mitigation; usercopy/swapgs barriers and __user pointer sanitization
 Vulnerability Spectre v2:        Mitigation; Retpolines, IBPB conditional, IBRS_FW, STIBP conditional, RSB filling, PBRSB-eIBRS Not affected
 Vulnerability Srbds:             Not affected
 Vulnerability Tsx async abort:   Not affected
 Flags:                           fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush mmx fxsr sse sse2 ht syscall nx mmxext fxsr_opt pdpe1gb rdtscp lm constant_tsc rep_good nopl tsc_reliable nonstop_tsc cpuid extd_apicid pni pclmulqdq ssse3 fma cx16 sse4_1 sse4_2 movbe popcnt aes xsave avx f16c rdrand hypervisor lahf_lm cmp_legacy cr8_legacy abm sse4a misalignsse 3dnowprefetch osvw topoext ibrs ibpb stibp vmmcall fsgsbase bmi1 avx2 smep bmi2 erms rdseed adx smap clflushopt clwb sha_ni xsaveopt xsavec xgetbv1 xsaves clzero xsaveerptr arat umip vaes vpclmulqdq rdpid fsrm

 ***CMake***
 /usr/local/bin/cmake
 cmake version 3.22.2

 CMake suite maintained and supported by Kitware (kitware.com/cmake).

 ***g++***
 /usr/bin/g++
 g++ (Ubuntu 9.4.0-1ubuntu1~20.04.1) 9.4.0
 Copyright (C) 2019 Free Software Foundation, Inc.
 This is free software; see the source for copying conditions.  There is NO
 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.


 ***nvcc***
 /usr/local/cuda-12.0/bin/nvcc
 nvcc: NVIDIA (R) Cuda compiler driver
 Copyright (c) 2005-2022 NVIDIA Corporation
 Built on Mon_Oct_24_19:12:58_PDT_2022
 Cuda compilation tools, release 12.0, V12.0.76
 Build cuda_12.0.r12.0/compiler.31968024_0

 ***Python***

 ***Environment Variables***
 PATH                            : /usr/local/cuda-12.0/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/usr/lib/wsl/lib:/mnt/c/Program
 Files                           : (x86)/Razer
 Chroma                          : SDK/bin:/mnt/c/Program
 Files/Razer                     : Chroma
 SDK/bin:/mnt/c/ProgramData/Oracle/Java/javapath:/mnt/c/Program: Files
 (x86)/Intel/iCLS                : Client/:/mnt/c/Program
 Files/Intel/iCLS                : Client/:/mnt/c/Windows/system32:/mnt/c/Windows:/mnt/c/Windows/System32/Wbem:/mnt/c/Windows/System32/WindowsPowerShell/v1.0/:/mnt/c/Users/jouya/.dnx/bin:/mnt/c/Program
 Files/Microsoft                 : DNX/Dnvm/:/mnt/c/Program
 Files/Microsoft                 : SQL
 Server/130/Tools/Binn/:/mnt/c/Program: Files
 (x86)/Intel/Intel(R)            : Management
 Engine                          : Components/DAL:/mnt/c/Program
 Files/Intel/Intel(R)            : Management
 Engine                          : Components/DAL:/mnt/c/Program
 Files                           : (x86)/Intel/Intel(R)
 Management                      : Engine
 Components/IPT:/mnt/c/Program   : Files/Intel/Intel(R)
 Management                      : Engine
 Components/IPT:/mnt/c/Program   : Files
 (x86)/NVIDIA                    : Corporation/PhysX/Common:/mnt/c/Program
 Files/Intel/WiFi/bin/:/mnt/c/Program: Files/Common
 Files/Intel/WirelessCommon/:/mnt/c/WINDOWS/system32:/mnt/c/WINDOWS:/mnt/c/WINDOWS/System32/Wbem:/mnt/c/WINDOWS/System32/WindowsPowerShell/v1.0/:/mnt/c/Program: Files/MySQL/MySQL
 Utilities                       : 1.6/:/mnt/c/Program
 Files/Git/cmd:/mnt/c/Program    : Files/dotnet/:/mnt/c/WINDOWS/System32/OpenSSH/:/mnt/c/WINDOWS/system32/config/systemprofile/AppData/Local/Microsoft/WindowsApps:/mnt/c/Users/jouya/AppData/Roaming/nvm:/mnt/c/Program
 Files/nodejs:/mnt/c/Program     : Files/PuTTY/:/mnt/c/WINDOWS/system32:/mnt/c/WINDOWS:/mnt/c/WINDOWS/System32/Wbem:/mnt/c/WINDOWS/System32/WindowsPowerShell/v1.0/:/mnt/c/WINDOWS/System32/OpenSSH/:/mnt/c/Program
 Files/NVIDIA                    : Corporation/NVIDIA
 NvDLISR:/mnt/c/Users/jouya/AppData/Local/Microsoft/WindowsApps:/mnt/c/Users/jouya/AppData/Local/Programs/Microsoft: VS
 Code/bin:/mnt/c/Users/jouya/.dotnet/tools:/mnt/c/Users/jouya/AppData/Local/Microsoft/WindowsApps:
 LD_LIBRARY_PATH                 : /usr/local/cuda-12.0/lib64
 NUMBAPRO_NVVM                   :
 NUMBAPRO_LIBDEVICE              :
 CONDA_PREFIX                    :
 PYTHON_PATH                     :

 conda not found
 ***pip packages***
 /usr/bin/pip
 Package                Version
 ---------------------- --------------------
 attrs                  19.3.0
 Automat                0.8.0
 blinker                1.4
 certifi                2019.11.28
 chardet                3.0.4
 Click                  7.0
 cloud-init             22.4.2
 colorama               0.4.3
 command-not-found      0.3
 configobj              5.0.6
 constantly             15.1.0
 cryptography           2.8
 dbus-python            1.2.16
 distro                 1.4.0
 distro-info            0.23ubuntu1
 entrypoints            0.3
 httplib2               0.14.0
 hyperlink              19.0.0
 idna                   2.8
 importlib-metadata     1.5.0
 incremental            16.10.1
 Jinja2                 2.10.1
 jsonpatch              1.22
 jsonpointer            2.0
 jsonschema             3.2.0
 keyring                18.0.1
 language-selector      0.1
 launchpadlib           1.10.13
 lazr.restfulclient     0.14.2
 lazr.uri               1.0.3
 MarkupSafe             1.1.0
 more-itertools         4.2.0
 netifaces              0.10.4
 oauthlib               3.1.0
 pexpect                4.6.0
 pip                    20.0.2
 pyasn1                 0.4.2
 pyasn1-modules         0.2.1
 PyGObject              3.36.0
 PyHamcrest             1.9.0
 PyJWT                  1.7.1
 pymacaroons            0.13.0
 PyNaCl                 1.3.0
 pyOpenSSL              19.0.0
 pyrsistent             0.15.5
 pyserial               3.4
 python-apt             2.0.0+ubuntu0.20.4.8
 python-debian          0.1.36ubuntu1
 PyYAML                 5.3.1
 requests               2.22.0
 requests-unixsocket    0.2.0
 SecretStorage          2.3.1
 service-identity       18.1.0
 setuptools             45.2.0
 simplejson             3.16.0
 six                    1.14.0
 sos                    4.4
 ssh-import-id          5.10
 systemd-python         234
 Twisted                18.9.0
 ubuntu-advantage-tools 27.12
 ufw                    0.36
 unattended-upgrades    0.1
 urllib3                1.25.8
 wadllib                1.3.3
 wheel                  0.34.2
 zipp                   1.0.0
 zope.interface         4.7.1

Julianouyang avatar Jan 04 '23 21:01 Julianouyang

I managed to get it built by symlinking the corresponding shared object files from my OS (I'm on Ubuntu 22.04 LTS)

In other words ...

$ cd <path_to_cv-cuda_src>/src/util/stubs
$ mv libdl-2.17_stub.so libdl-2.17_stub_orig.so
$ mv libpthread-2.17_stub.so libpthread-2.17_stub_orig.so
$ mv librt-2.17_stub.so librt-2.17_stub_orig.so
$ ln -s /usr/lib/libdlfaker.so libdl-2.17_stub.so
$ ln -s /usr/lib/x86_64-linux-gnu/libpthread.so.0 libpthread-2.17_stub.so
$ ln -s /usr/lib/x86_64-linux-gnu/librt.so.1 librt-2.17_stub.so

After making the above changes, it didn't throw any additional errors during the build

FuzzyAtish avatar Jan 17 '23 23:01 FuzzyAtish

Closing as resolved by community input.

milesp-nvidia avatar May 10 '23 17:05 milesp-nvidia

可能问题原因: 构建.so的开发用的是wsl,然后在Windows端做了操作,导致文件格式不是ELF格式~ 有开发反馈使用wsl做Linux开发,如果通过Windows下载lib库,会更改文件格式,导致在wsl链接lib时会出现 file format not recognized; treating as linker script

当前解决方案要么是用源码编译,要么在wsl里下载lib文件,再同步到visual studio开发环境

jing-pei avatar Jul 14 '23 05:07 jing-pei