pycuda installation failure on jetson nano

the second half of the problem might manifest during the “make” in a missing “pyconfig.h” file.
this will (hopefully) resolve when the matching python3-dev and libpython3-dev are added. (sorry but i cant reproduce in maximum detail what else might be needed - i am just telling you that i tried out a little bit more upfront this follow up step…)

Hi, alexander.stohr

It looks like this issue is already fixed. Is it correct?

Are you using JetPack4.2?
Some of the package you mentioned is pre-installed in the JetPack4.2.
The command share in #3 should be enough for v4.2.

Please let us know if there is still some issues.
Thanks.

Hi

Thanks alexander.stohr for your suggestion.
I tried adding the PATH (export PATH=$PATH:/usr/local/cuda-10.1/bin) but it did not help.

I am not able to use JetPack4.2 as it has a known issue in the latest release notes regarding limiting the size of SDCard to only 16GB even if I am using 64GB SDcard. I can find the link for that and post it here.
I indeed once tried Jetpack4.2 and only 16GB on SDcard was used and the rest was unused and unallocated and I could add it to any parition due to limited number of primary partitions.

So I instead tried to add the include path for cuda into CPATH:

export CPATH=$CPATH:/usr/local/cuda-10.0/include

That helped in building but then it fails finding curand library:

In file included from /usr/include/c++/7/memory:80:0,
                     from bpl-subset/bpl_subset/boost/config/no_tr1/memory.hpp:21,
                     from bpl-subset/bpl_subset/boost/smart_ptr/shared_ptr.hpp:27,
                     from bpl-subset/bpl_subset/boost/shared_ptr.hpp:17,
                     from src/cpp/cuda.hpp:30,
                     from src/wrapper/wrap_curand.cpp:1:
    /usr/include/c++/7/bits/unique_ptr.h:51:28: note: declared here
       template<typename> class auto_ptr;
                                ^~~~~~~~
    In file included from src/wrapper/wrap_curand.cpp:1:0:
    src/cpp/cuda.hpp: In function ‘Py_ssize_t pycuda::mem_alloc_pitch(std::auto_ptr<pycuda::device_allocation>&, unsigned int, unsigned int, unsigned int)’:
    src/cpp/cuda.hpp:1574:15: warning: ‘template<class> class std::auto_ptr’ is deprecated [-Wdeprecated-declarations]
         da = std::auto_ptr<device_allocation>(new device_allocation(devptr));
                   ^~~~~~~~
    In file included from /usr/include/c++/7/memory:80:0,
                     from bpl-subset/bpl_subset/boost/config/no_tr1/memory.hpp:21,
                     from bpl-subset/bpl_subset/boost/smart_ptr/shared_ptr.hpp:27,
                     from bpl-subset/bpl_subset/boost/shared_ptr.hpp:17,
                     from src/cpp/cuda.hpp:30,
                     from src/wrapper/wrap_curand.cpp:1:
    /usr/include/c++/7/bits/unique_ptr.h:51:28: note: declared here
       template<typename> class auto_ptr;
                                ^~~~~~~~
    In file included from src/wrapper/wrap_curand.cpp:2:0:
    src/cpp/curand.hpp: In function ‘void pycuda::curandom::py_curand_get_direction_vectors(curandDirectionVectorSet_t, pycudaboost::python::api::object, int)’:
    src/cpp/curand.hpp:55:26: warning: unused variable ‘len’ [-Wunused-variable]
         PYCUDA_BUFFER_SIZE_T len = buf_wrapper.m_buf.len;
                              ^~~
    In file included from src/wrapper/wrap_curand.cpp:2:0:
    src/cpp/curand.hpp: In function ‘void pycuda::curandom::py_curand_get_scramble_constants32(pycudaboost::python::api::object, int)’:
    src/cpp/curand.hpp:96:26: warning: unused variable ‘len’ [-Wunused-variable]
         PYCUDA_BUFFER_SIZE_T len = buf_wrapper.m_buf.len;
                              ^~~
    src/cpp/curand.hpp: In function ‘void pycuda::curandom::py_curand_get_scramble_constants64(pycudaboost::python::api::object, int)’:
    src/cpp/curand.hpp:118:26: warning: unused variable ‘len’ [-Wunused-variable]
         PYCUDA_BUFFER_SIZE_T len = buf_wrapper.m_buf.len;
                              ^~~
    aarch64-linux-gnu-g++ -pthread -shared -Wl,-Bsymbolic-functions -Wl,-Bsymbolic-functions -Wl,-z,relro -Wl,-Bsymbolic-functions -Wl,-z,relro -g -fstack-protector-strong -Wformat -Werror=format-security -Wdate-time -D_FORTIFY_SOURCE=2 build/temp.linux-aarch64-3.6/src/cpp/cuda.o build/temp.linux-aarch64-3.6/src/cpp/bitlog.o build/temp.linux-aarch64-3.6/src/wrapper/wrap_cudadrv.o build/temp.linux-aarch64-3.6/src/wrapper/mempool.o build/temp.linux-aarch64-3.6/bpl-subset/bpl_subset/libs/python/src/object/class.o build/temp.linux-aarch64-3.6/bpl-subset/bpl_subset/libs/python/src/object/life_support.o build/temp.linux-aarch64-3.6/bpl-subset/bpl_subset/libs/python/src/object/inheritance.o build/temp.linux-aarch64-3.6/bpl-subset/bpl_subset/libs/python/src/object/enum.o build/temp.linux-aarch64-3.6/bpl-subset/bpl_subset/libs/python/src/object/stl_iterator.o build/temp.linux-aarch64-3.6/bpl-subset/bpl_subset/libs/python/src/object/iterator.o build/temp.linux-aarch64-3.6/bpl-subset/bpl_subset/libs/python/src/object/function.o build/temp.linux-aarch64-3.6/bpl-subset/bpl_subset/libs/python/src/object/function_doc_signature.o build/temp.linux-aarch64-3.6/bpl-subset/bpl_subset/libs/python/src/object/pickle_support.o build/temp.linux-aarch64-3.6/bpl-subset/bpl_subset/libs/python/src/converter/type_id.o build/temp.linux-aarch64-3.6/bpl-subset/bpl_subset/libs/python/src/converter/from_python.o build/temp.linux-aarch64-3.6/bpl-subset/bpl_subset/libs/python/src/converter/builtin_converters.o build/temp.linux-aarch64-3.6/bpl-subset/bpl_subset/libs/python/src/converter/arg_to_python_base.o build/temp.linux-aarch64-3.6/bpl-subset/bpl_subset/libs/python/src/converter/registry.o build/temp.linux-aarch64-3.6/bpl-subset/bpl_subset/libs/python/src/list.o build/temp.linux-aarch64-3.6/bpl-subset/bpl_subset/libs/python/src/object_operators.o build/temp.linux-aarch64-3.6/bpl-subset/bpl_subset/libs/python/src/import.o build/temp.linux-aarch64-3.6/bpl-subset/bpl_subset/libs/python/src/wrapper.o build/temp.linux-aarch64-3.6/bpl-subset/bpl_subset/libs/python/src/str.o build/temp.linux-aarch64-3.6/bpl-subset/bpl_subset/libs/python/src/long.o build/temp.linux-aarch64-3.6/bpl-subset/bpl_subset/libs/python/src/errors.o build/temp.linux-aarch64-3.6/bpl-subset/bpl_subset/libs/python/src/numeric.o build/temp.linux-aarch64-3.6/bpl-subset/bpl_subset/libs/python/src/object_protocol.o build/temp.linux-aarch64-3.6/bpl-subset/bpl_subset/libs/python/src/module.o build/temp.linux-aarch64-3.6/bpl-subset/bpl_subset/libs/python/src/tuple.o build/temp.linux-aarch64-3.6/bpl-subset/bpl_subset/libs/python/src/slice.o build/temp.linux-aarch64-3.6/bpl-subset/bpl_subset/libs/python/src/exec.o build/temp.linux-aarch64-3.6/bpl-subset/bpl_subset/libs/python/src/dict.o build/temp.linux-aarch64-3.6/bpl-subset/bpl_subset/libs/system/src/error_code.o build/temp.linux-aarch64-3.6/bpl-subset/bpl_subset/libs/smart_ptr/src/sp_collector.o build/temp.linux-aarch64-3.6/bpl-subset/bpl_subset/libs/smart_ptr/src/sp_debug_hooks.o build/temp.linux-aarch64-3.6/bpl-subset/bpl_subset/libs/thread/src/pthread/thread.o build/temp.linux-aarch64-3.6/bpl-subset/bpl_subset/libs/thread/src/pthread/once.o build/temp.linux-aarch64-3.6/src/wrapper/wrap_curand.o -lcuda -lcurand -o build/lib.linux-aarch64-3.6/pycuda/_driver.cpython-36m-aarch64-linux-gnu.so
    /usr/bin/ld: cannot find -lcurand
    collect2: error: ld returned 1 exit status
    error: command 'aarch64-linux-gnu-g++' failed with exit status 1

    ----------------------------------------
