【已解决】RuntimeError: “nll_loss_forward_reduce_cuda_kernel_2d_index“ not implemented for ‘Float‘

问题描述

        最近在复现Watermark-Robustness-Toolbox的时候出现了一些问题,并通过不懈的努力(不是)把这个给完美的跑起来了,这很“完美”。

        先来简单介绍一下,这是一个攻防项目,

        github链接为:https://github.com/dnn-security/Watermark-Robustness-Toolbox

        论文链接为:https://arxiv.org/abs/2108.04974

        环境是:python==3.8,系统ubuntu20.04,其他按照readme操作就可以。

        遇到的问题包括但不仅限于no module named 'backdoor' ,

        IndexError: tensors used as indices must be long, int, byte or bool tensors

        DeprecationWarning: `np.int` is a deprecated alias for the builtin `int`. To silence this warning, use `int` by itself. Doing this will not modify any behavior and is safe.

        RuntimeError: "nll_loss_forward_reduce_cuda_kernel_2d_index" not implemented for 'Float',

        RuntimeError: Trying to backward through the graph a second time (or directly access saved tensors after they have already been freed). Saved intermediate values of the graph are freed when you call .backward() or autograd.grad(). Specify retain_graph=True if you need to backward through the graph a second time or if you need to access saved tensors after calling backward.

        RuntimeError: Input type (long int) and bias type (float) should be the same

        ValueError: zero-size array to reduction operation minimum which has no identity

        RuntimeError: element 0 of tensors does not require grad and does not have a grad_fn

        RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation: [torch.cuda.FloatTensor [96, 96, 3, 3]] is at version 2; expected version 1 instead. Hint: enable anomaly detection to find the operation that failed to compute its gradient, with torch.autograd.set_detect_anomaly(True).

        ImportError: cannot import name 'OrderedDict' from 'typing' (/home/visionx/anaconda3/envs/waterwater/lib/python3.7/typing.py)

        RuntimeError: one of the variables needed for gradient computation has been modified by an inplace operation"

        ImportError: urllib3 v2.0 only supports OpenSSL 1.1.1+, currently the 'ssl' module is compiled with 'OpenSSL 1.0.2u  20 Dec 2019'. See: https://github.com/urllib3/urllib3/issues/2168

        AttributeError: module 'torch.jit' has no attribute '_script_if_tracing'

        AttributeError: 'version_info' object has no attribute '__version__'

        

        PackagesNotFoundError: The following packages are not available from current channels:

  - python==3.6

Current channels:

  - https://repo.anaconda.com/pkgs/main/linux-64
  - https://repo.anaconda.com/pkgs/main/noarch
  - https://repo.anaconda.com/pkgs/r/linux-64
  - https://repo.anaconda.com/pkgs/r/noarch

解决办法

        1、RuntimeError: "nll_loss_forward_reduce_cuda_kernel_2d_index" not implemented for 'Float'

        只要在loss这行的标签后面加上long()转化数据格式就可以。

        2、 PackagesNotFoundError: The following packages are not available from current channels: 

        将conda-forge添加到搜索路径上,当出现这种报错时,应该首先尝试使用以下命令将conda-forge channel添加到你的channel列表中:

conda config --append channels conda-forge

         它告诉conda在搜索软件包时也要在conda-forge channel上查看。然后你就可以尝试利用如下命令再次安装

conda install 包名

完结撒花

        自己真正想去的地方,上帝也不要告诉 

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值