pycuda 踩坑传 Nvidia Jetson Nano 2GB
从Nvidia官方下载L4T镜像烧录到SD开开机后开始安装pycuda环境
换apt源
修改文件:
sudo vim /etc/apt/sources.list
添加源:
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic main multiverse restricted universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-security main multiverse restricted universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-updates main multiverse restricted universe
deb http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-backports main multiverse restricted universe
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic main multiverse restricted universe
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-security main multiverse restricted universe
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-updates main multiverse restricted universe
deb-src http://mirrors.tuna.tsinghua.edu.cn/ubuntu-ports/ bionic-backports main multiverse restricted universe
更新源:
sudo apt update
修改默认python版本
# 安装python
sudo apt install python3.8
# 安装pip
curl https://bootstrap.pypa.io/get-pip.py -o get-pip.py # 下载安装脚本
sudo python get-pip.py # 运行安装脚本
# 列出所有可用python替代版本信息
update-alternatives --list python
输出: update-alternatives: 错误: 无 python 的候选项
# 将python的替代版本添加进去 最后的数字越大优先级越高
sudo update-alternatives --install /usr/bin/python python /usr/bin/python2.7 1
sudo update-alternatives --install /usr/bin/python python /usr/bin/python3.6 2
# 列出可用的python替代版本
update-alternatives --list python
/usr/bin/python2.7
/usr/bin/python3.6
# 切换python替代版本
update-alternatives --config python
有 2 个候选项可用于替换 python (提供 /usr/bin/python)。
选择 路径 优先级 状态
------------------------------------------------------------
* 0 /usr/bin/python3.5 2 自动模式
1 /usr/bin/python2.7 1 手动模式
2 /usr/bin/python3.5 2 手动模式
要维持当前值[*]请按<回车键>,或者键入选择的编号:1
# 删除不可用的python替代版本
sudo update-alternatives --remove python /usr/bin/python2.7
# 更改python版本导致pip不可用的情况
sudo apt-get install python-pip #python2
sudo apt-get install python3-pip #python3
# 更新pip
pip install —upgrade pip
系统没有cuda时需 检查cuda是否安装完成, 有cuda则可跳过
sudo apt update
sudo apt install cuda-toolkit-10-2
sudo apt install cuda-curand-dev-10-2
sudo apt install cuda-*
sudo apt install cuda*
sudo apt install cuda-core-10-2
sudo apt install cuda-curand-10-2
sudo apt install cuda-cublas-10-2
sudo apt install cuda-cusolver-10-2
sudo apt install cuda-cusparse-10-2
pip install pycuda报错踩坑
# cuda.h错误
export CUDA_HOME=/usr/local/cuda-10.2
export CPATH=${CUDA_HOME}/include:${CPATH}
export LIBRARY_PATH=${CUDA_HOME}/lib64:$LIBRARY_PATH
# pyconfig.h找不到文件错误
sudo apt install libpython3.8-dev
export CPLUS_INCLUDE_PATH=/usr/include/python3.8
# nvcc没有配置
export PATH=/usr/local/cuda/bin${PATH:+:${PATH}}
export LD_LIBRARY_PATH=/usr/local/cuda/lib64${LD_LIBRARY_PATH:+:${LD_LIBRARY_PATH}}
# 其它未知依赖问题
sudo apt install python-dev libxml2-dev libxslt-dev
sudo apt install python3-dev
sudo apt install python3.6-dev
版权声明:本文为zhanghao3389原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。