How do I install pynvjpeg in an NVIDIA L4T PyTorch container(l4t-pytorch:r32.5.0-pth1.7-py3)?

My environment is below.
・ Jetson AGX Xavier
・ JetPack4.5.1

https://ngc.nvidia.com/catalog/containers/nvidia:l4t-pytorch

Using the instructions in the link above i installed the container.

The container is started with the following command.

“xhost +
sudo docker run -it --rm --runtime nvidia --privileged --network host -v /home /work: /home /work -v /tmp/.X12-unix:/tmp/.X11-unix- e DISPLAY = $ DISPLAY nvcr.io/nvidia/l4t-pytorch: r32.5.0-pth1.7-py3”

If you install pynvjpeg in Docker, an error will occur.

root@desktop:/# pip3 install pynvjpeg
Collecting pynvjpeg
Downloading pynvjpeg-0.0.13.tar.gz (11 kB)
Requirement already satisfied: numpy>=1.17 in /usr/local/lib/python3.6/dist-packages (from pynvjpeg) (1.19.4)
Building wheels for collected packages: pynvjpeg
Building wheel for pynvjpeg (setup.py) … error
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3 -u -c ‘import io, os, sys, setuptools, tokenize; sys.argv[0] = ‘"’"’/tmp/pip-install-bxmzv9w8/pynvjpeg_786331bd1ece4288b7905c0349e8342d/setup.py’"’"’; file=’"’"’/tmp/pip-install-bxmzv9w8/pynvjpeg_786331bd1ece4288b7905c0349e8342d/setup.py’"’"’;f = getattr(tokenize, ‘"’"‘open’"’"’, open)(file) if os.path.exists(file) else io.StringIO(’"’"‘from setuptools import setup; setup()’"’"’);code = f.read().replace(’"’"’\r\n’"’"’, ‘"’"’\n’"’"’);f.close();exec(compile(code, file, ‘"’"‘exec’"’"’))’ bdist_wheel -d /tmp/pip-wheel-1rjljr9p
cwd: /tmp/pip-install-bxmzv9w8/pynvjpeg_786331bd1ece4288b7905c0349e8342d/
Complete output (15 lines):
running bdist_wheel
running build
running build_ext
building ‘nvjpeg’ extension
creating build
creating build/temp.linux-aarch64-3.6
creating build/temp.linux-aarch64-3.6/src
creating build/temp.linux-aarch64-3.6/src/x86
aarch64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DJPEGCODER_ARCH=x86 -Iinclude -I/usr/local/lib/python3.6/dist-packages/numpy/core/include -I/usr/local/cuda/include -I/usr/include/python3.6m -c nvjpeg-python.cpp -o build/temp.linux-aarch64-3.6/nvjpeg-python.o
aarch64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DJPEGCODER_ARCH=x86 -Iinclude -I/usr/local/lib/python3.6/dist-packages/numpy/core/include -I/usr/local/cuda/include -I/usr/include/python3.6m -c src/x86/JpegCoder.cpp -o build/temp.linux-aarch64-3.6/src/x86/JpegCoder.o
src/x86/JpegCoder.cpp:2:10: fatal error: nvjpeg.h: No such file or directory
#include <nvjpeg.h>
^~~~~~~~~~
compilation terminated.
error: command ‘aarch64-linux-gnu-gcc’ failed with exit status 1

