Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UFuncTypeError: Cannot cast ufunc 'add' output from dtype('O') to dtype('float64') with casting rule 'same_kind' #69

Closed
rojinakashefi opened this issue Nov 18, 2023 · 6 comments

Comments

@rojinakashefi
Copy link

This is my code:
`!pip install paddlepaddle-gpu
!git clone https://github.com/PaddlePaddle/InterpretDL.git
import os
import sys
os.chdir(/content/InterpretDL)
sys.path.insert(0, os.getcwd())
import interpretdl as it
!wget -c https://paddle-imagenet-models-name.bj.bcebos.com/dygraph/ViT_base_patch16_224_pretrained.pdparams -P /content/InterpretDL/tutorials/assets/
from tutorials.assets.vision_transformer import ViT_base_patch16_224
paddle_model = ViT_base_patch16_224()
MODEL_PATH = /content/InterpretDL/tutorials/assets/ViT_base_patch16_224_pretrained.pdparams
paddle_model.state_dict(paddle.load(MODEL_PATH))
img_path = /content/InterpretDL/imgs/catdog.jpg
tam = it.TAMInterpreter(paddle_model)
heatmap = tam.interpret(
img_path,
start_layer=4,
label=None, # cat
visual=True,
save_path=None)'
But i keep getting this error:
UFuncTypeError: Cannot cast ufunc 'add' output from dtype('O') to dtype('float64') with casting rule 'same_kind'
why?

@rojinakashefi
Copy link
Author

the problem is from transition_attention_maps.py predict_fn function where attns[-1].grad is None, however i don't know how to fix it

@holyseven
Copy link
Collaborator

holyseven commented Nov 20, 2023

see if this solves this issue, #52.

let me know if it does not work.

@rojinakashefi
Copy link
Author

I am using google colab environment
trying to install paddle 2.3.2 for python3.10 form this link cpu version. however when i import paddle i get this error: Error: Can not import avx core while this file exists: /usr/local/lib/python3.10/dist-packages/paddle/fluid/core_avx.so

@rojinakashefi
Copy link
Author

版本&环境信息 Version & Environment Information
Paddle version: N/A
Paddle With CUDA: N/A

OS: ubuntu 22.04
GCC version: (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0
Clang version: 14.0.0-1ubuntu1.1
CMake version: version 3.27.7
Libc version: glibc 2.35
Python version: 3.10.12

CUDA version: 11.8.89
Build cuda_11.8.r11.8/compiler.31833905_0
cuDNN version: 8.9.6
Nvidia driver version: N/A

@holyseven
Copy link
Collaborator

try python -m pip install --force-reinstall paddlepaddle==2.3.2 for the paddle installation issue. Or create a new env to install paddlepaddle

@rojinakashefi
Copy link
Author

the thing is paddlepaddle==2.3.2 can't be installed in ubuntu 22.4 and requires ubuntu lower than 20.4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants