Jetson.inference with custom network

Hello,

i went through the 2 days to a demo and tried out the following python-code. My question is, is it possible to fit my own keras-network in instead of googlenet and if so, where can i find the code to adapt that?

width = 640
	height = 480
	network = "googlenet"
	camera = "/dev/video0"
	
	# load the recognition network
	net = jetson.inference.imageNet(network, [])

	# create the camera and display
	font = jetson.utils.cudaFont()
	camera = jetson.utils.gstCamera(width, height, camera)
	display = jetson.utils.glDisplay()

	while display.IsOpen():
		# capture the image
		img, width, height = camera.CaptureRGBA()

		#classify the image
		class_idx, confidence = net.Classify(img, width, height)

		#find the object description
		class_desc = net.GetClassDesc(class_idx)

		#overlay the result on the image	
		font.OverlayText(img, width, height, "{:05.2f}% {:s}".format(confidence * 100, class_desc), 5, 5, font.White, font.Gray40)
		
		#render the image
		display.RenderOnce(img, width, height)

		#update the title bar
		display.SetTitle("{:s} | Network {:.0f} FPS".format(net.GetNetworkName(), 1000.0 / net.GetNetworkTime()))

Thank you for your help.

Hi,

You will need to convert the keras model into .uff file first.
Here is a sample for your reference: /usr/src/tensorrt/samples/python/uff_ssd/

After having the uff file, you can follow this page to feed a customized model:
https://github.com/dusty-nv/jetson-inference/blob/master/docs/imagenet-custom.md

Thanks.

I will try it out and give feedback, thank you

In the /usr/src/tensorrt/samples/python/uff_ssd/ sample, I tried to exexcute the requirements.txt but it got stuck at Pycuda installation.

