Error while installing PyCUDA

I am trying to install pycuda on a Jetson nano (latest SD card image)
and I am getting the following error while installing pycuda:

pip3 install pycuda
Collecting pycuda
  Using cached
Collecting appdirs>=1.4.0 (from pycuda)
  Using cached
Collecting mako (from pycuda)
  Using cached
Collecting pytools>=2011.2 (from pycuda)
Collecting MarkupSafe>=0.9.2 (from mako->pycuda)
Collecting numpy>=1.6.0 (from pytools>=2011.2->pycuda)
Collecting dataclasses>=0.7; python_version <= "3.6" (from pytools>=2011.2->pycuda)
  Using cached
Building wheels for collected packages: pycuda
  Running bdist_wheel for pycuda ... error
  Failed building wheel for pycuda
  Running clean for pycuda
Failed to build pycuda
Installing collected packages: appdirs, MarkupSafe, mako, numpy, dataclasses, pytools, pycuda
  Running install for pycuda ... error
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/pip/compat/", line 73, in console_to_str
    return s.decode(sys.__stdout__.encoding)
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb7 in position 19: invalid start byte

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/pip/", line 215, in main
    status =, args)
  File "/usr/lib/python3/dist-packages/pip/commands/", line 360, in run
  File "/usr/lib/python3/dist-packages/pip/req/", line 784, in install
  File "/usr/lib/python3/dist-packages/pip/req/", line 878, in install
  File "/usr/lib/python3/dist-packages/pip/utils/", line 694, in call_subprocess
    line = console_to_str(proc.stdout.readline())
  File "/usr/lib/python3/dist-packages/pip/compat/", line 75, in console_to_str
    return s.decode('utf_8')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xb7 in position 19: invalid start byte

The following commands were used:

pip3 install cython
export CPATH=$PATH:/usr/local/cuda-10.2/targets/aarch64-linux/include
export LIBRARY_PATH=$LIBRARY_PATH:/usr/local/cuda-10.2/targets/aarch64-linux/lib
export CUDA_INC_DIR=/usr/local/cuda/include
export PATH=$PATH:/usr/local/cuda/bin
pip3 install pycuda

Running pip3 install pycuda --verbose prints out this error:

 aarch64-linux-gnu-gcc -pthread -fwrapv -Wall -O3 -DNDEBUG -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/cuda/include -I/home/user/.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 bpl-subset/bpl_subset/boost/lexical_cast.hpp:47:0,
                     from bpl-subset/bpl_subset/boost/python/operators.hpp:19,
                     from bpl-subset/bpl_subset/boost/python.hpp:50,
                     from src/cpp/cuda.hpp:36,
                     from src/cpp/cuda.cpp:4:
    /usr/bin/locale:1:1: error: stray ‘\177’ in program

Any idea how this can be resolved?


Could you try below?

$ pip3 install pycuda --user



I found out what went wrong:

In this line:
export CPATH=$PATH:/usr/local/cuda-10.2/targets/aarch64-linux/include
I accidentally used PATH instead of CPATH

Therefore /usr/bin was added as an include path and the compiler tried to include /usr/bin/locale (which is a program)

instead of the include file: /usr/include/c++/7/locale

It’s working now - sorry for the inconvenience

Good to know this.
Thanks for the feedback.