Skip to content

🐛[BUG]: RuntimeError: physicsnemo::signed_distance_field() Expected a value of type 'Tensor' for argument 'mesh_vertices' but instead found type 'ndarray'. #278

@Dimitri666

Description

@Dimitri666

Version

PhysicsNeMo: 1.3.0 PhysicsNeMo Sym:2.3.0

On which installation method(s) does this occur?

No response

Describe the issue

I tried to analyze a stl file and the case code, but it meet a bug. I cant understand why i happened.

Minimum reproducible example

from physicsnemo.sym.geometry.tessellation_warp import Tessellation
from physicsnemo.sym.utils.io.vtk import var_to_polyvtk

nr_pts = 10000

geo = Tessellation.from_stl(".../r-1.stl")

s = geo.sample_boundary(nr_points=nr_pts)
var_to_polyvtk(s, 'r-1_boundary')
s = geo.sample_interior(nr_points=nr_pts, compute_sdf_derivatives=False)
var_to_polyvtk(s, 'r-1_interior')

Relevant log output

Traceback (most recent call last):
  File "/mnt/lp-mcu/bsk/rotor_strength/stl_model.py", line 9, in <module>
    s = geo.sample_boundary(nr_points=nr_pts)
  File "/root/conda/envs/bsk/lib/python3.10/site-packages/physicsnemo/sym/geometry/geometry.py", line 489, in sample_boundary
    [
  File "/root/conda/envs/bsk/lib/python3.10/site-packages/physicsnemo/sym/geometry/geometry.py", line 490, in <listcomp>
    curve.approx_area(parameterization, criteria=closed_boundary_criteria)
  File "/root/conda/envs/bsk/lib/python3.10/site-packages/physicsnemo/sym/geometry/curve.py", line 144, in approx_area
    computed_criteria = criteria(s, p)
  File "/root/conda/envs/bsk/lib/python3.10/site-packages/physicsnemo/sym/geometry/geometry.py", line 481, in boundary_criteria
    return self.boundary_criteria(invar, criteria=criteria, params=params)
  File "/root/conda/envs/bsk/lib/python3.10/site-packages/physicsnemo/sym/geometry/geometry.py", line 401, in boundary_criteria
    sdf_normal_plus = self.sdf(
  File "/root/conda/envs/bsk/lib/python3.10/site-packages/physicsnemo/sym/geometry/tessellation_warp.py", line 384, in sdf
    sdf_field, sdf_derivative = signed_distance_field(
  File "/root/conda/envs/bsk/lib/python3.10/site-packages/torch/_library/custom_ops.py", line 676, in __call__
    return self._opoverload(*args, **kwargs)
  File "/root/conda/envs/bsk/lib/python3.10/site-packages/torch/_ops.py", line 841, in __call__
    return self._op(*args, **kwargs)
RuntimeError: physicsnemo::signed_distance_field() Expected a value of type 'Tensor' for argument 'mesh_vertices' but instead found type 'ndarray'.
Position: 0
Value: array([[9.23256819e-01, 6.62935291e-01, 1.48257803e-01],
       [1.00069586e+00, 6.22622958e-01, 2.82779263e-08],
       [9.23256819e-01, 6.62935291e-01, 2.82779263e-08],
       ...,
       [5.45385135e-01, 6.08438976e-01, 2.82779263e-08],
       [6.74102512e-01, 7.41493180e-01, 2.82779263e-08],
       [7.88778284e-01, 6.73883655e-01, 2.82779263e-08]])
Declaration: physicsnemo::signed_distance_field(Tensor mesh_vertices, Tensor mesh_indices, Tensor input_points, float max_dist=100000000., bool use_sign_winding_number=False) -> (Tensor, Tensor)
Cast error details: Unable to cast [[9.23256819e-01 6.62935291e-01 1.48257803e-01]
 [1.00069586e+00 6.22622958e-01 2.82779263e-08]
 [9.23256819e-01 6.62935291e-01 2.82779263e-08]
 ...
 [5.45385135e-01 6.08438976e-01 2.82779263e-08]
 [6.74102512e-01 7.41493180e-01 2.82779263e-08]
 [7.88778284e-01 6.73883655e-01 2.82779263e-08]] to Tensor
[HAMI-core Msg(7063:140306564354560:multiprocess_memory_limit.c:468)]: Calling exit handler 7063

Environment details

operator env: 
Linux version 5.15.0-142-generic (buildd@lcy02-amd64-032) (gcc (Ubuntu 11.4.0-1ubuntu1~22.04) 11.4.0, GNU ld (GNU Binutils for Ubuntu) 2.38) #152-Ubuntu SMP Mon May 19 10:54:31 UTC 2025
conda enviroment:
absl-py                            2.3.1
aiobotocore                        2.26.0
aiohappyeyeballs                   2.6.1
aiohttp                            3.13.2
aioitertools                       0.13.0
aiosignal                          1.4.0
alembic                            1.17.2
annotated-doc                      0.0.4
annotated-types                    0.7.0
antlr4-python3-runtime             4.9.3
anyio                              4.12.0
argon2-cffi                        25.1.0
argon2-cffi-bindings               25.1.0
arrow                              1.4.0
asciitree                          0.3.3
asttokens                          3.0.1
astunparse                         1.6.3
async-lru                          2.0.5
async-timeout                      5.0.1
attrs                              25.4.0
babel                              2.17.0
beautifulsoup4                     4.14.3
bleach                             6.3.0
blinker                            1.9.0
boto3                              1.41.5
botocore                           1.41.5
braceexpand                        0.1.7
bracex                             2.6
Brotli                             1.2.0
cachetools                         6.2.4
catboost                           1.2.8
certifi                            2025.11.12
cffi                               2.0.0
cfgv                               3.5.0
cftime                             1.6.5
chaospy                            4.3.21
charset-normalizer                 3.4.4
click                              8.3.1
cloudpickle                        3.1.2
colorama                           0.4.6
comm                               0.2.3
contourpy                          1.3.2
coverage                           6.5.0
cryptography                       46.0.3
cycler                             0.12.1
Cython                             3.2.3
databricks-sdk                     0.76.0
debugpy                            1.8.19
decorator                          5.2.1
defusedxml                         0.7.1
distlib                            0.4.0
dm-tree                            0.1.9
docker                             7.1.0
einops                             0.8.1
exceptiongroup                     1.3.1
executing                          2.2.1
fastapi                            0.127.0
fasteners                          0.20
fastjsonschema                     2.21.2
filelock                           3.20.0
Flask                              3.1.2
flask-cors                         6.0.2
flexcache                          0.3
flexparser                         0.4
fonttools                          4.61.0
fqdn                               1.5.1
frozenlist                         1.8.0
fsspec                             2025.12.0
gast                               0.6.0
gitdb                              4.0.12
GitPython                          3.1.45
gmpy2                              2.2.1
google-auth                        2.45.0
graphene                           3.4.3
graphql-core                       3.2.7
graphql-relay                      3.2.0
graphviz                           0.21
greenlet                           3.3.0
grpcio                             1.76.0
gunicorn                           23.0.0
h11                                0.16.0
h2                                 4.3.0
h5py                               3.15.1
hf-xet                             1.2.0
hpack                              4.1.0
httpcore                           1.0.9
httpx                              0.28.1
huey                               2.5.5
huggingface_hub                    1.2.3
hydra-core                         1.3.2
hyperframe                         6.1.0
identify                           2.6.15
idna                               3.11
ImageIO                            2.37.2
imageio-ffmpeg                     0.6.0
importlib_metadata                 8.7.1
iniconfig                          2.3.0
interrogate                        1.5.0
ipykernel                          7.1.0
ipython                            8.37.0
isoduration                        20.11.0
itsdangerous                       2.2.0
jaxtyping                          0.3.4
jedi                               0.19.2
Jinja2                             3.1.6
jmespath                           1.0.1
joblib                             1.5.2
json5                              0.12.1
jsonpointer                        3.0.0
jsonschema                         4.25.1
jsonschema-specifications          2025.9.1
jupyter_client                     8.7.0
jupyter_core                       5.9.1
jupyter-events                     0.12.0
jupyter-lsp                        2.3.0
jupyter_server                     2.17.0
jupyter_server_terminals           0.5.3
jupyterlab                         4.5.1
jupyterlab_pygments                0.3.0
jupyterlab_server                  2.28.0
kiwisolver                         1.4.9
lark                               1.3.1
lazy_loader                        0.4
makefun                            1.16.0
Mako                               1.3.10
Markdown                           3.10
MarkupSafe                         3.0.3
matplotlib                         3.10.7
matplotlib-inline                  0.2.1
mistune                            3.1.4
ml_dtypes                          0.5.4
mlflow                             3.8.0
mlflow-skinny                      3.8.0
mlflow-tracing                     3.8.0
moto                               5.1.18
moviepy                            2.2.1
mpmath                             1.3.0
multi-storage-client               0.39.1
multidict                          6.7.0
narwhals                           2.13.0
nbclient                           0.10.4
nbconvert                          7.16.6
nbformat                           5.10.4
nest-asyncio                       1.6.0
netCDF4                            1.7.3
networkx                           3.4.2
ninja                              1.13.0
nodeenv                            1.10.0
notebook                           7.5.1
notebook_shim                      0.2.4
numcodecs                          0.13.1
numpoly                            1.3.4
numpy                              1.26.0
numpy-stl                          3.2.0
nvidia-cublas-cu12                 12.8.4.1
nvidia-cuda-cupti-cu12             12.8.90
nvidia-cuda-nvrtc-cu12             12.8.93
nvidia-cuda-runtime-cu12           12.8.90
nvidia-cudnn-cu12                  9.10.2.21
nvidia-cufft-cu12                  11.3.3.83
nvidia-cufile-cu12                 1.13.1.3
nvidia-curand-cu12                 10.3.9.90
nvidia-cusolver-cu12               11.7.3.90
nvidia-cusparse-cu12               12.5.8.93
nvidia-cusparselt-cu12             0.7.1
nvidia-dali-cuda120                1.52.0
nvidia-nccl-cu12                   2.27.5
nvidia-nvcomp-cu12                 5.0.0.6
nvidia-nvimgcodec-cu12             0.6.1.37
nvidia-nvjitlink-cu12              12.8.93
nvidia-nvjpeg-cu12                 12.4.0.76
nvidia-nvjpeg2k-cu12               0.9.1.47
nvidia-nvshmem-cu12                3.3.20
nvidia-nvtiff-cu12                 0.6.0.78
nvidia-nvtx-cu12                   12.8.90
nvidia-physicsnemo                 1.3.0
nvidia-physicsnemo.sym             2.3.0
nvtx                               0.2.14
omegaconf                          2.3.0
onnx                               1.20.0
opencv-python                      4.12.0.88
opentelemetry-api                  1.39.1
opentelemetry-proto                1.39.1
opentelemetry-sdk                  1.39.1
opentelemetry-semantic-conventions 0.60b1
opt_einsum                         3.4.0
overrides                          7.7.0
packaging                          25.0
pandas                             2.3.3
pandocfilters                      1.5.1
parso                              0.8.5
pexpect                            4.9.0
pillow                             11.3.0
Pint                               0.24.4
pip                                25.3
platformdirs                       4.5.1
plotly                             6.5.0
pluggy                             1.6.0
pooch                              1.8.2
pre_commit                         4.5.1
prettytable                        3.17.0
proglog                            0.1.12
prometheus_client                  0.23.1
prompt_toolkit                     3.0.52
propcache                          0.4.1
protobuf                           6.33.2
psutil                             7.1.3
ptyprocess                         0.7.0
pure_eval                          0.2.3
py                                 1.11.0
py-partiql-parser                  0.6.3
pyarrow                            22.0.0
pyasn1                             0.6.1
pyasn1_modules                     0.4.2
pycparser                          2.22
pydantic                           2.12.5
pydantic_core                      2.41.5
Pygments                           2.19.2
pyparsing                          3.2.5
PySocks                            1.7.1
pyspng                             0.1.4
pytest                             9.0.2
python-dateutil                    2.9.0.post0
python-dotenv                      1.2.1
python-json-logger                 4.0.0
python-utils                       3.9.1
pytorch-ranger                     0.1.1
pytz                               2025.2
pyvista                            0.46.4
PyYAML                             6.0.3
pyzmq                              27.1.0
referencing                        0.37.0
requests                           2.32.5
responses                          0.25.8
rfc3339-validator                  0.1.4
rfc3986-validator                  0.1.1
rfc3987-syntax                     1.1.0
rpds-py                            0.30.0
rsa                                4.9.1
ruamel.yaml                        0.18.17
ruamel.yaml.clib                   0.2.15
ruff                               0.12.5
s3fs                               2025.12.0
s3transfer                         0.15.0
safetensors                        0.7.0
scikit-image                       0.25.2
scikit-learn                       1.7.2
scipy                              1.15.3
scooby                             0.11.0
Send2Trash                         1.8.3
sentry-sdk                         2.48.0
setuptools                         80.9.0
shapely                            2.1.2
shellingham                        1.5.4
six                                1.17.0
smmap                              5.0.2
soupsieve                          2.8.1
SQLAlchemy                         2.0.45
sqlparse                           0.5.5
stack-data                         0.6.3
starlette                          0.50.0
symengine                          0.14.1
sympy                              1.14.0
tabulate                           0.9.0
tensorboard                        2.20.0
tensorboard-data-server            0.7.2
tensorly                           0.9.0
tensorly-torch                     0.5.0
termcolor                          3.2.0
terminado                          0.18.1
threadpoolctl                      3.6.0
tifffile                           2025.5.10
timm                               1.0.22
tinycss2                           1.4.0
toml                               0.10.2
tomli                              2.3.0
torch                              2.9.1
torch-cluster                      1.6.1+pt20cu118
torch-geometric                    2.7.0
torch-harmonics                    0.6.5
torch-optimizer                    0.3.0
torch-scatter                      2.1.1+pt20cu118
torch-sparse                       0.6.17+pt20cu118
torch-spline-conv                  1.2.2+pt20cu118
torchinfo                          1.8.0
torchvision                        0.24.1
tornado                            6.5.4
tqdm                               4.67.1
traitlets                          5.14.3
transforms3d                       0.4.2
treelib                            1.8.0
triton                             3.5.1
typer-slim                         0.20.1
typing                             3.7.4.3
typing_extensions                  4.15.0
typing-inspection                  0.4.2
tzdata                             2025.2
uri-template                       1.3.0
urllib3                            2.5.0
uvicorn                            0.40.0
virtualenv                         20.35.4
vtk                                9.5.2
wadler_lindig                      0.1.7
wandb                              0.23.1
warp-lang                          1.10.1
wcmatch                            10.1
wcwidth                            0.2.14
webcolors                          25.10.0
webdataset                         1.0.2
webencodings                       0.5.1
websocket-client                   1.9.0
Werkzeug                           3.1.4
wheel                              0.45.1
wrapt                              1.17.3
xarray                             2025.6.1
xattr                              1.3.0
xmltodict                          1.0.2
xxhash                             3.6.0
yarl                               1.22.0
zarr                               2.18.3
zipp                               3.23.0

Other/Misc.

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions