Error while installing PyCUDA

Hi,
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 https://files.pythonhosted.org/packages/5a/56/4682a5118a234d15aa1c8768a528aac4858c7b04d2674e18d586d3dfda04/pycuda-2021.1.tar.gz
Collecting appdirs>=1.4.0 (from pycuda)
  Using cached https://files.pythonhosted.org/packages/3b/00/2344469e2084fb287c2e0b57b72910309874c3245463acd6cf5e3db69324/appdirs-1.4.4-py2.py3-none-any.whl
Collecting mako (from pycuda)
  Using cached https://files.pythonhosted.org/packages/75/69/c3ab0db9234fa5681a85a1c55203763a62902d56ad76b6d9b9bfa2c83694/Mako-1.1.5-py2.py3-none-any.whl
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 https://files.pythonhosted.org/packages/fe/ca/75fac5856ab5cfa51bbbcefa250182e50441074fdc3f803f6e76451fab43/dataclasses-0.8-py3-none-any.whl
Building wheels for collected packages: pycuda
  Running setup.py bdist_wheel for pycuda ... error
  Failed building wheel for pycuda
  Running setup.py clean for pycuda
Failed to build pycuda
Installing collected packages: appdirs, MarkupSafe, mako, numpy, dataclasses, pytools, pycuda
  Running setup.py install for pycuda ... error
Exception:
Traceback (most recent call last):
  File "/usr/lib/python3/dist-packages/pip/compat/__init__.py", 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/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 694, in call_subprocess
    line = console_to_str(proc.stdout.readline())
  File "/usr/lib/python3/dist-packages/pip/compat/__init__.py", 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?

1 Like

Hi,

Could you try below?

$ pip3 install pycuda --user

Thanks.

Hi,

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.