ZiangYan / amm.pytorch

Implementation of our T-PAMI 2019 paper: Adversarial Margin Maximization Networks
7 stars 3 forks source link

how to fix it Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu! #1

Open aspnetcs opened 3 years ago

aspnetcs commented 3 years ago

python3 generalization.py --scratch --dataset mnist --arch mlp800 --use-trainval --lmbd 0 --lr 0.005

Traceback (most recent call last): File "generalization.py", line 849, in main() File "generalization.py", line 746, in main train(model) File "generalization.py", line 644, in train grad_all[selected] = torch.nn.utils.clip_gradnorm(model.parameters(), args.clip_grad, norm_type=2) RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!

ZiangYan commented 3 years ago

Hi, which pytorch and torchvision version do you use?

aspnetcs commented 3 years ago

Type "help", "copyright", "credits" or "license" for more information.

import torch

torch.version

'1.7.1+cu101'

import torchvision

torchvision.version

'0.8.2+cu101'

--

At 2021-02-27 23:45:50, "yanziang" notifications@github.com wrote:

Hi, which pytorch and torchvision version do you use?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

aspnetcs commented 3 years ago

可以下拉docker docker push aspnetcs88/dlp:amm.pytorch

运行docker nvidia-docker run -it aspnetcs88/dlp:amm.pytorch /bin/bash

进入dock而后, 运行 python3 generalization.py --scratch --dataset mnist --arch mlp800 --use-trainval --lmbd 0 --lr 0.005 便会出现 Traceback (most recent call last): File "generalization.py", line 849, in main() File "generalization.py", line 746, in main train(model) File "generalization.py", line 644, in train grad_all[selected] = torch.nn.utils.clip_gradnorm(model.parameters(), args.clip_grad, norm_type=2) RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cuda:0 and cpu!

--

At 2021-02-27 23:45:50, "yanziang" notifications@github.com wrote:

Hi, which pytorch and torchvision version do you use?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

ZiangYan commented 3 years ago

Hi, this codebase is tested on python 3.5 + pytorch 1.1.0 + torchvision 0.2.2, and I'm not sure it can work without modification on the newest pytorch (1.7.1).

Type "help", "copyright", "credits" or "license" for more information.

import torch >> torch.version '1.7.1+cu101' import torchvision >> torchvision.version '0.8.2+cu101'

-- At 2021-02-27 23:45:50, "yanziang" notifications@github.com wrote: Hi, which pytorch and torchvision version do you use? — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

aspnetcs commented 3 years ago

Policy-Driven Attack: Learning to Query for Hard-label Black-box Adversarial Examples

Is the source code of this article open source?

--

At 2021-02-28 12:55:16, "yanziang" notifications@github.com wrote:

Hi, this codebase is tested on python 3.5 + pytorch 1.1.0 + torchvision 0.2.2, and I'm not sure it can work without modification on the newest pytorch (1.7.1).

Type "help", "copyright", "credits" or "license" for more information.

import torch >> torch.version '1.7.1+cu101' import torchvision >> torchvision.version '0.8.2+cu101' …

-- At 2021-02-27 23:45:50, "yanziang" notifications@github.com wrote: Hi, which pytorch and torchvision version do you use? — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

ZiangYan commented 3 years ago

Not yet.

aspnetcs commented 3 years ago

waiting........

--

在 2021-03-05 23:15:38,"yanziang" notifications@github.com 写道:

Not yet.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

ZiangYan commented 3 years ago

Policy-Driven Attack: Learning to Query for Hard-label Black-box Adversarial Examples Is the source code of this article open source? -- At 2021-02-28 12:55:16, "yanziang" notifications@github.com wrote: Hi, this codebase is tested on python 3.5 + pytorch 1.1.0 + torchvision 0.2.2, and I'm not sure it can work without modification on the newest pytorch (1.7.1). Type "help", "copyright", "credits" or "license" for more information. import torch >> torch.version '1.7.1+cu101' import torchvision >> torchvision.version '0.8.2+cu101' … -- At 2021-02-27 23:45:50, "yanziang" notifications@github.com wrote: Hi, which pytorch and torchvision version do you use? — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe. — You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

Hi, the source code for our ICLR 2021 paper has been released at https://github.com/ZiangYan/pda.pytorch