645.set-mismatch

本文介绍了一种高效算法,用于解决数据集中一个数字重复而另一个数字缺失的问题。通过计算差值和平方差值,该算法能准确找到重复的数字和缺失的数字,并确保输出顺序符合题目要求。

The set S originally contains numbers from 1 to n. But unfortunately, due to the data error, one of the numbers in the set got duplicated to another number in the set, which results in repetition of one number and loss of another number. 

Given an array nums representing the data status of this set after the error. Your task is to firstly find the number occurs twice and then find the number that is missing. Return them in the form of an array.

Example 1:

Input: nums = [1,2,2,4]
Output: [2,3]

Note:

  1. The given array size will in the range [2, 10000].
  2. The given array's numbers won't have any order.

解题思路:

    这道题可以通过求这两个数的差和他们的平方差来求解得到两个答案,但是题目要求的是先输出重复的数字,再输出缺失的数字,所以我们要判断他们的差是否大于0

解题代码:

        ans=[0,0]
        sub=subsquare=0        
        for i, num in enumerate(nums):
            sub+=i+1-num
            subsquare+=(i+1)**2-num**2
        ans[0]=(subsquare/sub-sub)/2
        ans[1]=sub+ans[0]
        ans.sort()
        if sub>0:
            return ans
        return ans[::-1]