Command "/usr/bin/python3 -u -c "import setuptools, tokenize;__file__='/tmp/pip-build-a2zgr18l/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-n6523yei-record/install-record.txt --single-version-externally-managed --compile --user --prefix=" failed with error code 1 in /tmp/pip-build-a2zgr18l/pycuda/

I tried to add the lib path to LI_LIBRARY_PATH:

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/cuda-10.0/lib64

But it does not help. I do not know how to fix this now?
Please advise.

Thanks

Hello AastaLLL [nvidia],

Thanks for asking.

In my case the target was not that tightly related to a Jetson setup but only to a current CUDA centric setup with a very similar picture. Initially i had no clue, but the provided answers (even if still incomplete) paved me the way for solving it for me. In the hope my steps will help others i posted them. As of now i have no longer a problem (or at least not at a so early level anymore) and thus i feel like i can not contribute any other help than already done. (@ am_merati - Sorry to say that for the moment, no clue where its stuck for you.)

Regards, Alex.

@ am_merati

Looking at your latest report i can see this:
“cannot find -lcurand”

On my local Linux x86_64 installation the needed library for linking the native target is there (retrived this with the “locate” command):

/usr/local/cuda-10.1/targets/x86_64-linux/lib/libcurand.so
/usr/local/cuda-10.1/targets/x86_64-linux/lib/libcurand.so.10
/usr/local/cuda-10.1/targets/x86_64-linux/lib/libcurand.so.10.1.168

