jnuaipr / MINDG

A Drug-Target Interaction Prediction Method Based on an Integrated Learning Algorithm
BSD 2-Clause "Simplified" License
6 stars 1 forks source link

There is a problem using the code #1

Open Sentence99 opened 6 months ago

Sentence99 commented 6 months ago

Hi!When I run the code, I get the following error, I checked that the data is on the cpu, but I'm not sure if it's a problem with HDN.py?

Traceback (most recent call last): File "C:/Users/75172/Desktop/papers/code/MINDG-main/src/MINDG.py", line 375, in run('DAVIS') File "C:/Users/75172/Desktop/papers/code/MINDG-main/src/MINDG.py", line 326, in run pred = mindg_model( v_d, v_p, idx_1,idx_2) File "C:\anaconda3\envs\FP-GNN\lib\site-packages\torch\nn\modules\module.py", line 1194, in _call_impl return forward_call(*input, kwargs) File "C:/Users/75172/Desktop/papers/code/MINDG-main/src/MINDG.py", line 42, in forward pred1 = self.view1_model(v_d, v_p) # sequence File "C:\anaconda3\envs\FP-GNN\lib\site-packages\torch\nn\modules\module.py", line 1194, in _call_impl return forward_call(*input, *kwargs) File "C:\anaconda3\envs\FP-GNN\lib\site-packages\DeepPurpose\DTI.py", line 50, in forward v_P = self.model_protein(v_P) File "C:\anaconda3\envs\FP-GNN\lib\site-packages\torch\nn\modules\module.py", line 1194, in _call_impl return forward_call(input, kwargs) File "C:\anaconda3\envs\FP-GNN\lib\site-packages\DeepPurpose\encoders.py", line 102, in forward v = self._forward_features(v.double()) File "C:\anaconda3\envs\FP-GNN\lib\site-packages\DeepPurpose\encoders.py", line 97, in _forward_features x = F.relu(l(x)) File "C:\anaconda3\envs\FP-GNN\lib\site-packages\torch\nn\modules\module.py", line 1194, in _call_impl return forward_call(*input, **kwargs) File "C:\anaconda3\envs\FP-GNN\lib\site-packages\torch\nn\modules\conv.py", line 313, in forward return self._conv_forward(input, self.weight, self.bias) File "C:\anaconda3\envs\FP-GNN\lib\site-packages\torch\nn\modules\conv.py", line 310, in _conv_forward self.padding, self.dilation, self.groups) RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cpu and cuda:0! (when checking argument for argument weight in method wrapper___slow_conv2d_forward)

chinesebear commented 4 months ago

RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cpu and cuda:0!

Check your codes. The error message means that some tensors are on cpu and the other are on cuda. This is not supported.

hujili007 commented 4 months ago

Hi!When I run the code, I get the following error, I checked that the data is on the cpu, but I'm not sure if it's a problem with HDN.py?

Traceback (most recent call last): File "C:/Users/75172/Desktop/papers/code/MINDG-main/src/MINDG.py", line 375, in run('DAVIS') File "C:/Users/75172/Desktop/papers/code/MINDG-main/src/MINDG.py", line 326, in run pred = mindg_model( v_d, v_p, idx_1,idx_2) File "C:\anaconda3\envs\FP-GNN\lib\site-packages\torch\nn\modules\module.py", line 1194, in _call_impl return forward_call(*input, kwargs) File "C:/Users/75172/Desktop/papers/code/MINDG-main/src/MINDG.py", line 42, in forward pred1 = self.view1_model(v_d, v_p) # sequence File "C:\anaconda3\envs\FP-GNN\lib\site-packages\torch\nn\modules\module.py", line 1194, in _call_impl return forward_call(*input, *kwargs) File "C:\anaconda3\envs\FP-GNN\lib\site-packages\DeepPurpose\DTI.py", line 50, in forward v_P = self.model_protein(v_P) File "C:\anaconda3\envs\FP-GNN\lib\site-packages\torch\nn\modules\module.py", line 1194, in _call_impl return forward_call(input, kwargs) File "C:\anaconda3\envs\FP-GNN\lib\site-packages\DeepPurpose\encoders.py", line 102, in forward v = self._forward_features(v.double()) File "C:\anaconda3\envs\FP-GNN\lib\site-packages\DeepPurpose\encoders.py", line 97, in _forward_features x = F.relu(l(x)) File "C:\anaconda3\envs\FP-GNN\lib\site-packages\torch\nn\modules\module.py", line 1194, in _call_impl return forward_call(*input, **kwargs) File "C:\anaconda3\envs\FP-GNN\lib\site-packages\torch\nn\modules\conv.py", line 313, in forward return self._conv_forward(input, self.weight, self.bias) File "C:\anaconda3\envs\FP-GNN\lib\site-packages\torch\nn\modules\conv.py", line 310, in _conv_forward self.padding, self.dilation, self.groups) RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cpu and cuda:0! (when checking argument for argument weight in method wrapper___slow_conv2d_forward)

I encountered the same issue. Have you resolved it? I added model.to(device) to the model but it still throws an error. RuntimeError: Expected all tensors to be on the same device, but found at least two devices, cpu and cuda:0! (when checking argument for argument weight in method wrapper___slow_conv2d_forward)

chinesebear commented 4 months ago

I advise that you can try you tensor code only on CPU, detailed codes as follow:

// device=torch.device('cpu')
run('DAVIS', phase="train",batch_size=32,epochs=5,learning_rate=5e-4,lr_step_size=10,seed_id=10,device=torch.device('cpu'))