pytorch / pytorch/vision

build from source error

Open
#7,513 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
17.9k
Forks
7.3k
Avg merge
1d 15h
Merged PRs (30d)
13

Description

🐛 Describe the bug

I try to build vision_0.15.1 (last release) from source in my system
build command (from PKGBUILD)

$PYTORCH_ROCM_ARCH = gfx1030
$CFLAGS="-march=native -O3 -flto -pipe -fno-plt -fexceptions \
        -Wp,-D_FORTIFY_SOURCE=2,-D_GLIBCXX_ASSERTIONS \
        -Wformat \
        -fstack-clash-protection -fcf-protection"
$LDFLAGS="-Wl,-O1,--sort-common,--as-needed,-z,relro,-z,now"


  cmake "../" \
    -DCMAKE_INSTALL_PREFIX=/usr \
    -DCMAKE_BUILD_TYPE=None \
    -DCMAKE_CXX_FLAGS="${CXXFLAGS} -O3" \
    -DCMAKE_SHARED_LINKER_FLAGS="${LDFLAGS}" \
    -DWITH_PNG=ON \
    -DWITH_JPEG=ON
  make

  # fix bin/hipcc not found, because ROCM_HOME is lost
  # https://github.com/pytorch/vision/issues/6707#issuecomment-1269640873
  cd "${srcdir}/${_pkgname}-${pkgver}"
  FORCE_CUDA=1 \
    ROCM_HOME=/opt/rocm/ \
    TORCHVISION_INCLUDE=${srcdir} \
    TORCHVISION_LIBRARY=/usr/lib \
    TORCHVISION_USE_NVJPEG=0 \
    TORCHVISION_USE_VIDEO_CODEC=0 \
    TORCHVISION_USE_FFMPEG=1 \
    python setup.py build

first error on execute command - not librt.a. this file was found in /usr/lib/x86_64-linux-gnu/, not in real place /usr/lib/
i just linked file to target folder and build continue

second -

[100%] Linking CXX shared library libtorchvision.so
/usr/bin/ld: CMakeFiles/torchvision.dir/torchvision/csrc/vision_hip.cpp.o (symbol from plugin): в функции «vision::cuda_version()»:
(.text+0x0): повторное определение «vision::cuda_version()»; CMakeFiles/torchvision.dir/torchvision/csrc/vision.cpp.o (symbol from plugin):(.text+0x0): здесь первое определение
collect2: ошибка: выполнение ld завершилось с кодом возврата 1
make[2]: *** [CMakeFiles/torchvision.dir/build.make:580: libtorchvision.so] Ошибка 1
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/torchvision.dir/all] Ошибка 2
make: *** [Makefile:136: all] Ошибка 2

conflict between vision::cuda_version() in vision_hip.cpp and in vision.cpp
I dont know what to do

Versions

PyTorch version: 2.0.0
Is debug build: False
CUDA used to build PyTorch: N/A
ROCM used to build PyTorch: 5.4.22804-

OS: Manjaro Linux (x86_64)
GCC version: (GCC) 12.2.1 20230201
Clang version: 15.0.7
CMake version: version 3.25.0
Libc version: glibc-2.37

Python version: 3.10.10 (main, Mar 5 2023, 22:26:53) [GCC 12.2.1 20230201] (64-bit runtime)
Python platform: Linux-6.0.8-1-clear-x86_64-with-glibc2.37
Is CUDA available: True
CUDA runtime version: Could not collect
CUDA_MODULE_LOADING set to: LAZY
GPU models and configuration: AMD Radeon RX 6600M
Nvidia driver version: Could not collect
cuDNN version: Could not collect
HIP runtime version: 5.4.22802
MIOpen runtime version: 2.19.0
Is XNNPACK available: True

CPU:
Архитектура: x86_64
CPU op-mode(s): 32-bit, 64-bit
Address sizes: 39 bits physical, 48 bits virtual
Порядок байт: Little Endian
CPU(s): 16
On-line CPU(s) list: 0-15
ID прроизводителя: GenuineIntel
Имя модели: Genuine Intel(R) CPU 0000 @ 2.10GHz
Семейство ЦПУ: 6
Модель: 158
Thread(s) per core: 2
Ядер на сокет: 8
Сокетов: 1
Степпинг: 12
CPU(s) scaling MHz: 87%
CPU max MHz: 4400,0000
CPU min MHz: 800,0000
BogoMIPS: 4199,88
Флаги: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat pse36 clflush dts acpi mmx fxsr sse sse2 ss ht tm pbe syscall nx pdpe1gb rdtscp lm constant_tsc art arch_perfmon pebs bts rep_good nopl xtopology nonstop_tsc cpuid aperfmperf pni pclmulqdq dtes64 monitor ds_cpl vmx smx est tm2 ssse3 sdbg fma cx16 xtpr pdcm pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsave avx f16c rdrand lahf_lm abm 3dnowprefetch cpuid_fault invpcid_single ssbd ibrs ibpb stibp tpr_shadow vnmi flexpriority ept vpid ept_ad fsgsbase tsc_adjust bmi1 avx2 smep bmi2 erms invpcid mpx rdseed adx smap clflushopt intel_pt xsaveopt xsavec xgetbv1 xsaves dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_epp md_clear flush_l1d arch_capabilities
Виртуализация: VT-x
L1d cache: 256 KiB (8 instances)
L1i cache: 256 KiB (8 instances)
L2 cache: 2 MiB (8 instances)
L3 cache: 16 MiB (1 instance)
NUMA node(s): 1
NUMA node0 CPU(s): 0-15
Vulnerability Itlb multihit: KVM: Mitigation: VMX disabled
Vulnerability L1tf: Not affected
Vulnerability Mds: Mitigation; Clear CPU buffers; SMT vulnerable
Vulnerability Meltdown: Not affected
Vulnerability Mmio stale data: Mitigation; Clear CPU buffers; SMT vulnerable
Vulnerability Retbleed: Vulnerable
Vulnerability Spec store bypass: Mitigation; Speculative Store Bypass disabled via prctl
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: Mitigation; Microcode
Vulnerability Tsx async abort: Mitigation; TSX disabled

Versions of relevant libraries:
[pip3] mypy-extensions==0.4.3
[pip3] numpy==1.23.3
[pip3] pytorch-lightning==1.7.6
[pip3] pytorch-triton-rocm==2.0.1
[pip3] torch==2.0.0
[pip3] torchaudio==2.0.1+rocm5.4.2
[pip3] torchdiffeq==0.2.3
[pip3] torchmetrics==0.9.3
[pip3] torchvision==0.15.1+rocm5.4.2
[conda] Could not collect

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the CMake build and the reported sources torchvision/csrc/vision.cpp and torchvision/csrc/vision_hip.cpp, using the provided PyTorch, ROCm, and Manjaro versions to reproduce the linker errors. Done means the source build no longer reports the duplicate cuda_version symbol or the missing librt.a path.

Written by the indexing model from the issue text.

Assessment

Tech stack
cmake, cpp, linux, python
Domain
build-system, computer-vision
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.