Building wheels for collected packages: pycuda
  Building wheel for pycuda (setup.py) ... error
  ERROR: Command errored out with exit status 1:
   command: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-yz75nu2i/pycuda/setup.py'"'"'; __file__='"'"'/tmp/pip-install-yz75nu2i/pycuda/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' bdist_wheel -d /tmp/pip-wheel-wq06hbq4 --python-tag cp36
       cwd: /tmp/pip-install-yz75nu2i/pycuda/
  Complete output (106 lines):
  ***************************************************************
  *** WARNING: nvcc not in path.
  *** May need to set CUDA_INC_DIR for installation to succeed.
  ***************************************************************
  *************************************************************
  *** I have detected that you have not run configure.py.
  *************************************************************
  *** Additionally, no global config files were found.
  *** I will go ahead with the default configuration.
  *** In all likelihood, this will not work out.
  ***
  *** See README_SETUP.txt for more information.
  ***
  *** If the build does fail, just re-run configure.py with the
  *** correct arguments, and then retry. Good luck!
  *************************************************************
  *** HIT Ctrl-C NOW IF THIS IS NOT WHAT YOU WANT
  *************************************************************
  Continuing in 1 seconds...    
  /usr/lib/python3.6/distutils/dist.py:261: UserWarning: Unknown distribution option: 'test_requires'
    warnings.warn(msg)
  running bdist_wheel
  running build
  running build_py
  creating build
  creating build/lib.linux-aarch64-3.6
  creating build/lib.linux-aarch64-3.6/pycuda
  copying pycuda/debug.py -> build/lib.linux-aarch64-3.6/pycuda
  copying pycuda/elementwise.py -> build/lib.linux-aarch64-3.6/pycuda
  copying pycuda/characterize.py -> build/lib.linux-aarch64-3.6/pycuda
  copying pycuda/curandom.py -> build/lib.linux-aarch64-3.6/pycuda
  copying pycuda/driver.py -> build/lib.linux-aarch64-3.6/pycuda
  copying pycuda/reduction.py -> build/lib.linux-aarch64-3.6/pycuda
  copying pycuda/gpuarray.py -> build/lib.linux-aarch64-3.6/pycuda
  copying pycuda/autoinit.py -> build/lib.linux-aarch64-3.6/pycuda
  copying pycuda/_cluda.py -> build/lib.linux-aarch64-3.6/pycuda
  copying pycuda/scan.py -> build/lib.linux-aarch64-3.6/pycuda
  copying pycuda/tools.py -> build/lib.linux-aarch64-3.6/pycuda
  copying pycuda/_mymako.py -> build/lib.linux-aarch64-3.6/pycuda
  copying pycuda/__init__.py -> build/lib.linux-aarch64-3.6/pycuda
  copying pycuda/cumath.py -> build/lib.linux-aarch64-3.6/pycuda
  copying pycuda/compiler.py -> build/lib.linux-aarch64-3.6/pycuda
  creating build/lib.linux-aarch64-3.6/pycuda/gl
  copying pycuda/gl/autoinit.py -> build/lib.linux-aarch64-3.6/pycuda/gl
  copying pycuda/gl/__init__.py -> build/lib.linux-aarch64-3.6/pycuda/gl
  creating build/lib.linux-aarch64-3.6/pycuda/sparse
  copying pycuda/sparse/coordinate.py -> build/lib.linux-aarch64-3.6/pycuda/sparse
  copying pycuda/sparse/pkt_build.py -> build/lib.linux-aarch64-3.6/pycuda/sparse
  copying pycuda/sparse/cg.py -> build/lib.linux-aarch64-3.6/pycuda/sparse
  copying pycuda/sparse/inner.py -> build/lib.linux-aarch64-3.6/pycuda/sparse
  copying pycuda/sparse/packeted.py -> build/lib.linux-aarch64-3.6/pycuda/sparse
  copying pycuda/sparse/__init__.py -> build/lib.linux-aarch64-3.6/pycuda/sparse
  copying pycuda/sparse/operator.py -> build/lib.linux-aarch64-3.6/pycuda/sparse
  creating build/lib.linux-aarch64-3.6/pycuda/compyte
  copying pycuda/compyte/array.py -> build/lib.linux-aarch64-3.6/pycuda/compyte
  copying pycuda/compyte/dtypes.py -> build/lib.linux-aarch64-3.6/pycuda/compyte
  copying pycuda/compyte/__init__.py -> build/lib.linux-aarch64-3.6/pycuda/compyte
  running egg_info
  writing pycuda.egg-info/PKG-INFO
  writing dependency_links to pycuda.egg-info/dependency_links.txt
  writing requirements to pycuda.egg-info/requires.txt
  writing top-level names to pycuda.egg-info/top_level.txt
  reading manifest file 'pycuda.egg-info/SOURCES.txt'
  reading manifest template 'MANIFEST.in'
  warning: no files found matching 'doc/source/_static/*.css'
  warning: no files found matching 'doc/source/_templates/*.html'
  warning: no files found matching '*.cpp' under directory 'bpl-subset/bpl_subset/boost'
  warning: no files found matching '*.html' under directory 'bpl-subset/bpl_subset/boost'
  warning: no files found matching '*.inl' under directory 'bpl-subset/bpl_subset/boost'
  warning: no files found matching '*.txt' under directory 'bpl-subset/bpl_subset/boost'
  warning: no files found matching '*.h' under directory 'bpl-subset/bpl_subset/libs'
  warning: no files found matching '*.ipp' under directory 'bpl-subset/bpl_subset/libs'
  warning: no files found matching '*.pl' under directory 'bpl-subset/bpl_subset/libs'
  writing manifest file 'pycuda.egg-info/SOURCES.txt'
  creating build/lib.linux-aarch64-3.6/pycuda/cuda
  copying pycuda/cuda/pycuda-complex-impl.hpp -> build/lib.linux-aarch64-3.6/pycuda/cuda
  copying pycuda/cuda/pycuda-complex.hpp -> build/lib.linux-aarch64-3.6/pycuda/cuda
  copying pycuda/cuda/pycuda-helpers.hpp -> build/lib.linux-aarch64-3.6/pycuda/cuda
  copying pycuda/sparse/pkt_build_cython.pyx -> build/lib.linux-aarch64-3.6/pycuda/sparse
  running build_ext
  building '_driver' extension
  creating build/temp.linux-aarch64-3.6
  creating build/temp.linux-aarch64-3.6/src
  creating build/temp.linux-aarch64-3.6/src/cpp
  creating build/temp.linux-aarch64-3.6/src/wrapper
  creating build/temp.linux-aarch64-3.6/bpl-subset
  creating build/temp.linux-aarch64-3.6/bpl-subset/bpl_subset
  creating build/temp.linux-aarch64-3.6/bpl-subset/bpl_subset/libs
  creating build/temp.linux-aarch64-3.6/bpl-subset/bpl_subset/libs/python
  creating build/temp.linux-aarch64-3.6/bpl-subset/bpl_subset/libs/python/src
  creating build/temp.linux-aarch64-3.6/bpl-subset/bpl_subset/libs/python/src/object
  creating build/temp.linux-aarch64-3.6/bpl-subset/bpl_subset/libs/python/src/converter
  creating build/temp.linux-aarch64-3.6/bpl-subset/bpl_subset/libs/system
  creating build/temp.linux-aarch64-3.6/bpl-subset/bpl_subset/libs/system/src
  creating build/temp.linux-aarch64-3.6/bpl-subset/bpl_subset/libs/smart_ptr
  creating build/temp.linux-aarch64-3.6/bpl-subset/bpl_subset/libs/smart_ptr/src
  creating build/temp.linux-aarch64-3.6/bpl-subset/bpl_subset/libs/thread
  creating build/temp.linux-aarch64-3.6/bpl-subset/bpl_subset/libs/thread/src
  creating build/temp.linux-aarch64-3.6/bpl-subset/bpl_subset/libs/thread/src/pthread
  aarch64-linux-gnu-gcc -pthread -fwrapv -Wall -O3 -DNDEBUG -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DBOOST_ALL_NO_LIB=1 -DBOOST_THREAD_BUILD_DLL=1 -DBOOST_MULTI_INDEX_DISABLE_SERIALIZATION=1 -DBOOST_PYTHON_SOURCE=1 -Dboost=pycudaboost -DBOOST_THREAD_DONT_USE_CHRONO=1 -DPYGPU_PACKAGE=pycuda -DPYGPU_PYCUDA=1 -DHAVE_CURAND=1 -Isrc/cpp -Ibpl-subset/bpl_subset -I/usr/local/lib/python3.6/dist-packages/numpy/core/include -I/usr/include/python3.6m -c src/cpp/cuda.cpp -o build/temp.linux-aarch64-3.6/src/cpp/cuda.o
  In file included from src/cpp/cuda.cpp:4:0:
  src/cpp/cuda.hpp:14:10: fatal error: cuda.h: No such file or directory
   #include <cuda.h>
            ^~~~~~~~
  compilation terminated.
  error: command 'aarch64-linux-gnu-gcc' failed with exit status 1
  ----------------------------------------
  ERROR: Failed building wheel for pycuda
  Running setup.py clean for pycuda
Failed to build pycuda
Installing collected packages: pycuda
    Running setup.py install for pycuda ... error
    ERROR: Command errored out with exit status 1:
     command: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-yz75nu2i/pycuda/setup.py'"'"'; __file__='"'"'/tmp/pip-install-yz75nu2i/pycuda/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-ldafdzjk/install-record.txt --single-version-externally-managed --compile
         cwd: /tmp/pip-install-yz75nu2i/pycuda/
    Complete output (106 lines):
    ***************************************************************
    *** WARNING: nvcc not in path.
    *** May need to set CUDA_INC_DIR for installation to succeed.
    ***************************************************************
    *************************************************************
    *** I have detected that you have not run configure.py.
    *************************************************************
    *** Additionally, no global config files were found.
    *** I will go ahead with the default configuration.
    *** In all likelihood, this will not work out.
    ***
    *** See README_SETUP.txt for more information.
    ***
    *** If the build does fail, just re-run configure.py with the
    *** correct arguments, and then retry. Good luck!
    *************************************************************
    *** HIT Ctrl-C NOW IF THIS IS NOT WHAT YOU WANT
    *************************************************************
    Continuing in 1 seconds...    
    /usr/lib/python3.6/distutils/dist.py:261: UserWarning: Unknown distribution option: 'test_requires'
      warnings.warn(msg)
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-aarch64-3.6
    creating build/lib.linux-aarch64-3.6/pycuda
    copying pycuda/debug.py -> build/lib.linux-aarch64-3.6/pycuda
    copying pycuda/elementwise.py -> build/lib.linux-aarch64-3.6/pycuda
    copying pycuda/characterize.py -> build/lib.linux-aarch64-3.6/pycuda
    copying pycuda/curandom.py -> build/lib.linux-aarch64-3.6/pycuda
    copying pycuda/driver.py -> build/lib.linux-aarch64-3.6/pycuda
    copying pycuda/reduction.py -> build/lib.linux-aarch64-3.6/pycuda
    copying pycuda/gpuarray.py -> build/lib.linux-aarch64-3.6/pycuda
    copying pycuda/autoinit.py -> build/lib.linux-aarch64-3.6/pycuda
    copying pycuda/_cluda.py -> build/lib.linux-aarch64-3.6/pycuda
    copying pycuda/scan.py -> build/lib.linux-aarch64-3.6/pycuda
    copying pycuda/tools.py -> build/lib.linux-aarch64-3.6/pycuda
    copying pycuda/_mymako.py -> build/lib.linux-aarch64-3.6/pycuda
    copying pycuda/__init__.py -> build/lib.linux-aarch64-3.6/pycuda
    copying pycuda/cumath.py -> build/lib.linux-aarch64-3.6/pycuda
    copying pycuda/compiler.py -> build/lib.linux-aarch64-3.6/pycuda
    creating build/lib.linux-aarch64-3.6/pycuda/gl
    copying pycuda/gl/autoinit.py -> build/lib.linux-aarch64-3.6/pycuda/gl
    copying pycuda/gl/__init__.py -> build/lib.linux-aarch64-3.6/pycuda/gl
    creating build/lib.linux-aarch64-3.6/pycuda/sparse
    copying pycuda/sparse/coordinate.py -> build/lib.linux-aarch64-3.6/pycuda/sparse
    copying pycuda/sparse/pkt_build.py -> build/lib.linux-aarch64-3.6/pycuda/sparse
    copying pycuda/sparse/cg.py -> build/lib.linux-aarch64-3.6/pycuda/sparse
    copying pycuda/sparse/inner.py -> build/lib.linux-aarch64-3.6/pycuda/sparse
    copying pycuda/sparse/packeted.py -> build/lib.linux-aarch64-3.6/pycuda/sparse
    copying pycuda/sparse/__init__.py -> build/lib.linux-aarch64-3.6/pycuda/sparse
    copying pycuda/sparse/operator.py -> build/lib.linux-aarch64-3.6/pycuda/sparse
    creating build/lib.linux-aarch64-3.6/pycuda/compyte
    copying pycuda/compyte/array.py -> build/lib.linux-aarch64-3.6/pycuda/compyte
    copying pycuda/compyte/dtypes.py -> build/lib.linux-aarch64-3.6/pycuda/compyte
    copying pycuda/compyte/__init__.py -> build/lib.linux-aarch64-3.6/pycuda/compyte
    running egg_info
    writing pycuda.egg-info/PKG-INFO
    writing dependency_links to pycuda.egg-info/dependency_links.txt
    writing requirements to pycuda.egg-info/requires.txt
    writing top-level names to pycuda.egg-info/top_level.txt
    reading manifest file 'pycuda.egg-info/SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    warning: no files found matching 'doc/source/_static/*.css'
    warning: no files found matching 'doc/source/_templates/*.html'
    warning: no files found matching '*.cpp' under directory 'bpl-subset/bpl_subset/boost'
    warning: no files found matching '*.html' under directory 'bpl-subset/bpl_subset/boost'
    warning: no files found matching '*.inl' under directory 'bpl-subset/bpl_subset/boost'
    warning: no files found matching '*.txt' under directory 'bpl-subset/bpl_subset/boost'
    warning: no files found matching '*.h' under directory 'bpl-subset/bpl_subset/libs'
    warning: no files found matching '*.ipp' under directory 'bpl-subset/bpl_subset/libs'
    warning: no files found matching '*.pl' under directory 'bpl-subset/bpl_subset/libs'
    writing manifest file 'pycuda.egg-info/SOURCES.txt'
    creating build/lib.linux-aarch64-3.6/pycuda/cuda
    copying pycuda/cuda/pycuda-complex-impl.hpp -> build/lib.linux-aarch64-3.6/pycuda/cuda
    copying pycuda/cuda/pycuda-complex.hpp -> build/lib.linux-aarch64-3.6/pycuda/cuda
    copying pycuda/cuda/pycuda-helpers.hpp -> build/lib.linux-aarch64-3.6/pycuda/cuda
    copying pycuda/sparse/pkt_build_cython.pyx -> build/lib.linux-aarch64-3.6/pycuda/sparse
    running build_ext
    building '_driver' extension
    creating build/temp.linux-aarch64-3.6
    creating build/temp.linux-aarch64-3.6/src
    creating build/temp.linux-aarch64-3.6/src/cpp
    creating build/temp.linux-aarch64-3.6/src/wrapper
    creating build/temp.linux-aarch64-3.6/bpl-subset
    creating build/temp.linux-aarch64-3.6/bpl-subset/bpl_subset
    creating build/temp.linux-aarch64-3.6/bpl-subset/bpl_subset/libs
    creating build/temp.linux-aarch64-3.6/bpl-subset/bpl_subset/libs/python
    creating build/temp.linux-aarch64-3.6/bpl-subset/bpl_subset/libs/python/src
    creating build/temp.linux-aarch64-3.6/bpl-subset/bpl_subset/libs/python/src/object
    creating build/temp.linux-aarch64-3.6/bpl-subset/bpl_subset/libs/python/src/converter
    creating build/temp.linux-aarch64-3.6/bpl-subset/bpl_subset/libs/system
    creating build/temp.linux-aarch64-3.6/bpl-subset/bpl_subset/libs/system/src
    creating build/temp.linux-aarch64-3.6/bpl-subset/bpl_subset/libs/smart_ptr
    creating build/temp.linux-aarch64-3.6/bpl-subset/bpl_subset/libs/smart_ptr/src
    creating build/temp.linux-aarch64-3.6/bpl-subset/bpl_subset/libs/thread
    creating build/temp.linux-aarch64-3.6/bpl-subset/bpl_subset/libs/thread/src
    creating build/temp.linux-aarch64-3.6/bpl-subset/bpl_subset/libs/thread/src/pthread
    aarch64-linux-gnu-gcc -pthread -fwrapv -Wall -O3 -DNDEBUG -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DBOOST_ALL_NO_LIB=1 -DBOOST_THREAD_BUILD_DLL=1 -DBOOST_MULTI_INDEX_DISABLE_SERIALIZATION=1 -DBOOST_PYTHON_SOURCE=1 -Dboost=pycudaboost -DBOOST_THREAD_DONT_USE_CHRONO=1 -DPYGPU_PACKAGE=pycuda -DPYGPU_PYCUDA=1 -DHAVE_CURAND=1 -Isrc/cpp -Ibpl-subset/bpl_subset -I/usr/local/lib/python3.6/dist-packages/numpy/core/include -I/usr/include/python3.6m -c src/cpp/cuda.cpp -o build/temp.linux-aarch64-3.6/src/cpp/cuda.o
    In file included from src/cpp/cuda.cpp:4:0:
    src/cpp/cuda.hpp:14:10: fatal error: cuda.h: No such file or directory
     #include <cuda.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 sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-yz75nu2i/pycuda/setup.py'"'"'; __file__='"'"'/tmp/pip-install-yz75nu2i/pycuda/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-ldafdzjk/install-record.txt --single-version-externally-managed --compile Check the logs for full command output.

I haven’t figured out the problem yet, what would your opinion be about that issue?

Looking forward hearing from you.

Hi steffen.epp, add these lines to the bottom of your ~/.bashrc file:

export PATH=/usr/local/cuda-10.0/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda-10.0/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}

Then close and restart your terminal instance. PyCUDA should then be able to find your CUDA toolkit when you install PyCUDA again.

I still get an error message. Is it even possible to install pycuda with “sudo pip3 install pycuda”, or do i have to do it according to: https://wiki.tiker.net/PyCuda/Installation/Linux

Running setup.py install for pycuda ... error
    ERROR: Command errored out with exit status 1:
     command: /usr/bin/python3 -u -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-76uga2ts/pycuda/setup.py'"'"'; __file__='"'"'/tmp/pip-install-76uga2ts/pycuda/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-wjaoky4h/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.6/pycuda
         cwd: /tmp/pip-install-76uga2ts/pycuda/
    Complete output (106 lines):
    ***************************************************************
    *** WARNING: nvcc not in path.
    *** May need to set CUDA_INC_DIR for installation to succeed.
    ***************************************************************
    *************************************************************
    *** I have detected that you have not run configure.py.
    *************************************************************
    *** Additionally, no global config files were found.
    *** I will go ahead with the default configuration.
    *** In all likelihood, this will not work out.
    ***
    *** See README_SETUP.txt for more information.
    ***
    *** If the build does fail, just re-run configure.py with the
    *** correct arguments, and then retry. Good luck!
    *************************************************************
    *** HIT Ctrl-C NOW IF THIS IS NOT WHAT YOU WANT
    *************************************************************
    Continuing in 1 seconds...    
    /usr/lib/python3.6/distutils/dist.py:261: UserWarning: Unknown distribution option: 'test_requires'
      warnings.warn(msg)
    running install
    running build
    running build_py
    creating build
    creating build/lib.linux-aarch64-3.6
    creating build/lib.linux-aarch64-3.6/pycuda
    copying pycuda/debug.py -> build/lib.linux-aarch64-3.6/pycuda
    copying pycuda/elementwise.py -> build/lib.linux-aarch64-3.6/pycuda
    copying pycuda/characterize.py -> build/lib.linux-aarch64-3.6/pycuda
    copying pycuda/curandom.py -> build/lib.linux-aarch64-3.6/pycuda
    copying pycuda/driver.py -> build/lib.linux-aarch64-3.6/pycuda
    copying pycuda/reduction.py -> build/lib.linux-aarch64-3.6/pycuda
    copying pycuda/gpuarray.py -> build/lib.linux-aarch64-3.6/pycuda
    copying pycuda/autoinit.py -> build/lib.linux-aarch64-3.6/pycuda
    copying pycuda/_cluda.py -> build/lib.linux-aarch64-3.6/pycuda
    copying pycuda/scan.py -> build/lib.linux-aarch64-3.6/pycuda
    copying pycuda/tools.py -> build/lib.linux-aarch64-3.6/pycuda
    copying pycuda/_mymako.py -> build/lib.linux-aarch64-3.6/pycuda
    copying pycuda/__init__.py -> build/lib.linux-aarch64-3.6/pycuda
    copying pycuda/cumath.py -> build/lib.linux-aarch64-3.6/pycuda
    copying pycuda/compiler.py -> build/lib.linux-aarch64-3.6/pycuda
    creating build/lib.linux-aarch64-3.6/pycuda/gl
    copying pycuda/gl/autoinit.py -> build/lib.linux-aarch64-3.6/pycuda/gl
    copying pycuda/gl/__init__.py -> build/lib.linux-aarch64-3.6/pycuda/gl
    creating build/lib.linux-aarch64-3.6/pycuda/sparse
    copying pycuda/sparse/coordinate.py -> build/lib.linux-aarch64-3.6/pycuda/sparse
    copying pycuda/sparse/pkt_build.py -> build/lib.linux-aarch64-3.6/pycuda/sparse
    copying pycuda/sparse/cg.py -> build/lib.linux-aarch64-3.6/pycuda/sparse
    copying pycuda/sparse/inner.py -> build/lib.linux-aarch64-3.6/pycuda/sparse
    copying pycuda/sparse/packeted.py -> build/lib.linux-aarch64-3.6/pycuda/sparse
    copying pycuda/sparse/__init__.py -> build/lib.linux-aarch64-3.6/pycuda/sparse
    copying pycuda/sparse/operator.py -> build/lib.linux-aarch64-3.6/pycuda/sparse
    creating build/lib.linux-aarch64-3.6/pycuda/compyte
    copying pycuda/compyte/array.py -> build/lib.linux-aarch64-3.6/pycuda/compyte
    copying pycuda/compyte/dtypes.py -> build/lib.linux-aarch64-3.6/pycuda/compyte
    copying pycuda/compyte/__init__.py -> build/lib.linux-aarch64-3.6/pycuda/compyte
    running egg_info
    writing pycuda.egg-info/PKG-INFO
    writing dependency_links to pycuda.egg-info/dependency_links.txt
    writing requirements to pycuda.egg-info/requires.txt
    writing top-level names to pycuda.egg-info/top_level.txt
    reading manifest file 'pycuda.egg-info/SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    warning: no files found matching 'doc/source/_static/*.css'
    warning: no files found matching 'doc/source/_templates/*.html'
    warning: no files found matching '*.cpp' under directory 'bpl-subset/bpl_subset/boost'
    warning: no files found matching '*.html' under directory 'bpl-subset/bpl_subset/boost'
    warning: no files found matching '*.inl' under directory 'bpl-subset/bpl_subset/boost'
    warning: no files found matching '*.txt' under directory 'bpl-subset/bpl_subset/boost'
    warning: no files found matching '*.h' under directory 'bpl-subset/bpl_subset/libs'
    warning: no files found matching '*.ipp' under directory 'bpl-subset/bpl_subset/libs'
    warning: no files found matching '*.pl' under directory 'bpl-subset/bpl_subset/libs'
    writing manifest file 'pycuda.egg-info/SOURCES.txt'
    creating build/lib.linux-aarch64-3.6/pycuda/cuda
    copying pycuda/cuda/pycuda-complex-impl.hpp -> build/lib.linux-aarch64-3.6/pycuda/cuda
    copying pycuda/cuda/pycuda-complex.hpp -> build/lib.linux-aarch64-3.6/pycuda/cuda
    copying pycuda/cuda/pycuda-helpers.hpp -> build/lib.linux-aarch64-3.6/pycuda/cuda
    copying pycuda/sparse/pkt_build_cython.pyx -> build/lib.linux-aarch64-3.6/pycuda/sparse
    running build_ext
    building '_driver' extension
    creating build/temp.linux-aarch64-3.6
    creating build/temp.linux-aarch64-3.6/src
    creating build/temp.linux-aarch64-3.6/src/cpp
    creating build/temp.linux-aarch64-3.6/src/wrapper
    creating build/temp.linux-aarch64-3.6/bpl-subset
    creating build/temp.linux-aarch64-3.6/bpl-subset/bpl_subset
    creating build/temp.linux-aarch64-3.6/bpl-subset/bpl_subset/libs
    creating build/temp.linux-aarch64-3.6/bpl-subset/bpl_subset/libs/python
    creating build/temp.linux-aarch64-3.6/bpl-subset/bpl_subset/libs/python/src
    creating build/temp.linux-aarch64-3.6/bpl-subset/bpl_subset/libs/python/src/object
    creating build/temp.linux-aarch64-3.6/bpl-subset/bpl_subset/libs/python/src/converter
    creating build/temp.linux-aarch64-3.6/bpl-subset/bpl_subset/libs/system
    creating build/temp.linux-aarch64-3.6/bpl-subset/bpl_subset/libs/system/src
    creating build/temp.linux-aarch64-3.6/bpl-subset/bpl_subset/libs/smart_ptr
    creating build/temp.linux-aarch64-3.6/bpl-subset/bpl_subset/libs/smart_ptr/src
    creating build/temp.linux-aarch64-3.6/bpl-subset/bpl_subset/libs/thread
    creating build/temp.linux-aarch64-3.6/bpl-subset/bpl_subset/libs/thread/src
    creating build/temp.linux-aarch64-3.6/bpl-subset/bpl_subset/libs/thread/src/pthread
    aarch64-linux-gnu-gcc -pthread -fwrapv -Wall -O3 -DNDEBUG -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 -fPIC -DBOOST_ALL_NO_LIB=1 -DBOOST_THREAD_BUILD_DLL=1 -DBOOST_MULTI_INDEX_DISABLE_SERIALIZATION=1 -DBOOST_PYTHON_SOURCE=1 -Dboost=pycudaboost -DBOOST_THREAD_DONT_USE_CHRONO=1 -DPYGPU_PACKAGE=pycuda -DPYGPU_PYCUDA=1 -DHAVE_CURAND=1 -Isrc/cpp -Ibpl-subset/bpl_subset -I/usr/local/lib/python3.6/dist-packages/numpy/core/include -I/usr/include/python3.6m -c src/cpp/cuda.cpp -o build/temp.linux-aarch64-3.6/src/cpp/cuda.o
    In file included from src/cpp/cuda.cpp:4:0:
    src/cpp/cuda.hpp:14:10: fatal error: cuda.h: No such file or directory
     #include <cuda.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 sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-76uga2ts/pycuda/setup.py'"'"'; __file__='"'"'/tmp/pip-install-76uga2ts/pycuda/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' install --record /tmp/pip-record-wjaoky4h/install-record.txt --single-version-externally-managed --compile --install-headers /usr/local/include/python3.6/pycuda Check the logs for full command output.

Yes, I normally install pycuda through pip. From the log, it still can’t find NVCC in your path:

Try running the following your terminal or .bashrc before trying to install pycuda:

export PATH=/usr/local/cuda/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}

Note that I changed these paths to reference /usr/local/cuda (instead of /usr/local/cuda-10.0 specifically) in case you have a different JetPack/CUDA version installed.

Hello, sorry for the late response.

I added it to the bashrc and i ran it in the terminal before trying to install it. But it is still not working with the same error message.

Anything else i can do there?

Hi Steffen, what if you try setting CUDA_INC_DIR also?

export CUDA_INC_DIR=/usr/local/cuda/include

yes, if i set cuda_inc_dir it is still not working.
I also tried to run it with the user tag. Didn’t work either.

I also checked the path and the nvcc file is there.

As a temporary solution, if i convert the custom model to an .uff on my linux laptop & then copy it on the nano. It looked to me, that I just need PyCuda for converting my custom model, and not when loading the model in?

Maybe I miss something. Here is my bashrc:

bashrc

case $- in
i) ;;
*) return;;
esac

HISTCONTROL=ignoreboth

shopt -s histappend

HISTSIZE=1000
HISTFILESIZE=2000

shopt -s checkwinsize

[ -x /usr/bin/lesspipe ] && eval “$(SHELL=/bin/sh lesspipe)”

if [ -z "{debian_chroot:-}" ] && [ -r /etc/debian_chroot ]; then debian_chroot=(cat /etc/debian_chroot)
fi

case “$TERM” in
xterm-color|*-256color) color_prompt=yes;;
esac

if [ -n “$force_color_prompt” ]; then
if [ -x /usr/bin/tput ] && tput setaf 1 >&/dev/null; then
# We have color support; assume it’s compliant with Ecma-48
# (ISO/IEC-6429). (Lack of such support is extremely rare, and such
# a case would tend to support setf rather than setaf.)
color_prompt=yes
else
color_prompt=
fi
fi

if [ "color_prompt" = yes ]; then PS1='{debian_chroot:+(debian_chroot)}\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;34m\]\w\[\033[00m\]\$ ' else PS1='{debian_chroot:+($debian_chroot)}\u@\h:\w$ ’
fi
unset color_prompt force_color_prompt

If this is an xterm set the title to user@host:dir

case “TERM" in xterm*|rxvt*) PS1="\[\e]0;{debian_chroot:+($debian_chroot)}\u@\h: \w\a]$PS1”
;;
*)
;;
esac

enable color support of ls and also add handy aliases

if [ -x /usr/bin/dircolors ]; then
test -r ~/.dircolors && eval “(dircolors -b ~/.dircolors)" || eval "(dircolors -b)”
alias ls=‘ls --color=auto’

alias grep='grep --color=auto'
alias fgrep='fgrep --color=auto'
alias egrep='egrep --color=auto'

fi

alias ll=‘ls -alF’
alias la=‘ls -A’
alias l=‘ls -CF’

Add an “alert” alias for long running commands. Use like so:

sleep 10; alert

alias alert=‘notify-send --urgency=low -i “([ ? = 0 ] && echo terminal || echo error)” "(history|tail -n1|sed -e '\''s/^\s*[0-9]\+\s*//;s/[;&|]\s*alert//’’’)"’

Alias definitions.

You may want to put all your additions into a separate file like

~/.bash_aliases, instead of adding them here directly.

See /usr/share/doc/bash-doc/examples in the bash-doc package.

if [ -f ~/.bash_aliases ]; then
. ~/.bash_aliases
fi

enable programmable completion features (you don’t need to enable

this, if it’s already enabled in /etc/bash.bashrc and /etc/profile

sources /etc/bash.bashrc).

if ! shopt -oq posix; then
if [ -f /usr/share/bash-completion/bash_completion ]; then
. /usr/share/bash-completion/bash_completion
elif [ -f /etc/bash_completion ]; then
. /etc/bash_completion
fi
fi
export LLVM_CONFIG="/home/dlinano/emotionAwareHMI/librosa/llvm-7.0.1.src/llvm_build_dir/bin/llvm-config"
alias llvm=’/home/dlinano/emotionAwareHMI/librosa/llvm-7.0.1.src/llvm_build_dir/bin/llvm-lit’

export PATH=/usr/local/cuda-10.0/bin${PATH:+:{PATH}} export LD_LIBRARY_PATH=/usr/local/cuda-10.0/lib64{LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
export CUDA_INC_DIR=/usr/local/cuda/include

Yes, you could convert the model to UFF on PC and copy it to your Jetson. Alternatively these ML containers for Jetson already include pyCUDA installed (these are for JetPack 4.4 DP). You can access the TensorRT samples from within those containers as well.

Also, the imageNet class from jetson-inference isn’t already tested against UFF models, since I had previously used ONNX and caffe models for classification. So you may need to add some calls to the UFF loader and pre-processing for your model (i.e. mean pixel subtraction coefficients and desired tensor format) to imageNet.cpp. You can see existing support for UFF in detectNet.cpp, since that uses the SSD models from UFF format.