PySDF error in Modulus 22.03

Hello,

I am trying a bare metal installation of Modulus 22.03. The operating system used is Ubuntu 20.04 LTS.

The Modulus and the PySDF library installations completed without error and “examples/ldc/ldc_2d.py” was successfully executed. However, the following error occurred when executing “examples/aneurysm/aneurysm.py”.

junichi@GLM:~/Modulus/examples/v22.03/examples/aneurysm$ python3 aneurysm.py
Error importing pysdf. Make sure ‘libsdf.so’ is in LD_LIBRARY_PATH and pysdf is installed
Traceback (most recent call last):
File “aneurysm.py”, line 25, in
from modulus.geometry.tessellation.tessellation import Tessellation
File “/home/junichi/.local/lib/python3.8/site-packages/modulus-22.3-py3.8.egg/modulus/geometry/tessellation/tessellation.py”, line 11, in
import pysdf.sdf as pysdf
ImportError: libsdf.so: cannot open shared object file: No such file or directory

The above error was avoided by modifying line 11 in “Modulus/modulus/geometry/tessellation/tessellation.py” as follows.

  • Before modification

import pysdf.sdf as pysdf

  • After modification

import pysdf as pysdf

However, when “aneurysm.py” was run again, the following error occurred

junichi@GLM:~/Modulus/examples/v22.03/examples/aneurysm$ python3 aneurysm.py
training:
max_steps: 1500000
grad_agg_freq: 1
rec_results_freq: 10000
rec_validation_freq: ${training.rec_results_freq}
rec_inference_freq: ${training.rec_results_freq}
rec_monitor_freq: ${training.rec_results_freq}
rec_constraint_freq: 50000
save_network_freq: 1000
print_stats_freq: 100
summary_freq: 1000
amp: false
amp_dtype: float16
ntk:
use_ntk: false
save_name: null
run_freq: 1000
profiler:
profile: false
start_step: 0
end_step: 100
name: nvtx
network_dir: .
initialization_network_dir: ‘’
save_filetypes: vtk
summary_histograms: false
jit: false
device: ‘’
debug: false
run_mode: train
arch:
fully_connected:
target: modulus.architecture.fully_connected.FullyConnectedArch
layer_size: 512
nr_layers: 6
skip_connections: false
adaptive_activations: false
weight_norm: true
loss:
target: modulus.aggregator.Sum
weights: null
optimizer:
params:
compute_gradients: adam_compute_gradients
apply_gradients: adam_apply_gradients
target: torch.optim.Adam
lr: 0.001
betas:
- 0.9
- 0.999
eps: 1.0e-08
weight_decay: 0.0
amsgrad: false
scheduler:
target: custom
name: tf.ExponentialLR
decay_rate: 0.95
decay_steps: 15000
batch_size:
inlet: 1100
outlet: 650
no_slip: 5200
interior: 6000
integral_continuity: 310
custom: ???

Error executing job with overrides: [ ]
Traceback (most recent call last):
File “aneurysm.py”, line 153, in run
interior = PointwiseInteriorConstraint(
File “/home/junichi/.local/lib/python3.8/site-packages/modulus-22.3-py3.8.egg/modulus/continuous/constraints/constraint.py”, line 399, in __init__
invar = geometry.sample_interior(
File “/home/junichi/.local/lib/python3.8/site-packages/modulus-22.3-py3.8.egg/modulus/geometry/tessellation/tessellation.py”, line 375, in sample_interior
sdf_field, sdf_derivative = self.sdf(sampled_points)
File “/home/junichi/.local/lib/python3.8/site-packages/modulus-22.3-py3.8.egg/modulus/geometry/tessellation/tessellation.py”, line 64, in _sdf
sdf_field, sdf_derivative = pysdf.signed_distance_field(
AttributeError: module ‘pysdf’ has no attribute ‘signed_distance_field’

Set the environment variable HYDRA_FULL_ERROR=1 for a complete stack trace.

I would appreciate it if you could advise me how to resolve this error.

Best regards,
Junichi Fukui

I faced the same issue. I used the pysdf from the older version with the older steps. It works fine.

Thank you for your advice! I will try to run the tutorial with the older version of pysdf library.

Hello, unfortunately we decided to pull the pysdf support for the bare metal installation because it became too cumbersome to maintain. This is reflected in the installation instructions. If the tessellated geometry module is required then we suggest using the Docker image. We are pushing now to have pysdf released as a separate library but don’t have any release date for this. In the mean time we are looking into a slower fallback option when pysdf is not installed.

Hi I managed to install pysdf in the bare metal installation using the provided egg file via easy_install. Here are the steps

  1. downgrade setuptools (pip3 install setuptools==42.0.0) since easy_install command is not exposed in the latest setuptools versions. see ref.

  2. install the provided egg file

cd path_to_modulus_source_code/modulus/external/eggs
python3 -m easy_install pysdf-0.1-py3.8-linux-x86_64.egg

  1. you can make sure the installation is successful by checking pip3 list. You can also upgrade setuptools back to the latest version.

  2. add libsdf.so to your LD_LIBRARY_PATH

then you can successfully run aneurysm.py without changing the source code.

1 Like

Hi, I’m now using 22.09 and using bare metal installation. I tried the mtd by zhongyf111.

Step 1 is ok but step 2 is not cos the egg file is not found. I went to take the 22.03 version and run the command.

The lib file is @ /opt/conda/lib/python3.8/site-packages/pysdf-0.1-py3.8-linux-x86_64.egg/pysdf/sdf.cpython-38-x86_64-linux-gnu.so.

I also copied libsdf.so from 22.03 and put it in the same dir and the dir to the LD_LIBRARY_PATH. However, it’s still not working:

root@eb8245cc19b8:/examples_2209/aneurysm# python aneurysm.py
Error importing pysdf. Make sure 'libsdf.so' is in LD_LIBRARY_PATH and pysdf is installed
Traceback (most recent call last):
  File "aneurysm.py", line 20, in <module>
    from modulus.geometry.tessellation import Tessellation
  File "/opt/conda/lib/python3.8/site-packages/modulus-22.9-py3.8.egg/modulus/geometry/tessellation.py", line 11, in <module>
    import pysdf.sdf as pysdf
ImportError: /opt/conda/lib/python3.8/site-packages/pysdf-0.1-py3.8-linux-x86_64.egg/pysdf/sdf.cpython-38-x86_64-linux-gnu.so: undefined symbol: testPrint

Hope someone can help.

1 Like