plotoptix icon indicating copy to clipboard operation
plotoptix copied to clipboard

Does not work on Ubuntu

Open Han-ga86caq opened this issue 3 years ago • 0 comments

I installed plotoptix following the instructions in documentation, however, when I tried to run the example in the readme:

import numpy as np
from plotoptix import TkOptiX

n = 1000000                                  # 1M points, better not try this with matplotlib
xyz = 3 * (np.random.random((n, 3)) - 0.5)   # random 3D positions
r = 0.02 * np.random.random(n) + 0.002       # random radii

plot = TkOptiX()
plot.set_data("my plot", xyz, r=r)
plot.show()

And I got the following error message:

********************************************************************************
********************************************************************************
.NET ray tracing libraries initialization failed, cannot continue.
********************************************************************************
********************************************************************************
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
~/.local/lib/python3.10/site-packages/plotoptix/_load_lib.py in __init__(self)
    546         try:
--> 547             json_assembly = clr.System.Reflection.Assembly.LoadFile(json_name)
    548             tiff_assembly = clr.System.Reflection.Assembly.LoadFile(tiff_name)

AttributeError: module 'clr' has no attribute 'System'

During handling of the above exception, another exception occurred:

ImportError                               Traceback (most recent call last)
<ipython-input-1-19d747a1c849> in <module>
      1 import numpy as np
----> 2 from plotoptix import TkOptiX
      3 
      4 n = 1000000                                  # 1M points, better not try this with matplotlib
      5 xyz = 3 * (np.random.random((n, 3)) - 0.5)   # random 3D positions

~/.local/lib/python3.10/site-packages/plotoptix/__init__.py in <module>
     22 # import PlotOptiX modules ###############################################
     23 from plotoptix.enums import *
---> 24 from plotoptix.npoptix import NpOptiX
     25 from plotoptix.tkoptix import TkOptiX
     26 

~/.local/lib/python3.10/site-packages/plotoptix/npoptix.py in <module>
     15 from plotoptix.geometry import GeometryMeta
     16 from plotoptix._load_lib import load_optix, PARAM_NONE_CALLBACK, PARAM_INT_CALLBACK
---> 17 from plotoptix.utils import _make_contiguous_vector, _make_contiguous_3d
     18 from plotoptix.enums import *
     19 

~/.local/lib/python3.10/site-packages/plotoptix/utils.py in <module>
     12 from plotoptix.enums import GpuArchitecture, ChannelOrder
     13 
---> 14 _optix = load_optix()
     15 
     16 

~/.local/lib/python3.10/site-packages/plotoptix/_load_lib.py in load_optix()
   1154         optix = _load_optix_win()
   1155     elif PLATFORM == "Linux":
-> 1156         optix = _ClrOptiX()
   1157     else:
   1158         raise NotImplementedError

~/.local/lib/python3.10/site-packages/plotoptix/_load_lib.py in __init__(self)
    552             print(".NET ray tracing libraries initialization failed, cannot continue.")
    553             print(80 * "*"); print(80 * "*")
--> 554             raise ImportError
    555 
    556         clr.AddReference(os.path.splitext(tail)[0])

ImportError: 

My system is Ubuntu 22.04, with Nvidia driver version: 510.73.05 and CUDA version 11.6, the required package mentioned in README.rst.

According to the message, I checked the corresponding file _load_lib.py line 539-554:

        json_name = os.path.join(os.path.dirname(__file__), BIN_PATH, "Newtonsoft.Json.dll")
        tiff_name = os.path.join(os.path.dirname(__file__), BIN_PATH, "BitMiracle.LibTiff.NET.dll")
        rnd_name = os.path.join(os.path.dirname(__file__), BIN_PATH, "RnD.SharpOptiX.dll")

        head, tail = os.path.split(rnd_name)
        sys.path.append(head)

        try:
            json_assembly = clr.System.Reflection.Assembly.LoadFile(json_name)
            tiff_assembly = clr.System.Reflection.Assembly.LoadFile(tiff_name)
            rnd_assembly = clr.System.Reflection.Assembly.LoadFile(rnd_name)
        except:
            print(80 * "*"); print(80 * "*")
            print(".NET ray tracing libraries initialization failed, cannot continue.")
            print(80 * "*"); print(80 * "*")
            raise ImportError

It seems that even in Linux, the python code still tries to load .dll files, which is supposed to work only on windows. From my understanding, the equivalence shall be somthing.so right? Is it a bug of the code or configuration issue of my system that misleads the code going to this branch?

Thanks a lot!

Han-ga86caq avatar May 22 '22 12:05 Han-ga86caq