So your g++ command line should have a similar path added for the respective target. (I often prefer explicit manual path specs, especially in cases where already some problem exists - rather than tweaking build systems or some environment variables - as not everything is really in effect.)

Seeing your note on LD_LIBRARY_PATH - this one might be for the run time (=execution time, see maybe also “man ldconfig”), but not for link time.
At link time rather LD_FLAGS or LXX_FLAGS or whatever might do a much better job.
If you are cross compiling it might even be something more /fragile/ with a longer name. (Not firm on it out of my memory - please ask google based on this hints, its your friend. :-) )

Regards and have success,
Alex.

Hi

Thanks Alex.
Following your suggestion I used the path in targets path:

export CPATH=$CPATH:/usr/local/cuda-10.0/targets/aarch64-linux/include
export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/cuda-10.0/targets/aarch64-linux/lib

and I managed to successfully install pycuda using

$ pip3 install pycuda --user
Collecting pycuda
  Using cached https://files.pythonhosted.org/packages/4d/29/5a3eb66c2f1a4adc681f6c8131e9ed677af31b0c8a78726d540bd44b3403/pycuda-2019.1.tar.gz
Collecting pytools>=2011.2 (from pycuda)
Collecting pytest>=2 (from pycuda)
  Using cached https://files.pythonhosted.org/packages/4c/35/e13740d90c413fb5ec3c9b5243f79981f7bc759f4a12a959d8dadd57f971/pytest-5.0.0-py3-none-any.whl
