Help with fixing python path/ torch plugin issue

Hi,

I have this error in the logs when I start the software.

[Python] You seem to be using Anaconda but your PYTHONPATH does not include the 'DLLs' and 'Lib' directories. This can lead to crashes due to missing modules. We will add these paths to your environment. To prevent this behaviour, either add these paths to your PYTHONPATH or enable "Don't modify sys.path" in the settings. Your sys.path will be: C:/Users/mkattel/AppData/Local/anaconda3/DLLs;C:/Users/mkattel/AppData/Local/anaconda3/Lib
[Base.Framework] Could not load plugin C:/Program Files/ImFusion/ImFusion Suite/Suite/plugins/TorchPlugin.dll: The specified module could not be found. 
[Base.Framework] Available Plugins: ImFusionAS, ImFusionCT, ImFusionDicom, ImFusionDicomGui, ImFusionLiveUS, ImFusionML, ImFusionPython, ImFusionRGB-D, ImFusionROS, ImFusionReg, ImFusionRobotics, ImFusionSeg, ImFusionStream, ImFusionUS, ImFusionVR, ImFusionVision.
Could not import 'imfusion' package in Python. Consequently, 'imfusion.app' could not be set.
The error was ImportError: The imfusion package requires numpy to be installed in the current environment

At:
  C:\Program Files/ImFusion/ImFusion Suite/Suite\imfusion\__init__.py(36): <module>
  <frozen importlib._bootstrap>(488): _call_with_frames_removed
  <frozen importlib._bootstrap_external>(995): exec_module
  <frozen importlib._bootstrap>(950): _load_unlocked
  <frozen importlib._bootstrap>(1333): _find_and_load_unlocked
  <frozen importlib._bootstrap>(1360): _find_and_load

Additionally, when I try to run DISA registration, I get the following error.

[DISAFeaturesAlgorithm] Preset model 'DISA-LC2' cannot be used since neither ONNX or Torch engine is available
[DescriptorsRegistrationAlgorithm] DISA Algorithm failed.
[DescriptorsRegistrationAlgorithm] Error in extracting descriptors
[DescriptorsRegistrationAlgorithm] Error in computing features

Both numpy and torch have been correctly installed at the python path so I don’t understand what else I could do to fix this problem.

Could you please provide any help on how to approach this problem?

Regards,
Manasi Kattel

Based on your logs, I think it is likely that you have a conflict between a torch installation in your Python environment and our own torch that we ship in the installer.
Can you try using a new Python environment that does not have pytorch installed?

Hi, the error stays the same with or without pytorch installation. The only reason I installed pytorch was to check if installing it would solve the issue.

Is there anything else I could do?

So there are multiple things to go off of from the log messages.

DISA by itself is not using Python at all. The issue that causes the DISA algo to fail is the missing TorchPlugin.dll. This is not to be confused with pytorch. TorchPlugin is a plugin of the ImFusionSuite that we ship with our installers.
First of all, could you please verify that the TorchPlugin.dll exists in the location given in the log.
There is a possibility that some torch dlls are loaded ahead of TorchPlugin (maybe from Python) which could cause the loading of TorchPlugin to fail.
Additionally, Anaconda is not well supported in the Suite.

If the TorchPlugin.dll exists, could you please try the following:

  • Open ImFusionSuite and navigate to Settings → Python → Python Environment
  • Unset the environment (temporarily, to avoid any potential interference from pytorch)
  • Restart Suite
  • Try running DISA again

If this works, you can try also the following to re-enable Python in the Suite:

  • Create a new virtual environment using a standard Python interpreter from python.org and python -m venv
  • Make sure pytorch is not installed in the env
  • Point the Suite to the Python executable inside the newly created environment (Settings → Python → Python Environment again)
  • Restart Suite
  • Check that DISA still works

I hope that this solves the issue. Otherwise, it might also be an issue with the dependencies of torch, e.g some cuda libraries not being found by the TorchPlugin.

Cheers,
Ilja

Hi Ilja,

Thank you for your detailed response. Here’s a list of checks I did.

  1. TorchPlugin.dll exists at the path provided by the log.
  2. Unset the python environment (Also made sure the python environment did not have pytorch installed either way)
  3. Tried to run DISA again

Here is the error message I get at the start of the program:

[Base.Framework] Could not load plugin C:/Program Files/ImFusion/ImFusion Suite/Suite/plugins/TorchPlugin.dll: The specified module could not be found. 
[Base.Framework] Available Plugins: ImFusionAS, ImFusionCT, ImFusionDicom, ImFusionDicomGui, ImFusionLiveUS, ImFusionML, ImFusionPython, ImFusionRGB-D, ImFusionROS, ImFusionReg, ImFusionRobotics, ImFusionSeg, ImFusionStream, ImFusionUS, ImFusionVR, ImFusionVision.
Could not import 'imfusion' package in Python. Consequently, 'imfusion.app' could not be set.
The error was ImportError: The imfusion package requires numpy to be installed in the current environment

At:
  C:\Program Files/ImFusion/ImFusion Suite/Suite\imfusion\__init__.py(36): <module>
  <frozen importlib._bootstrap>(488): _call_with_frames_removed
  <frozen importlib._bootstrap_external>(999): exec_module
  <frozen importlib._bootstrap>(950): _load_unlocked
  <frozen importlib._bootstrap>(1333): _find_and_load_unlocked
  <frozen importlib._bootstrap>(1360): _find_and_load

It is strange that even when the TorchPlugin.dll exists, it is unable to load this plugin. Maybe with the error message you can understand better.

If I try to run DISA anyway, the error message is the following:

[DISAFeaturesAlgorithm] Preset model 'DISA-LC2' cannot be used since neither ONNX or Torch engine is available
[DescriptorsRegistrationAlgorithm] DISA Algorithm failed.
[DescriptorsRegistrationAlgorithm] Error in extracting descriptors
[DescriptorsRegistrationAlgorithm] Error in computing features

Could you please let me know what else could I check?

Manasi

Hi Manasi,

I missed that the Suite attempts to automatically detect existing Python interpreters if the Python env setting is empty.
It does not seem likely at this stage that Python is the issue unless you have globally installed packages but just to be extra sure that there is no interference, could you please move ImFusionPython.dll out of the plugins folder (also where TorchPlugin should be).

As I mentioned in passing, there is also the possibility that TorchPlugin cannot find some DLLs it needs, e.g. some CUDA related stuff.
You can investigate this using tools like Dependencies or Dependency Walker.

Cheers,
Ilja

Hi Ilja,

Removing the ImFusionPython.dll does not solve the issue at all. The log has the following message now.

Maybe it is indeed about the TorchPlugin dependencies?

Manasi

Hi @IljaManakov

Here I tried to investigate the dependencies of TorchPlugin using Dependencies; and it shows the following. Would you know how to get those dlls?

Manasi

Hi Manasi,
Could you please take a screenshot/check that those dependencies (torch_cuda.dll, torch_cpu.dll, c10_cuda.dll, c10.dll) are in the “ImFusion/ImFusion Suite/Suite” folder? Also, if open the ImFusionSuite and then go in Settings/License Information, can you see the TorchPlugin among the licenses modules?
Best,
Maria

Hi Maria,

Yes the dependencies are present in ImFusion/ImFusion Suite/Suite. However, I cannot see TorchPlugin in Settings>License Information>Licensed Modules in ImFusionSuite.

How could I solve this issue?

Manasi

Dear Manasi,

Thank you for your reply. As this seems to be more of a licensing issue, please contact us at info@imfusion.com. You will be redirected to me such that we can follow-up on this.

Thank you,
Maria