ERROR: Failed building wheel for pynvjpeg
Running setup.py clean for pynvjpeg
Failed to build pynvjpeg
Installing collected packages: pynvjpeg
Running setup.py install for pynvjpeg … error
ERROR: Command errored out with exit status 1:
command: /usr/bin/python3 -u -c ‘import io, os, sys, setuptools, tokenize; sys.argv[0] = ‘"’"’/tmp/pip-install-bxmzv9w8/pynvjpeg_786331bd1ece4288b7905c0349e8342d/setup.py’"’"’; file=’"’"’/tmp/pip-install-bxmzv9w8/pynvjpeg_786331bd1ece4288b7905c0349e8342d/setup.py’"’"’;f = getattr(tokenize, ‘"’"‘open’"’"’, open)(file) if os.path.exists(file) else io.StringIO(’"’"‘from setuptools import setup; setup()’"’"’);code = f.read().replace(’"’"’\r\n’"’"’, ‘"’"’\n’"’"’);f.close();exec(compile(code, file, ‘"’"‘exec’"’"’))’ install --record /tmp/pip-record-euq3nb4d/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.6/pynvjpeg
cwd: /tmp/pip-install-bxmzv9w8/pynvjpeg_786331bd1ece4288b7905c0349e8342d/
Complete output (15 lines):
running install
running build
running build_ext
building ‘nvjpeg’ extension
creating build
creating build/temp.linux-aarch64-3.6
creating build/temp.linux-aarch64-3.6/src
creating build/temp.linux-aarch64-3.6/src/x86
aarch64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DJPEGCODER_ARCH=x86 -Iinclude -I/usr/local/lib/python3.6/dist-packages/numpy/core/include -I/usr/local/cuda/include -I/usr/include/python3.6m -c nvjpeg-python.cpp -o build/temp.linux-aarch64-3.6/nvjpeg-python.o
aarch64-linux-gnu-gcc -pthread -DNDEBUG -g -fwrapv -O2 -Wall -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DJPEGCODER_ARCH=x86 -Iinclude -I/usr/local/lib/python3.6/dist-packages/numpy/core/include -I/usr/local/cuda/include -I/usr/include/python3.6m -c src/x86/JpegCoder.cpp -o build/temp.linux-aarch64-3.6/src/x86/JpegCoder.o
src/x86/JpegCoder.cpp:2:10: fatal error: nvjpeg.h: No such file or directory
#include <nvjpeg.h>
^~~~~~~~~~
compilation terminated.
error: command ‘aarch64-linux-gnu-gcc’ failed with exit status 1
----------------------------------------
ERROR: Command errored out with exit status 1: /usr/bin/python3 -u -c ‘import io, os, sys, setuptools, tokenize; sys.argv[0] = ‘"’"’/tmp/pip-install-bxmzv9w8/pynvjpeg_786331bd1ece4288b7905c0349e8342d/setup.py’"’"’; file=’"’"’/tmp/pip-install-bxmzv9w8/pynvjpeg_786331bd1ece4288b7905c0349e8342d/setup.py’"’"’;f = getattr(tokenize, ‘"’"‘open’"’"’, open)(file) if os.path.exists(file) else io.StringIO(’"’"‘from setuptools import setup; setup()’"’"’);code = f.read().replace(’"’"’\r\n’"’"’, ‘"’"’\n’"’"’);f.close();exec(compile(code, file, ‘"’"‘exec’"’"’))’ install --record /tmp/pip-record-euq3nb4d/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.6/pynvjpeg Check the logs for full command output.

Please tell me how to install.

Hi,

Confirmed that we can reproduce this issue in our device.
When compiling pynvjpeg module within container, the architecture is set to x86 unexpectedly.

aarch64-linux-gnu-gcc ... -DJPEGCODER_ARCH=x86 ...

We are checking this with our internal team.
Will get back to you later.

Currently, you can install it outside the container as a workaround.
The same PyTorch package can be found in this topic.

Thanks.

Hi,

Just check the pynvjpeg source (this is a third-party implementation).
It use the existence of /usr/src/jetson_multimedia_api to distinguish Jetson or x86 environment.

So please mounting the folder when launching the container.
We can install pynvjpeg via following command:

sudo docker run -it --rm --runtime nvidia -v /usr/src/jetson_multimedia_api:/usr/src/jetson_multimedia_api --
# pip3 install pynvjpeg
Collecting pynvjpeg
  Downloading https://files.pythonhosted.org/packages/4a/d3/cdafe2fdebae3a7e219e8db0ddc8c9f67ee72a466dc095f56b12c0280252/pynvjpeg-0.0.13.tar.gz
Requirement already satisfied: numpy>=1.17 in /usr/local/lib/python3.6/dist-packages (from pynvjpeg)
Building wheels for collected packages: pynvjpeg
  Running setup.py bdist_wheel for pynvjpeg ... done
  Stored in directory: /root/.cache/pip/wheels/ab/04/6d/bb197d2c99cf89c88abebab0ca5b6aa4b69e0722d83bade387
Successfully built pynvjpeg
Installing collected packages: pynvjpeg
Successfully installed pynvjpeg-0.0.13

Thanks.

Thank you for your reply.
I was able to install it successfully.
thank you!