Collecting decorator>=3.2.0 (from pycuda)
  Using cached https://files.pythonhosted.org/packages/5f/88/0075e461560a1e750a0dcbf77f1d9de775028c37a19a346a6c565a257399/decorator-4.4.0-py2.py3-none-any.whl
Collecting appdirs>=1.4.0 (from pycuda)
  Using cached https://files.pythonhosted.org/packages/56/eb/810e700ed1349edde4cbdc1b2a21e28cdf115f9faf263f6bbf8447c1abf3/appdirs-1.4.3-py2.py3-none-any.whl
Collecting mako (from pycuda)
Collecting numpy>=1.6.0 (from pytools>=2011.2->pycuda)
Collecting six>=1.8.0 (from pytools>=2011.2->pycuda)
  Using cached https://files.pythonhosted.org/packages/73/fb/00a976f728d0d1fecfe898238ce23f502a721c0ac0ecfedb80e0d88c64e9/six-1.12.0-py2.py3-none-any.whl
Collecting wcwidth (from pytest>=2->pycuda)
  Using cached https://files.pythonhosted.org/packages/7e/9f/526a6947247599b084ee5232e4f9190a38f398d7300d866af3ab571a5bfe/wcwidth-0.1.7-py2.py3-none-any.whl
Collecting attrs>=17.4.0 (from pytest>=2->pycuda)
  Using cached https://files.pythonhosted.org/packages/23/96/d828354fa2dbdf216eaa7b7de0db692f12c234f7ef888cc14980ef40d1d2/attrs-19.1.0-py2.py3-none-any.whl
Collecting pluggy<1.0,>=0.12 (from pytest>=2->pycuda)
  Using cached https://files.pythonhosted.org/packages/06/ee/de89e0582276e3551df3110088bf20844de2b0e7df2748406876cc78e021/pluggy-0.12.0-py2.py3-none-any.whl
Collecting atomicwrites>=1.0 (from pytest>=2->pycuda)
  Using cached https://files.pythonhosted.org/packages/52/90/6155aa926f43f2b2a22b01be7241be3bfd1ceaf7d0b3267213e8127d41f4/atomicwrites-1.3.0-py2.py3-none-any.whl
Collecting importlib-metadata>=0.12 (from pytest>=2->pycuda)
  Using cached https://files.pythonhosted.org/packages/bd/23/dce4879ec58acf3959580bfe769926ed8198727250c5e395e6785c764a02/importlib_metadata-0.18-py2.py3-none-any.whl
Collecting more-itertools>=4.0.0 (from pytest>=2->pycuda)
  Using cached https://files.pythonhosted.org/packages/1f/9e/942df77ddde2fae3f319f2ab8b5d00d5f6b115496e2eb4bad37d1aaefeea/more_itertools-7.1.0-py3-none-any.whl
Collecting packaging (from pytest>=2->pycuda)
  Using cached https://files.pythonhosted.org/packages/91/32/58bc30e646e55eab8b21abf89e353f59c0cc02c417e42929f4a9546e1b1d/packaging-19.0-py2.py3-none-any.whl
Collecting py>=1.5.0 (from pytest>=2->pycuda)
  Using cached https://files.pythonhosted.org/packages/76/bc/394ad449851729244a97857ee14d7cba61ddb268dce3db538ba2f2ba1f0f/py-1.8.0-py2.py3-none-any.whl
Collecting MarkupSafe>=0.9.2 (from mako->pycuda)
Collecting zipp>=0.5 (from importlib-metadata>=0.12->pytest>=2->pycuda)
  Using cached https://files.pythonhosted.org/packages/a0/0f/9bf71d438d2e9d5fd0e4569ea4d1a2b6f5a524c234c6d221b494298bb4d1/zipp-0.5.1-py2.py3-none-any.whl
Collecting pyparsing>=2.0.2 (from packaging->pytest>=2->pycuda)
  Using cached https://files.pythonhosted.org/packages/dd/d9/3ec19e966301a6e25769976999bd7bbe552016f0d32b577dc9d63d2e0c49/pyparsing-2.4.0-py2.py3-none-any.whl
