在Jetson Xavier NX上安装pycuda报错:src/cpp/cuda.hpp:14:10: fatal error: cuda.h: No such file or directory

1 我的系统环境和遇到问题分析

1.1 我的系统环境

  • 我的详细系统环境如下:使用jetson_release -v查看
  • 设备是NVIDIA Jetson Xavier NX,该设备是ARM架构
zhihui@zhihui-desktop:~$ jetson_release -v
 - NVIDIA Jetson Xavier NX (Developer Kit Version)
   * Jetpack 4.4.1 [L4T 32.4.4]
   * NV Power Mode: MODE_15W_6CORE - Type: 2
   * jetson_stats.service: active
 - Board info:
   * Type: Xavier NX (Developer Kit Version)
   * SOC Family: tegra194 - ID:25
   * Module: P3668 - Board: P3509-000
   * Code Name: jakku
   * CUDA GPU architecture (ARCH_BIN): 7.2
   * Serial Number: 1422420034718
 - Libraries:
   * CUDA: 10.2.89
   * cuDNN: 8.0.0.180
   * TensorRT: 7.1.3.0
   * Visionworks: 1.6.0.501
   * OpenCV: 4.1.1 compiled CUDA: NO
   * VPI: 0.4.4
   * Vulkan: 1.2.70
 - jetson-stats:
   * Version 3.0.2
   * Works on Python 3.6.9
zhihui@zhihui-desktop:~$ 

1.2 问题描述

1、在使用pip安装pycuda库包的时候报错

pip3 install pycuda

具体报错信息如下,意思就是找不到头文件cuda.h
在这里插入图片描述

2、但是我使用find可以找到cuda.h头文件,因此我们需要添加相关环境变量

find /usr/local/cuda-10.2 -name cuda.h

zhihui@zhihui-desktop:~$ find /usr/local/cuda-10.2 -name cuda.h
/usr/local/cuda-10.2/targets/aarch64-linux/include/cuda.h
zhihui@zhihui-desktop:~$ 

2 问题解决方式

1、切换到root用户

sudo su

2、添加环境变量

vim ~/.bashrc

添加如下环境变量

export PATH=/usr/local/cuda-10.2/bin:/usr/local/cuda/bin:$PATH

环境变量生效

source ~/.bashrc

3、再切换到你的你的用户

sudo su zhihui

4、再在该用户下再添加一次上面的环境变量

vim ~/.bashrc

添加如下环境变量

export PATH=/usr/local/cuda-10.2/bin:/usr/local/cuda/bin:$PATH

环境变量生效

source ~/.bashrc

5、重新打开一个新的terminal,然后安装pycuda

pip3 install pycuda

成功安装pycuda:

Collecting pycuda==2019.1.2
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/5e/3f/5658c38579b41866ba21ee1b5020b8225cec86fe717e4b1c5c972de0a33c/pycuda-2019.1.2.tar.gz
Collecting appdirs>=1.4.0 (from pycuda==2019.1.2)
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/3b/00/2344469e2084fb287c2e0b57b72910309874c3245463acd6cf5e3db69324/appdirs-1.4.4-py2.py3-none-any.whl
Collecting decorator>=3.2.0 (from pycuda==2019.1.2)
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/ed/1b/72a1821152d07cf1d8b6fce298aeb06a7eb90f4d6d41acec9861e7cc6df0/decorator-4.4.2-py2.py3-none-any.whl
Collecting mako (from pycuda==2019.1.2)
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/a6/37/0e706200d22172eb8fa17d68a7ae22dec7631a0a92266634fb518a88a5b2/Mako-1.1.3-py2.py3-none-any.whl
Collecting pytools>=2011.2 (from pycuda==2019.1.2)
Collecting MarkupSafe>=0.9.2 (from mako->pycuda==2019.1.2)
Collecting numpy>=1.6.0 (from pytools>=2011.2->pycuda==2019.1.2)
Collecting six>=1.8.0 (from pytools>=2011.2->pycuda==2019.1.2)
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/ee/ff/48bde5c0f013094d729fe4b0316ba2a24774b3ff1c52d924a8a4cb04078a/six-1.15.0-py2.py3-none-any.whl
Collecting dataclasses>=0.7; python_version <= "3.6" (from pytools>=2011.2->pycuda==2019.1.2)
  Using cached https://pypi.tuna.tsinghua.edu.cn/packages/fe/ca/75fac5856ab5cfa51bbbcefa250182e50441074fdc3f803f6e76451fab43/dataclasses-0.8-py3-none-any.whl
Building wheels for collected packages: pycuda
  Running setup.py bdist_wheel for pycuda ... done
  Stored in directory: /home/zhihui/.cache/pip/wheels/98/18/21/a789db879355a5aabdb9647ffb8c4c851a01fc820b39e88700
Successfully built pycuda
Installing collected packages: appdirs, decorator, MarkupSafe, mako, numpy, six, dataclasses, pytools, pycuda
Successfully installed MarkupSafe-1.1.1 appdirs-1.4.4 dataclasses-0.8 decorator-4.4.2 mako-1.1.3 numpy-1.19.4 pycuda-2019.1.2 pytools-2020.4.3 six-1.15.0
zhihui@zhihui-desktop:~$ 
欢迎大家关注笔者,你的关注是我持续更博的最大动力


原创文章,转载告知,盗版必究

微信:suihailiang0816
QQ:931762054
wx公众号:仰望星空的小随
已标记关键词 清除标记
相关推荐
©️2020 CSDN 皮肤主题: 猿与汪的秘密 设计师:白松林 返回首页