x-stable-diffusion
x-stable-diffusion copied to clipboard
AttributeError: module 'numpy' has no attribute 'bool'
After got unet.engine, then run "python demo.py", and got the following errors, who know this issue, thanks!
(env_py39) [jch@localhost TensorRT]$ python demo.py
[12/27/2022-06:37:00] [TRT] [W] The getMaxBatchSize() function should not be used with an engine built from a network created with NetworkDefinitionCreationFlag::kEXPLICIT_BATCH flag. This function will always return 1.
/home/jch/anaconda3/envs/env_py39/lib/python3.9/site-packages/tensorrt/init.py:166: FutureWarning: In the future np.bool
will be defined as the corresponding NumPy scalar. (This may have returned Python scalars in past versions.
bool: np.bool,
Traceback (most recent call last):
File "/home/jch/work/x-stable-diffusion/TensorRT/demo.py", line 125, in
Hi @ClementCJ, I think that inputs datatype from TensorRT model may not been supported by TensorRT. Please make sure that inputs are in float32 type. You can print out engine.get_binding_dtype(binding) to see what is data type of the input.
@Toan-Do , The reason was found, because numpy==1.24.0, the version is too high. (env_py39) [jch@localhost TensorRT]$ python Python 3.9.15 (main, Nov 24 2022, 14:31:59) [GCC 11.2.0] :: Anaconda, Inc. on linux Type "help", "copyright", "credits" or "license" for more information.
import numpy as np np.version '1.24.0' np.bool
:1: FutureWarning: In the future np.bool
will be defined as the corresponding NumPy scalar. (This may have returned Python scalars in past versions. Traceback (most recent call last): File "", line 1, in File "/home/jch/anaconda3/envs/env_py39/lib/python3.9/site-packages/numpy/init.py", line 284, in getattr raise AttributeError("module {!r} has no attribute " AttributeError: module 'numpy' has no attribute 'bool'
However, when I downgraded the numpy version to 1.19.0, the python demo.py prompt was executed:
(env_py39) [jch@localhost TensorRT]$ python demo.py
RuntimeError: module compiled against API version 0x10 but this version of numpy is 0xd . Check the section C-API incompatibility at the Troubleshooting ImportError section at https://numpy.org/devdocs/user/troubleshooting-importerror.html#c-api-incompatibility for indications on how to solve this problem .
Traceback (most recent call last):
File "/home/jch/work/x-stable-diffusion/TensorRT/demo.py", line 4, in
So, I upgraded numpy to 1.24.0 again. and modify the file "/home/jch/anaconda3/envs/env_py39/lib/python3.9/site-packages/tensorrt/init.py " line 166. bool: np.bool --> bool: np.bool_
Eventually, the problem is solved.