Building wheels for collected packages: pycuda
  Running setup.py bdist_wheel for pycuda ... done
  Stored in directory: /home/amin/.cache/pip/wheels/de/c2/d5/351a6b47b20d417e82a669cf53f8cb4d7b55a57f73cbd05184
Successfully built pycuda
Installing collected packages: numpy, appdirs, decorator, six, pytools, wcwidth, attrs, zipp, importlib-metadata, pluggy, atomicwrites, more-itertools, pyparsing, packaging, py, pytest, MarkupSafe, mako, pycuda
Successfully installed MarkupSafe-1.1.1 appdirs-1.4.3 atomicwrites-1.3.0 attrs-19.1.0 decorator-4.4.0 importlib-metadata-0.18 mako-1.0.12 more-itertools-7.1.0 numpy-1.16.4 packaging-19.0 pluggy-0.12.0 py-1.8.0 pycuda-2019.1 pyparsing-2.4.0 pytest-5.0.0 pytools-2019.1.1 six-1.12.0 wcwidth-0.1.7 zipp-0.5.1

:

7 Likes

Many thanks for the informations.

I will try to install pycuda on my Nano.

Alain

Hello,

i have succed to install pycuda on my Jetson Nano but i have a problem :

When i try to run a pycuda example, i get this issue :

pytools.prefork.ExecError: error invoking ‘nvcc --version’: [Errno 2] No such file or directory: ‘nvcc’: ‘nvcc’

I tried to add this to the python program :

import sys
sys.path.insert(0, “/usr/local/cuda/bin/”)

Unfortunately, it does not solve my problem. I think it was a stupid idea.

Any good idea ?

Alain

Hello,

finally, i have solved my problem.

PyCuda examples work on my Nano.

I tested Mandelbrot example :

GPU 1.35s
Numpy : 10.8s

It works.

Alain

1 Like

congratulations.
i feel the topic can be closed now.

I use the following script to install “pycuda” on Jetson Nano. It builds “pycuda” from source and does “sudo pip3 install”. Feel free to give it a try.

[url]https://github.com/jkjung-avt/tensorrt_demos/blob/master/ssd/install.sh[/url]

Both the Accepted Answer as well as the script in #12 is not working for me.
NVCC is missing!

How to install NVCC on my Jetson Nano?

It seems I can get NVCC via ‘nvidia-cuda-toolkit’ - which I also cannot install. (Package ‘nvidia-cuda-toolkit’ has no installation candidate)

I saw it seems possible to get the the nvidia-cuda-toolkit via SDK-Manager.
But again SDK-manager is only available for ‘amd64’ platform, and the Jetson is ARM64/AARCH64.
Do I need another Ubuntu Machine?

‘nvcc’ should be present at ‘/usr/local/cuda/bin’ on your Jetson Nano already. Just add it to your PATH.

# add the following to your ${HOME}/.bashrc
export PATH=/usr/local/cuda/bin:\${PATH}
export LD_LIBRARY_PATH=/usr/local/cuda/lib64:\${LD_LIBRARY_PATH}

Reference: https://github.com/jkjung-avt/jetson_nano/blob/master/install_basics.sh

3 Likes

Thanks for your help!

nvcc is available in /usr/local/cuda/bin,

I was able to install pycuda using your scrips

cuda-10.0 should be changed to cuda-10.2 for anyone who will use this in the future

1 Like

FYI, to install PyCuda in one line via pip, the following command has worked for me previously

sudo pip3 install --global-option=build_ext --global-option="-I/usr/local/cuda/include" --global-option="-L/usr/local/cuda/lib64" pycuda

This will build the extension, passing the required include and link directories.

Please let me know if this helps or you run into issues.

Best,
John

17 Likes

this worked thanx

thank you very much this is worked for me

Thanks, this solved my problem and worked for me.

Thanks. This worked. The reply that was marked as solution didn’t though. Maybe because it’s 2 years old. So for people checking out this post in the future, I think this reply should be marked as the solution.