Skip to content

ROCm Build from source hit error: multiple definition of `vision::cuda_version()' #9298

@unavailableun

Description

@unavailableun

🐛 Describe the bug

I am building pytorch 2.9.1 and torchvision 0.24.1 from source based on ROCm 6.2, while hit an error during torchvision building stage: multiple definition of `vision::cuda_version()'. Am I missed something for ROCm?

build code:

# build torch v2.9.1 from source for rocm6.2
RUN git clone https://github.com/pytorch/pytorch.git
WORKDIR /pytorch
RUN git checkout v2.9.1
RUN git submodule sync
RUN git submodule update --init --recursive
RUN pip install --group dev
RUN pip install mkl-static mkl-include
RUN make triton
RUN python tools/amd_build/build_amd.py
ENV CMAKE_PREFIX_PATH=${CONDA_PREFIX:-/opt/conda}:${CMAKE_PREFIX_PATH}
ENV PYTORCH_BUILD_VERSION=2.9.1
ENV PYTORCH_BUILD_NUMBER=1
RUN python -m pip install --no-build-isolation -v .
WORKDIR /

# build torchvision v0.24.1 from source for rocm6.2
RUN git clone https://github.com/pytorch/vision.git
WORKDIR /vision
RUN git checkout v0.24.1
RUN pip install . -v --no-build-isolation
WORKDIR /

error message

#25 28.81   g++ -pthread -B /opt/conda/envs/ptca/compiler_compat -Wno-unused-result -Wsign-compare -DNDEBUG -fwrapv -O2 -Wall -fPIC -O2 -isystem /opt/conda/envs/ptca/include -fPIC -O2 -isystem /opt/conda/envs/ptca/include -shared /vision/build/temp.linux-x86_64-cpython-310/vision/torchvision/csrc/ops/autocast/deform_conv2d_kernel.o /vision/build/temp.linux-x86_64-cpython-310/vision/torchvision/csrc/ops/autocast/nms_kernel.o /vision/build/temp.linux-x86_64-cpython-310/vision/torchvision/csrc/ops/autocast/ps_roi_align_kernel.o /vision/build/temp.linux-x86_64-cpython-310/vision/torchvision/csrc/ops/autocast/ps_roi_pool_kernel.o /vision/build/temp.linux-x86_64-cpython-310/vision/torchvision/csrc/ops/autocast/roi_align_kernel.o /vision/build/temp.linux-x86_64-cpython-310/vision/torchvision/csrc/ops/autocast/roi_pool_kernel.o /vision/build/temp.linux-x86_64-cpython-310/vision/torchvision/csrc/ops/autograd/deform_conv2d_kernel.o /vision/build/temp.linux-x86_64-cpython-310/vision/torchvision/csrc/ops/autograd/ps_roi_align_kernel.o /vision/build/temp.linux-x86_64-cpython-310/vision/torchvision/csrc/ops/autograd/ps_roi_pool_kernel.o /vision/build/temp.linux-x86_64-cpython-310/vision/torchvision/csrc/ops/autograd/roi_align_kernel.o /vision/build/temp.linux-x86_64-cpython-310/vision/torchvision/csrc/ops/autograd/roi_pool_kernel.o /vision/build/temp.linux-x86_64-cpython-310/vision/torchvision/csrc/ops/cpu/deform_conv2d_kernel.o /vision/build/temp.linux-x86_64-cpython-310/vision/torchvision/csrc/ops/cpu/nms_kernel.o /vision/build/temp.linux-x86_64-cpython-310/vision/torchvision/csrc/ops/cpu/ps_roi_align_kernel.o /vision/build/temp.linux-x86_64-cpython-310/vision/torchvision/csrc/ops/cpu/ps_roi_pool_kernel.o /vision/build/temp.linux-x86_64-cpython-310/vision/torchvision/csrc/ops/cpu/roi_align_kernel.o /vision/build/temp.linux-x86_64-cpython-310/vision/torchvision/csrc/ops/cpu/roi_align_kernel_hip.o /vision/build/temp.linux-x86_64-cpython-310/vision/torchvision/csrc/ops/cpu/roi_pool_kernel.o /vision/build/temp.linux-x86_64-cpython-310/vision/torchvision/csrc/ops/deform_conv2d.o /vision/build/temp.linux-x86_64-cpython-310/vision/torchvision/csrc/ops/nms.o /vision/build/temp.linux-x86_64-cpython-310/vision/torchvision/csrc/ops/ps_roi_align.o /vision/build/temp.linux-x86_64-cpython-310/vision/torchvision/csrc/ops/ps_roi_pool.o /vision/build/temp.linux-x86_64-cpython-310/vision/torchvision/csrc/ops/quantized/cpu/qnms_kernel.o /vision/build/temp.linux-x86_64-cpython-310/vision/torchvision/csrc/ops/quantized/cpu/qroi_align_kernel.o /vision/build/temp.linux-x86_64-cpython-310/vision/torchvision/csrc/ops/roi_align.o /vision/build/temp.linux-x86_64-cpython-310/vision/torchvision/csrc/ops/roi_pool.o /vision/build/temp.linux-x86_64-cpython-310/vision/torchvision/csrc/vision.o /vision/build/temp.linux-x86_64-cpython-310/vision/torchvision/csrc/vision_hip.o -L/opt/conda/envs/ptca/lib/python3.10/site-packages/torch/lib -lc10 -ltorch -ltorch_cpu -ltorch_python -o build/lib.linux-x86_64-cpython-310/torchvision/_C.so
#25 28.84   /usr/bin/ld: /vision/build/temp.linux-x86_64-cpython-310/vision/torchvision/csrc/vision_hip.o: in function `vision::cuda_version()':
#25 28.84   vision_hip.cpp:(.text+0x0): multiple definition of `vision::cuda_version()'; /vision/build/temp.linux-x86_64-cpython-310/vision/torchvision/csrc/vision.o:vision.cpp:(.text+0x0): first defined here
#25 29.19   collect2: error: ld returned 1 exit status
#25 29.19   error: command '/usr/bin/g++' failed with exit code 1
#25 30.17   error: subprocess-exited-with-error
#25 30.17   
#25 30.17   × Building wheel for torchvision (pyproject.toml) did not run successfully.
#25 30.17   │ exit code: 1
#25 30.17   ╰─> No available output.

Versions

The docker hasn't been built successfully, hard to run the collect_env.py script for now.

cc @jeffdaily @jithunnair-amd

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions