Install PyCuda on Nano?

I have tried to install pycuda I need for rapid measurement system. However, it just will not install.
keeps telling me it is missing something…

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
Regards,
John

Hi @john1,

You are not able to install pycuda because it seems you are missing the installation of the CUDA library itself.

Did you use the pre-built SD card image and followed this Getting Started with Jetson Nano guide from NVIDIA? https://developer.nvidia.com/embedded/learn/get-started-jetson-nano-devkit

You can also use the Nvidia SDK Manager to install CUDA and its dependencies. After that, you can continue with the pycuda installation.

Regards,
Fabian
www.ridgerun.com

Yes, used the SD image and I have CUDA. I have even run the samples, like OceanFFT great performance.
I have the cuda.h file. I don’t know why the system thinks it is missing. maybe Pycuda has a different .h file? Bit like dlls.
It is in :
use/local/cuda/include/cuda.h
With all the other cuda stuff???

It is just pycuda that cannot find it??
Regards,
John

My expertise is in Python, but need the speed of cuda code to undertake a very fast measurement task.
I want it to measure all the stars in an image set of about 100 frames looking for planets. small short dips in the light.
It could do this continuously for say a couple of hours and scan say 200 stars per image.
All the best
John

Hi @john1, before attempting to install pyCUDA, run this in your terminal:

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

Ok did that and tried the
sudo pip3 install pycuda
Still has cuda.h missing…
Should the includes be in the export??
John

maybe a guess???
export INCLUDE=/usr/local/cuda/include:${INCLUDE}

What do you think?
John

Try export CUDA_ROOT=/usr/local/cuda

If that doesn’t work either, please provide the output of pip3 install pycuda --verbose

OK this is the output…BUT with all the links removed as requested by the site…

The directory '/home/john/.cache/pip/http' or its parent directory is not owned by the current user and the cache has been disabled. Please check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
The directory '/home/john/.cache/pip' or its parent directory is not owned by the current user and caching wheels has been disabled. check the permissions and owner of that directory. If executing pip with sudo, you may want sudo's -H flag.
Collecting pycuda
  1 location(s) to search for versions of pycuda:
  
  No cache entry available
  Starting new HTTPS connection (1): 
 
  Updating cache with response from 
  Caching permanant redirect
  Looking up in the cache
  No cache entry available
  Starting new HTTPS connection (1):
 
  Updating cache with response from
  Caching due to etag
  Analyzing links from page
    Found link 
    Found link 
    Found link 
  Caching due to etag
    100% |████████████████████████████████| 1.6MB 306kB/s 
  Running setup.py (path:/tmp/pip-build-9x4d92yv/pycuda/setup.py) egg_info for package pycuda
    Running command python setup.py egg_info
    ***************************************************************
    *** 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...    
    running egg_info
    creating pip-egg-info/pycuda.egg-info
    writing pip-egg-info/pycuda.egg-info/PKG-INFO
    writing dependency_links to pip-egg-info/pycuda.egg-info/dependency_links.txt
    writing requirements to pip-egg-info/pycuda.egg-info/requires.txt
    writing top-level names to pip-egg-info/pycuda.egg-info/top_level.txt
    writing manifest file 'pip-egg-info/pycuda.egg-info/SOURCES.txt'
    reading manifest file 'pip-egg-info/pycuda.egg-info/SOURCES.txt'
    reading manifest template 'MANIFEST.in'
    /usr/lib/python3.6/distutils/dist.py:261: UserWarning: Unknown distribution option: 'test_requires'
      warnings.warn(msg)
    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 'pip-egg-info/pycuda.egg-info/SOURCES.txt'
  Source in /tmp/pip-build-9x4d92yv/pycuda has version 2019.1.2, which satisfies requirement pycuda from 
Requirement already satisfied: appdirs>=1.4.0 in /home/john/.local/lib/python3.6/site-packages (from pycuda)
Requirement already satisfied: decorator>=3.2.0 in /home/john/.local/lib/python3.6/site-packages (from pycuda)
Requirement already satisfied: mako in /home/john/.local/lib/python3.6/site-packages (from pycuda)
Requirement already satisfied: pytools>=2011.2 in /usr/local/lib/python3.6/dist-packages (from pycuda)
Requirement already satisfied: MarkupSafe>=0.9.2 in /home/john/.local/lib/python3.6/site-packages (from mako->pycuda)
Requirement already satisfied: numpy>=1.6.0 in /home/john/.local/lib/python3.6/site-packages (from pytools>=2011.2->pycuda)
Requirement already satisfied: six>=1.8.0 in /home/john/.local/lib/python3.6/site-packages (from pytools>=2011.2->pycuda)
Installing collected packages: pycuda
  Running setup.py install for pycuda ...     Running command /usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-9x4d92yv/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-zar2nits-record/install-record.txt --single-version-externally-managed --compile
    ***************************************************************
    *** 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/curandom.py -> build/lib.linux-aarch64-3.6/pycuda
    copying pycuda/reduction.py -> build/lib.linux-aarch64-3.6/pycuda
    copying pycuda/autoinit.py -> build/lib.linux-aarch64-3.6/pycuda
    copying pycuda/characterize.py -> build/lib.linux-aarch64-3.6/pycuda
    copying pycuda/_cluda.py -> build/lib.linux-aarch64-3.6/pycuda
    copying pycuda/debug.py -> build/lib.linux-aarch64-3.6/pycuda
    copying pycuda/gpuarray.py -> build/lib.linux-aarch64-3.6/pycuda
    copying pycuda/tools.py -> build/lib.linux-aarch64-3.6/pycuda
    copying pycuda/driver.py -> build/lib.linux-aarch64-3.6/pycuda
    copying pycuda/_mymako.py -> build/lib.linux-aarch64-3.6/pycuda
    copying pycuda/compiler.py -> build/lib.linux-aarch64-3.6/pycuda
    copying pycuda/scan.py -> build/lib.linux-aarch64-3.6/pycuda
    copying pycuda/cumath.py -> build/lib.linux-aarch64-3.6/pycuda
    copying pycuda/elementwise.py -> build/lib.linux-aarch64-3.6/pycuda
    copying pycuda/__init__.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/operator.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/inner.py -> build/lib.linux-aarch64-3.6/pycuda/sparse
    copying pycuda/sparse/coordinate.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/packeted.py -> build/lib.linux-aarch64-3.6/pycuda/sparse
    copying pycuda/sparse/__init__.py -> build/lib.linux-aarch64-3.6/pycuda/sparse
    creating build/lib.linux-aarch64-3.6/pycuda/compyte
    copying pycuda/compyte/dtypes.py -> build/lib.linux-aarch64-3.6/pycuda/compyte
    copying pycuda/compyte/array.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/converter
    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/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/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/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/home/john/.local/lib/python3.6/site-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
Cleaning up...
  Removing source in /tmp/pip-build-9x4d92yv/pycuda
Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-9x4d92yv/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-zar2nits-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-9x4d92yv/pycuda/
Exception information:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/pip/basecommand.py", line 215, in main
    status = self.run(options, args)
  File "/usr/lib/python3/dist-packages/pip/commands/install.py", line 360, in run
    prefix=options.prefix_path,
  File "/usr/lib/python3/dist-packages/pip/req/req_set.py", line 784, in install
    **kwargs
  File "/usr/lib/python3/dist-packages/pip/req/req_install.py", line 878, in install
    spinner=spinner,
  File "/usr/lib/python3/dist-packages/pip/utils/__init__.py", line 725, in call_subprocess
    % (command_desc, proc.returncode, cwd))
pip.exceptions.InstallationError: Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-9x4d92yv/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-zar2nits-record/install-record.txt --single-version-externally-managed --compile" failed with error code 1 in /tmp/pip-build-9x4d92yv/pycuda/

export??
John

Yes, it looks like it needs export CUDA_INC_DIR=/usr/local/cuda/include set. Does that help?

Ok Dusty_nv,
I have been looking more methodically…
I did a printenv
( was in the cuda directory… The env variables were not there!!
So I restarted terminal and looked at where I was… home/john
Then did printenv No variables!!
So I set them all again and checked they were all ok including adding to the PATH :/usr/local/cuda/bin
The, from the home/john directory ran pip3 install pycuda
Did not get the error cuda.h … yes…BUT got another error
osserr cython not installed?? and another cythonize.py error
So then tried: pip install pycuda
It installed successfully. So maybe python3 is not compatible with pycuda??
So two lessons:
1.env variable change depending where you are or su… Not sure I understand why
2.python3 is not necessarily the correct basic software.
So will try a simple cuda code running from home/john using python not python3.
What do you think (for a person who spent his life with computers but knowing nothing about nano)?
best regards,
John

You could use this script to install pycuda on Jetson Nano: https://github.com/jkjung-avt/tensorrt_demos/blob/master/ssd/install_pycuda.sh

You need to pip3 install Cython and then it should work with python3 too.