FAILED: out/target/product/p12_k37mv1_bsp/dex_bootjars/system/framework/arm/boot.art /bin/bash -c "(mkdir -p out/target/product/p12_k37mv1_bsp/symbols/system/framework/arm/ ) && (rm -f out/target/product/p12_k37mv1_bsp/dex_bootjars/system/framework/arm//*.art out/target/product/p12_k37mv1_bsp/dex_bootjars/system/framework/arm//*.oat out/target/product/p12_k37mv1_bsp/dex_bootjars/system/framework/arm//*.art.rel ) && (rm -f out/target/product/p12_k37mv1_bsp/symbols/system/framework/arm//*.art ) && (rm -f out/target/product/p12_k37mv1_bsp/symbols/system/framework/arm//*.oat ) && (rm -f out/target/product/p12_k37mv1_bsp/symbols/system/framework/arm//*.art.rel ) && (ANDROID_LOG_TAGS=\"*:e\" out/host/linux-x86/bin/dex2oatd --runtime-arg -Xms64m --runtime-arg -Xmx64m --compiler-filter=speed-profile --profile-file=out/target/product/p12_k37mv1_bsp/dex_bootjars/system/framework/boot.prof --dex-file=out/target/common/obj/JAVA_LIBRARIES/mediatek-common_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/mediatek-framework_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/mediatek-telephony-common_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/mediatek-telephony-base_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/core-oj_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/core-libart_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/conscrypt_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/okhttp_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/bouncycastle_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/apache-xml_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/ext_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/framework_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/telephony-common_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/voip-common_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/ims-common_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/android.hidl.base-V1.0-java_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/android.hidl.manager-V1.0-java_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/framework-oahl-backward-compatibility_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/android.test.base_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/mediatek-ims-common_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/mediatek-telecom-common_intermediates/javalib.jar --dex-file=out/target/common/obj/JAVA_LIBRARIES/mediatek-cta_intermediates/javalib.jar --dex-location=/system/framework/mediatek-common.jar --dex-location=/system/framework/mediatek-framework.jar --dex-location=/system/framework/mediatek-telephony-common.jar --dex-location=/system/framework/mediatek-telephony-base.jar --dex-location=/system/framework/core-oj.jar --dex-location=/system/framework/core-libart.jar --dex-location=/system/framework/conscrypt.jar --dex-location=/system/framework/okhttp.jar --dex-location=/system/framework/bouncycastle.jar --dex-location=/system/framework/apache-xml.jar --dex-location=/system/framework/ext.jar --dex-location=/system/framework/framework.jar --dex-location=/system/framework/telephony-common.jar --dex-location=/system/framework/voip-common.jar --dex-location=/system/framework/ims-common.jar --dex-location=/system/framework/android.hidl.base-V1.0-java.jar --dex-location=/system/framework/android.hidl.manager-V1.0-java.jar --dex-location=/system/framework/framework-oahl-backward-compatibility.jar --dex-location=/system/framework/android.test.base.jar --dex-location=/system/framework/mediatek-ims-common.jar --dex-location=/system/framework/mediatek-telecom-common.jar --dex-location=/system/framework/mediatek-cta.jar --oat-symbols=out/target/product/p12_k37mv1_bsp/symbols/system/framework/arm/boot.oat --oat-file=out/target/product/p12_k37mv1_bsp/dex_bootjars/system/framework/arm/boot.oat --oat-location=/system/framework/arm/boot.oat --image=out/target/product/p12_k37mv1_bsp/dex_bootjars/system/framework/arm/boot.art --base=0x70000000 --instruction-set=arm --instruction-set-variant=cortex-a53 --instruction-set-features=default --android-root=out/target/product/p12_k37mv1_bsp/system --runtime-arg -Xnorelocate --compile-pic --no-generate-debug-info --generate-build-id --multi-image --no-inline-from=core-oj.jar --abort-on-hard-verifier-error --abort-on-soft-verifier-error --no-abort-on-soft-verifier-error --generate-mini-debug-info || ( echo \"ERROR: Dex2oat failed to compile a boot image. It is likely that the boot classpath is inconsistent. Rebuild with ART_BOOT_IMAGE_EXTRA_ARGS=\"--runtime-arg -verbose:verifier\" to see verification errors.\" ; false ) && ANDROID_LOG_TAGS=\"*:e\" ANDROID_ROOT=out/target/product/p12_k37mv1_bsp/system ANDROID_DATA=out/target/product/p12_k37mv1_bsp/dex_bootjars/system/framework/arm/ out/host/linux-x86/bin/patchoatd --input-image-location=out/target/product/p12_k37mv1_bsp/dex_bootjars/system/framework/boot.art --output-image-relocation-directory=out/target/product/p12_k37mv1_bsp/dex_bootjars/system/framework/arm/ --instruction-set=arm --base-offset-delta=0x10000000 )" patchoatd E 08-01 17:03:32 1204514 1204514 image_space.cc:1761] Could not create image space with image file 'out/target/product/p12_k37mv1_bsp/dex_bootjars/system/framework/boot.art'. Attempting to fall back to imageless running. Error was: Failed to mmap at expected address, mapped at 0x72f9d8a00000 instead of 0x7057a000 patchoatd E 08-01 17:03:32 1204514 1204514 image_space.cc:1761] Attempted image: out/target/product/p12_k37mv1_bsp/dex_bootjars/system/framework/boot-framework.art patchoatd E 08-01 17:03:32 1204514 1204514 runtime.cc:1290] Dex file fallback disabled, cannot continue without image. patchoatd E 08-01 17:03:32 1204514 1204514 patchoat.cc:485] Unable to initialize runtime [ 32% 292/886] //frameworks/base/media/jni:libmedia2_jni link libmedia2_jni.so ninja: build stopped: subcommand failed. 17:03:37 ninja failed with: exit status 1
08-02
copying mmcv/ops/csrc/parrots/min_area_polygons_pytorch.h -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/parrots copying mmcv/ops/csrc/parrots/modulated_deform_conv.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/parrots copying mmcv/ops/csrc/parrots/modulated_deform_conv_parrots.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/parrots copying mmcv/ops/csrc/parrots/modulated_deform_conv_pytorch.h -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/parrots copying mmcv/ops/csrc/parrots/ms_deform_attn.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/parrots copying mmcv/ops/csrc/parrots/ms_deform_attn_parrots.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/parrots copying mmcv/ops/csrc/parrots/nms.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/parrots copying mmcv/ops/csrc/parrots/nms_parrots.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/parrots copying mmcv/ops/csrc/parrots/nms_pytorch.h -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/parrots copying mmcv/ops/csrc/parrots/nms_rotated.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/parrots copying mmcv/ops/csrc/parrots/pixel_group.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/parrots copying mmcv/ops/csrc/parrots/pixel_group_parrots.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/parrots copying mmcv/ops/csrc/parrots/pixel_group_pytorch.h -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/parrots copying mmcv/ops/csrc/parrots/points_in_boxes.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/parrots copying mmcv/ops/csrc/parrots/points_in_boxes_parrots.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/parrots copying mmcv/ops/csrc/parrots/points_in_boxes_pytorch.h -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/parrots copying mmcv/ops/csrc/parrots/points_in_polygons.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/parrots copying mmcv/ops/csrc/parrots/points_in_polygons_parrots.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/parrots copying mmcv/ops/csrc/parrots/points_in_polygons_pytorch.h -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/parrots copying mmcv/ops/csrc/parrots/psamask.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/parrots copying mmcv/ops/csrc/parrots/psamask_parrots.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/parrots copying mmcv/ops/csrc/parrots/psamask_pytorch.h -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/parrots copying mmcv/ops/csrc/parrots/riroi_align_rotated.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/parrots copying mmcv/ops/csrc/parrots/riroi_align_rotated_parrots.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/parrots copying mmcv/ops/csrc/parrots/riroi_align_rotated_pytorch.h -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/parrots copying mmcv/ops/csrc/parrots/roi_align.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/parrots copying mmcv/ops/csrc/parrots/roi_align_parrots.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/parrots copying mmcv/ops/csrc/parrots/roi_align_pytorch.h -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/parrots copying mmcv/ops/csrc/parrots/roi_align_rotated.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/parrots copying mmcv/ops/csrc/parrots/roi_align_rotated_parrots.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/parrots copying mmcv/ops/csrc/parrots/roi_align_rotated_pytorch.h -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/parrots copying mmcv/ops/csrc/parrots/roi_pool.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/parrots copying mmcv/ops/csrc/parrots/roi_pool_parrots.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/parrots copying mmcv/ops/csrc/parrots/roi_pool_pytorch.h -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/parrots copying mmcv/ops/csrc/parrots/roiaware_pool3d.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/parrots copying mmcv/ops/csrc/parrots/roiaware_pool3d_parrots.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/parrots copying mmcv/ops/csrc/parrots/roiaware_pool3d_pytorch.h -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/parrots copying mmcv/ops/csrc/parrots/roipoint_pool3d.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/parrots copying mmcv/ops/csrc/parrots/roipoint_pool3d_parrots.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/parrots copying mmcv/ops/csrc/parrots/roipoint_pool3d_pytorch.h -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/parrots copying mmcv/ops/csrc/parrots/rotated_feature_align.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/parrots copying mmcv/ops/csrc/parrots/rotated_feature_align_parrots.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/parrots copying mmcv/ops/csrc/parrots/rotated_feature_align_pytorch.h -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/parrots copying mmcv/ops/csrc/parrots/sync_bn.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/parrots copying mmcv/ops/csrc/parrots/sync_bn_parrots.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/parrots copying mmcv/ops/csrc/parrots/sync_bn_pytorch.h -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/parrots copying mmcv/ops/csrc/parrots/three_interpolate.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/parrots copying mmcv/ops/csrc/parrots/three_interpolate_parrots.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/parrots copying mmcv/ops/csrc/parrots/three_interpolate_pytorch.h -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/parrots copying mmcv/ops/csrc/parrots/three_nn.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/parrots copying mmcv/ops/csrc/parrots/three_nn_parrots.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/parrots copying mmcv/ops/csrc/parrots/three_nn_pytorch.h -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/parrots copying mmcv/ops/csrc/parrots/tin_shift.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/parrots copying mmcv/ops/csrc/parrots/tin_shift_parrots.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/parrots copying mmcv/ops/csrc/parrots/tin_shift_pytorch.h -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/parrots copying mmcv/ops/csrc/parrots/upfirdn2d.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/parrots copying mmcv/ops/csrc/parrots/upfirdn2d_parrots.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/parrots copying mmcv/ops/csrc/parrots/voxelization.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/parrots copying mmcv/ops/csrc/parrots/voxelization_parrots.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/parrots copying mmcv/ops/csrc/parrots/voxelization_pytorch.h -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/parrots creating build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch copying mmcv/ops/csrc/pytorch/active_rotated_filter.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch copying mmcv/ops/csrc/pytorch/assign_score_withk.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch copying mmcv/ops/csrc/pytorch/ball_query.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch copying mmcv/ops/csrc/pytorch/bbox_overlaps.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch copying mmcv/ops/csrc/pytorch/border_align.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch copying mmcv/ops/csrc/pytorch/box_iou_rotated.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch copying mmcv/ops/csrc/pytorch/carafe.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch copying mmcv/ops/csrc/pytorch/carafe_naive.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch copying mmcv/ops/csrc/pytorch/contour_expand.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch copying mmcv/ops/csrc/pytorch/convex_iou.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch copying mmcv/ops/csrc/pytorch/correlation.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch copying mmcv/ops/csrc/pytorch/deform_conv.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch copying mmcv/ops/csrc/pytorch/deform_roi_pool.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch copying mmcv/ops/csrc/pytorch/diff_iou_rotated.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch copying mmcv/ops/csrc/pytorch/focal_loss.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch copying mmcv/ops/csrc/pytorch/furthest_point_sample.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch copying mmcv/ops/csrc/pytorch/fused_bias_leakyrelu.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch copying mmcv/ops/csrc/pytorch/fused_spconv_ops.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch copying mmcv/ops/csrc/pytorch/gather_points.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch copying mmcv/ops/csrc/pytorch/group_points.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch copying mmcv/ops/csrc/pytorch/info.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch copying mmcv/ops/csrc/pytorch/iou3d.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch copying mmcv/ops/csrc/pytorch/knn.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch copying mmcv/ops/csrc/pytorch/masked_conv2d.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch copying mmcv/ops/csrc/pytorch/min_area_polygons.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch copying mmcv/ops/csrc/pytorch/modulated_deform_conv.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch copying mmcv/ops/csrc/pytorch/ms_deform_attn.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch copying mmcv/ops/csrc/pytorch/nms.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch copying mmcv/ops/csrc/pytorch/nms_rotated.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch copying mmcv/ops/csrc/pytorch/pixel_group.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch copying mmcv/ops/csrc/pytorch/points_in_boxes.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch copying mmcv/ops/csrc/pytorch/points_in_polygons.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch copying mmcv/ops/csrc/pytorch/psamask.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch copying mmcv/ops/csrc/pytorch/pybind.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch copying mmcv/ops/csrc/pytorch/riroi_align_rotated.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch copying mmcv/ops/csrc/pytorch/roi_align.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch copying mmcv/ops/csrc/pytorch/roi_align_rotated.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch copying mmcv/ops/csrc/pytorch/roi_pool.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch copying mmcv/ops/csrc/pytorch/roiaware_pool3d.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch copying mmcv/ops/csrc/pytorch/roipoint_pool3d.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch copying mmcv/ops/csrc/pytorch/rotated_feature_align.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch copying mmcv/ops/csrc/pytorch/scatter_points.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch copying mmcv/ops/csrc/pytorch/sparse_pool_ops.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch copying mmcv/ops/csrc/pytorch/spconv_ops.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch copying mmcv/ops/csrc/pytorch/spconv_utils.h -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch copying mmcv/ops/csrc/pytorch/sync_bn.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch copying mmcv/ops/csrc/pytorch/three_interpolate.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch copying mmcv/ops/csrc/pytorch/three_nn.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch copying mmcv/ops/csrc/pytorch/tin_shift.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch copying mmcv/ops/csrc/pytorch/upfirdn2d.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch copying mmcv/ops/csrc/pytorch/voxelization.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch creating build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch/cpu copying mmcv/ops/csrc/pytorch/cpu/active_rotated_filter.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch/cpu copying mmcv/ops/csrc/pytorch/cpu/box_iou_rotated.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch/cpu copying mmcv/ops/csrc/pytorch/cpu/deform_conv.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch/cpu copying mmcv/ops/csrc/pytorch/cpu/modulated_deform_conv.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch/cpu copying mmcv/ops/csrc/pytorch/cpu/nms.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch/cpu copying mmcv/ops/csrc/pytorch/cpu/nms_rotated.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch/cpu copying mmcv/ops/csrc/pytorch/cpu/pixel_group.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch/cpu copying mmcv/ops/csrc/pytorch/cpu/points_in_boxes.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch/cpu copying mmcv/ops/csrc/pytorch/cpu/psamask.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch/cpu copying mmcv/ops/csrc/pytorch/cpu/roi_align.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch/cpu copying mmcv/ops/csrc/pytorch/cpu/roi_align_rotated.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch/cpu copying mmcv/ops/csrc/pytorch/cpu/sparse_indice.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch/cpu copying mmcv/ops/csrc/pytorch/cpu/sparse_maxpool.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch/cpu copying mmcv/ops/csrc/pytorch/cpu/sparse_reordering.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch/cpu copying mmcv/ops/csrc/pytorch/cpu/voxelization.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch/cpu creating build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch/cuda copying mmcv/ops/csrc/pytorch/cuda/active_rotated_filter_cuda.cu -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch/cuda copying mmcv/ops/csrc/pytorch/cuda/assign_score_withk_cuda.cu -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch/cuda copying mmcv/ops/csrc/pytorch/cuda/ball_query_cuda.cu -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch/cuda copying mmcv/ops/csrc/pytorch/cuda/bbox_overlaps_cuda.cu -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch/cuda copying mmcv/ops/csrc/pytorch/cuda/border_align_cuda.cu -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch/cuda copying mmcv/ops/csrc/pytorch/cuda/box_iou_rotated_cuda.cu -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch/cuda copying mmcv/ops/csrc/pytorch/cuda/carafe_cuda.cu -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch/cuda copying mmcv/ops/csrc/pytorch/cuda/carafe_naive_cuda.cu -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch/cuda copying mmcv/ops/csrc/pytorch/cuda/convex_iou.cu -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch/cuda copying mmcv/ops/csrc/pytorch/cuda/correlation_cuda.cu -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch/cuda copying mmcv/ops/csrc/pytorch/cuda/cudabind.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch/cuda copying mmcv/ops/csrc/pytorch/cuda/deform_conv_cuda.cu -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch/cuda copying mmcv/ops/csrc/pytorch/cuda/deform_roi_pool_cuda.cu -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch/cuda copying mmcv/ops/csrc/pytorch/cuda/diff_iou_rotated_cuda.cu -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch/cuda copying mmcv/ops/csrc/pytorch/cuda/focal_loss_cuda.cu -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch/cuda copying mmcv/ops/csrc/pytorch/cuda/furthest_point_sample_cuda.cu -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch/cuda copying mmcv/ops/csrc/pytorch/cuda/fused_bias_leakyrelu_cuda.cu -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch/cuda copying mmcv/ops/csrc/pytorch/cuda/fused_spconv_ops_cuda.cu -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch/cuda copying mmcv/ops/csrc/pytorch/cuda/gather_points_cuda.cu -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch/cuda copying mmcv/ops/csrc/pytorch/cuda/group_points_cuda.cu -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch/cuda copying mmcv/ops/csrc/pytorch/cuda/iou3d_cuda.cu -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch/cuda copying mmcv/ops/csrc/pytorch/cuda/knn_cuda.cu -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch/cuda copying mmcv/ops/csrc/pytorch/cuda/masked_conv2d_cuda.cu -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch/cuda copying mmcv/ops/csrc/pytorch/cuda/min_area_polygons.cu -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch/cuda copying mmcv/ops/csrc/pytorch/cuda/modulated_deform_conv_cuda.cu -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch/cuda copying mmcv/ops/csrc/pytorch/cuda/ms_deform_attn_cuda.cu -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch/cuda copying mmcv/ops/csrc/pytorch/cuda/nms_cuda.cu -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch/cuda copying mmcv/ops/csrc/pytorch/cuda/nms_rotated_cuda.cu -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch/cuda copying mmcv/ops/csrc/pytorch/cuda/points_in_boxes_cuda.cu -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch/cuda copying mmcv/ops/csrc/pytorch/cuda/points_in_polygons_cuda.cu -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch/cuda copying mmcv/ops/csrc/pytorch/cuda/psamask_cuda.cu -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch/cuda copying mmcv/ops/csrc/pytorch/cuda/riroi_align_rotated_cuda.cu -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch/cuda copying mmcv/ops/csrc/pytorch/cuda/roi_align_cuda.cu -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch/cuda copying mmcv/ops/csrc/pytorch/cuda/roi_align_rotated_cuda.cu -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch/cuda copying mmcv/ops/csrc/pytorch/cuda/roi_pool_cuda.cu -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch/cuda copying mmcv/ops/csrc/pytorch/cuda/roiaware_pool3d_cuda.cu -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch/cuda copying mmcv/ops/csrc/pytorch/cuda/roipoint_pool3d_cuda.cu -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch/cuda copying mmcv/ops/csrc/pytorch/cuda/rotated_feature_align_cuda.cu -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch/cuda copying mmcv/ops/csrc/pytorch/cuda/scatter_points_cuda.cu -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch/cuda copying mmcv/ops/csrc/pytorch/cuda/sparse_indice.cu -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch/cuda copying mmcv/ops/csrc/pytorch/cuda/sparse_maxpool.cu -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch/cuda copying mmcv/ops/csrc/pytorch/cuda/sparse_pool_ops_cuda.cu -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch/cuda copying mmcv/ops/csrc/pytorch/cuda/sparse_reordering.cu -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch/cuda copying mmcv/ops/csrc/pytorch/cuda/spconv_ops_cuda.cu -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch/cuda copying mmcv/ops/csrc/pytorch/cuda/sync_bn_cuda.cu -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch/cuda copying mmcv/ops/csrc/pytorch/cuda/three_interpolate_cuda.cu -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch/cuda copying mmcv/ops/csrc/pytorch/cuda/three_nn_cuda.cu -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch/cuda copying mmcv/ops/csrc/pytorch/cuda/tin_shift_cuda.cu -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch/cuda copying mmcv/ops/csrc/pytorch/cuda/upfirdn2d_kernel.cu -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch/cuda copying mmcv/ops/csrc/pytorch/cuda/voxelization_cuda.cu -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch/cuda creating build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch/mlu copying mmcv/ops/csrc/pytorch/mlu/bbox_overlaps_mlu.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch/mlu copying mmcv/ops/csrc/pytorch/mlu/focal_loss_sigmoid_mlu.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch/mlu copying mmcv/ops/csrc/pytorch/mlu/nms_mlu.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch/mlu copying mmcv/ops/csrc/pytorch/mlu/roi_align_mlu.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch/mlu copying mmcv/ops/csrc/pytorch/mlu/tin_shift_mlu.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/pytorch/mlu creating build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/tensorrt copying mmcv/ops/csrc/tensorrt/trt_corner_pool.hpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/tensorrt copying mmcv/ops/csrc/tensorrt/trt_cuda_helper.cuh -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/tensorrt copying mmcv/ops/csrc/tensorrt/trt_cummaxmin.hpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/tensorrt copying mmcv/ops/csrc/tensorrt/trt_deform_conv.hpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/tensorrt copying mmcv/ops/csrc/tensorrt/trt_grid_sampler.hpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/tensorrt copying mmcv/ops/csrc/tensorrt/trt_instance_norm.hpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/tensorrt copying mmcv/ops/csrc/tensorrt/trt_modulated_deform_conv.hpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/tensorrt copying mmcv/ops/csrc/tensorrt/trt_nms.hpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/tensorrt copying mmcv/ops/csrc/tensorrt/trt_plugin.hpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/tensorrt copying mmcv/ops/csrc/tensorrt/trt_plugin_helper.hpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/tensorrt copying mmcv/ops/csrc/tensorrt/trt_roi_align.hpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/tensorrt copying mmcv/ops/csrc/tensorrt/trt_scatternd.hpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/tensorrt copying mmcv/ops/csrc/tensorrt/trt_serialize.hpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/tensorrt creating build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/tensorrt/plugins copying mmcv/ops/csrc/tensorrt/plugins/trt_corner_pool.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/tensorrt/plugins copying mmcv/ops/csrc/tensorrt/plugins/trt_corner_pool_kernel.cu -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/tensorrt/plugins copying mmcv/ops/csrc/tensorrt/plugins/trt_cuda_helper.cu -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/tensorrt/plugins copying mmcv/ops/csrc/tensorrt/plugins/trt_cummaxmin.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/tensorrt/plugins copying mmcv/ops/csrc/tensorrt/plugins/trt_cummaxmin_kernel.cu -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/tensorrt/plugins copying mmcv/ops/csrc/tensorrt/plugins/trt_deform_conv.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/tensorrt/plugins copying mmcv/ops/csrc/tensorrt/plugins/trt_deform_conv_kernel.cu -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/tensorrt/plugins copying mmcv/ops/csrc/tensorrt/plugins/trt_grid_sampler.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/tensorrt/plugins copying mmcv/ops/csrc/tensorrt/plugins/trt_grid_sampler_kernel.cu -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/tensorrt/plugins copying mmcv/ops/csrc/tensorrt/plugins/trt_instance_norm.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/tensorrt/plugins copying mmcv/ops/csrc/tensorrt/plugins/trt_modulated_deform_conv.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/tensorrt/plugins copying mmcv/ops/csrc/tensorrt/plugins/trt_modulated_deform_conv_kernel.cu -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/tensorrt/plugins copying mmcv/ops/csrc/tensorrt/plugins/trt_nms.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/tensorrt/plugins copying mmcv/ops/csrc/tensorrt/plugins/trt_nms_kernel.cu -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/tensorrt/plugins copying mmcv/ops/csrc/tensorrt/plugins/trt_plugin.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/tensorrt/plugins copying mmcv/ops/csrc/tensorrt/plugins/trt_roi_align.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/tensorrt/plugins copying mmcv/ops/csrc/tensorrt/plugins/trt_roi_align_kernel.cu -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/tensorrt/plugins copying mmcv/ops/csrc/tensorrt/plugins/trt_scatternd.cpp -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/tensorrt/plugins copying mmcv/ops/csrc/tensorrt/plugins/trt_scatternd_kernel.cu -> build/lib.linux-x86_64-cpython-310/mmcv/ops/csrc/tensorrt/plugins running build_ext Traceback (most recent call last): File "<string>", line 2, in <module> File "<pip-setuptools-caller>", line 35, in <module> File "/tmp/pip-install-llwa_afu/mmcv-full_ee0517bc5c5749f89f22f446bfc7022a/setup.py", line 393, in <module> setup( File "/home/tj/miniconda3/envs/hamer/lib/python3.10/site-packages/setuptools/__init__.py", line 117, in setup return distutils.core.setup(**attrs) File "/home/tj/miniconda3/envs/hamer/lib/python3.10/site-packages/setuptools/_distutils/core.py", line 186, in setup return run_commands(dist) File "/home/tj/miniconda3/envs/hamer/lib/python3.10/site-packages/setuptools/_distutils/core.py", line 202, in run_commands dist.run_commands() File "/home/tj/miniconda3/envs/hamer/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 1002, in run_commands self.run_command(cmd) File "/home/tj/miniconda3/envs/hamer/lib/python3.10/site-packages/setuptools/dist.py", line 1104, in run_command super().run_command(command) File "/home/tj/miniconda3/envs/hamer/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 1021, in run_command cmd_obj.run() File "/home/tj/miniconda3/envs/hamer/lib/python3.10/site-packages/setuptools/command/bdist_wheel.py", line 370, in run self.run_command("build") File "/home/tj/miniconda3/envs/hamer/lib/python3.10/site-packages/setuptools/_distutils/cmd.py", line 357, in run_command self.distribution.run_command(command) File "/home/tj/miniconda3/envs/hamer/lib/python3.10/site-packages/setuptools/dist.py", line 1104, in run_command super().run_command(command) File "/home/tj/miniconda3/envs/hamer/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 1021, in run_command cmd_obj.run() File "/home/tj/miniconda3/envs/hamer/lib/python3.10/site-packages/setuptools/_distutils/command/build.py", line 135, in run self.run_command(cmd_name) File "/home/tj/miniconda3/envs/hamer/lib/python3.10/site-packages/setuptools/_distutils/cmd.py", line 357, in run_command self.distribution.run_command(command) File "/home/tj/miniconda3/envs/hamer/lib/python3.10/site-packages/setuptools/dist.py", line 1104, in run_command super().run_command(command) File "/home/tj/miniconda3/envs/hamer/lib/python3.10/site-packages/setuptools/_distutils/dist.py", line 1021, in run_command cmd_obj.run() File "/home/tj/miniconda3/envs/hamer/lib/python3.10/site-packages/setuptools/command/build_ext.py", line 99, in run _build_ext.run(self) File "/home/tj/miniconda3/envs/hamer/lib/python3.10/site-packages/setuptools/_distutils/command/build_ext.py", line 368, in run self.build_extensions() File "/home/tj/miniconda3/envs/hamer/lib/python3.10/site-packages/torch/utils/cpp_extension.py", line 650, in build_extensions _check_cuda_version(compiler_name, compiler_version) File "/home/tj/miniconda3/envs/hamer/lib/python3.10/site-packages/torch/utils/cpp_extension.py", line 506, in _check_cuda_version raise RuntimeError(CUDA_MISMATCH_MESSAGE, cuda_str_version, torch.version.cuda) RuntimeError: ('The detected CUDA version (%s) mismatches the version that was used to compilePyTorch (%s). Please make sure to use the same CUDA versions.', '11.7', '12.8') [end of output] note: This error originates from a subprocess, and is likely not a problem with pip. ERROR: Failed building wheel for mmcv-full Running setup.py clean for mmcv-full Failed to build mmcv-full error: failed-wheel-build-for-install × Failed to build installable wheels for some pyproject.toml based projects ╰─> mmcv-full
最新发布
10-06
<think>根据用户描述,在运行`camera_demo_light.py`脚本时遇到mmcv-full库构建失败的问题,具体错误是CUDA版本(11.7)与编译PyTorch时使用的CUDA版本(12.8)不匹配。这是一个常见的环境配置问题,我们需要确保CUDA、PyTorch和mmcv-full的版本兼容。 ### 问题分析 1. **版本不匹配**:PyTorch可能是使用CUDA 12.1编译的,而当前系统中安装的CUDA版本是11.7。mmcv-full在安装时会根据系统中CUDA的版本和PyTorch的版本来编译,如果版本不一致,就会导致编译失败。 2. **解决方案**:需要确保PyTorch、CUDA和mmcv-full三者的版本兼容。 ### 解决步骤 #### 步骤1:确认当前环境中的CUDA版本和PyTorch编译使用的CUDA版本 - 在终端中运行以下命令检查CUDA版本: ```bash nvcc --version ``` 或者 ```bash cat /usr/local/cuda/version.txt ``` - 在Python中检查PyTorch使用的CUDA版本: ```python import torch print(torch.__version__) print(torch.version.cuda) ``` #### 步骤2:调整环境以统一版本 有两种解决方案: ##### 方案A:升级系统CUDA到12.1(推荐但操作复杂) 1. 卸载当前CUDA 11.7,安装CUDA 12.1。 2. 重新安装与CUDA 12.1匹配的PyTorch版本。 3. 安装与PyTorch和CUDA 12.1兼容的mmcv-full。 ##### 方案B:安装与CUDA 11.7匹配的PyTorch版本(更简单) 1. 卸载当前PyTorch(使用CUDA 12.1编译的版本)。 2. 安装使用CUDA 11.7编译的PyTorch版本。 3. 安装与CUDA 11.7和PyTorch版本匹配的mmcv-full。 由于升级系统CUDA可能影响其他程序,推荐方案B。 #### 步骤3:具体操作(方案B) 1. **卸载当前PyTorch**: ```bash pip uninstall torch torchvision torchaudio ``` 2. **安装CUDA 11.7版本的PyTorch**: 访问[PyTorch官网](https://pytorch.org/get-started/previous-versions/),查找与CUDA 11.7兼容的版本。例如,对于PyTorch 2.0.1,安装命令为: ```bash pip install torch==2.0.1+cu117 torchvision==0.15.2+cu117 torchaudio==2.0.2 --index-url https://download.pytorch.org/whl/cu117 ``` 3. **安装匹配的mmcv-full**: 根据PyTorch和CUDA版本,选择合适的mmcv-full版本。可以查看[mmcv官方文档](https://mmcv.readthedocs.io/en/latest/get_started/installation.html)获取版本匹配信息。 例如,对于PyTorch 2.0.1和CUDA 11.7,可以安装: ```bash pip install mmcv-full==1.7.1 -f https://download.openmmlab.com/mmcv/dist/cu117/torch2.0.1/index.html ``` #### 步骤4:验证安装 运行以下Python代码检查版本: ```python import torch import mmcv print(f"PyTorch版本: {torch.__version__}") print(f"PyTorch使用的CUDA版本: {torch.version.cuda}") print(f"mmcv-full版本: {mmcv.__version__}") ``` 确保输出中PyTorch的CUDA版本为11.7,且mmcv-full版本与安装一致。 ### 注意事项 - 如果使用conda环境,请确保在正确的环境中操作。 - 安装过程中可能会遇到依赖冲突,建议使用干净的虚拟环境。 - 如果安装mmcv-full时仍然遇到问题,可以尝试从源码编译,但过程较为复杂。详情参考[官方编译指南](https://mmcv.readthedocs.io/en/latest/get_started/build.html)。 ### 替代解决方案 如果上述步骤仍然无法解决问题,可以考虑使用预编译的Docker镜像,其中已经配置好兼容的环境。例如,使用OpenMMLab提供的Docker镜像: ```bash docker pull openmmlab/mmdetection:3.0.0 ``` ### 相关问题 1. 如何检查系统中安装的CUDA版本? 2. PyTorch版本与CUDA版本不兼容会出现哪些问题? 3. 卸载CUDA的正确步骤是什么? 通过以上步骤,应该能够解决mmcv-full安装时的版本不匹配问题[^1]。 </think>### 解决mmcv-full构建失败:CUDA版本不匹配问题 #### 问题诊断 CUDA版本与PyTorch编译版本不匹配的根本原因是: $$ \text{系统CUDA版本}(11.7) \neq \text{PyTorch编译时CUDA版本}(12.8) $$ 这种不兼容会导致mmcv-full编译时出现底层库链接错误[^1]。 --- ### 解决方案步骤 #### 步骤1:验证实际环境版本 ```bash # 检查系统CUDA版本 nvcc --version # 检查PyTorch使用的CUDA版本 python -c "import torch; print(f'PyTorch CUDA: {torch.version.cuda}')" # 检查已安装mmcv版本 pip list | grep mmcv ``` #### 步骤2:重新安装匹配的PyTorch ```bash # 卸载当前PyTorch pip uninstall -y torch torchvision torchaudio # 安装CUDA 11.7兼容的PyTorch (2023年10月最新版本) pip install torch==2.0.1+cu117 torchvision==0.15.2+cu117 torchaudio==2.0.2 \ --index-url https://download.pytorch.org/whl/cu117 ``` #### 步骤3:安装兼容的mmcv-full ```bash # 安装匹配CUDA 11.7的mmcv-full pip install mmcv-full==1.7.1 -f https://download.openmmlab.com/mmcv/dist/cu117/torch2.0.0/index.html ``` #### 步骤4:环境验证脚本 创建`verify_env.py`: ```python import torch import mmcv def check_versions(): print(f"[✓] PyTorch版本: {torch.__version__}") print(f"[✓] PyTorch CUDA: {torch.version.cuda}") print(f"[✓] mmcv-full版本: {mmcv.__version__}") # 验证CUDA兼容性 if "cu117" in torch.__version__ and "cu117" in mmcv.__version__: print("[✓] CUDA 11.7环境验证通过") else: print("[×] 版本不匹配!请检查安装") # 测试基本功能 if torch.cuda.is_available(): print(f"[✓] CUDA设备可用: {torch.cuda.get_device_name(0)}") else: print("[×] CUDA不可用!") if __name__ == "__main__": check_versions() ``` #### 步骤5:清理缓存并重试 ```bash # 强制清除构建缓存 rm -rf ~/.cache/pip rm -rf ~/.cache/torch_extensions # 重新运行您的脚本 python camera_demo_light.py ``` --- ### 版本兼容矩阵(关键) | 组件 | 推荐版本 | 验证组合 | |-------------|-------------|------------------| | PyTorch | 2.0.1+cu117 | ✅ 稳定运行 | | torchvision | 0.15.2+cu117| ✅ 兼容性好 | | mmcv-full | 1.7.1 | ✅ 完美兼容cu117 | | CUDA | 11.7 | ✅ 官方支持版本 | > **注意**:避免使用`conda`安装PyTorch,因其CUDA版本管理不如pip直接[^1]。 --- ### 高级解决方案(适用于持续集成) 创建`install_deps.sh`自动化脚本: ```bash #!/bin/bash # 强制设置CUDA版本 export FORCE_CUDA="1" export CUDA_HOME="/usr/local/cuda-11.7" # 安装PyTorch pip install torch==2.0.1+cu117 torchvision==0.15.2+cu117 --extra-index-url https://download.pytorch.org/whl/cu117 # 从源码编译mmcv-full (确保最佳兼容性) git clone https://github.com/open-mmlab/mmcv.git cd mmcv MMCV_WITH_OPS=1 pip install -e . -v ``` --- ### 常见错误处理 1. **`nvcc not found`错误**: ```bash # 确保CUDA路径正确 export PATH="/usr/local/cuda-11.7/bin:$PATH" export LD_LIBRARY_PATH="/usr/local/cuda-11.7/lib64:$LD_LIBRARY_PATH" ``` 2. **`undefined symbol`运行时错误**: ```bash # 完全重装所有依赖 pip uninstall -y mmcv-full rm -rf build/ pip install -v -e . ``` --- ### 性能优化建议 启用JIT编译加速: ```python # 在camera_demo_light.py中添加 torch.set_flush_denormal(True) torch.backends.cudnn.benchmark = True # 启用cuDNN自动优化 ``` > 注:Jetson设备需额外执行 `sudo nvpmodel -m 0` 启用最大性能模式[^1]。
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值