dusty-nv / jetson-inference

Hello AI World guide to deploying deep-learning inference networks and deep vision primitives with TensorRT and NVIDIA Jetson.
https://developer.nvidia.com/embedded/twodaystoademo
MIT License
7.75k stars 2.97k forks source link

How to use jetson-inference to conda env? #1771

Closed gradypark86 closed 8 months ago

gradypark86 commented 8 months ago

Hi Dusty. I have an issue about using jetson-inference in conda env, with a jetson orin nano 8GB, Jetpack 5.1.2.

I have installed jetson-inference in system Python env (/usr/lib/python*/dist-packages/), and I can import jetson_inference and import jetson_utils normally.

Now I want to install jetson-inference to a conda env, as you mentioned in this issue #1523, I modified jetson-inference/python/bindings/CMakeLists.txt and jetson-utils/python/bindings/CMakeLists.txt, change PYTHON_BINDING_INSTALL_DIR from /usr/lib/python${PYTHON_VERSION_MAJOR}.${PYTHON_VERSION_MINOR}/dist-packages to /home/username/miniconda3/envs/envname/lib/python3.8/site-packages and then

cmake ../
make -j$(nproc)
sudo make install
sudo ldconfig

But when I import jetson_inference and import jetson_utils in this conda env, it reported an error:

Traceback (most recent call last): File "/home/username/Lab/jetson-inference/test.py", line 1, in import jetson_inference File "/home/username/miniconda3/envs/envname/lib/python3.8/site-packages/jetson_inference/init.py", line 5, in import jetson_utils File "/home/username/miniconda3/envs/envname/lib/python3.8/site-packages/jetson_utils/init.py", line 4, in from jetson_utils_python import * ImportError: /lib/aarch64-linux-gnu/libgstrtspserver-1.0.so.0: undefined symbol: gst_rtsp_watch_send_messages

I can only import jetson with no error. Then I installed jetson-inference to another conda env and import jetson_inference, the error is:

Traceback (most recent call last): File "/home/username/Lab/jetson-inference/test.py", line 1, in import jetson_inference File "/home/username/miniconda3/envs/envname1/lib/python3.8/site-packages/jetson_inference/init.py", line 5, in import jetson_utils File "/home/username/miniconda3/envs/envname1/lib/python3.8/site-packages/jetson_utils/init.py", line 4, in from jetson_utils_python import * ImportError: /lib/aarch64-linux-gnu/libgobject-2.0.so.0: undefined symbol: ffi_type_uint32, version LIBFFI_BASE_7.0

Could you give me a hint about that? Is it because I've already installed it in the system Python environment and it won't install properly in conda virtual environments?

Thanks.

dusty-nv commented 8 months ago

Hi @gradypark86 sorry I'm not sure, I don't use conda - does it have an option to include --system-site-packages like virtualenv does?

gradypark86 commented 8 months ago

Hi Dusty, thank you for your reply and sorry for taking up your time.

Unfortunately, conda does not have --system-site-packages option. But I figured it out and import jetson_inference successfully in conda env.

  1. Modify 2 Cmakelists.txt files as I mentioned above and install. Or just cp jetson Jetson jetson_inference jetson_utils folders and jetson_utils_python.so jetson_inference_python.so from /usr/lib/python3.8/dist-packages to ~/miniconda3/envs/envname/lib/python3.8/site-packages.
  2. export LD_PRELOAD=/usr/lib/aarch64-linux-gnu/libffi.so.7, otherwise it will report an error:

    ImportError: /lib/aarch64-linux-gnu/libgobject-2.0.so.0: undefined symbol: ffi_type_uint32, version LIBFFI_BASE_7.0

  3. Normally import jetson_inference and import jetson_utils in conda env.

The previous issue may have been due to a problematic conda environment.